|
|
@@ -9,6 +9,10 @@
|
|
|
#include "alarm.h"
|
|
|
#include "stat.h"
|
|
|
#include "ymodem.h"
|
|
|
+#include <stdio.h>
|
|
|
+#include <stdlib.h>
|
|
|
+#include <stdint.h>
|
|
|
+#include <string.h>
|
|
|
|
|
|
Nb_Run_t NbRun;
|
|
|
uint8_t NB_CHECK_TDC_COMPLETE_FLAG = 0;
|
|
|
@@ -1479,20 +1483,23 @@ void NbTread(void)
|
|
|
break; //
|
|
|
if (at_cmd_send(npos++, NB_ATE0, NB_ATE0_ACK, 3, 2) == -1) // 关闭回显
|
|
|
break;
|
|
|
- /////////////设置频段//////////////////////////
|
|
|
- if(Paramx.nb_band_flag!=0)
|
|
|
- {if (at_cmd_send(npos++, "AT+QCFG=\"band\",0,0x10,0,1\r\n", NB_AT_ACK, 3, 5) == -1)
|
|
|
- break;
|
|
|
- set_nb_band();
|
|
|
- if (at_cmd_send(1, NB_CFUN0, NB_AT_ACK, 3, 3) == -1)
|
|
|
- break;
|
|
|
- rt_thread_mdelay(1000);
|
|
|
- if (at_cmd_send(1, NB_CFUN1, NB_AT_ACK, 3, 3) == -1)
|
|
|
- break;
|
|
|
- rt_thread_mdelay(1200);
|
|
|
-
|
|
|
- }
|
|
|
- //////////////////////////////////////////
|
|
|
+ /////////////设置频段//////////////////////////
|
|
|
+ if (Paramx.nb_band_flag != 0)
|
|
|
+ {
|
|
|
+ // if (at_cmd_send(npos++, "AT+QCFG=\"band\",0,0x10,0,1\r\n", NB_AT_ACK, 3, 5) == -1)
|
|
|
+ // break;
|
|
|
+ if (at_cmd_send(npos++, "AT+QCFG=\"band\",0,0x008800D5,0,1\r\n", NB_AT_ACK, 3, 5) == -1)
|
|
|
+ break;
|
|
|
+
|
|
|
+ set_nb_band();
|
|
|
+ if (at_cmd_send(1, NB_CFUN0, NB_AT_ACK, 3, 3) == -1)
|
|
|
+ break;
|
|
|
+ rt_thread_mdelay(1000);
|
|
|
+ if (at_cmd_send(1, NB_CFUN1, NB_AT_ACK, 3, 3) == -1)
|
|
|
+ break;
|
|
|
+ rt_thread_mdelay(1200);
|
|
|
+ }
|
|
|
+ //////////////////////////////////////////
|
|
|
// if (at_cmd_send(1, NB_CFUN0, NB_AT_ACK, 3, 2) == -1)
|
|
|
// break;
|
|
|
// rt_thread_mdelay(1000);
|
|
|
@@ -1650,7 +1657,7 @@ void NbTread(void)
|
|
|
// get_nb_csq();
|
|
|
ncnt = 5;
|
|
|
vflag = 1;
|
|
|
- while (ncnt--) // 查询无线信号强度 BC800有
|
|
|
+ while (ncnt--) // 查询无线信号强度 EC800有
|
|
|
{
|
|
|
if (at_cmd_send(npos++, "AT+QENG=\"servingcell\"\r\n", "+QENG: \"servingcell\"", 3, 2) == -1)
|
|
|
{
|
|
|
@@ -1670,6 +1677,8 @@ void NbTread(void)
|
|
|
break;
|
|
|
if (at_cmd_send(npos++, "AT+QIACT?\r\n", "+QIACT: 1,1", 3, 3) == -1) // 查询场景激活状态
|
|
|
break;
|
|
|
+
|
|
|
+#ifdef NB_AUTO_GET_NET_TIME
|
|
|
if ((NbRun.upload.mode & NB_UPLOAD_TIMER) != 0)
|
|
|
{
|
|
|
if (at_cmd_send(npos, "AT+QNTP=1,\"202.112.10.36\",123\r\n", "+QNTP: 0,", 1, 15) == 0)
|
|
|
@@ -1678,6 +1687,7 @@ void NbTread(void)
|
|
|
LOG("get net time!\t\n");
|
|
|
}
|
|
|
}
|
|
|
+#endif
|
|
|
npos++;
|
|
|
int16_t link_code;
|
|
|
vflag = 0x80;
|
|
|
@@ -2190,16 +2200,16 @@ static void BuildDataReportNb(uint8_t *data)
|
|
|
// cell id in AT+NUESTATS response
|
|
|
data[8] = (unsigned char)(nb_run->bts_id);
|
|
|
data[9] = (unsigned char)(nb_run->bts_id >> 8);
|
|
|
- data[10] = 0x00;
|
|
|
- data[11] = 0x00;
|
|
|
+ data[10] = (unsigned char)(nb_run->bts_id >> 16);
|
|
|
+ data[11] = (unsigned char)(nb_run->bts_id >> 24);
|
|
|
|
|
|
// physical cell id
|
|
|
data[12] = (unsigned char)(nb_run->physical_cell_id);
|
|
|
data[13] = (unsigned char)(nb_run->physical_cell_id >> 8);
|
|
|
|
|
|
// rsrp
|
|
|
- data[14] = (unsigned char)(nb_run->rsrp);
|
|
|
- data[15] = (unsigned char)(nb_run->rsrp >> 8);
|
|
|
+ data[14] = (unsigned char)(nb_run->rsrp_bak);
|
|
|
+ data[15] = (unsigned char)(nb_run->rsrp_bak >> 8);
|
|
|
|
|
|
// snr
|
|
|
data[16] = (unsigned char)(nb_run->snr);
|
|
|
@@ -2708,55 +2718,76 @@ void save_datetime_from_at(uint8_t *buf, uint16_t dat_len)
|
|
|
}
|
|
|
tm.year %= 100;
|
|
|
SetRtcTime(&tm);
|
|
|
+ save_cur_flow_flag = 1;
|
|
|
}
|
|
|
|
|
|
//+QENG: "servingcell","NOCONN","LTE","FDD",460,11,EA6CE03,77,100,1,5,5,EA15,-94,-8,-66,24,26
|
|
|
// rsrp rwrq rssi sinr
|
|
|
uint8_t get_nb_signal(uint8_t *buf, uint16_t dat_len)
|
|
|
{
|
|
|
- char temp[8];
|
|
|
- char *p;
|
|
|
- int8_t index1 = 0, index2 = 0;
|
|
|
- int16_t *out_val = NULL;
|
|
|
- uint8_t ret = 0;
|
|
|
-
|
|
|
- buf[dat_len] = 0; // 确保终止位
|
|
|
- p = strstr((char *)buf, "servingcell");
|
|
|
- if (p == NULL)
|
|
|
+ // 确保数据包含预期的关键字
|
|
|
+ if (buf == NULL || strstr((char *)buf, "+QENG: \"servingcell\"") == NULL)
|
|
|
+ {
|
|
|
return 0;
|
|
|
+ }
|
|
|
|
|
|
- index1 = strnchar(p, ',', 12);
|
|
|
+ char temp[256] = {0};
|
|
|
+ memcpy(temp, buf, sizeof(temp) - 1);
|
|
|
|
|
|
- // 依次提取 rsrp_bak, rsrq, rssi, snr
|
|
|
- for (uint8_t i = 0; i < 4; i++)
|
|
|
+ char *token = NULL;
|
|
|
+ char *tokens[20]; // 足足够容纳所有分割的子字符串
|
|
|
+ int count = 0;
|
|
|
+
|
|
|
+ // 使用 strtok 按逗号分割字符串
|
|
|
+ token = strtok(temp, ",");
|
|
|
+ while (token != NULL && count < 20)
|
|
|
{
|
|
|
- if (index1 == -1)
|
|
|
- break; // 上一次查找失败,直接退出
|
|
|
+ tokens[count++] = token;
|
|
|
+ token = strtok(NULL, ",");
|
|
|
+ }
|
|
|
|
|
|
- index2 = strnchar(p, ',', 13 + i);
|
|
|
- if (index2 != -1 && index1 < index2)
|
|
|
- {
|
|
|
- memset(temp, 0, sizeof(temp));
|
|
|
- memcpy(temp, p + index1 + 1, index2 - index1 - 1);
|
|
|
+ // 根据您提供的格式,各字段在分割后的索引如下:
|
|
|
+ // [0] +QENG: "servingcell"
|
|
|
+ // [1] "NOCONN"
|
|
|
+ // [2] "LTE"
|
|
|
+ // [3] "FDD"
|
|
|
+ // [4] 460
|
|
|
+ // [5] 11
|
|
|
+ // [6] 9C8C712 -> 基站id (需转为uint32_t)
|
|
|
+ // [7] 119 -> 物理小区id
|
|
|
+ // [8] 2452
|
|
|
+ // [9] 5
|
|
|
+ // [10] 3
|
|
|
+ // [11] 3
|
|
|
+ // [12] EA15
|
|
|
+ // [13] -85 -> 参考信号接收功率
|
|
|
+ // [14] -15 -> 参考信号接收质量
|
|
|
+ // [15] -53 -> 接收信号强度指示
|
|
|
+ // [16] 0 -> SINR (有效范围 -20~40)
|
|
|
|
|
|
- int16_t val = atoi(temp);
|
|
|
- switch (i)
|
|
|
- {
|
|
|
- case 0:
|
|
|
- NbRun.rsrp_bak = val;
|
|
|
- break;
|
|
|
- case 1:
|
|
|
- NbRun.rsrq = val;
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- NbRun.rssi = val;
|
|
|
- ret = 1;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- index1 = index2; // 将当前的右边界作为下一次的左边界
|
|
|
+ // 确保分割出的字段数量足够
|
|
|
+ if (count > 16)
|
|
|
+ {
|
|
|
+ // 基站id是16进制字符串,使用 strtoul 转换为 32位无符号数
|
|
|
+ NbRun.bts_id = (uint32_t)strtoul(tokens[6], NULL, 16);
|
|
|
+
|
|
|
+ // 物理小区id是10进制数
|
|
|
+ NbRun.physical_cell_id = (uint32_t)atoi(tokens[7]);
|
|
|
+
|
|
|
+ // 参考信号接收功率
|
|
|
+ NbRun.rsrp_bak = atoi(tokens[13]);
|
|
|
+
|
|
|
+ // 参考信号接收质量
|
|
|
+ NbRun.rsrq = atoi(tokens[14]);
|
|
|
+
|
|
|
+ // 接收信号强度指示
|
|
|
+ NbRun.rssi = atoi(tokens[15]);
|
|
|
+
|
|
|
+ // SINR
|
|
|
+ NbRun.snr = atoi(tokens[16]);
|
|
|
+ return 1;
|
|
|
}
|
|
|
- return ret;
|
|
|
+ return 0;
|
|
|
}
|
|
|
uint8_t check_sub_service_flag(void)
|
|
|
{
|