static int g_listen_sock = 0;
struct sockaddr_in sourceAddr = {0};
static osTimerId_t g_timer_time_sync = NULL;
+#if USE_CAT1_SLEEP_TIMER
static osTimerId_t g_timer_cat1_sleep = NULL;
+#endif
static uint8_t g_time_synced = 0;
#define MAX_TIME_SYNC_RETRY_TIME 5
static uint8_t g_time_sync_retry_time = 0;
return 1;
}
+
+#if USE_CAT1_SLEEP_TIMER
void mcu_remove_sleepvote_and_stoptimer(void)
{
// uapi_cat1_wakeup_cat1(0);// 反馈给cat1,它也可以自己睡
WEARABLE_LOGE(WEARABLE_LOG_MODULE_MAIN_SERVICE,"sleep mcu\n");
do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_TYPE_REMOVE_CAT1VOTE,NULL,0);
}
+
//目前只在 被cat1唤醒的中断函数里执行,
void restart_sleep_cat1_timer(void)
{
// WEARABLE_LOGI(WEARABLE_LOG_MODULE_MAIN_SERVICE,"osTimerStart g_timer_cat1_sleep ret %d\n",ret);
}
}
-
+#endif
static void time_sync_func(void)
{
PRINT("time_sync_func\n");
+
+ runtime_status_t * runtime = get_device_runtime_status();
+ if (uapi_cat1_get_power_stat() == false )
+ {
+ //开关是关的 则cat1所有状态清空
+ runtime->cat1_runtime.cat1_powerOn = 0;
+ runtime->cat1_runtime.network_on = 0;
+ runtime->cat1_runtime.signal = 99;
+ runtime->cat1_runtime.sim = 0;
+ runtime->cat1_runtime.volte = 0;
+ return ;
+ }else{
+ runtime->cat1_runtime.cat1_powerOn = 1;
+
+ }
cat1_getsignal();
if(osTimerIsRunning(g_timer_time_sync)==1 && g_time_synced == 1 )
// if( index >= 0 ) {
// udp_send_response(tx_buffer, rx_buffer, "OK"/* msg_wifi_resp[index]*/);
// }
+
+ #ifndef USE_CAT1_SLEEP_TIMER
uapi_cat1_remove_cat1_vote(); //中断会添加休眠投票,此处代表已经收到cat1的消息,可以移除投票进入休眠了。
-
+ #endif
}
}
if (g_timer_time_sync == NULL)
PRINT("g_timer_time_sync create failed\n");
+ restart_time_sync();
+
+#if USE_CAT1_SLEEP_TIMER
g_timer_cat1_sleep = osTimerNew((osTimerFunc_t)timeout_handler_sleep_cat1, osTimerPeriodic, NULL, NULL);
if (g_timer_cat1_sleep == NULL)
PRINT("g_timer_cat1_sleep create failed\n");
//第一次启动,要确保去除已经添加过的cat1 Vote
restart_sleep_cat1_timer();
-
+#endif
return ERRCODE_SUCC;
}
uapi_cat1_add_cat1_vote();
//中断会在此添加休眠投票,在收到cat1的消息后,会移除投票进入休眠。
//之前的5秒后移除投票延迟太久,与5秒更新一次信号强度
- // restart_sleep_cat1_timer();
+ #if USE_CAT1_SLEEP_TIMER
+ restart_sleep_cat1_timer();
+ #endif
break;
case CUSTOM_CMD_MSG_TYPE_REMOVE_CAT1VOTE:
- mcu_remove_sleepvote_and_stoptimer();
+ #if USE_CAT1_SLEEP_TIMER
+ mcu_remove_sleepvote_and_stoptimer();
+ #endif
break;
case CUSTOM_CMD_MSG_TYPE_CHANGE_SYSTEM_VOLUME:
{