notify gives "

I am using the nrfconnectSDK v2.4.0  and zephyr

i called the function shown below

int notify_results = bt_gatt_notify_cb(conn, &params);

with params containing 

struct bt_gatt_notify_params params = {0};
params.attr = m_ble_metadata_response_attribute;
params.data = (const void*)&command_data->command;
params.len = (uint16_t)(command_data->parameter_length + 2);
params.func = vsg_service_metadata_response_complete;

the m_ble_metadata_response_attribute

pointed to the last characteristic in my service.

and it failed with 

<wrn> bt_gatt: gatt_notify: Device is not subscribed to characteristic

when i used nrfconnect on my iphone.

this is the end of my service.

they are my last two characteristics.

BT_GATT_CHARACTERISTIC(BT_UUID_CHR_METADATA_COMMAND,
BT_GATT_CHRC_WRITE ,
BT_GATT_PERM_WRITE,
NULL, write_metadata_command_cb, &m_queued_metadata_command),

BT_GATT_CHARACTERISTIC(BT_UUID_CHR_METADATA_RESPONSE,
BT_GATT_CHRC_NOTIFY,
BT_GATT_PERM_NONE,
NULL, NULL, NULL),

then i added one more line to my service and it worked.!!

BT_GATT_CHARACTERISTIC(BT_UUID_CHR_METADATA_COMMAND,
BT_GATT_CHRC_WRITE ,
BT_GATT_PERM_WRITE,
NULL, write_metadata_command_cb, &m_queued_metadata_command),

BT_GATT_CHARACTERISTIC(BT_UUID_CHR_METADATA_RESPONSE,
BT_GATT_CHRC_NOTIFY,
BT_GATT_PERM_NONE,
NULL, NULL, NULL),

BT_GATT_CCC(on_cccd_changed, BT_GATT_PERM_READ | BT_GATT_PERM_WRITE),

so my question is 

Does the function bt_gatt_notify_cb(conn, &params); work correctly when the NOTIFY characteristic is the last characteristic in the service ?

thanks

phil

Parents
  • Hi Phil

    Any characteristic using notifications or indications will need to include the CCCD (Client Characteristic Configuration Descriptor), otherwise the client is not able to enable the notifications/indications. 

    In other words it makes sense that adding the BT_GATT_CCC(..) line would make notifications work. 

    Whether or not the notify characteristic is the last in the service should not make any difference. 

    Best regards
    Torbjørn

Reply
  • Hi Phil

    Any characteristic using notifications or indications will need to include the CCCD (Client Characteristic Configuration Descriptor), otherwise the client is not able to enable the notifications/indications. 

    In other words it makes sense that adding the BT_GATT_CCC(..) line would make notifications work. 

    Whether or not the notify characteristic is the last in the service should not make any difference. 

    Best regards
    Torbjørn

Children
Related