bt_gatt_notify doing nothing when called from zephyr thread

Hello all,

I am working on a ble application on zephyr. I need to send a notification on a specific characteristic.

If I call bt_gatt_notify from where I want to send, it works. However, If i queue my message and call bt_gatt_notify from an other thread, it does nothing, despite returning 0.

static void _ble_tx_process_thread(void) {
while (1) {
struct message_t *message = k_fifo_get(&_tx_fifo, K_FOREVER);
bt_gatt_notify(NULL, &svc.attrs[3], message->data, message->len);
}
}
K_THREAD_DEFINE(_ble_tx_process_thread_id, 1024, _ble_tx_process_thread, NULL, NULL, NULL, 5, 0, 0);
void ble_send(uint8_t *data, uint16_t len) {
fragment_tx_init();
fragment_tx_append(data, len);
int nb_fragments = fragment_tx_finish();

for (int i = 0; i < nb_fragments; i++) {
struct fragment *fragment = fragment_tx_get_fragment(i);
_tx_message.data = fragment->data;
_tx_message.len = fragment->len;

k_fifo_put(&_tx_fifo, &_tx_message);
}
}

If rather than calling ble_send I call bt_gatt_notify(NULL, &svc.attrs[3], fragment->data, fragment.len), I get my notification.

What can be wrong ?

Parents Reply Children
No Data
Related