This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Update timer speed once connected

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 !

Parents Reply Children
  • Hi,

    I don't know how to calculate it but here it is : 

    #define CONN_SUP_TIMEOUT MSEC_TO_UNITS(4000, UNIT_10_MS)

    Sorry I'm on my phone

  • Try setting this value to a larger number and see if the connection lasts longer.

    Thanks for a very detailed log by the way! Not very often we see these things, so it is much appreciated.

    Best regards,

    Simon

  • No problem, you asked for it :D

    I really want this to be fixed so I try to give you as much informations as possible.

    For the CONN_SUP_TIMEOUT, I tried 8000 and even 10000 but I have the same result and behaviour.

    So I tried lower number, with 2000 same result.

    But during my manipulation I was able to reproduce the exact same issue apparently (no saadc_callback trigger) if I comment the saadc_init(); line in the DEVICE_SET case.

    So I tried to put a nrf_delay_us(100000) just after saadc_init() just in case this was because the init is not yet finish before it start advertising but without success.

    If I comment the saadc_init and saadc_uninit from the switch case (so it stay always initialized because it's init during first boot) the problem is still there.

    So I put log in every function that I call when disconnecting. Log when entering and log when exiting. Every time when it's not working, I do not see all logs. Sometimes I miss "exit saadc_uninit" or sometimes I miss "enter and exit GPIO_lowpower" and even "End DEVICE_GOtoLowpower".

    So I added nrf_delay_ms(25) between each line of DEVICE_SET case and DEVICE_GotoLowpower case. So far, I did not reproduce the issue after ~40 trials.

    Now the game is to find which one is really useful...

    EDIT : It looks like the only important one is the first one of DEVICE_GotoLowpower case to make sure the saadc_sample is finished before uninit everything. Please take a look at my other answer here.

Related