暂存,测试了新平台切换,以及将初始的上报周期写为默认值
This commit is contained in:
parent
6bcbcb854d
commit
de7bd7454c
|
@ -5,7 +5,7 @@
|
|||
"type": "mrs-debugger",
|
||||
"request": "launch",
|
||||
"name": "JT-DT-YD4N02A_RTT_MRS-4G",
|
||||
"cwd": "d:\\SXDT\\Project\\CH32\\JT-DT-YD4N02A_RTT_MRS-NT26K",
|
||||
"cwd": "c:\\Users\\张喆1223\\Desktop\\NT26K\\JT-DT-YD4N02A_4G_RTT_MRS",
|
||||
"openOCDCfg": {
|
||||
"useLocalOpenOCD": true,
|
||||
"executable": "c:/MounRiver/MounRiver_Studio2/resources/app/resources/win32/components/WCH/OpenOCD/OpenOCD/bin/openocd.exe",
|
||||
|
@ -39,8 +39,8 @@
|
|||
"additionalCommands": []
|
||||
},
|
||||
"loadedFiles": {
|
||||
"executableFile": "d:\\SXDT\\Project\\CH32\\JT-DT-YD4N02A_RTT_MRS-NT26K\\obj\\JT-DT-YD4N02A_RTT_MRS-4G.elf",
|
||||
"symbolFile": "d:\\SXDT\\Project\\CH32\\JT-DT-YD4N02A_RTT_MRS-NT26K\\obj\\JT-DT-YD4N02A_RTT_MRS-4G.elf",
|
||||
"executableFile": "c:\\Users\\张喆1223\\Desktop\\NT26K\\JT-DT-YD4N02A_4G_RTT_MRS\\obj\\JT-DT-YD4N02A_RTT_MRS-4G.elf",
|
||||
"symbolFile": "c:\\Users\\张喆1223\\Desktop\\NT26K\\JT-DT-YD4N02A_4G_RTT_MRS\\obj\\JT-DT-YD4N02A_RTT_MRS-4G.elf",
|
||||
"executableFileOffset": 0,
|
||||
"symbolFileOffset": 0
|
||||
},
|
||||
|
|
|
@ -214,7 +214,7 @@ uint32_t ip_to_uint32(const char *ip_str)
|
|||
return ip;
|
||||
}
|
||||
|
||||
int Convert_To_Hex(const struct flash_sever_info *sever_info, uint8_t *hex_array)
|
||||
int Convert_To_Hex(flash_sever_info *sever_info, uint8_t *hex_array)
|
||||
{
|
||||
// 将 IP 地址转换为字节数组
|
||||
uint32_t ip_addr = ip_to_uint32(sever_info->server_url);
|
||||
|
@ -253,7 +253,9 @@ rt_uint32_t IMEI_Delay(void)
|
|||
|
||||
int BSP_SYS_Init(void)
|
||||
{
|
||||
|
||||
BSP_WDG_Init();
|
||||
|
||||
BSP_RTC_Init();
|
||||
BSP_Rng_Init();
|
||||
BSP_LED_Init();
|
||||
|
|
|
@ -105,7 +105,7 @@ void String2Hex(char *hex_arry, char *str);
|
|||
unsigned int VerToHex(const char *version);
|
||||
int Extract_Value(const char *str, const char *key);
|
||||
int _Self_Check_Mode(void);
|
||||
int Convert_To_Hex(const struct flash_sever_info *sever_info, uint8_t *hex_array);
|
||||
int Convert_To_Hex(flash_sever_info *sever_info, uint8_t *hex_array);
|
||||
int BSP_SYS_Init(void);
|
||||
rt_uint32_t IMEI_Delay(void);
|
||||
#endif //!__USER_SYS_H__
|
||||
|
|
|
@ -248,12 +248,11 @@ typedef struct __attribute__((packed))
|
|||
rt_uint8_t iot_iccid[20]; // ICCID
|
||||
} sys_config_info;
|
||||
|
||||
struct flash_sever_info
|
||||
typedef struct
|
||||
{
|
||||
char server_url[64];
|
||||
char server_port[8];
|
||||
};
|
||||
extern struct flash_sever_info sever_info;
|
||||
}flash_sever_info;
|
||||
void Flash_Write_Record(TeRecord record);
|
||||
int Get_IotImei(char *buf, rt_size_t len);
|
||||
int Get_IotImsi(char *buf, rt_size_t len);
|
||||
|
@ -290,7 +289,7 @@ rt_uint8_t Flash_Sys_Cfg(TeFlashCfgInfoId id, rt_uint8_t *buf, rt_size_t len);
|
|||
|
||||
size_t Flash_Get_SysCfg(TeFlashCfgInfoId id);
|
||||
int BSP_Flash_Write_Info(rt_uint8_t *buf, rt_size_t len);
|
||||
int Flash_Get_Sever_Data(struct flash_sever_info *sever_info);
|
||||
int Flash_Get_Sever_Data(flash_sever_info *sever_info);
|
||||
int Flash_Set_Sever_Data(rt_uint8_t *data);
|
||||
rt_uint16_t Flash_Get_WorkDuration(void);
|
||||
int Flash_Set_WorkDuration(rt_uint16_t value);
|
||||
|
|
|
@ -314,11 +314,11 @@ int at_device_nt26k_disconnect_tcp(struct at_device *device)
|
|||
|
||||
static int at_device_nt26k_connect_tcp(struct at_device *device)
|
||||
{
|
||||
|
||||
if (nt26k_conncet_tcp_flag)
|
||||
return RT_EOK;
|
||||
ASSERT(device);
|
||||
int err_code = 0;
|
||||
flash_sever_info upload_sever_info = {0};
|
||||
at_response_t resp = at_create_resp(64, 4, AT_DEFAULT_TIMEOUT);
|
||||
if (resp == RT_NULL)
|
||||
{
|
||||
|
@ -326,13 +326,13 @@ static int at_device_nt26k_connect_tcp(struct at_device *device)
|
|||
at_delete_resp(resp);
|
||||
return -RT_ENOMEM;
|
||||
}
|
||||
if (Flash_Get_Sever_Data(&sever_info) != RT_EOK)
|
||||
if (Flash_Get_Sever_Data(&upload_sever_info) != RT_EOK)
|
||||
{
|
||||
LOG_E("Get Sever Data Failed");
|
||||
at_delete_resp(resp);
|
||||
return RT_ERROR;
|
||||
}
|
||||
if (at_obj_exec_cmd(device->client, resp, TCP_CONNECT_CMD, sever_info.server_url, sever_info.server_port) == RT_EOK)
|
||||
if (at_obj_exec_cmd(device->client, resp, TCP_CONNECT_CMD, upload_sever_info.server_url, upload_sever_info.server_port) == RT_EOK)
|
||||
{
|
||||
if (at_resp_parse_line_args_by_kw(resp, "+QIOPEN:", "+QIOPEN:%d,%d", &socket_id, &err_code) > 0)
|
||||
{
|
||||
|
|
|
@ -80,10 +80,10 @@ const rt_uint32_t hr_sys_cfg_info_len[kCnt] = {
|
|||
static rt_base_t interrupt_value;
|
||||
|
||||
/*默认的系统配置*/
|
||||
struct flash_sever_info sever_info =
|
||||
{
|
||||
.server_url = SYS_IOT_URL,
|
||||
.server_port = SYS_IOT_PORT,
|
||||
flash_sever_info sever_info =
|
||||
{
|
||||
.server_url = SYS_IOT_URL,
|
||||
.server_port = SYS_IOT_PORT,
|
||||
};
|
||||
|
||||
static void BSP_Flash_UnLock (void)
|
||||
|
@ -274,7 +274,7 @@ int Flash_Set_WorkDuration (rt_uint16_t value)
|
|||
return Flash_Write_ConfigInfo (page_buf);
|
||||
}
|
||||
|
||||
int Flash_Get_Sever_Data (struct flash_sever_info *sever_info)
|
||||
int Flash_Get_Sever_Data (flash_sever_info *sever_info)
|
||||
{
|
||||
rt_uint8_t data[FLASH_SERVER_LEN] = {0};
|
||||
rt_memcpy (data, (rt_uint8_t *)FLASH_SERVER_ADDR_ADDR, FLASH_SERVER_LEN);
|
||||
|
@ -682,12 +682,10 @@ rt_uint8_t Flash_Sys_Cfg (TeFlashCfgInfoId id, rt_uint8_t *buf, rt_size_t len)
|
|||
LOG_D ("buf len %d > id len[%d]", len, hr_sys_cfg_info_len[id]);
|
||||
return -RT_ERROR;
|
||||
}
|
||||
|
||||
for (rt_uint8_t i = 0; i < hr_sys_cfg_info_len[id]; i++)
|
||||
{
|
||||
page_buf[in_page_offset + i] = buf[i];
|
||||
}
|
||||
|
||||
return Flash_Write_ConfigInfo (page_buf);
|
||||
}
|
||||
|
||||
|
@ -773,7 +771,10 @@ void BSP_Flash_EraseRecodrs (void)
|
|||
|
||||
int BSP_Flash_Init (void)
|
||||
{
|
||||
if (*(rt_uint16_t *)FLASH_INIT_FLAG_ADDR != FLASH_FIRST_INIT_VALUE)
|
||||
|
||||
rt_uint16_t flag_value = *(rt_uint16_t *)FLASH_INIT_FLAG_ADDR;
|
||||
rt_thread_mdelay(10);
|
||||
if (flag_value != FLASH_FIRST_INIT_VALUE)
|
||||
{
|
||||
LOG_D ("BSP_Flash_EraseRecodrs!");
|
||||
rt_uint8_t flash_init_flag[2];
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* @Author: mbw
|
||||
* @Date: 2024-11-14 10:21:04
|
||||
* @LastEditors: mbw && 1600520629@qq.com
|
||||
* @LastEditTime: 2025-01-20 14:30:22
|
||||
* @LastEditTime: 2025-01-17 10:46:51
|
||||
* @FilePath: \JT-DT-YD4N02A_RTT_MRS-NT26K\bsp\src\bsp_h308.c
|
||||
* @Description:
|
||||
*
|
||||
|
@ -223,22 +223,18 @@ static uint8_t H308_CheckData(void)
|
|||
uint8_t IS_H308_EndOfLife(void)
|
||||
{
|
||||
RTC_GetTime();
|
||||
if (RtcDateTime.year >= 2035)//至少大于2035年再检测
|
||||
if (RtcDateTime.year > 2035)//至少大于2035年再检测
|
||||
{
|
||||
if (RTC_GetCounter() >= H308.expiration_seconds)
|
||||
{
|
||||
H308.end_of_life = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
H308.end_of_life = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
H308.end_of_life = 0;
|
||||
}
|
||||
return H308.end_of_life;
|
||||
// else
|
||||
// {
|
||||
// H308.end_of_life = 0;
|
||||
// }
|
||||
return H308.end_of_life;
|
||||
}
|
||||
|
||||
void UART4_Init(void)
|
||||
|
@ -290,7 +286,7 @@ static void h308_thread_entry(void *param)
|
|||
static uint8_t str[UART4_RX_RB_LENGTH] = {0};
|
||||
static uint8_t h308_rx_timout_cnt = 0;
|
||||
static uint8_t h308_err_cnt = 0;
|
||||
|
||||
rt_thread_mdelay(1000);
|
||||
H308.alarm_value = Flash_Get_SysCfg(kAlarmLValueId); // 获取系统报警阈值
|
||||
LOG_D("报警阈值:%d%LEL", H308.alarm_value);
|
||||
|
||||
|
@ -394,7 +390,7 @@ int BSP_H308_Init(void)
|
|||
|
||||
return ret;
|
||||
}
|
||||
INIT_PREV_EXPORT(BSP_H308_Init);
|
||||
INIT_DEVICE_EXPORT(BSP_H308_Init);
|
||||
|
||||
void UART4_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
|
||||
void UART4_IRQHandler(void)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* @Author: mbw
|
||||
* @Date: 2024-10-09 08:42:14
|
||||
* @LastEditors: mbw && 1600520629@qq.com
|
||||
* @LastEditTime: 2025-01-20 11:31:31
|
||||
* @LastEditTime: 2025-01-18 15:39:10
|
||||
* @FilePath: \JT-DT-YD4N02A_RTT_MRS-NT26K\bsp\src\bsp_nt26k.c
|
||||
* @Description:
|
||||
*
|
||||
|
@ -819,7 +819,7 @@ int Nt26k_Process_Events(Nt26kEvent nt26k_recv_event, struct at_device *device,
|
|||
}
|
||||
else
|
||||
{
|
||||
LOG_E("nt26k send cmd failed\n"); // 收不到两种情况,1,在平台未注册,2:断网
|
||||
LOG_E("nt26k send cmd failed\n"); // 收不到说明断网了,重连下10s后再发送
|
||||
LOG_D("rt_sem_release (nt26k_disconnect_sem)");
|
||||
nt26k_conncet_tcp_flag = 0;
|
||||
rt_thread_mdelay(1);
|
||||
|
@ -834,18 +834,19 @@ int Nt26k_Process_Events(Nt26kEvent nt26k_recv_event, struct at_device *device,
|
|||
}
|
||||
}
|
||||
if (rt_strcmp(event->event_name, "掉电事件") == RT_EOK)
|
||||
{
|
||||
rt_uint8_t cnt = 0;
|
||||
while ((device_power_down_flag == 0)&&(cnt < 10))
|
||||
{
|
||||
rt_thread_mdelay(500);
|
||||
}
|
||||
if (device->class->device_ops->control(device, AT_DEVICE_CTRL_POWER_OFF, RT_NULL) == RT_EOK)
|
||||
{
|
||||
LOG_D("关闭模组");
|
||||
nt26k_power_down_flag = 1;
|
||||
}
|
||||
}
|
||||
rt_uint8_t cnt = 0;
|
||||
while ((device_power_down_flag == 0)&&(cnt < 10))
|
||||
{
|
||||
rt_thread_mdelay(500);
|
||||
}
|
||||
if (device->class->device_ops->control(device, AT_DEVICE_CTRL_POWER_OFF, RT_NULL) == RT_EOK)
|
||||
{
|
||||
LOG_D("关闭模组");
|
||||
nt26k_power_down_flag = 1;
|
||||
return RT_EOK;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1126,12 +1127,13 @@ void Handle_Sever_Addr_Set(struct Nt26k_Ops *ops)
|
|||
rt_uint8_t data[6] = {0};
|
||||
char imei[16] = {0};
|
||||
char temp[32] = "0";
|
||||
|
||||
flash_sever_info sever_info= {0};
|
||||
Get_IotImei(imei, FLASH_IOT_IMEI_LEN);
|
||||
String2Hex(temp, imei); // 将字符串转为十六进制字符串
|
||||
rt_memcpy(data, (ops->recv->recv_data.res_data + 9), FLASH_SERVER_LEN);
|
||||
LOG_D("data[%d] = %x data[%d] = %x data[%d] = %x data[%d] = %x data[%d] = %x data[%d] = %x", 0, data[0], 1, data[1], 2, data[2], 3, data[3], 4, data[4], 5, data[5]);
|
||||
Flash_Set_Sever_Data(data);
|
||||
rt_thread_mdelay(10);
|
||||
if (Flash_Get_Sever_Data(&sever_info) != RT_EOK)
|
||||
{
|
||||
LOG_E("服务器地址修改失败\n");
|
||||
|
@ -1139,7 +1141,12 @@ void Handle_Sever_Addr_Set(struct Nt26k_Ops *ops)
|
|||
else
|
||||
{
|
||||
LOG_D("服务器地址修改成功\n");
|
||||
ops->Resp(ops, DATA_SERIAL_NUM, CMD_TYPE_INSTRUCTION_REPLY, DEVICE_TYPE_NT26K, INSTRUCTION_DOWN_SEVER_ADDR, temp, RESPONSE_CODE_SUCCESS);
|
||||
if(ops->Resp(ops, DATA_SERIAL_NUM, CMD_TYPE_INSTRUCTION_REPLY, DEVICE_TYPE_NT26K, INSTRUCTION_DOWN_SEVER_ADDR, temp, RESPONSE_CODE_SUCCESS)==RT_EOK)
|
||||
{
|
||||
Flash_Set_WorkDuration(work_duration);
|
||||
rt_thread_mdelay(2000);
|
||||
reboot();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,11 +15,11 @@
|
|||
|
||||
/*使用动态日志及密码功能时,需开启宏 FINSH_USING_AUTH ULOG_USING_FILTER ENABLE_LOG_ALL ULOG_OUTPUT_LVL = 7 以及设置ulog.c 1522行 输出等级为0*/
|
||||
/**/
|
||||
#define FINSH_USING_AUTH //开启终端密码登录功能
|
||||
#define ULOG_USING_FILTER //开启动态修改日志等级 默认修改在ulog.c 1522行
|
||||
// #define FINSH_USING_AUTH //开启终端密码登录功能
|
||||
// #define ULOG_USING_FILTER //开启动态修改日志等级 默认修改在ulog.c 1522行
|
||||
|
||||
#define ENABLE_LOG_ALL
|
||||
// #define TEST_ENABLE //打开所有的终端测试程序
|
||||
#define TEST_ENABLE //打开所有的终端测试程序
|
||||
#define ULOG_OUTPUT_LVL 7 // 生产时将其设为0
|
||||
#define IOT_MODULE_SWITCH 1 //开启物联网功能
|
||||
|
||||
|
|
Loading…
Reference in New Issue