chore: silence GNSS application logs by default
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
#include "sockets.h"
|
||||
#include "netdb.h"
|
||||
#include "app_inc.h"
|
||||
#include "app_gnss_log.h"
|
||||
|
||||
// 新增宏定义(原代码中未定义)
|
||||
#define GNSS_FAST_MODE_HOLD_TIME (5 * 60 * 1000) // FAST模式持续5分钟后切SLOW
|
||||
@@ -211,10 +212,7 @@ void quec_gnss_callback(char *data, int len)
|
||||
char nmea_buffer[512];
|
||||
int fix_status = 0;
|
||||
|
||||
// 打印原始 NMEA 数据
|
||||
for (i = 0; i < len; i++) {
|
||||
printf("%c", data[i]);
|
||||
}
|
||||
APP_GNSS_LOG("%.*s", len, data);
|
||||
|
||||
// 在 data 中定位 GGA 句子的起止位置
|
||||
// GGA 格式: $xxGGA,...,*CS\r\n
|
||||
@@ -267,7 +265,7 @@ void quec_gnss_callback(char *data, int len)
|
||||
g_gps_location.is_valid = (fix_status >= 1) ? 1 : 0;
|
||||
} else {
|
||||
g_gps_location.is_valid = 0;
|
||||
printf("\n[GNSS Parse failed] FS=%d, %s\n",
|
||||
APP_GNSS_LOG("\n[GNSS Parse failed] FS=%d, %s\n",
|
||||
fix_status,
|
||||
(fix_status == 0) ? "No Fix (Invalid)" : "Format error");
|
||||
}
|
||||
@@ -321,7 +319,7 @@ void quec_gnss_callback(char *data, int len)
|
||||
void set_gnss_mode(gnss_mode_t mode)
|
||||
{
|
||||
g_gnss_mode = mode;
|
||||
printf("[GNSSMode] Set to %s Mode\n",
|
||||
APP_GNSS_LOG("[GNSSMode] Set to %s Mode\n",
|
||||
(mode == GNSS_MODE_FAST) ? "Fast (30s)" : "Slow (5min)");
|
||||
}
|
||||
|
||||
@@ -353,11 +351,11 @@ gps_location_info_t* get_gps_location_info(void)
|
||||
void print_gps_location_info(void)
|
||||
{
|
||||
if (g_gps_location.is_valid) {
|
||||
printf("[GPSinfo] Latitude: %.8f, Longitude: %.8f\n",
|
||||
APP_GNSS_LOG("[GPSinfo] Latitude: %.8f, Longitude: %.8f\n",
|
||||
g_gps_location.latitude, g_gps_location.longitude);
|
||||
printf("[GPSinfo] rawNMEA: %s\n", g_gps_location.raw_nmea);
|
||||
APP_GNSS_LOG("[GPSinfo] rawNMEA: %s\n", g_gps_location.raw_nmea);
|
||||
} else {
|
||||
printf("[GPSinfo] No valid position data\n");
|
||||
APP_GNSS_LOG("[GPSinfo] No valid position data\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -395,26 +393,29 @@ static void quec_gnss_test(void * argv)
|
||||
/* ========== FAST MODE ========== */
|
||||
if (fast_mode_start_time == 0) {
|
||||
fast_mode_start_time = hal_os_up_time_ms();
|
||||
printf("[GNSS] Enter FAST mode\n");
|
||||
APP_GNSS_LOG("[GNSS] Enter FAST mode\n");
|
||||
}
|
||||
|
||||
if (!gnss_is_open) {
|
||||
gnss_is_open = 1;
|
||||
app_set_app_operation(1);
|
||||
ql_gnss_open(quec_gnss_callback);
|
||||
printf("[GNSS] FAST: GPS OPEN\n");
|
||||
APP_GNSS_LOG("[GNSS] FAST: GPS OPEN\n");
|
||||
}
|
||||
|
||||
// 5分钟超时切SLOW
|
||||
if (hal_os_up_time_ms() - fast_mode_start_time >= GNSS_FAST_MODE_HOLD_TIME) {
|
||||
printf("[GNSS] FAST 5min timeout -> SLOW\n");
|
||||
APP_GNSS_LOG("[GNSS] FAST 5min timeout -> SLOW\n");
|
||||
g_gnss_mode = GNSS_MODE_SLOW;
|
||||
fast_mode_start_time = 0;
|
||||
slow_mode_start_time = 0;
|
||||
slow_next_wake_time = 0;
|
||||
|
||||
gnss_is_open = 0;
|
||||
printf("[GNSS] SLOW: GPS CLOSED ret:%d\n", ql_gnss_close());
|
||||
|
||||
int close_ret = ql_gnss_close();
|
||||
(void)close_ret;
|
||||
APP_GNSS_LOG("[GNSS] SLOW: GPS CLOSED ret:%d\n", close_ret);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -426,12 +427,12 @@ static void quec_gnss_test(void * argv)
|
||||
if (slow_mode_start_time == 0) {
|
||||
slow_mode_start_time = now;
|
||||
slow_next_wake_time = now; // 立即尝试第一次定位
|
||||
printf("[GNSS] Enter SLOW mode (fixed 15min interval)\n");
|
||||
APP_GNSS_LOG("[GNSS] Enter SLOW mode (fixed 15min interval)\n");
|
||||
}
|
||||
|
||||
// 检查是否到达唤醒时间
|
||||
if (now < slow_next_wake_time) {
|
||||
printf("[GNSS] SLOW: next wake in %d s\n",
|
||||
APP_GNSS_LOG("[GNSS] SLOW: next wake in %d s\n",
|
||||
(slow_next_wake_time - now) / 1000);
|
||||
}
|
||||
else if (!gnss_is_open) {
|
||||
@@ -444,7 +445,7 @@ static void quec_gnss_test(void * argv)
|
||||
app_set_app_operation(1);
|
||||
ql_gnss_open(quec_gnss_callback);
|
||||
|
||||
printf("[GNSS] SLOW: GPS OPEN, search start\n");
|
||||
APP_GNSS_LOG("[GNSS] SLOW: GPS OPEN, search start\n");
|
||||
|
||||
/* ---- 第一阶段:60秒卫星检测 ---- */
|
||||
int sat_found = 0;
|
||||
@@ -454,7 +455,7 @@ static void quec_gnss_test(void * argv)
|
||||
elapsed++;
|
||||
if (g_gnss_sat_count > 1) {
|
||||
sat_found = 1;
|
||||
printf("[GNSS] SLOW: Sat found! count=%d, after %ds\n",
|
||||
APP_GNSS_LOG("[GNSS] SLOW: Sat found! count=%d, after %ds\n",
|
||||
g_gnss_sat_count, elapsed);
|
||||
break;
|
||||
}
|
||||
@@ -462,10 +463,13 @@ static void quec_gnss_test(void * argv)
|
||||
|
||||
if (!sat_found) {
|
||||
// 60秒无卫星 → 立即关闭,等待15分钟
|
||||
printf("[GNSS] SLOW: No satellite in 30s, stop ret:%d.\n", ql_gnss_close());
|
||||
|
||||
int close_ret = ql_gnss_close();
|
||||
(void)close_ret;
|
||||
APP_GNSS_LOG("[GNSS] SLOW: No satellite in 30s, stop ret:%d.\n", close_ret);
|
||||
gnss_is_open = 0;
|
||||
slow_next_wake_time = search_start_time + (GNSS_SEARCH_INTERVAL * 1000);
|
||||
printf("[GNSS] SLOW: GPS CLOSED, next search at +%ds\n", GNSS_SEARCH_INTERVAL);
|
||||
APP_GNSS_LOG("[GNSS] SLOW: GPS CLOSED, next search at +%ds\n", GNSS_SEARCH_INTERVAL);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -478,17 +482,20 @@ static void quec_gnss_test(void * argv)
|
||||
|
||||
// 1.5分钟时刻检查卫星数
|
||||
int sat_count_now = g_gnss_sat_count;
|
||||
printf("[GNSS] SLOW: 1min check, satellite count = %d\n", sat_count_now);
|
||||
APP_GNSS_LOG("[GNSS] SLOW: 1min check, satellite count = %d\n", sat_count_now);
|
||||
if (sat_count_now < GNSS_SAT_MIN_COUNT) {
|
||||
printf("[GNSS] SLOW: Sat count < %d, stop search ret:%d.\n", GNSS_SAT_MIN_COUNT,ql_gnss_close());
|
||||
|
||||
int close_ret = ql_gnss_close();
|
||||
(void)close_ret;
|
||||
APP_GNSS_LOG("[GNSS] SLOW: Sat count < %d, stop search ret:%d.\n", GNSS_SAT_MIN_COUNT, close_ret);
|
||||
gnss_is_open = 0;
|
||||
slow_next_wake_time = search_start_time + (GNSS_SEARCH_INTERVAL * 1000);
|
||||
printf("[GNSS] SLOW: GPS CLOSED, next search at +%ds\n", GNSS_SEARCH_INTERVAL);
|
||||
APP_GNSS_LOG("[GNSS] SLOW: GPS CLOSED, next search at +%ds\n", GNSS_SEARCH_INTERVAL);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* ---- 第三阶段:卫星足够,继续定位,但总时间不超过3分钟 ---- */
|
||||
printf("[GNSS] SLOW: Sat count OK, continue for fix (max %ds total)\n",
|
||||
APP_GNSS_LOG("[GNSS] SLOW: Sat count OK, continue for fix (max %ds total)\n",
|
||||
GNSS_MAX_SEARCH_TIME);
|
||||
|
||||
// 继续等待直到总时间达到 GNSS_MAX_SEARCH_TIME (180秒)
|
||||
@@ -498,28 +505,30 @@ static void quec_gnss_test(void * argv)
|
||||
|
||||
// 如果获得有效定位,打印提示(但继续等待至3分钟)
|
||||
if (g_gps_location.is_valid) {
|
||||
printf("[GNSS] SLOW: Fix obtained at %ds!\n", elapsed);
|
||||
APP_GNSS_LOG("[GNSS] SLOW: Fix obtained at %ds!\n", elapsed);
|
||||
print_gps_location_info();
|
||||
// 若希望在定位成功后立即关闭,可在此 break,但此处按“最长3分钟”处理
|
||||
}
|
||||
}
|
||||
|
||||
// 3分钟时间到,关闭GPS
|
||||
printf("[GNSS] SLOW: Max search time reached, stop.\n");
|
||||
APP_GNSS_LOG("[GNSS] SLOW: Max search time reached, stop.\n");
|
||||
if (g_gps_location.is_valid) {
|
||||
printf("[GNSS] SLOW: Final valid position:\n");
|
||||
APP_GNSS_LOG("[GNSS] SLOW: Final valid position:\n");
|
||||
print_gps_location_info();
|
||||
} else {
|
||||
printf("[GNSS] SLOW: No valid fix within 3min.\n");
|
||||
APP_GNSS_LOG("[GNSS] SLOW: No valid fix within 3min.\n");
|
||||
}
|
||||
|
||||
printf("[GNSS] SLOW: GPS CLOSED ret:%d",ql_gnss_close());
|
||||
int close_ret = ql_gnss_close();
|
||||
(void)close_ret;
|
||||
APP_GNSS_LOG("[GNSS] SLOW: GPS CLOSED ret:%d", close_ret);
|
||||
gnss_is_open = 0;
|
||||
g_gps_location.is_valid = 0; // 重置状态
|
||||
|
||||
// 设置下次唤醒时间为 15分钟 后
|
||||
slow_next_wake_time = search_start_time + (GNSS_SEARCH_INTERVAL * 1000);
|
||||
printf("[GNSS] SLOW: GPS CLOSED, next search at +%ds\n", GNSS_SEARCH_INTERVAL);
|
||||
APP_GNSS_LOG("[GNSS] SLOW: GPS CLOSED, next search at +%ds\n", GNSS_SEARCH_INTERVAL);
|
||||
}
|
||||
// else: GPS正在运行中(理论上不会到这里)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef APP_GNSS_LOG_H
|
||||
#define APP_GNSS_LOG_H
|
||||
|
||||
/* GNSS diagnostics are quiet by default while investigating voice replies.
|
||||
* Define APP_GNSS_LOG_ENABLED=1 at build time to restore application logs.
|
||||
* Keep state changes and hardware operations outside log arguments. */
|
||||
#ifndef APP_GNSS_LOG_ENABLED
|
||||
#define APP_GNSS_LOG_ENABLED 0
|
||||
#endif
|
||||
|
||||
#if APP_GNSS_LOG_ENABLED
|
||||
#include <stdio.h>
|
||||
#define APP_GNSS_LOG(...) printf(__VA_ARGS__)
|
||||
#else
|
||||
#define APP_GNSS_LOG(...) ((void)0)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "ql_application.h"
|
||||
#include "sockets.h"
|
||||
#include "app_inc.h"
|
||||
#include "app_gnss_log.h"
|
||||
#include "cjson.h"
|
||||
#include "ql_fs.h"
|
||||
#include "ql_fota.h"
|
||||
@@ -442,7 +443,7 @@ int parse_command(const char *json_str, command_t *cmd)
|
||||
if (params != NULL) {
|
||||
switch (cmd->type) {
|
||||
case MSG_GPS_QUERY:
|
||||
printf("MSG_GPS_QUERY\r\n");
|
||||
APP_GNSS_LOG("MSG_GPS_QUERY\r\n");
|
||||
/*返回当前的GPS坐标信息*/
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user