bt_gatt_service_register not working

I tested out bt_gatt_service_register using the samples/bluetooth/peripheral sample by adding

CONFIG_BT_GATT_DYNAMIC_DB=y

to the proj.conf and the following to the start of main:
static struct bt_uuid_128 uuid;
uuid = (struct bt_uuid_128)BT_UUID_INIT_128(0x53, 0xF5, 0x3C, 0x12, 0xF0, 0xD6, 0x25, 0xAD, 0xD6, 0x4E, 0xA6, 0x48, 0x01, 0x00, 0x54, 0xE7);
static struct bt_gatt_attr attr;
attr = (struct bt_gatt_attr)BT_GATT_PRIMARY_SERVICE(&uuid);
static struct bt_gatt_service service;
service = (struct bt_gatt_service) { .attrs = &attr, .attr_count = 1 };
int result = bt_gatt_service_register(&service);
if (result != 0) {
printk("Bluetooth dynamic service registration failed (result %d)\n", result);
return 0;
}
This works and I can see the service on an iOS device.
However, if I do the same with my own products application then the service can NOT be seen on an iOS device.  The bt_gatt_service_register does return success.  I can see changes to statically defined services.
I have copied all my proj.conf options into the samples/bluetooth/peripheral sample to see if maybe one the settings was causing the issue, but it still works.
Anyone else run into this?  Or have any ideas for how to debug and figure out why the bt_gatt_service_register service does not seem to be working in my application?
  • Hi,


    I would recommend that you compare the two .config files, this way you will be able to see what is different in the projects and assess what could be the problem.  
    Also might be of value to compare any log files also. 

    Regards,
    Jonathan 

  • I've already compared config and copied my config to the sample as indicated in my original message.  I've looked at the log and did not see any relevant BLE errors logged.  The bt_gatt_service_register function returns success.  However, that gatt service is not found when connecting via BLE.

    Any tips on where to set break points in the Zephyr BLE code to see why service discovery is not including the dynamic services?

  • Did you compare the output .config file? So the files that are generated when building the project. 

    Regards,
    Jonathan

  • I have the same problem.

    Did you find a solution?

    Br Mads

  • Pleas create a new ticket and link to this ticket if you are not able to solve the issue. We will do our best to help solve this. 

    Regards,
    Jonathan

1 2