// GPS停止等待定时器相关变量
static osTimerId_t g_stop_wait_timer = NULL;
static int g_stop_wait_count = 0;
-static const int MAX_WAIT_COUNT = 80; // 最多等待8秒 (80 * 100ms)
+static const int MAX_WAIT_COUNT = 8; // 最多等待8秒 (80 * 100ms)
// 全局变量,存储当前有效的时间戳文件夹路径
static char *g_current_agnss_folder = NULL;
g_stop_wait_count++;
// 检查数据监听是否已停止
- if (g_is_listening_data == 0) {
- printf("PGnssServerStop: Data listening stopped, executing cleanup...\r\n");
+ if (g_is_listening_data == 1) {
+ printf("PGnssServerStop: GPS has initialized and is listening, executing safe cleanup...\r\n");
// 停止定时器
if (g_stop_wait_timer != NULL) {
}
// 打印等待进度(每1秒打印一次)
- if (g_stop_wait_count % 10 == 0) {
- printf("PGnssServerStop: Waiting for data listening to stop... (%d/%d ms)\r\n",
- g_stop_wait_count * 100, MAX_WAIT_COUNT * 100);
+ if (g_stop_wait_count % 2 == 0) {
+ printf("PGnssServerStop: Waiting for data listening to stop... (%d/%d s)\r\n",
+ g_stop_wait_count * 2, MAX_WAIT_COUNT * 2);
}
// 超时处理:如果等待时间超过最大值,强制执行清理
}
// 如果数据监听已经停止,直接执行清理
- if (g_is_listening_data == 0) {
+ if (g_is_listening_data == 1) {
printf("PGnssServerStop: Data listening already stopped, executing cleanup immediately\r\n");
do_gps_stop_cleanup();
return;
}
// 启动定时器(100ms间隔)
- int tick = osMs2Tick(100);
+ int tick = osMs2Tick(1000);
osStatus_t ret = osTimerStart(g_stop_wait_timer, tick);
if (ret != osOK) {
printf("PGnssServerStop: Failed to start wait timer (ret=%d), executing cleanup immediately\r\n", ret);