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

can not creat my own characteristic

HI ALL i have successfully creat my own service referring to the example ble_app_lbs and reference nAN-36. but when i tried to creat my own characteristic in my service, it did not wrok(the device became unable to advertise, and the reason is that sd_ble_gatts_characteristic_add() return an error) i creat my characteristic according to the 'static uint32_t button_char_add(ble_lbs_t * p_lbs, const ble_lbs_init_t * p_lbs_init)' in ble_app_lbs (almost copying all its content)

can someone give me a favor? thank you for your time!

  • Sorry,everyone,i think i find out the problem. the problem is: If i use the following codes: // ble_uuid.type = p_myservice->uuid_type; // ble_uuid.uuid = MYDATA_UUID_CHAR; my device will came out the problem i have said above but if i replace them with this code: // BLE_UUID_BLE_ASSIGN(ble_uuid, MYDATA_UUID_CHAR); the problem sloved !

    i really do not konw why, can someone explain it? thank you for your time!

  • You could easily find the actual value that is assigned to ble_uuid by entering debug mode and putting a breakpoint after the assigment. Then you could compare both implementations and see the difference.

    This question may also be helpful. I would also recommend you to read sections 2.2.3 and 2.2.4 in nAN-36.

    In ble_lbs_init() you have the function sd_ble_uuid_vs_add(&base_uuid, &p_lbs->uuid_type); This sets the uuid_type to 0x02, which is BLE_UUID_TYPE_VENDOR_BEGIN (see ble_types.h) It defines that the UUID is vendor specific, with your own base UUID, not the Bluetooth SIG base UUID.

    BLE_UUID_BLE_ASSIGN() sets the uuid_type to 0x01, which is BLE_UUID_TYPE_BLE. This defines that the UUID is defined by the Bluetooth SIG, and is to be used together with the Bluetooth SIG base UUID.

    In the LED Button example vendor specific UUIDs are you be used, since the service is not a standard service defined by the Bluetooth SIG, but something we have created on our own.

Related