简体   繁体   中英

How do I add my own service to a BLE application?

I am currently working on an Android BLE app with which I want to connect to a Nucleo IDB05A1. I looked into the examples given for both sides, meaning the Bluetooth Le Gatt example app and some example code for the Nucleo. Discovering and connecting to the device works fine, I played a little bit with the code and can read as well as write the given characteristics on the Nucleo.

My problem now is that I want to add a custom service to (for example) write text on my phone, write it to a custom characteristic of this service so that I can put it on UART with the Nucleo board. Unfortunately, I could not find a proper explanation on how to develop an own BLE service.

I would really appreciate some help on both the Android code and the code for my uC (Nucleo F401RE with Nucleo IDB05A1 BLE module).

Best approach for that should be to determine what exact BLE stack is used for Nucleo (I don't know details for ST since I've been working mostly with TI or Nordic). After that, you should try to find documentation for exact BLE stack and start to analyse your working example.

Point that you have to check are:

  • Stack initialization
  • Stack callbacks
  • Advertisement data
  • Services declaration (usually a structure that describes service)
  • Characteristics declaration (usually set of properties that have to be set in order to define custom service)

After you understand mentioned above, I would suggest you to start from Advertisement data changing and go further into development of custom service.

Hope it helps...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM