#include <stdbool.h>
#include <stdlib.h>
#include "pmu_interrupt.h"
+#ifdef SUPPORT_CAT1_SERVICE
+#include "cat1_porting.h"
+#include "pm_definition.h"
+#endif
/* 乒乓缓冲区配置 */
#ifndef SIO_PING_PONG_BUFFER_SIZE
/* 数据处理回调函数指针 - 用于将数据传递给SLIP */
static void (*g_sio_data_callback)(const uint8_t *data, uint32_t len) = NULL;
+#ifdef SUPPORT_CAT1_SERVICE
+/* CAT1投票管理:记录最后接收数据的时间,用于idle检测 */
+static uint32_t g_sio_last_rx_time_ms = 0;
+static bool g_sio_cat1_vote_added = false;
+#define SIO_CAT1_VOTE_IDLE_MS 10000 // 10秒idle后移除投票
+#endif
+
/* 内部函数声明 */
// ⚠️ 更新全局时间戳(供ISR使用,ISR中不能调用时间函数)
g_sio_timer_timestamp_ms = current_time;
-
+#ifdef SUPPORT_CAT1_SERVICE
+ // ✅ CAT1投票管理:检测idle状态,超过10秒后移除投票
+ if (g_sio_cat1_vote_added && g_sio_last_rx_time_ms > 0) {
+ uint32_t idle_time = current_time - g_sio_last_rx_time_ms;
+ if (idle_time >= SIO_CAT1_VOTE_IDLE_MS) {
+ // 空闲时间超过10秒,移除投票允许CAT1休眠
+ cat1_api_remove_cat1_vote();
+ g_sio_cat1_vote_added = false;
+ g_sio_last_rx_time_ms = 0;
+ printf("[SIO] Removed CAT1 vote after %ums idle\n", idle_time);
+ }
+ }
+#endif
if (g_sio_ping_pong_buffers == NULL) {
goto restart_timer;
g_sio_stats.total_interrupts++;
g_sio_stats.total_bytes_received += length;
-
+#ifdef SUPPORT_CAT1_SERVICE
+ // ✅ CAT1投票管理:收到数据时,更新接收时间并添加投票
+ g_sio_last_rx_time_ms = g_sio_timer_timestamp_ms;
+ if (!g_sio_cat1_vote_added) {
+ cat1_api_add_cat1_vote();
+ g_sio_cat1_vote_added = true;
+ }
+#endif
uint8_t current_idx = g_sio_current_buffer_index;
sio_ping_pong_buffer_t *current_buffer = &g_sio_ping_pong_buffers[current_idx];
#define LWIP_DEFINE_SWITCH 0
#define LOSCFG_CONFIG_MQTT 1
-#define LWIP_LOWPOWER 1
+#define LWIP_LOWPOWER 0
/* time unit */
#define MS_PER_SECOND 1000
// tcpip_thread_id = sys_thread_new(TCPIP_THREAD_NAME, tcpip_thread, NULL, TCPIP_THREAD_STACKSIZE, TCPIP_THREAD_PRIO);
taskcfg.create_queue_handle = NULL;
taskcfg.attr.name=TCPIP_THREAD_NAME;
- taskcfg.attr.priority = osPriorityBelowNormal;// osPriorityBelowNormal;
+ taskcfg.attr.priority = osPriorityNormal;// osPriorityBelowNormal;
taskcfg.attr.stack_size = TCPIP_THREAD_STACKSIZE;
taskcfg.func = tcpip_thread;
taskcfg.use_mem = USE_EXTEND_MEM;
#define PEER_IP "172.16.1.2"
#define PEER_PORT 5000
#define SERVER_IP "172.16.1.5"
-#define PORT 1000
+#define PORT 1000
+#define TIME_SYNC_INTERVAL 10000 // 时间同步定时器间隔,单位:毫秒
//"F"UDP_COMMAND_HEAD , len ,data
enum UDP_COMMAND_HEAD {
UDP_CMD_GET_CAT1VER = 0x00, // 获取 Cat1 版本号
if(osTimerIsRunning(g_timer_time_sync)==0 )
{
// cat1_print_info("cat1 restart_time_sync timer \n");
- // uint32_t tick = (uint32_t )osMs2Tick(5000); // 60000: seconds of a minute
- osStatus_t ret = osTimerStart(g_timer_time_sync,5000); //5秒后重试同步时间
+ // uint32_t tick = (uint32_t )osMs2Tick(TIME_SYNC_INTERVAL); // 60000: seconds of a minute
+ osStatus_t ret = osTimerStart(g_timer_time_sync, TIME_SYNC_INTERVAL); // 时间同步定时器启动
cat1_print_info("cat1 restart_time_sync timer ret %d\n",ret);
}
g_timer_time_Dial = osTimerNew((osTimerFunc_t)time_dial_func, osTimerPeriodic, NULL, NULL);
if (g_timer_time_Dial == NULL)
- cat1_print_err("g_timer_time_sync create failed\n");
+ cat1_print_err("g_timer_time_Dial create failed\n");
g_timer_time_answer = osTimerNew((osTimerFunc_t)time_answer_func, osTimerPeriodic, NULL, NULL);
if (g_timer_time_answer == NULL)
- cat1_print_err("g_timer_time_sync create failed\n");
+ cat1_print_err("g_timer_time_answer create failed\n");
#ifdef USE_CAT1_SLEEP_TIMER
}
else if(cmd == 1 && !osTimerIsRunning(g_timer_time_sync))
{
- osTimerStart(g_timer_time_sync,5000);
+ osTimerStart(g_timer_time_sync, TIME_SYNC_INTERVAL);
}
}
1,
S_AGPIO_L24,//reset_pin
1,
- S_MGPIO22,//ring_pin
+ PIN_NONE,//S_MGPIO22,//ring_pin
0,
S_MGPIO21,//wakemodem_pin
0,
// 检测到idle且未suspend,执行suspend
if (g_ws_is_suspended == 0) {
HAISI_WS_DEBUG("Idle detected, suspending WebSocket\n");
- uapi_ws_suspend();
+ // uapi_ws_suspend();
}
} else {
// 检测到busy且已suspend,执行resume
if (g_ws_is_suspended != 0) {
HAISI_WS_DEBUG("Busy detected, resuming WebSocket\n");
- uapi_ws_resume();
+ // uapi_ws_resume();
}
}
}