|
@ -76,6 +76,8 @@ void ENTER_DEEP_SLEEP() { |
|
|
|
|
|
|
|
|
static void poweroff() { |
|
|
static void poweroff() { |
|
|
if (!m_ispoweron) return; |
|
|
if (!m_ispoweron) return; |
|
|
|
|
|
BoardLight_setGreenLightEffect(kLightEffect_close); |
|
|
|
|
|
|
|
|
BoardBeepCtrl_unload(); |
|
|
BoardBeepCtrl_unload(); |
|
|
BoardLight_unload(); |
|
|
BoardLight_unload(); |
|
|
BoardBattery_unload(); |
|
|
BoardBattery_unload(); |
|
@ -86,7 +88,6 @@ static void poweroff() { |
|
|
zble_module_stop_adv(); |
|
|
zble_module_stop_adv(); |
|
|
zble_module_disconnect(); |
|
|
zble_module_disconnect(); |
|
|
// sd_ble_gap_disconnect() |
|
|
// sd_ble_gap_disconnect() |
|
|
BoardLight_setGreenLightEffect(kLightEffect_close); |
|
|
|
|
|
// 进入深度睡眠前,使能唤醒引脚 |
|
|
// 进入深度睡眠前,使能唤醒引脚 |
|
|
|
|
|
|
|
|
ENTER_DEEP_SLEEP(); |
|
|
ENTER_DEEP_SLEEP(); |
|
@ -185,7 +186,6 @@ static void app_event_listener(void* p_event_data, uint16_t event_size) { // |
|
|
|
|
|
|
|
|
// |
|
|
// |
|
|
else if (m_device_state == kdevice_state_ready) { |
|
|
else if (m_device_state == kdevice_state_ready) { |
|
|
|
|
|
|
|
|
if (DeviceCtrl_cur_state_haspassed_ms() > 3000) { |
|
|
if (DeviceCtrl_cur_state_haspassed_ms() > 3000) { |
|
|
if (!zble_module_is_connected() && DeviceCtrl_cur_state_haspassed_ms() > APP_AUTO_SLEEP_TIMEOUT_MS) { |
|
|
if (!zble_module_is_connected() && DeviceCtrl_cur_state_haspassed_ms() > APP_AUTO_SLEEP_TIMEOUT_MS) { |
|
|
ZLOGI("auto sleep"); |
|
|
ZLOGI("auto sleep"); |
|
@ -316,8 +316,9 @@ void DeviceCtrl_init() { |
|
|
// BoardLight_blockFlash(3, 100); |
|
|
// BoardLight_blockFlash(3, 100); |
|
|
BoardBattery_load(); |
|
|
BoardBattery_load(); |
|
|
if (BoardBattery_get_battery_level() < APP_LOW_BATTERY_POWER_ON_LIMIT) { |
|
|
if (BoardBattery_get_battery_level() < APP_LOW_BATTERY_POWER_ON_LIMIT) { |
|
|
|
|
|
BoardLight_load(); |
|
|
BoardLight_blockFlash(3, 100); |
|
|
BoardLight_blockFlash(3, 100); |
|
|
|
|
|
|
|
|
|
|
|
BoardLight_unload(); |
|
|
// 系统进入深度睡眠,进入深度睡眠前,使能唤醒引脚 |
|
|
// 系统进入深度睡眠,进入深度睡眠前,使能唤醒引脚 |
|
|
ENTER_DEEP_SLEEP(); |
|
|
ENTER_DEEP_SLEEP(); |
|
|
} |
|
|
} |
|
@ -330,7 +331,7 @@ void DeviceCtrl_init() { |
|
|
// 切换到待机状态 |
|
|
// 切换到待机状态 |
|
|
prvf_change_to_ready_state(); |
|
|
prvf_change_to_ready_state(); |
|
|
|
|
|
|
|
|
wd_init(); |
|
|
|
|
|
|
|
|
// wd_init(); |
|
|
|
|
|
|
|
|
ZERROR_CHECK(app_timer_create(&m_state_machine_driver_tmr, APP_TIMER_MODE_REPEATED, state_machine_driver_tmr_cb)); |
|
|
ZERROR_CHECK(app_timer_create(&m_state_machine_driver_tmr, APP_TIMER_MODE_REPEATED, state_machine_driver_tmr_cb)); |
|
|
ZERROR_CHECK(app_timer_start(m_state_machine_driver_tmr, APP_TIMER_TICKS(100), NULL)); // 200HZ采样 |
|
|
ZERROR_CHECK(app_timer_start(m_state_machine_driver_tmr, APP_TIMER_TICKS(100), NULL)); // 200HZ采样 |
|
|