I have a custom Characteristic in my GATT that is sending data in Notify mode every 30ms.
In my firmware I use timer to do this with something like this :
#define RTC1_TICK_DURATION 31
#define TIMER_ONE_DURATION 33 // 30ms /**<(deflt:1000)[ms] sending/measurement cycle duration for 1s cycled characteristics*/
#define TIMER_ONE_TICKS_NB (TIMER_ONE_DURATION * 1000 / RTC1_TICK_DURATION)
err_code = app_timer_start(m_TimerOne_id, (uint32_t)TIMER_ONE_TICKS_NB, NULL);
Everything is working great but sometimes, randomly, my app using BLE or my laptop using Web BLE (so two different device with two different source code with the same behavior) are unable to retrieve value for this Characteristic. They are able to connect to my device but no Characteristic value is send.I tried to change the interval from 30ms to 90ms and so far I am not able to reproduce this issue so it lead me to think that the speed can be the source of the issue.How would you deal with that ? Is it possible to notify at a low pace, then one second after a connection is made, increase the speed ? Or better, when someone subscribe to the Notifying Characteristic increase speed, when it disconnect decrease speed ?Thanks !
How often does this occur? And do you have to disconnect from the device in order to retrieve the characteristic when this happens, or is it enough to just wait? Do you get any error code when it happens?
As for changing the pace of your notification events after you've established a connection, I don't think you will be able to do that.
Thanks for your answer.
I would say it happen 1 out of 10 in average. In order to solve this problem I do not specifically need to disconnect. I just unsubscribe, then resubscribe to the characteristic. Just by doing this resolve the issue.
I do not get any error though.
If you need meed to share my advertising_init function or something else, feel free to ask.
It seems strange that your interval between notifications should be the issue. Have you looked at our cusstom ble service example over on GitHub? I suggest you have a look at that example, which uses notifies in a similar way you are, and I don't think there are any issues with the timing there.
Ok thanks I will take a close look at it !
But for you a notification with a 30ms interval between each sending is not "too fast" ?
Good thing you mentioned that! Seeing as notifications are sent each connection event, you can't have a notification interval that is faster than your connection interval, this will likely end in an error, and this might be the reason you encounter these disconnections. What kind of connection interval parameters do you have?