Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

custom service and characteristic not receiving write events

I started with the ble_app_template and a preexisting project written with sdk 12.

I have a custom service and 2 characteristics.

The point I am at now is that my DK advertises the proper name and such. When I connect I can see my service and characteristics.

When I write to the writable characteristic, I get an even into my ble_eas_on_ble_evt function, but the p_ble_evet->header.evt_id is always 2. It is never BLE_GATTS_EVT_WRITE.

I am sure I just missed something simple. Please advise.

  • I forgot to say I am using SEGGER studio and nRF5_SDK_15.0.0.a...

  • Hi,

    Do you mind posting your code? It's hard to say what you have missed without it. We can make the case private if you prefer confidentiality.

  • I ended up starting all over and just went step by step making sure the app was working right. Still not sure what the difference is that makes it work versus not, but it is working now.

    I would like to recommend that you make an example with a custom service and multiple characteristics instead of just having the basic template with commented out code that doesn't completely work when you uncomment it.

    Please make different characteristics, some read, some write, some both, some notify, some not and have it all working and not just commented out example code.

    You can call it the custom service template example or something like that.

  • I'm glad it works.

    You might be interested in this tutorial

    We also have these. They are somewhat outdated now, but the process of adding a service and characteristic shouldn't be that different in the new SDKs. 

  • That is actually the tutorial I used to finally get it working.

    What I am suggesting is that you have a example project that is the final result of something like that tutorial, but is complete and working AND includes more than just a single characteristic. It would be nice if it included acharacteristic with read/write/notify and then 1 each characteristic with only read or write or notify.

    With an example like that the user could just remove the characteristics they don't want or duplicate them or whatever and be ready to go. Then we could spend our time working on the business logic of our app instead of trying to navigate the complexity of trying to get the characteristics to work.

    This is just a suggestion.

    As an alternative maybe it would be even better to come up with a tool like what Cypress has that lets you define services and characteristics in a GUI that has you fill out all the details and then it writes the code for you.

    I know many devs want to slug through all this stuff on their own, but many of us would rather spend our time working on the meat of our apps and have the services and characteristic setup be more automated.

Related