Arch_ble_ext_WakeUp_on的目的是什么?

7个帖子/ 0新
最后一篇
oren.
Offline
最后一次露面:1年7个月前
专家
加入:2014-06-28 22:03
Arch_ble_ext_WakeUp_on的目的是什么?

Hi,
我们正在使用SDK 5.0.4,我正在查看user_sleepmode示例。
It looks like the program listens to button-click interrupts in two cases.

The first case is during a connection. To begin listening,user_app_set_button_event被调用并执行:

wkupct_register_callback(user_app_button_press_cb);
wkupct_enable_irq(wkupct_pin_select(gpio_button_port,gpio_button_pin),
WKUPCT_PIN_POLARITY(GPIO_BUTTON_PORT, GPIO_BUTTON_PIN, next_event), // polarity
1,// 1事件
10);

和listening is stopped byuser_app_disable_button.这是一个电话wkupct_disable_irq();
The listening callback (user_app_button_press_cb)也呼叫user_app_set_button_eventto keep listening to button clicks (actually it listens to switches in the button-mode, by choosing the right "next_event").

第二种情况是程序停止广告(10秒后)。什么时候user_app_adv_undirect_complete被称为状态GAP_ERR_CANCELED(即它是一个刻意的adv-stop)它呼叫:

ARCH_BLE_EXT_WAKEUP_ON();
// Configure wakeup button
app_button_enable();

The purpose ofARCH_BLE_EXT_WAKEUP_ON.是:“将BLE核心放在永久性睡眠中。只有一个外部事件可以唤醒它。”。It simply sets an internal flag to true.
Then,app_button_enable.呼叫:

app_easy_wakeup_set(app_wakeup_cb);
wkupct_register_callback(app_button_press_cb);
wkupct_enable_irq(wkupct_pin_select(gpio_button_port,gpio_button_pin),// select pin (GPIO_BUTTON_PORT, GPIO_BUTTON_PIN)
wkupct_pin_polarity(gpio_button_port,gpio_button_pin,wkupct_pin_polarity_low),//极性低
1,// 1事件
40);

i.e. it savesapp_wakeup_cb.aside to be called in the future byapp_easy_wakeup,并对第一种情况运行类似的代码,以便开始侦听按钮中断。
发生中断时,app_button_press_cb被调用并执行:

if (GetBits16(SYS_STAT_REG, PER_IS_DOWN))
{
periph_init();
}
......

If I understand correctly, this code must be called in external wakeup during deep-sleep (Is it harmful to call it when using extended sleep?).
Then, the app_button_press_cb continues by calling:

if(arch_ble_ext_wakeup_get()))
{
ARCH_SET_SLEEP_MODE(app_default_sleep_mode);
ARCH_BLE_FORCE_WAKEUP();
ARCH_BLE_EXT_WAKEUP_OFF.();
app_easy_wakeup();
}

i.e. it checks that the external-wakeup-flag is on, initializes the sleep-mode (app_default_sleep_mode is deep-sleep), wakes up the BLE, turn off the external-wakeup flag (i.e. timers and BLE events can now wake up too) and callsapp_easy_wakeup()(which callsapp_wakeup_cb.as I explained before).

What are the advantages of the mechanism in the second case? We could avoid callingARCH_BLE_EXT_WAKEUP_ON()然后我们不必重新配置睡眠模式并重新唤醒BLE。什么是呼唤的点ARCH_BLE_EXT_WAKEUP_ON()if the program doesn't have any timers and doesn't advertise (i.e. timers and BLE events cannot wake up the program无论如何- 只有一个外部唤醒罐)。

Will the program consume less power during deep-sleep if we useARCH_BLE_EXT_WAKEUP_ON.

第二个案例如何从未拨打电话wkupct_disable_irq()?后会睡觉ARCH_BLE_EXT_WAKEUP_ON.意味着您不必打电话wkupct_disable_irq()醒来后?

谢谢,
oren zomer.

设备:
lc_dialog.
Offline
最后一次露面:2周1天前
职员
加入:2016-09-19 23:20
你好oren,

你好oren,

我为延迟回答你的问题而道歉......

为了你的第一个问题,
No. You can use this for extended sleep also. Only the default waking up option is set by the user. The SDK takes care of the rest of the process on how to wake up all the modules.
对于第二组问题,
Even though the system is in deep sleep, the system stack wakes up at regular intevals (defined in CFG_MAX_SLEEP_DURATION_EXTERNAL_WAKEUP_MS). This is to poll the UART (which is a side effect for operating over GTL interface of SDK) to check for any exisiting data. The arch_ble_ext_wakeup_on() in user_app_undirect_complete() will supress this process of waking up during these intervals to save the power.
Note: You can notice this in Smart Snippets by disabling this function
第三个问题,
For Interrupts, In the first case user is setting up the button to listen for the button press and later disabling it. However, the second case sleep is being handled by the sdk and would need the interrupts to be active for waking up the system everytime it is kept to sleep.
Note: For more information on sleep and wakeup modes, refer to these following documents.
Thank you for contacting us. Let us know if you have any further questions. We will be happy to help!
lc_dialog.
oren.
Offline
最后一次露面:1年7个月前
专家
加入:2014-06-28 22:03
嗨LC,

嗨LC,
感谢您的信息响应。
我们现在注意到CFG_MAX_SLEEP_DOURATION_EXTERNAL_WAKEUP_MS参数 - 该Rwip_sleep()function is very complicated, but we understand you explanation.
我们希望模块尽可能长时间保持深度睡眠,而不是每10秒醒来。我们不关心轮询UART - 在我们的用例中,一旦模块刻录,它就永远不会连接到UART。
是否可以增加cfg_max_sleep_duration_external_wakeup_ms参数?如果是这样,最大值是什么?
我想我们应该使用ARCH_BLE_EXT_WAKEUP_ON.当我们想要深睡眠,直到外部唤醒。然而,在某些情况下,我们只想长时间(小时,天)深度睡眠 - 我们通过创建定期计时器来完成ke_timer_delay_max-1和一个柜台。我们每300秒醒来时都可以醒来,但不想每10秒醒来......

问候,
oren zomer.

P.S.
我们不关心不精确的时间 - 如果我们设置了1小时的计时器,我们不关心它在50分或70分钟后会醒来。对于我们的用例,20%的精度足够好。

lc_dialog.
Offline
最后一次露面:2周1天前
职员
加入:2016-09-19 23:20
你好oren,

你好oren,

Yes, you can modify the value ofcfg_max_sleep_duration_external_wakeup_ms.从1SEC到最多23.3小时(以秒为单位批判的值)。当。。。的时候ARCH_BLE_EXT_WAKEUP_ON.调用它会抑制呢value to put the BLE into permanent sleep which is the same for any value on the sleep duration. However, if theARCH_BLE_EXT_WAKEUP_OFF.is invoked then the value on sleep_duration will come into effect.

For your second requirement, I haven't fully understood the use case. Can you elaborate the scenario.

但是,您可以通过更改上述定义来扩展睡眠持续时间。这将控制BLE的唤醒时间。但是,这可以通过调用来施加困惑arch_ble_ext_wake_on()要在外部事件(或)上唤醒,您还可以使用计时器作为唤醒机制而不是外部事件。

注意:BLE事件(假设10S)的睡眠过程由智能算法管理,该算法将决定将BLE放入睡眠状态。当我们在随机时间唤醒ble时,这种算法将检查它是否有效地返回睡眠或保持下一个正常事件(例如广告)并根据决定,这可能会消耗更多的能量预计。在安排唤醒时请考虑一下

问候,

LC

oren.
Offline
最后一次露面:1年7个月前
专家
加入:2014-06-28 22:03
Hello LC,

Hello LC,
The second requirement is, for example, when we have a sensor (button) and we want to deep-sleep until an external event happens or until 1-hour passed (since we began sleeping).

我们不能打电话ARCH_BLE_EXT_WAKEUP_ON.在这种情况下,如果我们需要在1小时后醒来,如果没有外部事件发生的......

app_easy_timer.不应调用上面的值ke_timer_delay_max-1(5分钟)所以我们使用一个计时器ke_timer_delay_max-1and a countdown counter that is initialized to 12.
当调用计时器 - 回调时,我们将计数器减少1,然后:
- 如果计数器高于0,我们重新创建定时器(延迟ke_timer_delay_max-1,即5分钟)。
- 如果计数器为0,我们知道12 * 5min = 1hour已通过。
如果介于两者之间发生了外部事件,则取消计时器。

我实际上认为这个诀窍应该是一个内置的功能app_easy_timer.in case large delays are used (in v5.0.4 the implementation ofapp_easy_timer.呼叫ASSERT_ERROR(delay < KE_TIMER_DELAY_MAX), i.e. large delays are simply not allowed).

你知道是否默认的10秒唤醒(由于cfg_max_sleep_duration_external_wakeup_ms.) also happened in previous SDK versions? To be specific, I want to know about versions 3.0.4 and 3.0.8. We will increase the value to 23.3 hours, but we already have lots of modules that were already burned with previous SDKs.

问候,
oren zomer.

oren.
Offline
最后一次露面:1年7个月前
专家
加入:2014-06-28 22:03
嗨LC,

嗨LC,
23小时为82800000毫秒。
max_sleep_duration_external_wakeup.is defined to bems_to_slots_convert(cfg_max_sleep_duration_external_wakeup_ms)MS_TO_SLOTS_CONVERT(x)宏给((int)((1000 * x)/ 625))))
乘法到1000创建编译警告:“整数操作结果超出范围”警告(虽然除以625后的最终值,则在范围内)。
快速修复可能是将宏改变为:((int)((1000 *(长长)x)/ 625))

只是想让你知道...

问候,
oren zomer.

lc_dialog.
Offline
最后一次露面:2周1天前
职员
加入:2016-09-19 23:20
你好oren,

你好oren,

As of now, what we would suggest is use a timer and restart the time until you reach your desired time. As that would be the best way which also helps in your debugging.

注意:我们不建议更改值max_sleep_duration_external_wakeup.as it is effectively changing the SDK implementation. It is also the same in the previous version 3.0.4 and 3.0.8.

我们会考虑您对默认选项的建议app_easy_timer。But, as of now it is not available as a default feature.

Also, thank you for the suggestion to change the macro. I will check it out and escalate to make the correction.

问候,

leepeng.