Hi Dialog,
I am working on the ble_app_peripheral project. I am issuing an app_easy_timer of a particular duration. Within this duration the device is switching role from observer to broadcaster and vice versa, a number of times, for which a number of gapm_reset_commands are issued. The problem arising is that, the handle of the timer is not getting invoked. Please suggest solutions for the same.
Thanks in advance,
Wisilica
Device:
Hi wisilica,
How do you know that the handler of the timer is not getting invoked ? I suppose that you are setting a timer during starting of a specific role and then from the handler you are issuing a GAPM_RESET command and then with the beggining of the new role you start the timer again. So where exactly in your code you are issuing the timer ? for example if the timer is set in the .app_on_init() callback function then a GAPM_RESET is issued after that function and all the messages in the kernel queue are flushed including timers and in general after a GAPM_RESET all the timers that are issued before that command are flushed. So you will have to check if the timer is indeed set and that a GAPM_RESET is not invoked before the timer has elapsed.
Thanks MT_dialog
Hi,
The scenario is Timer 1 and Timer 2 are initiated for a duration of say 3sec and 500ms and the device is advertising packets. The callback of timer 2 resets gap and switching to scanning mode. In scanning mode, Timer 2 is created for 500ms and in the callback resets gap and switches to adv mode. Thus timer 2 will alternate between scan and advertisement. In the callback of Timer1, timer 2 is deleted and devices stops advertisement and goes to sleep.
In this, Timer 2 will work properly as it is being created after a role switch and is created the next time after the role switch is completed.
From your response, if the timers are flushed whenever a gap role switch happens, how can we keep track of time? Is there any means to identify, how much more time was remaining for the timer to elapse? We have a requirement to keep track of time between role switches.
Hi wisilica,
As i ve mentioned when a GAPM_RESET occurs the whole stack is reseted, in order for you to configure your device in a different role, so the timers are flushed. From the scenario described (correct me if i got this wrong), you would like to operate as a central and as peripheral (thus advertising and scanning) and switch between those two roles every 500ms and a total of 3 seconds. I see that your problem is that Timer 1 is flushed away during switching, so you goal is to the 3 seconds operation of the device before going to sleep. So for this you have the following options:
Thanks MT_dialog
Hi, wisilica,
I have a same scenario as you which need to change the role between observer and perpheral. I use a button to do trigger a reset action, and send a reset cmd and re-config the role of the device , but when the stack always crashed at NMI_HandlerC, so I think there is something wrong with my process, can you share you code to me for a reference, I have been confused with this problem for a time, much appreciate! Thank you, and my mail isgjhe0409@163.com