Page 1 of 1

BLE notifications

Posted: Thu Sep 16, 2021 11:34 pm
by ndjurov
If a service has two or more characteristics that server uses to indicate/notify a client and this is done from different tasks, is it necessary to create some kind of transmission control - mutex, semaphore etc., or the Bluedroid stack will take care of this and serialize the transmission? In other words, are functions like esp_ble_gattc_write_char_descr() or esp_ble_gatts_send_indicate() thread safe?
Thanks.

Re: BLE notifications

Posted: Sun Sep 26, 2021 6:27 pm
by chegewara
You dont have to worry as long as 2 tasks wont try to notify from the same characteristic, i am 95% sure about that.

Re: BLE notifications

Posted: Mon Sep 27, 2021 11:22 pm
by ndjurov
Thanks you very much.
There is only one task doing the notification - sending just a keep-alive signal to the client every 2-3 seconds. That's all.

Re: BLE notifications

Posted: Mon Sep 27, 2021 11:27 pm
by chegewara
Maybe thats stupid question, but why are you sending keep alive notifications? This is all done by BLE low level driver and you even can control the timeout after which client will be disconnected.

Re: BLE notifications

Posted: Wed Oct 20, 2021 4:58 pm
by ndjurov
Thank you very much, and my apologies for not seeing your post earlier.

The answer is simple - I didn't know about this BLE feature. I knew that BLE keep-alive exists at same level as it is able to recognize if a peer got disconnected, but I didn't know that it could be used by the application. I have to read more about it to understand how to use it.
Thank you very much for this useful info.