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

Problem with custom service UUID and Notify

I've been following the custom service nAN-36 instructions and have it mostly working on my PCA10028 board, but I have two problems that I just can't figure out. I'm pretty sure they are related.

1st Problem

In advertising_init() if I implement the code to configure the service UUID the same as in nAN-36 my board won't initialize and gets stuck in a continuous reset loop. I can only get it to work if I use the BLE_UUID_TYPE_BLE as per the code snippet below, but I think this causes problems with the button Notify handler (see 2nd Problem).

  //ble_uuid_t adv_uuids[] = {{TAG_UUID_SERVICE, m_tag.uuid_type}};  //This should work but does not, causes the device to continuously reset
  ble_uuid_t adv_uuids[] = {{TAG_UUID_SERVICE, BLE_UUID_TYPE_BLE}}; //this does work, but crashes when sending a notification

2nd Problem

When I modify the advertising_init() as above, everything mostly works. But when I go to Master Control Panel, I can connect to the board, I can write to change the LED state characteristic, I can enable the CCCD on the Button characteristic. But when I toggle the button which calls the ble_on_button_change() handler, the PCA10028 hangs.

I'm attaching the source files, plus a zip of the entire project in the hope there is someone who can take a quick look and offer some advice on why this doesn't work.

main.c

ble_sfst_tag.c

ble_sfst_tag.h

CustomServiceProject.zip

Thanks!

  • I have resolved part of the problem. The call to ble_on_button_change() handler was hanging because I was calling it from a GPIOTE ISR which is not allowed. I modified the implementation to use the app_scheduler() to move the calling context to main and it works fine now. The system still however hangs on advertising_init() if I try and populate the service UUIDs like this:

     ble_uuid_t adv_uuids[] = {{LBS_UUID_SERVICE, m_lbs.uuid_type}};    
    
     advdata.uuids_complete.uuid_cnt = sizeof(adv_uuids) / sizeof(adv_uuids[0]);
    
     advdata.uuids_complete.p_uuids  = adv_uuids;
    

    If I put the service UUID in the Scan response packet it works fine. But it hangs if I put it in the in the initial advertising data packet. I don't know why.

  • Hey!

    1. This is probably caused by the advertisement packet being longer than the maximum of 31 bytes. See this. Moving a 128 UUID to the scan response packet is normally a good solution. The continous reset loop is caused by the default APP_ERROR_CHECK. If you do not alter it, or #define DEBUG, it will reset the chip. You should always check the return codes of softdevice calls, or most function calls in general :)

    It seems you have solved this yourself.

  • Thank you Anders! I haven't tried modifying APP_ERROR_CHECK to trap these errors before a reset. I'll do some research on how to do that now.

Related