This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Is there an example of a service with many characteristics ?

Hi,

I need to have a custom service which allows configuration of multiple parameters (perhaps 50 or more - which control registers in external peripherals)

I've looked at the examples and existing services to see if there is anything similar, but all I can find is code where each characteristic has its own, rather large, setup function.

Is there an example of having an array of characteristics? (They don't even need to be named, they could just be numbered)

BTW. I had initially thought that I would just duplicate the UART service and put it on a private UUID, but I think the maximum data size for a single write or read from a service would not be large enough to hold 50 or more bytes if config data, and having the ability to read or write individual characteristics is more flexible.

Thanks.

Parents
  • I would not recommend having a service that has 50 or more characteristics. Adding that many characteristics will lead a very long service discovery time. My suggestion would be to hold the parameters internally, assign an identifier to each of the parameters and then use only two characteristics, one for the parameter value and one to identify which parameter that is to be updated. You can do the same procedure when you want to read out the values, write the identifier to one of the characteristics and configure the device to notify the value that corresponds to the identifier.

Reply
  • I would not recommend having a service that has 50 or more characteristics. Adding that many characteristics will lead a very long service discovery time. My suggestion would be to hold the parameters internally, assign an identifier to each of the parameters and then use only two characteristics, one for the parameter value and one to identify which parameter that is to be updated. You can do the same procedure when you want to read out the values, write the identifier to one of the characteristics and configure the device to notify the value that corresponds to the identifier.

Children
No Data
Related