fix: tcp_json_srv_init 加一次性守卫 + callback NULL 诊断

问题: NET_SSC_ENABLE 时 g_net_state.flag 保持 1, net_srv_init 反复调用
      tcp_json_srv_init 第二次因 socket 已存在失败 → 过早 return
      → lup_set_sensor_callback 未执行 → 0xC0 回调永远 NULL

修复:
- tcp_json_srv_init: 加 static _init_done 守卫,防止重复执行
- lup_set_sensor_callback: 打印注册/清除日志
- lup_process_frame: 回调为 NULL 时打印诊断信息
This commit is contained in:
wangfq
2026-07-02 14:29:23 +08:00
parent d559294359
commit c4a2b50ca5
2 changed files with 7 additions and 0 deletions

View File

@@ -661,6 +661,7 @@ static lup_sensor_cb_t g_lup_sensor_cb = NULL;
void lup_set_sensor_callback(lup_sensor_cb_t cb)
{
g_lup_sensor_cb = cb;
PRINT("LUP: sensor callback %s\n", cb ? "registered" : "cleared");
}
/*
@@ -697,6 +698,8 @@ void lup_process_frame(const uint8_t *pkg, uint16_t len)
if (cmd == LUP_CMD_SENSOR_REPORT) {
if (g_lup_sensor_cb) {
g_lup_sensor_cb(pkg, len);
} else {
PRINT("LUP: 0xC0 received but no callback registered!\n");
}
return;
}