修改了hr rt_sprintf改为rt_snprintf

This commit is contained in:
小马_666 2025-01-15 11:08:37 +08:00
parent df52397e5b
commit 2f25d4903b
1 changed files with 15 additions and 6 deletions

View File

@ -2,7 +2,7 @@
* @Author : stark1898y 1658608470@qq.com * @Author : stark1898y 1658608470@qq.com
* @Date : 2024-09-04 17:33:57 * @Date : 2024-09-04 17:33:57
* @LastEditors: mbw && 1600520629@qq.com * @LastEditors: mbw && 1600520629@qq.com
* @LastEditTime: 2025-01-15 08:53:20 * @LastEditTime: 2025-01-15 11:04:00
* @FilePath: \JT-DT-YD4N02A_RTT_MRS-NT26K\bsp\src\bsp_hr.c * @FilePath: \JT-DT-YD4N02A_RTT_MRS-NT26K\bsp\src\bsp_hr.c
* @Description : * @Description :
* *
@ -440,7 +440,7 @@ int Process_Factor_Cmd(rt_uint8_t cmd)
{ {
rt_uint8_t time_buf[8] = {0}; rt_uint8_t time_buf[8] = {0};
if (*(rt_uint16_t *)FLASH_FACTOR_TIME_NUM_ADDR != 0xE3E9) if ((*(rt_uint16_t *)FLASH_FACTOR_TIME_NUM_ADDR != 0xE339)||(*(rt_uint16_t *)FLASH_FACTOR_TIME_NUM_ADDR != 0x39E3))
{ {
for (rt_uint8_t i = 0; i < 6; i++) for (rt_uint8_t i = 0; i < 6; i++)
{ {
@ -452,20 +452,29 @@ int Process_Factor_Cmd(rt_uint8_t cmd)
Get_IotImei(imei, FLASH_IOT_IMEI_LEN); Get_IotImei(imei, FLASH_IOT_IMEI_LEN);
Get_IotImsi(imsi, FLASH_IOT_IMSI_LEN); Get_IotImsi(imsi, FLASH_IOT_IMSI_LEN);
Get_IotIccid(iccid, FLASH_IOT_ICCID_LEN); Get_IotIccid(iccid, FLASH_IOT_ICCID_LEN);
rt_sprintf(buf, int len = rt_snprintf(buf, sizeof(buf),
"\r\n[ID :YD4N02/%02d%02d%02d%04d]\r\n" "\r\n[ID :YD4N02/%02d%02d%02d%04d]\r\n"
"[IMEI:%s]\r\n" "[IMEI:%s]\r\n"
"[IMSI:%s]\r\n" "[IMSI:%s]\r\n"
"[CCID:%s]\r\nOK\r\n", "[CCID:%s]\r\nOK\r\n",
time_buf[5], time_buf[4], time_buf[3], cnt, imei, imsi, iccid); time_buf[5], time_buf[4], time_buf[3], cnt, imei, imsi, iccid);
BSP_Hr_Send_Data(buf, rt_strlen(buf)); BSP_Hr_Send_Data(buf, len);
LOG_D("time_buf[2] = %02x time_buf[1] = %02x time_buf[0] = %02x cnt = %04d", time_buf[2], time_buf[1], time_buf[0], cnt); LOG_D("time_buf[2] = %02x time_buf[1] = %02x time_buf[0] = %02x cnt = %04d", time_buf[2], time_buf[1], time_buf[0], cnt);
} }
else else
{ {
LOG_E("[%s] is not set\r\n", "factory time"); Get_IotImei(imei, FLASH_IOT_IMEI_LEN);
BSP_Hr_Send_Data("factory time is not set\r\n", rt_strlen("factory time is not set\r\n")); Get_IotImsi(imsi, FLASH_IOT_IMSI_LEN);
Get_IotIccid(iccid, FLASH_IOT_ICCID_LEN);
int len = rt_snprintf(buf, sizeof(buf),
"\r\n[ID :YD4N02/%02d%02d%02d%04d]\r\n"
"[IMEI:%s]\r\n"
"[IMSI:%s]\r\n"
"[CCID:%s]\r\nOK\r\n",
time_buf[5], time_buf[4], time_buf[3], 1, imei, imsi, iccid);
BSP_Hr_Send_Data(buf, len);
} }
return RT_EOK; return RT_EOK;
} }