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
  • Hi

    First, I want to say that development without the possibility to debug is very hard, and ill advised, and you should avoid this in the future.

    Next, what you should look at are return values from the ble_service_on_value_change() function, to see how are you updating your firmware? By using a debugger or bootloader? If you do have a debugger you could use the RTT logger, to read these return values. If not you should test this on a development kit first, before implementing it into your product.

    I don't think this is a race condition per say, but maybe an interrupt from some process with a higher priority. Again, debugging is the correct way of finding out what is happening, as me guessing what the issue is, is really inefficient.

    Best regards,

    Simon

  • Hi ,

    As we discussed I've put debug in my source code and I checked the return value from ble_service_on_value_change().

    When it's working great it returns 0 obviously.

    But when it's not working, I get 12290 (integer) so I suppose 0x3002

    So sd_ble_gatts_hvx() returns 0x3002

    It's : BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.

    What does it mean to you ?

    By the way, I'm using SDK15.0.0 with Softdevice S132 v6

    Thanks !

Reply
  • Hi ,

    As we discussed I've put debug in my source code and I checked the return value from ble_service_on_value_change().

    When it's working great it returns 0 obviously.

    But when it's not working, I get 12290 (integer) so I suppose 0x3002

    So sd_ble_gatts_hvx() returns 0x3002

    It's : BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.

    What does it mean to you ?

    By the way, I'm using SDK15.0.0 with Softdevice S132 v6

    Thanks !

Children
No Data
Related