[BLE] Continuously notify to client

cudompan
Posts: 1
Joined: Tue Jul 02, 2024 5:26 pm

[BLE] Continuously notify to client

Postby cudompan » Tue Jul 02, 2024 5:48 pm

Hello,

I am working on a project which requires periodic streaming of data from the BLE server on top of the event handler, I am wondering if there is a way to continously notify the client (i.e. streaming data using

Code: Select all

esp_ble_gatts_send_indicate(gatts_if, param->write.conn_id, BLE::gatt_profile[PROFILE_A_APP_ID].char_handle,
                                                sizeof(notify_data), notify_data, false);
)

I have created a case in the write event after parsing my write data and check if the command sent from client is STREAM command. If so, I have kicked off a new periodic FreeRTOS thread that periodically call on esp_ble_gatts_send_indicate (with no response) to notify the BLE client.

However, I have realized that it wouldn't work unless I make it a function call that will eventually return with nested loop of <20 loops (instead of my RTOS thread). It would only work if my continuous send doesn't loop too many times. It also wouldn't work when I call once notify once in my periodic thread, even with empty busy loop.

In my periodic thread version and normal function call with the nested loop of esp_ble_gatts_send_indicates, they would behave the same, which seems like it hanged even though I can see that esp_ble_gatts_send_indicate is always being called.

In the working case, seems like the callback function is called all at once multiple times when the continuous send finishes and returns. Otherwise I would not see any of the callback being triggered.

Can someone help explain what might have been the issue and if there is a way to go around calling esp_ble_gatts_send_indicates in a periodic thread outside of my gatts_event_handler


Thank you very much!

Who is online

Users browsing this forum: No registered users and 94 guests