This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How do I create my own service on the BLE stack?

I've sifted through the examples given to me, and none of them seem to explain how to create your own service and add it to the stack. All of the services that are registered in the ble examples (nRF51 nordic pca10001) have their own header and c files.

Does anyone know how to create your own service, or at least know of any documentation that could point me in the right direction?

Thanks in advance!

Parents
  • To create a custom service, you should try to follow the general flow of the existing services, and mor or less copy them. The battery service (ble_bas.c/ble_bas.h) is probably the simplest one, and should provde a good starting point.

    If you look at it, you can see that the init function first adds a service, using the sd_ble_gatts_service_add() function, then calls an internal function to add a characteristic. This internal functions sets up a lot of parameter structures, that in different ways affect the characteristic added.

    Most services also needs to know what happens on run-time, so you need to create a event handler to handle events coming from the stack. This should be named service_name_on_ble_evt(), and be called from the applications main.c-file's ble_evt_dispatch() method.

    Finally, most services also need some API function to actually do something useful, for example the battery service's method to update the measured battery value.

  • Ahh thank you this helps a lot! From the 10,000 foot level it looked as though all their services depended on each other, but knowing that I can single one out will make things much easier.

    Thank you very much for bearing with my naivete!

Reply Children
No Data
Related