|
|
@@ -77,7 +77,6 @@ void DTU_Write(char *fmt, ...)
|
|
|
str_length = rt_vsnprintf(dtu_str, sizeof(dtu_str) - 1, fmt, arg);
|
|
|
if (str_length > 800 - 1)
|
|
|
str_length = 800 - 1;
|
|
|
-
|
|
|
rt_device_write(dtuserial, 0, dtu_str, str_length);
|
|
|
if(strstr(dtu_str,"volume")!=RT_NULL)
|
|
|
{
|
|
|
@@ -222,8 +221,10 @@ static void dtu_thread_entry_send(void *parameter)
|
|
|
else {
|
|
|
char *readinfo = makeJson_ReadInfo();
|
|
|
rt_kprintf("upload data:%s\n",readinfo);
|
|
|
- UpLoad_Data();
|
|
|
+ DTU_Write("%s",readinfo);
|
|
|
rt_free(readinfo);
|
|
|
+ rt_thread_delay(1000);
|
|
|
+ UpLoad_Data();
|
|
|
if(atoi(device_status.fuse_voltage)<1)
|
|
|
{
|
|
|
rt_thread_delay(500);
|
|
|
@@ -469,7 +470,7 @@ char * makeJson()
|
|
|
else if (device_status.version_type==6) {
|
|
|
rt_sprintf(device_status.driver,"%s-%s",VERSION_XCT,device_status.driver_4g);
|
|
|
}
|
|
|
- if(device_status.sensor_485_sta==1)
|
|
|
+ if(device_status.sensor_485_sta!=0)
|
|
|
{
|
|
|
if(strstr(device_status.driver,"485")==RT_NULL)
|
|
|
strcat(device_status.driver,".485");
|
|
|
@@ -598,7 +599,7 @@ char * makeJson()
|
|
|
rt_sprintf(utos, "%d",device_status.work_status);
|
|
|
cJSON_AddStringToObject(pSubJson,"ws",utos);
|
|
|
|
|
|
- char * p = cJSON_PrintUnformatted(pJsonRoot);
|
|
|
+ char *p = cJSON_PrintUnformatted(pJsonRoot);
|
|
|
if(NULL == p)
|
|
|
{
|
|
|
cJSON_Delete(pJsonRoot);
|
|
|
@@ -609,7 +610,7 @@ char * makeJson()
|
|
|
return p;
|
|
|
}
|
|
|
//JSON数据解析
|
|
|
-void parseDtu(char *json_string)
|
|
|
+int parseDtu(char *json_string)
|
|
|
{
|
|
|
extern int rt_hw_rtc_init(void);
|
|
|
char* json_s = NULL;
|
|
|
@@ -658,7 +659,7 @@ void parseDtu(char *json_string)
|
|
|
{
|
|
|
cJSON_Delete(root);
|
|
|
rt_kprintf("parse json err:%s",json_string);
|
|
|
- return;
|
|
|
+ return -1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -817,23 +818,20 @@ void parseDtu(char *json_string)
|
|
|
//设置温湿度
|
|
|
else if (strstr(item_cmd->valuestring,"sensor")!=RT_NULL) {
|
|
|
//2022-04-12add:485传感器正常,不再解析服务器下发的温湿度数据
|
|
|
- if(device_status.sensor_485_sta==1) return;
|
|
|
-
|
|
|
+ //if(device_status.sensor_485_sta!=0) return 0;
|
|
|
hum = cJSON_GetObjectItem(item_ext,"new_hum");
|
|
|
tmp = cJSON_GetObjectItem(item_ext,"new_tem");
|
|
|
if(hum!=NULL&&tmp!=NULL)
|
|
|
{
|
|
|
- device_status.sensor_sta = 1;
|
|
|
//先判断是否是空字符再判断数值是否合理
|
|
|
- if(strcmp(hum->valuestring,"")!=0&&atoi(hum->valuestring)>=0&&atoi(hum->valuestring)<=100&&atoi(hum->valuestring)!=30)
|
|
|
+ if(strcmp(hum->valuestring,"")!=0&&atoi(hum->valuestring)>=0&&atoi(hum->valuestring)<=100&&atoi(hum->valuestring)!=30&&device_status.sensor_485_sta==0)
|
|
|
{
|
|
|
if(atoi(hum->valuestring)!=atoi(device_status.humidity))
|
|
|
{
|
|
|
- rt_sprintf(device_status.humidity, "%s",hum->valuestring);
|
|
|
+ rt_sprintf(device_status.humidity, "%s",hum->valuestring);
|
|
|
ef_set_env_blob("env_h",&device_status.humidity,sizeof(device_status.humidity)); //湿度
|
|
|
rt_kprintf("保存湿度成功:%d\n",atoi(device_status.humidity));
|
|
|
}
|
|
|
- rt_sprintf(device_status.humidity, "%s",hum->valuestring);
|
|
|
rt_kprintf("设置湿度成功:%d\n",atoi(device_status.humidity));
|
|
|
}
|
|
|
else
|
|
|
@@ -841,7 +839,7 @@ void parseDtu(char *json_string)
|
|
|
rt_kprintf("设置湿度失败:%s!!!\n",hum->valuestring);
|
|
|
}
|
|
|
//先判断是否是空字符再判断数值是否合理
|
|
|
- if(strcmp(tmp->valuestring,"")!=0&&atoi(tmp->valuestring)>-50&&atoi(tmp->valuestring)<=100)
|
|
|
+ if(strcmp(tmp->valuestring,"")!=0&&atoi(tmp->valuestring)>-50&&atoi(tmp->valuestring)<=100&&device_status.sensor_485_sta==0)
|
|
|
{
|
|
|
if(atoi(tmp->valuestring)!=atoi(device_status.tempture))
|
|
|
{
|
|
|
@@ -849,7 +847,6 @@ void parseDtu(char *json_string)
|
|
|
ef_set_env_blob("env_t",&device_status.tempture,sizeof(device_status.tempture)); //湿度
|
|
|
rt_kprintf("保存温度成功:%d\n",atoi(device_status.tempture));
|
|
|
}
|
|
|
- rt_sprintf(device_status.tempture, "%s",tmp->valuestring);
|
|
|
rt_kprintf("设置温度成功:%d\n",atoi(device_status.tempture));
|
|
|
}
|
|
|
else {
|
|
|
@@ -1158,7 +1155,6 @@ void parseDtu(char *json_string)
|
|
|
rt_kprintf("结束时间et设置失败参数错误!!!\n");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
if(collt!=NULL)
|
|
|
@@ -1490,7 +1486,7 @@ void parseDtu(char *json_string)
|
|
|
}
|
|
|
cJSON_Delete(root);
|
|
|
}
|
|
|
- return;
|
|
|
+ return 0;
|
|
|
}
|
|
|
|
|
|
void UpLoad_Data(void)
|
|
|
@@ -1498,8 +1494,9 @@ void UpLoad_Data(void)
|
|
|
|
|
|
char *updata = makeJson();
|
|
|
rt_kprintf("upload data:%d\n%s\n",rt_strlen(updata),updata);
|
|
|
- DTU_Write("%s",updata);
|
|
|
rt_free(updata);
|
|
|
+ DTU_Write("%s",updata);
|
|
|
+ updata = NULL;
|
|
|
list_mem();
|
|
|
//播放数据上传中语音
|
|
|
}
|