|
|
@@ -66,7 +66,7 @@ static int DTU_uart2_init(void)
|
|
|
dtuconfig.stop_bits = STOP_BITS_1; //停止位1
|
|
|
#ifdef RT_USING_SERIAL_V2
|
|
|
dtuconfig.rx_bufsz = 1024;
|
|
|
- dtuconfig.tx_bufsz = 1024;
|
|
|
+ dtuconfig.tx_bufsz = 2048;
|
|
|
#else
|
|
|
dtuconfig.bufsz = 1024; //缓冲区1k
|
|
|
#endif
|
|
|
@@ -75,7 +75,7 @@ static int DTU_uart2_init(void)
|
|
|
rt_device_control(dtuserial, RT_DEVICE_CTRL_CONFIG, &dtuconfig);
|
|
|
/* step4:打开串口设备。以DMA接收及轮询发送模式打开串口设备 */
|
|
|
#ifdef RT_USING_SERIAL_V2
|
|
|
- rt_err_t uart_res = rt_device_open(dtuserial, RT_DEVICE_FLAG_RX_NON_BLOCKING | RT_DEVICE_FLAG_TX_BLOCKING); // 串口设备使用模式为 (发送阻塞 接收非阻塞) 模式
|
|
|
+ rt_err_t uart_res = rt_device_open(dtuserial, RT_DEVICE_FLAG_RX_NON_BLOCKING | RT_DEVICE_FLAG_RX_NON_BLOCKING); // 串口设备使用模式为 (发送阻塞 接收非阻塞) 模式
|
|
|
#else
|
|
|
rt_err_t uart_res = rt_device_open(dtuserial, RT_DEVICE_FLAG_DMA_RX); //RT_DEVICE_FLAG_DMA_RX
|
|
|
#endif
|
|
|
@@ -90,26 +90,16 @@ static int DTU_uart2_init(void)
|
|
|
/*数据发送*/
|
|
|
void DTU_Write(char *fmt, ...)
|
|
|
{
|
|
|
- //static const char dtu_conf[4] = {device_status.vol,0x00,0x00,0x00};
|
|
|
va_list ap;
|
|
|
- static char dtu_str[1024];
|
|
|
+ static char dtu_str[2048];
|
|
|
rt_size_t str_length;
|
|
|
va_start(ap,fmt);
|
|
|
- //str_length = rt_vsnprintf(dtu_str, sizeof(dtu_str) - 1, fmt, arg);
|
|
|
str_length = rt_vsnprintf(dtu_str, sizeof(dtu_str) - 1, fmt, ap);
|
|
|
va_end(ap);
|
|
|
- if (str_length > 1024 - 1)
|
|
|
- str_length = 1024 - 1;
|
|
|
+ if (str_length > 2048 - 1)
|
|
|
+ str_length = 2048 - 1;
|
|
|
rt_device_write(dtuserial, 0, dtu_str, str_length);
|
|
|
- rt_thread_mdelay(10);
|
|
|
-// if(strstr(dtu_str,"volume")!=RT_NULL)
|
|
|
-// {
|
|
|
-// rt_device_write(dtuserial,0,dtu_conf,4);
|
|
|
-// }
|
|
|
-// else if (strstr(dtu_str,"reset")!=RT_NULL) {
|
|
|
-// const char dtu_conf[4] = {7,0x00,0x00,0x00};
|
|
|
-// rt_device_write(dtuserial,0,dtu_conf,4);
|
|
|
-// }
|
|
|
+ LOG_D("DTU_Write:%s",dtu_str);
|
|
|
}
|
|
|
/* 接收数据回调函数 */
|
|
|
static rt_err_t dtu_input(rt_device_t dev, rt_size_t size)
|
|
|
@@ -122,163 +112,30 @@ static rt_err_t dtu_input(rt_device_t dev, rt_size_t size)
|
|
|
if ( result == -RT_EFULL)
|
|
|
{
|
|
|
/* 消息队列满 */
|
|
|
- LOG_E("message queue full!");
|
|
|
+ LOG_E("rx_mq_dtu message queue full!");
|
|
|
rt_mq_control(&rx_mq_dtu, RT_IPC_CMD_RESET, RT_NULL); // 清空队列
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
-// 最大JSON缓冲区长度(建议根据设备内存调整)
|
|
|
-#define MAX_JSON_BUFFER 1024
|
|
|
-// 全局缓冲区结构体
|
|
|
-static struct {
|
|
|
- char buffer[MAX_JSON_BUFFER]; // 数据存储区
|
|
|
- int index; // 当前写入位置
|
|
|
- rt_tick_t last_received; // 最后接收时间戳
|
|
|
- int nested_level; // 当前嵌套层数
|
|
|
-} json_ctx = {.index = 0, .last_received = 0, .nested_level = 0};
|
|
|
-
|
|
|
-
|
|
|
-// 自定义异常类型
|
|
|
-typedef enum {
|
|
|
- JSON_OK,
|
|
|
- JSON_INCOMPLETE,
|
|
|
- JSON_INVALID_CHAR,
|
|
|
- JSON_TOO_DEEP,
|
|
|
- JSON_TOO_LONG
|
|
|
-} json_status_t;
|
|
|
-
|
|
|
-
|
|
|
-// 查找完整JSON边界(支持嵌套)
|
|
|
-static json_status_t find_json_boundary(int *start, int *end)
|
|
|
-{
|
|
|
- *start = -1;
|
|
|
- *end = -1;
|
|
|
- int level = 0;
|
|
|
-
|
|
|
- for (int i = 0; i < json_ctx.index; i++) {
|
|
|
- if (json_ctx.buffer[i] == '{') {
|
|
|
- if (level == 0) *start = i;
|
|
|
- level++;
|
|
|
- if (level > 32) return JSON_TOO_DEEP;
|
|
|
- } else if (json_ctx.buffer[i] == '}') {
|
|
|
- level--;
|
|
|
- if (level < 0) return JSON_INVALID_CHAR;
|
|
|
- if (level == 0 && *start != -1) {
|
|
|
- *end = i;
|
|
|
- return JSON_OK;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (*start != -1) return JSON_INCOMPLETE;
|
|
|
- return JSON_OK;
|
|
|
-}
|
|
|
-
|
|
|
-#define RT_MIN(a, b) ((a) < (b) ? (a) : (b))
|
|
|
-// 核心处理函数
|
|
|
-void process_uart_data(const char *data, int length)
|
|
|
-{
|
|
|
- // 有效性检查
|
|
|
- if (data == NULL || length <= 0) return;
|
|
|
- json_ctx.last_received = rt_tick_get();
|
|
|
-
|
|
|
- // 缓冲区溢出保护
|
|
|
- int remain_space = MAX_JSON_BUFFER - json_ctx.index - 1;
|
|
|
- if (remain_space < length) {
|
|
|
- rt_kprintf("[JSON] Buffer overflow (%d/%d)\n",
|
|
|
- json_ctx.index + length, MAX_JSON_BUFFER);
|
|
|
- json_ctx.index = 0; // 清空缓冲区重新开始
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- // 追加新数据
|
|
|
- rt_memcpy(json_ctx.buffer + json_ctx.index, data, length);
|
|
|
- json_ctx.index += length;
|
|
|
- json_ctx.buffer[json_ctx.index] = '\0';
|
|
|
-
|
|
|
- // 循环处理所有完整报文
|
|
|
- while (1) {
|
|
|
- int start_pos, end_pos;
|
|
|
- json_status_t status = find_json_boundary(&start_pos, &end_pos);
|
|
|
-
|
|
|
- switch (status) {
|
|
|
- case JSON_OK:
|
|
|
- if (start_pos != -1 && end_pos != -1) {
|
|
|
- // 提取有效JSON内容
|
|
|
- char json_str[512] = {0};
|
|
|
- int json_len = end_pos - start_pos + 1;
|
|
|
- rt_strncpy(json_str, json_ctx.buffer + start_pos,
|
|
|
- RT_MIN(sizeof(json_str)-1, json_len));
|
|
|
-
|
|
|
- // 调用解析函数
|
|
|
- if (parseDtu(json_str) == RT_EOK) {
|
|
|
- rt_kprintf("[JSON] Parsed: %.*s\n", json_len, json_str);
|
|
|
- }
|
|
|
-
|
|
|
- // 移动缓冲区剩余内容
|
|
|
- int remain_data = json_ctx.index - (end_pos + 1);
|
|
|
- if (remain_data > 0) {
|
|
|
- rt_memmove(json_ctx.buffer,
|
|
|
- json_ctx.buffer + end_pos + 1,
|
|
|
- remain_data);
|
|
|
- }
|
|
|
- json_ctx.index = remain_data;
|
|
|
- json_ctx.buffer[json_ctx.index] = '\0';
|
|
|
- } else {
|
|
|
- return; // 无更多完整报文
|
|
|
- }
|
|
|
- break;
|
|
|
|
|
|
- case JSON_INCOMPLETE:
|
|
|
- return; // 等待更多数据
|
|
|
|
|
|
- default:
|
|
|
- rt_kprintf("[JSON] Error %d at pos %d\n", status, start_pos);
|
|
|
- // 错误恢复:跳过错误数据
|
|
|
- json_ctx.index = 0;
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
|
|
|
static void dtu_thread_entry_recv(void *parameter)
|
|
|
{
|
|
|
struct rx_msg msg;
|
|
|
rt_memset(&msg, 0, sizeof(msg));
|
|
|
- static int recv_cnt = 0;
|
|
|
+
|
|
|
+ rt_err_t result;
|
|
|
+ rt_uint32_t rx_length;
|
|
|
+ rt_uint32_t rx_err = 0;
|
|
|
+ static char str_check[2]={'{','}'};
|
|
|
+ static char rx_buffer[512];
|
|
|
+ static char rx_buffer_tmp[512];
|
|
|
+ static char rx_buffer_tmp2[512];
|
|
|
while(1)
|
|
|
{
|
|
|
- //
|
|
|
- // 从消息队列中获取被回调函数放入消息队列中的内容
|
|
|
- int result = rt_mq_recv(&rx_mq_dtu, &msg, sizeof(struct rx_msg), 100);
|
|
|
- if (result != RT_EOK){
|
|
|
- recv_cnt++;
|
|
|
- if(recv_cnt==15)
|
|
|
- {
|
|
|
- json_ctx.index = 0;
|
|
|
- }
|
|
|
- continue;
|
|
|
- }
|
|
|
- // 动态分配接收缓冲区
|
|
|
- char *rx_buffer = rt_malloc(msg.size + 1);
|
|
|
- if (!rx_buffer) {
|
|
|
- LOG_E("Memory allocation failed");
|
|
|
- continue;
|
|
|
- }
|
|
|
- // 安全读取数据
|
|
|
- int rx_length = rt_device_read(msg.dev, 0, rx_buffer, msg.size);
|
|
|
- if (rx_length <= 0) {
|
|
|
- rt_free(rx_buffer);
|
|
|
- continue;
|
|
|
- }
|
|
|
- recv_cnt = 0;
|
|
|
- rx_buffer[rx_length] = '\0';
|
|
|
- // 处理数据(新增调试接口)
|
|
|
- LOG_I("Raw Data:%s-%d",rx_buffer, rx_length);
|
|
|
-
|
|
|
- process_uart_data(rx_buffer, rx_length);
|
|
|
- rt_free(rx_buffer);
|
|
|
- #if 0
|
|
|
+ result = rt_mq_recv(&rx_mq_dtu, &msg, sizeof(struct rx_msg), 50);
|
|
|
+ #if 1
|
|
|
if(result == RT_EOK)
|
|
|
{
|
|
|
|
|
|
@@ -290,19 +147,13 @@ static void dtu_thread_entry_recv(void *parameter)
|
|
|
LOG_D("recv data:%s",rx_buffer);
|
|
|
if(strstr(rx_buffer,"{")==RT_NULL||strstr(rx_buffer,"}")==RT_NULL)
|
|
|
{
|
|
|
- if(device_status.dtype==7)
|
|
|
- {
|
|
|
- HMI_WRITE("sysTest.result.txt=\"%s\"",rx_buffer);
|
|
|
- }
|
|
|
-
|
|
|
if(device_status.dtype==3)
|
|
|
{
|
|
|
HMI_WRITE("sysSet.va0.txt=\"%s\"",rx_buffer);
|
|
|
rt_timer_stop(timer_uart2);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
+ device_status.C01 &= ~(1<<13); //通信 正常
|
|
|
//过滤异常数据
|
|
|
char str_check_head[2];
|
|
|
char str_check_end[2];
|
|
|
@@ -328,130 +179,28 @@ static void dtu_thread_entry_recv(void *parameter)
|
|
|
rt_memset(rx_buffer_tmp,0,sizeof(rx_buffer_tmp));
|
|
|
rt_memset(rx_buffer_tmp2,0,sizeof(rx_buffer_tmp2));
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
- #endif
|
|
|
- }
|
|
|
-}
|
|
|
-#if 0
|
|
|
-/*入口函数-指令发送*/
|
|
|
-static void dtu_thread_entry_send(void *parameter)
|
|
|
-{
|
|
|
|
|
|
- device_status.power_status = 1;
|
|
|
- device_status.num_updata = 0;
|
|
|
- rt_thread_delay(10000);
|
|
|
- static rt_uint16_t wait_i = 0;
|
|
|
- static rt_uint8_t check_i = 0;
|
|
|
- static rt_uint8_t power_i = 0;
|
|
|
- while(1)
|
|
|
- {
|
|
|
- time_t now_t;
|
|
|
- time(&now_t);
|
|
|
- static struct tm now_tm; //现在
|
|
|
- //获取当前时间戳
|
|
|
- now_tm =*localtime(&now_t);
|
|
|
- if(atoi(device_status.net)==0||atoi(device_status.gps)==1||(now_tm.tm_year+1900 >=2024)) //当前时间大于2024
|
|
|
- {
|
|
|
- if(device_status.rain_status==1||device_status.temp_status==1)
|
|
|
- {
|
|
|
- if(check_i==0)
|
|
|
- {
|
|
|
- check_i = 1;
|
|
|
- device_status.num_updata = 0;
|
|
|
- }
|
|
|
- }
|
|
|
- else {
|
|
|
- check_i = 0;
|
|
|
- }
|
|
|
- if(device_status.num_updata!=0)
|
|
|
- {
|
|
|
- device_status.num_updata--;
|
|
|
- //屏幕休眠
|
|
|
- if(device_status.num_updata==(device_status.dattim * 60-10))
|
|
|
- {
|
|
|
- HMI_WRITE("sleep=%d",1);
|
|
|
- }
|
|
|
- LOG_I("掉电检测:%d-%d",atoi(device_status.voltage),device_status.power_status);
|
|
|
- //检测到电源掉电
|
|
|
- if(atoi(device_status.voltage)<5&&device_status.power_status==1)
|
|
|
- {
|
|
|
- power_i++;
|
|
|
- //确定网络状态
|
|
|
- if(power_i==10)
|
|
|
- {
|
|
|
- device_status.bat_status = 1;
|
|
|
- rt_sprintf(device_status.net, "1");
|
|
|
- HMI_WRITE("sleep=%d",1); //屏幕休眠
|
|
|
- DTU_Write("%s",makeJson_Warn("power down","power"));
|
|
|
- device_status.power_status = 0;
|
|
|
- rt_thread_delay(5000);
|
|
|
- ctr_router(OFF);
|
|
|
- ctr_RTU_DTU(OFF);
|
|
|
- power_i = 0;
|
|
|
- }
|
|
|
- }
|
|
|
- if(atoi(device_status.voltage)>12&&device_status.power_status==0) //电压正常
|
|
|
- {
|
|
|
- device_status.power_status = 1;
|
|
|
- ctr_router(ON);
|
|
|
- ctr_RTU_DTU(ON);
|
|
|
- power_i = 0;
|
|
|
- }
|
|
|
- }
|
|
|
- else {
|
|
|
- char *readinfo = makeJson_ReadInfo();
|
|
|
- rt_kprintf("upload data:%s\n",readinfo);
|
|
|
- DTU_Write("%s",readinfo);
|
|
|
- rt_free(readinfo);
|
|
|
- rt_thread_delay(1000);
|
|
|
- UpLoad_Data();
|
|
|
- if(atoi(device_status.fuse_voltage)<1)
|
|
|
- {
|
|
|
- rt_thread_delay(500);
|
|
|
- static char res[30];
|
|
|
- sprintf(res, "Fuse is fusing:%s",device_status.fuse_voltage);
|
|
|
- char * res_fuse_warn = makeJson_Warn(res,"device");
|
|
|
- DTU_Write("%s",res_fuse_warn);
|
|
|
- rt_free(res_fuse_warn);
|
|
|
- }
|
|
|
- device_status.num_updata = device_status.dattim * 60;
|
|
|
- if(device_status.dattim==0) device_status.dattim=20; //数据上传时间间隔设置为0?
|
|
|
- if(device_status.bat_status==0) device_status.power_status = 1; //解除欠压,清除标志位
|
|
|
- }
|
|
|
- }
|
|
|
- else {
|
|
|
- wait_i ++;
|
|
|
- LOG_I("wait connect internet......%d",wait_i);
|
|
|
- //检测到电源掉电
|
|
|
- if(atoi(device_status.voltage)<5&&device_status.power_status==1&&wait_i>200)
|
|
|
- {
|
|
|
- check_i++;
|
|
|
- LOG_W("断网状态下检测到设备断电!%d",atoi(device_status.voltage));
|
|
|
- if(check_i==10)
|
|
|
- {
|
|
|
- device_status.bat_status = 1;
|
|
|
- device_status.power_status = 0;
|
|
|
- rt_thread_delay(5000);
|
|
|
- ctr_router(OFF);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ rx_err ++;
|
|
|
+ if(rx_err==54000)//90分钟未接收到数据
|
|
|
+ {
|
|
|
ctr_RTU_DTU(OFF);
|
|
|
- check_i = 0;
|
|
|
- }
|
|
|
- }
|
|
|
- if(Read_Real_Voltage()/100>10&&device_status.power_status==0)
|
|
|
- {
|
|
|
- check_i = 0;
|
|
|
- LOG_I("电源恢复正常,打开路由器和RTU供电!");
|
|
|
- device_status.power_status = 1;
|
|
|
- //打开路由器和RTU供电
|
|
|
- ctr_router(ON);
|
|
|
- ctr_RTU_DTU(ON);
|
|
|
- }
|
|
|
- }
|
|
|
- rt_thread_mdelay(1000);
|
|
|
- }
|
|
|
+ device_status.C01 |= (1<<13); //灯管 故障
|
|
|
+ }
|
|
|
+ else if (rx_err>54100&&device_status.bat_status==0)
|
|
|
+ {
|
|
|
+ LOG_W("通信中断,RTU重新上电");
|
|
|
+ rx_err = 0;
|
|
|
+ ctr_RTU_DTU(ON);
|
|
|
+ ctr_photo(ON);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ #endif
|
|
|
}
|
|
|
-#endif
|
|
|
+
|
|
|
/* 创建线程 */
|
|
|
int dtu_data_play(void)
|
|
|
{
|
|
|
@@ -470,7 +219,7 @@ int dtu_data_play(void)
|
|
|
rt_device_set_rx_indicate(dtuserial, dtu_input);
|
|
|
#if 0
|
|
|
/*创建线程-指令发送*/
|
|
|
- dtu_send_data = rt_thread_create("DTU_Uart_thread_send",
|
|
|
+ dtu_send_data = rt_thread_create("DTU_thread",
|
|
|
dtu_thread_entry_send,RT_NULL,
|
|
|
DTU_THREAD_STACK_SIZE,
|
|
|
3, //优先级高是为了保证数据上传的频率的精确度
|
|
|
@@ -478,7 +227,7 @@ int dtu_data_play(void)
|
|
|
);
|
|
|
#endif
|
|
|
/* 创建线程-指令接收解析*/
|
|
|
- dtu_recv_data = rt_thread_create("DTU_Uart_thread_recv",
|
|
|
+ dtu_recv_data = rt_thread_create("thread_uart2",
|
|
|
dtu_thread_entry_recv, RT_NULL,
|
|
|
DTU_THREAD_STACK_SIZE,
|
|
|
DTU_THREAD_PRIORITY,
|
|
|
@@ -1225,45 +974,7 @@ int parseDtu(char *json_string)
|
|
|
LOG_I("收到自检指令:%d",device_status.selfcheck_ws);
|
|
|
}
|
|
|
}
|
|
|
- //切换平台
|
|
|
- else if (strstr(item_cmd->valuestring,"platform")!=RT_NULL)
|
|
|
- {
|
|
|
- type = cJSON_GetObjectItem(item_ext,"type");
|
|
|
- if(strstr(type->valuestring,"8.136.98.49")!=RT_NULL)
|
|
|
- {
|
|
|
- rt_sprintf(device_status.mqttcfg1, "8.136.98.49");
|
|
|
- ef_set_env_blob("platform", &device_status.mqttcfg1, sizeof(device_status.mqttcfg1));
|
|
|
- //给RTU发送切换指令
|
|
|
- DTU_Write("%s",makeJson_platform("8.136.98.49"));
|
|
|
- rt_free(makeJson_platform("8.136.98.49"));
|
|
|
- rt_thread_delay(1000);
|
|
|
- rt_sprintf(device_status.json_w_platform,"平台操作:切换平台>大数据,操作时间:%s",device_status.stamp);
|
|
|
- json_s = makeJson_Warn(device_status.json_w_platform, "切换平台");
|
|
|
- ef_set_env_blob("json_w_platform", &device_status.json_w_platform, sizeof(device_status.json_w_platform)); //将修改屏幕参数操作记录保存到Flash中
|
|
|
- if(atoi(device_status.net)==0)
|
|
|
- DTU_Write("%s",json_s);
|
|
|
- rt_free(json_s);
|
|
|
- rt_thread_delay(1000);
|
|
|
- MA_save();
|
|
|
- }
|
|
|
- else if (strstr(type->valuestring,"120.27.222.26")!=RT_NULL)
|
|
|
- {
|
|
|
- rt_sprintf(device_status.mqttcfg1, "120.27.222.26");
|
|
|
- ef_set_env_blob("platform", &device_status.mqttcfg1, sizeof(device_status.mqttcfg1));
|
|
|
- //给RTU发送切换指令
|
|
|
- DTU_Write("%s",makeJson_platform("120.27.222.26"));
|
|
|
- rt_free(makeJson_platform("120.27.222.26"));
|
|
|
- rt_thread_delay(1000);
|
|
|
- rt_sprintf(device_status.json_w_platform,"平台操作:切换平台>四情,操作时间:%s",device_status.stamp);
|
|
|
- json_s = makeJson_Warn(device_status.json_w_platform, "切换平台");
|
|
|
- ef_set_env_blob("json_w_platform", &device_status.json_w_platform, sizeof(device_status.json_w_platform)); //将修改屏幕参数操作记录保存到Flash中
|
|
|
- if(atoi(device_status.net)==0)
|
|
|
- DTU_Write("%s",json_s);
|
|
|
- rt_free(json_s);
|
|
|
- rt_thread_delay(1000);
|
|
|
- MA_save();
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
//水稻2000万像素的串口拍照指令
|
|
|
else if (strstr(item_cmd->valuestring,"mvs_photo")!=RT_NULL)
|
|
|
{
|
|
|
@@ -1304,7 +1015,6 @@ int parseDtu(char *json_string)
|
|
|
{
|
|
|
char * readinfo = makeJson_ReadInfo();
|
|
|
DTU_Write("%s",readinfo);
|
|
|
- rt_kprintf("%s\n",readinfo);
|
|
|
rt_free(readinfo);
|
|
|
device_status.hmi_fresh = 2;
|
|
|
device_status.refresh_num = 15;
|
|
|
@@ -1796,6 +1506,31 @@ int parseDtu(char *json_string)
|
|
|
}
|
|
|
LOG_I("开始结束时间2:%d-%d",device_status.collecting_sh2,device_status.collecting_eh2);
|
|
|
}
|
|
|
+ else if (icnt==2)
|
|
|
+ {
|
|
|
+ if((ivalue[1]=='-'))
|
|
|
+ {
|
|
|
+ device_status.collecting_sh3 = atoi(&ivalue[0]);
|
|
|
+ if(strlen(ivalue)==3)
|
|
|
+ device_status.collecting_eh3 = atoi(&ivalue[2]);
|
|
|
+ if(strlen(ivalue)==4)
|
|
|
+ device_status.collecting_eh3 = atoi(&ivalue[3])<<8|atoi(&ivalue[2]);
|
|
|
+ ef_set_env_blob("collecting_sh3", &device_status.collecting_sh3, sizeof(device_status.collecting_sh3));
|
|
|
+ ef_set_env_blob("collecting_eh3", &device_status.collecting_eh3, sizeof(device_status.collecting_eh3));
|
|
|
+ }
|
|
|
+ if((ivalue[2]=='-'))
|
|
|
+ {
|
|
|
+ device_status.collecting_sh3 = atoi(&ivalue[1])<<8|atoi(&ivalue[0]);
|
|
|
+ if(strlen(ivalue)==3)
|
|
|
+ device_status.collecting_eh3 = atoi(&ivalue[2]);
|
|
|
+ if(strlen(ivalue)==5)
|
|
|
+ device_status.collecting_eh3 = atoi(&ivalue[4])<<8|atoi(&ivalue[3]);
|
|
|
+ ef_set_env_blob("collecting_sh3", &device_status.collecting_sh3, sizeof(device_status.collecting_sh3));
|
|
|
+ ef_set_env_blob("collecting_eh3", &device_status.collecting_eh3, sizeof(device_status.collecting_eh3));
|
|
|
+ }
|
|
|
+ LOG_I("开始结束时间3:%d-%d",device_status.collecting_sh3,device_status.collecting_eh3);
|
|
|
+ }
|
|
|
+
|
|
|
LOG_I("下发设置收集:%d-%s",icnt,ivalue);
|
|
|
}
|
|
|
}
|
|
|
@@ -2051,20 +1786,6 @@ int parseDtu(char *json_string)
|
|
|
}
|
|
|
}
|
|
|
UpLoad_Data();
|
|
|
- rt_thread_delay(2000);
|
|
|
- //2022/06/23,add:
|
|
|
- if(device_status.dtype==3)
|
|
|
- {
|
|
|
- rt_sprintf(device_status.json_w_clock,"平台操作:修改工作时间:开始-%d,结束-%d,模式-%d(0-光控,1-时控)-%s",device_status.startBar,device_status.stopBar,device_status.timeSwitch,device_status.stamp);
|
|
|
- json_s = makeJson_Warn(device_status.json_w_clock, "修改时间");
|
|
|
- ef_set_env_blob("json_w_clock", &device_status.json_w_clock, sizeof(device_status.json_w_clock)); //将修改屏幕参数操作记录保存到Flash中
|
|
|
- if(atoi(device_status.net)==0)
|
|
|
- DTU_Write("%s",json_s);
|
|
|
- rt_free(json_s);
|
|
|
- }
|
|
|
-
|
|
|
- rt_thread_delay(1000);
|
|
|
- MA_save();
|
|
|
rt_thread_delay(1000);
|
|
|
}
|
|
|
}
|
|
|
@@ -2076,11 +1797,8 @@ int parseDtu(char *json_string)
|
|
|
void UpLoad_Data(void)
|
|
|
{
|
|
|
char *updata = makeJson();
|
|
|
- LOG_I("upload data:%d %s",rt_strlen(updata),updata);
|
|
|
+ DTU_Write(updata);
|
|
|
rt_free(updata);
|
|
|
- #if Color_EN ==0
|
|
|
- DTU_Write("%s",updata);
|
|
|
- #endif
|
|
|
//list_mem();
|
|
|
//播放数据上传中语音
|
|
|
}
|