APP_EASY_TIMER复位后不工作

5 posts / 0 new
Last post
wisilica
Offline
Last seen:10 months 5 hours ago
加入:2015-03-17 08:16
APP_EASY_TIMER复位后不工作

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:
MT_dialog
Offline
Last seen:1 month 3 weeks ago
Staff
加入:2015-06-08 11:34
Hi wisilica,

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

wisilica
Offline
Last seen:10 months 5 hours ago
加入:2015-03-17 08:16
Hi,

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.

MT_dialog
Offline
Last seen:1 month 3 weeks ago
Staff
加入:2015-06-08 11:34
Hi wisilica,

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:

  • Count the switching, if every role should last for 500ms then you can count the amount of times that you 've switched, for example 3 seconds correspond to 6 switches, i suppose that this is the most reliable way.
  • Another thing that you could do is to read and store the value of the base time counter (lld_evt_time_get()) before the switching happens (so that you dont get zero after the switch) and check the accumulated value when you are about to switch, if its larger than your predefined time you can put your device to sleep.

Thanks MT_dialog

chris0409
Offline
Last seen:3 years 9 months ago
加入:2017-01-11 05:59
Hi, wisilica,

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