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

Add a service and characteristics to advertising data

Is it possible to include an existing service and characteristics on a peripheral to its advertising packets?

I would like to add a custom BLE service to my peripheral to be used as a status indicator. A central device would need to be able to read this as part of advertising data in order to decide whether or not it should connect, and then be able to write to it in order to change the status of the device. Currently I'm ble_advdata_set() in order to advertise service that I build on the fly, but I'm not sure if it's possible to use a previously added service for this and have it be discoverable as well.

Parents
  • Hi. You can advertise what services your devices provides, but you can't really advertise the service's value the way I think you suggest (in the service field of the advertising packet). What you can do is to add your information in the manufacturer specific data or scan response field. Then you can update your advertising data with relevant information whenever you like.

    If you just want to tell your central 'yes' or 'no' to connect (pretty much a boolean value) then maybe you can do this by manipulating the device appearance or tx power field and that way save your manufacturer specific data field for something else.

    Here is a tutorial on advertising btw.

  • Or just do connectable/not-connectable advertising :) But this could be the solution when peripheral can decide if central has to connect. Setting Your values in manufacturer specific data is better solution - You just have to parse it properly on central to read values.

Reply Children
No Data
Related