|
|
@@ -47,11 +47,11 @@ rt_thread_t dtu_recv_data = RT_NULL;
|
|
|
rt_thread_t dtu_send_data = RT_NULL;
|
|
|
|
|
|
|
|
|
-
|
|
|
rt_device_t dtuserial; /*串口设备句柄*/
|
|
|
struct serial_configure dtuconfig = RT_SERIAL_CONFIG_DEFAULT; /*初始化配置参数*/
|
|
|
static int num_updata = 0;
|
|
|
|
|
|
+
|
|
|
int DTU_uart2_init(void)
|
|
|
{
|
|
|
|
|
|
@@ -167,7 +167,7 @@ static void dtu_thread_entry_send(void *parameter)
|
|
|
if(num_updata!=0)
|
|
|
{
|
|
|
num_updata --;
|
|
|
-// //屏幕休眠
|
|
|
+// //屏幕休眠
|
|
|
if(num_updata==(device_status.dattim * 60-10))
|
|
|
{
|
|
|
HMI_WRITE("sleep=%d",1);
|
|
|
@@ -190,7 +190,7 @@ static void dtu_thread_entry_send(void *parameter)
|
|
|
LOG_I("upload data:%s\n",readinfo);
|
|
|
if(dev_sta==1)
|
|
|
{
|
|
|
- DTU_Write("%s",makeJson_Warn("turnon", "dev_sta"));
|
|
|
+ DTU_Write("%s",makeJson_Warn("turnon", "device_stm32"));
|
|
|
dev_sta = 0;
|
|
|
rt_thread_delay(500);
|
|
|
}
|
|
|
@@ -207,8 +207,8 @@ static void dtu_thread_entry_send(void *parameter)
|
|
|
DTU_Write("%s",res_fuse_warn);
|
|
|
rt_free(res_fuse_warn);
|
|
|
}
|
|
|
-
|
|
|
num_updata = device_status.dattim * 60;
|
|
|
+ if(device_status.dattim==0) device_status.dattim=20; //数据上传时间间隔设置为0?
|
|
|
}
|
|
|
rt_thread_mdelay(1000);
|
|
|
}
|
|
|
@@ -259,7 +259,7 @@ char * makeJson_ReadInfo()
|
|
|
{
|
|
|
return NULL;
|
|
|
}
|
|
|
- cJSON_AddStringToObject(rJsonRoot, "cmd", "GetInfo");
|
|
|
+ cJSON_AddStringToObject(rJsonRoot, "uart", "getinfo");
|
|
|
char * r = cJSON_PrintUnformatted(rJsonRoot);
|
|
|
if(NULL == r)
|
|
|
{
|
|
|
@@ -348,6 +348,10 @@ char *makeJson_Warn(char * s,char *t)
|
|
|
/*生成JSON数据*/
|
|
|
char * makeJson()
|
|
|
{
|
|
|
+
|
|
|
+ char utos[4];
|
|
|
+ if(device_status.gps==NULL)
|
|
|
+ rt_sprintf(device_status.gps, "0");
|
|
|
//如果设备工作并且电流小于500,灯管异常
|
|
|
if(atoi(device_status.power)<400&&device_status.work_status==1)
|
|
|
{
|
|
|
@@ -357,7 +361,6 @@ char * makeJson()
|
|
|
else {
|
|
|
device_status.lamp_status = 0;
|
|
|
}
|
|
|
- device_status.dtype = 3;
|
|
|
time_t stamp=time(RT_NULL);
|
|
|
static struct tm tm;
|
|
|
gmtime_r(&stamp, &tm);
|
|
|
@@ -395,18 +398,31 @@ char * makeJson()
|
|
|
cJSON_AddItemToObject(pJsonRoot, "ext", pSubJson);
|
|
|
cJSON_AddStringToObject(pSubJson, "dver", device_status.driver); //版本号,字符型
|
|
|
cJSON_AddStringToObject(pSubJson,"proj",device_status.project); //项目类型
|
|
|
- cJSON_AddNumberToObject(pSubJson,"dtype",device_status.dtype); //设备类型
|
|
|
- cJSON_AddNumberToObject(pSubJson,"tt",device_status.sunBar); //光控定时
|
|
|
- cJSON_AddNumberToObject(pSubJson,"shake",device_status.shake_ws); //震动开关
|
|
|
- cJSON_AddNumberToObject(pSubJson,"shake_sec",device_status.shake_sec); //震动时间
|
|
|
- cJSON_AddNumberToObject(pSubJson,"gps",device_status.gps); //定位状态
|
|
|
+ //设备类型
|
|
|
+ device_status.dtype=3;
|
|
|
+ rt_sprintf(utos, "%d",device_status.dtype);
|
|
|
+ cJSON_AddStringToObject(pSubJson,"dtype",utos);
|
|
|
+ //光控定时
|
|
|
+ rt_sprintf(utos, "%d",device_status.sunBar);
|
|
|
+ cJSON_AddStringToObject(pSubJson,"tt",utos);
|
|
|
+ //震动开关
|
|
|
+ rt_sprintf(utos, "%d",device_status.shake_ws);
|
|
|
+ cJSON_AddStringToObject(pSubJson,"shake",utos);
|
|
|
+ //震动时间
|
|
|
+ rt_sprintf(utos, "%d",device_status.shake_sec);
|
|
|
+ cJSON_AddStringToObject(pSubJson,"shake_sec",utos);
|
|
|
+ cJSON_AddStringToObject(pSubJson,"gps",device_status.gps); //定位状态
|
|
|
cJSON_AddNumberToObject(pSubJson,"ws",device_status.work_status); //工作状态
|
|
|
cJSON_AddNumberToObject(pSubJson,"ds",device_status.ds); //工作状态
|
|
|
cJSON_AddNumberToObject(pSubJson,"ts",device_status.timeSwitch); //定时模式
|
|
|
- cJSON_AddNumberToObject(pSubJson,"st",device_status.startBar); //开始时间
|
|
|
- cJSON_AddNumberToObject(pSubJson,"et",device_status.stopBar); //结束时间
|
|
|
- cJSON_AddStringToObject(pSubJson,"ah",device_status.humidity); //湿度
|
|
|
- cJSON_AddStringToObject(pSubJson,"at",device_status.tempture); //温度
|
|
|
+ //开始时间
|
|
|
+ cJSON_AddNumberToObject(pSubJson,"st",device_status.startBar);
|
|
|
+ //结束时间
|
|
|
+ cJSON_AddNumberToObject(pSubJson,"et",device_status.stopBar);
|
|
|
+ //湿度
|
|
|
+ cJSON_AddStringToObject(pSubJson,"ah",device_status.humidity);
|
|
|
+ //温度
|
|
|
+ cJSON_AddStringToObject(pSubJson,"at",device_status.tempture);
|
|
|
cJSON_AddNumberToObject(pSubJson,"tps",device_status.temp_status); //温控
|
|
|
cJSON_AddNumberToObject(pSubJson,"lps",device_status.sun_status); //光控状态
|
|
|
cJSON_AddNumberToObject(pSubJson,"rps",device_status.rain_status); //雨控状态
|
|
|
@@ -415,8 +431,11 @@ char * makeJson()
|
|
|
cJSON_AddStringToObject(pSubJson,"stamp",device_status.stamp); //时间
|
|
|
cJSON_AddStringToObject(pSubJson,"imei",device_status.imei); //IMEI
|
|
|
cJSON_AddStringToObject(pSubJson,"iccid",device_status.iccid); //ICCID
|
|
|
- cJSON_AddNumberToObject(pSubJson,"upds",device_status.up_status); //上仓门状态 1-打开,0-关闭-(通道) 打开为落虫,关闭为排水
|
|
|
- cJSON_AddNumberToObject(pSubJson,"dnds",device_status.down_status); //下仓门状态 1-打开,0-关闭
|
|
|
+ //上仓门状态 1-打开,0-关闭-(通道) 打开为落虫,关闭为排水
|
|
|
+ cJSON_AddNumberToObject(pSubJson,"upds",device_status.up_status);
|
|
|
+ //下仓门状态 1-打开,0-关闭
|
|
|
+
|
|
|
+ cJSON_AddNumberToObject(pSubJson,"dnds",device_status.down_status);
|
|
|
//经度
|
|
|
cJSON_AddStringToObject(pSubJson,"lng",device_status.lng);
|
|
|
//纬度
|
|
|
@@ -436,13 +455,14 @@ char * makeJson()
|
|
|
//加热状态
|
|
|
cJSON_AddNumberToObject(pSubJson,"hs",device_status.heat_status);
|
|
|
//收集时间(参数)
|
|
|
+
|
|
|
cJSON_AddNumberToObject(pSubJson,"collt",device_status.clt_time);
|
|
|
//加热时间(参数)
|
|
|
cJSON_AddNumberToObject(pSubJson,"htim",device_status.heattime);
|
|
|
//加热温度(参数)
|
|
|
- cJSON_AddNumberToObject(pSubJson,"hst",device_status.heatvale);
|
|
|
+ cJSON_AddNumberToObject(pSubJson,"hst",device_status.heatvalue);
|
|
|
//信号强度
|
|
|
- cJSON_AddNumberToObject(pSubJson,"csq",device_status.csq);
|
|
|
+ cJSON_AddStringToObject(pSubJson,"csq",device_status.csq);
|
|
|
//高温保护
|
|
|
cJSON_AddNumberToObject(pSubJson,"tph",device_status.tph);
|
|
|
//低温保护
|
|
|
@@ -488,10 +508,10 @@ void parseDtu(char *json_string)
|
|
|
cJSON* project = NULL; //Project
|
|
|
cJSON* ds = NULL; //设备状态
|
|
|
cJSON* vt = NULL; //版本类型
|
|
|
- cJSON* account_status = NULL; //卡状态
|
|
|
- cJSON* data_plan = NULL; //套餐
|
|
|
- cJSON* data_usage = NULL; //已使用
|
|
|
- cJSON* expiry_date = NULL; //到期时间
|
|
|
+// cJSON* account_status = NULL; //卡状态
|
|
|
+// cJSON* data_plan = NULL; //套餐
|
|
|
+// cJSON* data_usage = NULL; //已使用
|
|
|
+// cJSON* expiry_date = NULL; //到期时间
|
|
|
cJSON* mqttcfg1 = NULL;
|
|
|
cJSON* mqttcfg2 = NULL;
|
|
|
cJSON* type =NULL;
|
|
|
@@ -584,32 +604,34 @@ void parseDtu(char *json_string)
|
|
|
lng = cJSON_GetObjectItem(item_ext,"lng");
|
|
|
csq = cJSON_GetObjectItem(item_ext,"csq");
|
|
|
net = cJSON_GetObjectItem(item_ext,"net");
|
|
|
+ sim = cJSON_GetObjectItem(item_ext,"sim");
|
|
|
iccid = cJSON_GetObjectItem(item_ext,"iccid");
|
|
|
imei = cJSON_GetObjectItem(item_ext,"imei");
|
|
|
gps = cJSON_GetObjectItem(item_ext,"gps");
|
|
|
mqttcfg1 = cJSON_GetObjectItem(item_ext,"mqttcfg1");
|
|
|
mqttcfg2 = cJSON_GetObjectItem(item_ext,"mqttcfg2");
|
|
|
//如果DTU的IMEI和FLash中的不一样,保存到FLASH
|
|
|
- if(strstr(imei->valuestring,device_status.imei)==RT_NULL)
|
|
|
+ if(strstr(device_status.imei,imei->valuestring)==RT_NULL)
|
|
|
{
|
|
|
LOG_W("Change IMEI:new:%s-old:%s",imei->valuestring,device_status.imei);
|
|
|
rt_sprintf(device_status.imei, "%s",imei->valuestring);
|
|
|
ef_set_env_blob("imei", &device_status.imei, sizeof(device_status.imei)); //IMEI
|
|
|
}
|
|
|
-
|
|
|
else {
|
|
|
rt_sprintf(device_status.imei,"%s",imei->valuestring);
|
|
|
LOG_W("IMEI not change:%s-%s",imei->valuestring,device_status.imei);
|
|
|
}
|
|
|
//如果DTU的ICCID和FLash中的不一样,保存到FLASH
|
|
|
- if(strstr(iccid->valuestring,device_status.iccid)==RT_NULL)
|
|
|
+ if(strstr(device_status.iccid,iccid->valuestring)==RT_NULL)
|
|
|
{
|
|
|
LOG_W("Change ICCID:new:%s-old:%s",iccid->valuestring,device_status.iccid);
|
|
|
rt_sprintf(device_status.iccid,"%s",iccid->valuestring);
|
|
|
- ef_set_env_blob("iccid", &iccid->valuestring, sizeof(iccid->valuestring)); //Iccid
|
|
|
-
|
|
|
+ ef_set_env_blob("iccid", &device_status.iccid, sizeof(device_status.iccid)); //Iccid
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ rt_sprintf(device_status.iccid,"%s",iccid->valuestring);
|
|
|
+ LOG_W("ICCID not change:%s-%s",iccid->valuestring,device_status.iccid);
|
|
|
}
|
|
|
- sim = cJSON_GetObjectItem(item_ext,"sim");
|
|
|
rt_kprintf("DTU时间:%s",datetime->valuestring);
|
|
|
char year_s[5],month_s[3],day_s[3],hour_s[3],min_s[3],sec_s[3];
|
|
|
strncpy(year_s, datetime->valuestring, 4);
|
|
|
@@ -621,7 +643,7 @@ void parseDtu(char *json_string)
|
|
|
if(atoi(year_s)>2020&&atoi(year_s)<3000&&atoi(month_s)>0&&atoi(month_s)<13&&atoi(day_s)>0&&atoi(day_s)<32)
|
|
|
{
|
|
|
rt_kprintf("设置时间:%d年%d月%d日\n",atoi(year_s),atoi(month_s),atoi(day_s));
|
|
|
- if(net->valueint==0)
|
|
|
+ if(net->valueint==0||atoi(net->valuestring)==0)
|
|
|
{
|
|
|
set_date(atoi(year_s),atoi(month_s),atoi(day_s));
|
|
|
}
|
|
|
@@ -633,7 +655,7 @@ void parseDtu(char *json_string)
|
|
|
if(atoi(hour_s)>0&&atoi(hour_s)<=24&&atoi(min_s)>=0&&atoi(min_s)<=60&&atoi(sec_s)>=0&&atoi(sec_s)<=60)
|
|
|
{
|
|
|
rt_kprintf("设置时间:%d时%d分%d秒\n",atoi(hour_s),atoi(min_s),atoi(sec_s));
|
|
|
- if(net->valueint==0)
|
|
|
+ if(net->valueint==0||atoi(net->valuestring)==0)
|
|
|
{
|
|
|
set_time(atoi(hour_s),atoi(min_s),atoi(sec_s));
|
|
|
}
|
|
|
@@ -643,26 +665,41 @@ void parseDtu(char *json_string)
|
|
|
}
|
|
|
}
|
|
|
rt_kprintf("参数同步:\nlat:%s\nlng:%s\n",lat->valuestring,lng->valuestring);
|
|
|
- if(sim->valueint==0)
|
|
|
+ //CSQ
|
|
|
+ if(csq->valuestring!=NULL&&sizeof(csq->valuestring)<3)
|
|
|
{
|
|
|
- device_status.sim = 0;
|
|
|
+ rt_sprintf(device_status.csq,"%s",csq->valuestring);
|
|
|
}
|
|
|
- else {
|
|
|
- device_status.sim = 1;
|
|
|
+ //NET
|
|
|
+ if (net!=NULL&&sizeof(net->valuestring)<2)
|
|
|
+ {
|
|
|
+ rt_kprintf("网络状态:%s\n",net->valuestring);
|
|
|
+ rt_sprintf(device_status.net,"%s",net->valuestring);
|
|
|
+ }
|
|
|
+ //SIM
|
|
|
+ if (sim!=NULL&&sizeof(net->valuestring)<2)
|
|
|
+ {
|
|
|
+ rt_sprintf(device_status.sim,"%s",sim->valuestring);
|
|
|
}
|
|
|
- device_status.csq = atoi(csq->valuestring);
|
|
|
- device_status.net = net->valueint;
|
|
|
- device_status.gps = gps->valueint;
|
|
|
- if(gps->valueint!=0&&sizeof(lat->valuestring)>2)
|
|
|
+ //GPS
|
|
|
+ if (gps!=NULL&&sizeof(gps->valuestring)<2)
|
|
|
{
|
|
|
- sprintf(device_status.lat,"%s",lat->valuestring);
|
|
|
- sprintf(device_status.lng,"%s",lng->valuestring);
|
|
|
+ rt_sprintf(device_status.gps,"%s",gps->valuestring);
|
|
|
+ if(atoi(gps->valuestring)!=0)
|
|
|
+ {
|
|
|
+ sprintf(device_status.lat,"%s",lat->valuestring);
|
|
|
+ sprintf(device_status.lng,"%s",lng->valuestring);
|
|
|
+ }else if(atoi(gps->valuestring)==0)
|
|
|
+ {
|
|
|
+ sprintf(device_status.lat,"%s","34.8088073");
|
|
|
+ sprintf(device_status.lng,"%s","113.6624298");
|
|
|
+ }
|
|
|
}
|
|
|
- else if(gps->valueint==0||sizeof(lat->valuestring)<2) {
|
|
|
+ else {
|
|
|
+ rt_sprintf(device_status.gps,"0");
|
|
|
sprintf(device_status.lat,"%s","34.8088073");
|
|
|
sprintf(device_status.lng,"%s","113.6624298");
|
|
|
}
|
|
|
-
|
|
|
sprintf(device_status.driver_4g,"%s",driver_4g->valuestring);
|
|
|
sprintf(device_status.project,"%s",project->valuestring);
|
|
|
sprintf(device_status.mqttcfg1,"%s",mqttcfg1->valuestring);
|
|
|
@@ -682,9 +719,7 @@ void parseDtu(char *json_string)
|
|
|
rt_thread_delay(2000);
|
|
|
UpLoad_Data();
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
device_status.hmi_fresh = 0;
|
|
|
}
|
|
|
if(item_ext!=RT_NULL&&strstr(item_cmd->valuestring,"paramconf")!=RT_NULL)
|
|
|
@@ -703,61 +738,71 @@ void parseDtu(char *json_string)
|
|
|
htim = cJSON_GetObjectItem(item_ext,"htim");
|
|
|
ds = cJSON_GetObjectItem(item_ext,"ds");
|
|
|
vt = cJSON_GetObjectItem(item_ext,"vt");
|
|
|
- if(hst->valueint>10&&hst->valueint<150&&hst!=NULL)
|
|
|
+ if(atoi(hst->valuestring)>10&&atoi(hst->valuestring)<150&&hst!=NULL)
|
|
|
{
|
|
|
- device_status.heatvale = hst->valueint;
|
|
|
- ef_set_env_blob("jheat", &device_status.heatvale, sizeof(device_status.heatvale)); //加热温度
|
|
|
- rt_kprintf("加热温度hst:%d\n",hst->valueint);
|
|
|
+ device_status.heatvalue=atoi(hst->valuestring);
|
|
|
+ ef_set_env_blob("jheat", &device_status.heatvalue, sizeof(device_status.heatvalue)); //加热温度
|
|
|
+ rt_kprintf("加热温度hst:%d\n",atoi(hst->valuestring));
|
|
|
}
|
|
|
if (atoi(st->valuestring)>=0&&atoi(st->valuestring)<=23&&st!=NULL) {
|
|
|
device_status.startBar = atoi(st->valuestring);
|
|
|
ef_set_env_blob("startBar", &device_status.startBar, sizeof(device_status.startBar)); //开始时间
|
|
|
rt_kprintf("开始时间st:%d\n",atoi(st->valuestring));
|
|
|
}
|
|
|
+ else if (atoi(st->valuestring)>=0&&atoi(st->valuestring)<=23&&st!=NULL) {
|
|
|
+ device_status.startBar = atoi(st->valuestring);
|
|
|
+ ef_set_env_blob("startBar", &device_status.startBar, sizeof(device_status.startBar)); //开始时间
|
|
|
+ rt_kprintf("开始时间st:%d\n",atoi(st->valuestring));
|
|
|
+ }
|
|
|
if(atoi(et->valuestring)>=0&&atoi(et->valuestring)<=23&&et!=NULL){
|
|
|
device_status.stopBar = atoi(et->valuestring);
|
|
|
ef_set_env_blob("stopBar", &device_status.stopBar, sizeof(device_status.stopBar)); //结束时间
|
|
|
rt_kprintf("结束时间et:%d\n",atoi(et->valuestring));
|
|
|
}
|
|
|
- if(collt->valueint>=1&&collt->valueint<=60&&collt!=NULL){
|
|
|
- device_status.clt_time = collt->valueint;
|
|
|
+ else if (atoi(et->valuestring)>=0&&atoi(et->valuestring)<=23&&et!=NULL) {
|
|
|
+ device_status.stopBar = atoi(et->valuestring);
|
|
|
+ ef_set_env_blob("stopBar", &device_status.stopBar, sizeof(device_status.stopBar)); //结束时间
|
|
|
+ rt_kprintf("结束时间et:%d\n",atoi(et->valuestring));
|
|
|
+ }
|
|
|
+ if(atoi(collt->valuestring)>=1&&atoi(collt->valuestring)<=60&&collt!=NULL){
|
|
|
+ device_status.clt_time = atoi(collt->valuestring);
|
|
|
ef_set_env_blob("stime", &device_status.clt_time, sizeof(device_status.clt_time)); //收集时间
|
|
|
- rt_kprintf("收集时间collt:%d\n",collt->valueint);
|
|
|
+ rt_kprintf("收集时间collt:%d\n",atoi(collt->valuestring));
|
|
|
}
|
|
|
- if(datt->valueint>=1&&datt->valueint<=60&&datt!=NULL)
|
|
|
+ if(atoi(datt->valuestring)>=1&&atoi(datt->valuestring)<=60&&datt!=NULL)
|
|
|
{
|
|
|
- device_status.dattim = datt->valueint;
|
|
|
+ device_status.dattim = atoi(datt->valuestring);
|
|
|
ef_set_env_blob("dattim", &device_status.dattim, sizeof(device_status.dattim)); //数据上传间隔
|
|
|
- rt_kprintf("数据上传间隔datt:%d\n",datt->valueint);
|
|
|
+ rt_kprintf("数据上传间隔datt:%d\n",atoi(datt->valuestring));
|
|
|
}
|
|
|
- if(shake_sec->valueint>=1&&shake_sec->valueint<=10&&shake_sec!=NULL)
|
|
|
+ if(atoi(shake_sec->valuestring)>=1&&atoi(shake_sec->valuestring)<=10&&shake_sec!=NULL)
|
|
|
{
|
|
|
- device_status.shake_sec = shake_sec->valueint;
|
|
|
+ device_status.shake_sec = atoi(shake_sec->valuestring);
|
|
|
ef_set_env_blob("shake_sec", &device_status.shake_sec, sizeof(device_status.shake_sec)); //震动时间
|
|
|
- rt_kprintf("震动时间shake_sec:%d\n",shake_sec->valueint);
|
|
|
+ rt_kprintf("震动时间shake_sec:%d\n",atoi(shake_sec->valuestring));
|
|
|
}
|
|
|
- if((shake->valueint==0||shake->valueint==1)&&shake!=NULL)
|
|
|
+ if((atoi(shake->valuestring)==0||atoi(shake->valuestring)==1)&&shake!=NULL)
|
|
|
{
|
|
|
- device_status.shake_ws = shake->valueint;
|
|
|
+ device_status.shake_ws = atoi(shake->valuestring);
|
|
|
ef_set_env_blob("shake_ws", &device_status.shake_ws, sizeof(device_status.shake_ws)); //震动开关
|
|
|
- rt_kprintf("震动开关shake:%d\n",shake->valueint);
|
|
|
+ rt_kprintf("震动开关shake:%d\n",atoi(shake->valuestring));
|
|
|
}
|
|
|
- if(tt->valueint>=1&&tt->valueint<=10&&tt!=NULL)
|
|
|
+ if(atoi(tt->valuestring)>=1&&atoi(tt->valuestring)<=10&&tt!=NULL)
|
|
|
{
|
|
|
|
|
|
- device_status.sunBar = tt->valueint;
|
|
|
+ device_status.sunBar = atoi(tt->valuestring);
|
|
|
ef_set_env_blob("sunBar", &device_status.sunBar, sizeof(device_status.sunBar)); //光控定时
|
|
|
- rt_kprintf("光控定时tt:%d\n",tt->valueint);
|
|
|
+ rt_kprintf("光控定时tt:%d\n",atoi(tt->valuestring));
|
|
|
}
|
|
|
- if(htim->valueint>=1&&htim->valueint<=30&&htim!=NULL)
|
|
|
+ if(atoi(htim->valuestring)>=1&&atoi(htim->valuestring)<=30&&htim!=NULL)
|
|
|
{
|
|
|
- device_status.heattime = htim -> valueint;
|
|
|
+ device_status.heattime = atoi(htim->valuestring);
|
|
|
ef_set_env_blob("jtime", &device_status.heattime, sizeof(device_status.heattime)); //加热时间
|
|
|
- rt_kprintf("加热时长htim:%d\n",htim->valueint);
|
|
|
+ rt_kprintf("加热时长htim:%d\n",atoi(htim->valuestring));
|
|
|
}
|
|
|
- if((ts->valueint==0||ts->valueint==1)&&ts!=NULL)
|
|
|
+ if((atoi(ts->valuestring)==0||atoi(ts->valuestring)==1)&&ts!=NULL)
|
|
|
{
|
|
|
- device_status.timeSwitch = ts->valueint;
|
|
|
+ device_status.timeSwitch = atoi(ts->valuestring);
|
|
|
ef_set_env_blob("timeSwitch", &device_status.timeSwitch, sizeof(device_status.timeSwitch)); //工作模式
|
|
|
time_t now;
|
|
|
time(&now);
|
|
|
@@ -767,31 +812,31 @@ void parseDtu(char *json_string)
|
|
|
static rt_uint32_t nowstamp_num = 0;
|
|
|
nowstamp_num = mktime(&nowstamp);
|
|
|
device_status.light_over_tim = device_status.sunBar * 3600 + nowstamp_num;
|
|
|
- rt_kprintf("定时模式ts:%d\n",ts->valueint);
|
|
|
+ rt_kprintf("定时模式ts:%d\n",atoi(ts->valuestring));
|
|
|
}
|
|
|
- if(tpl ->valueint>=-50&&tpl ->valueint<=50&&tpl!=NULL)
|
|
|
+ if(atoi(tpl->valuestring)>=-50&&atoi(tpl->valuestring)<=50&&tpl!=NULL)
|
|
|
{
|
|
|
- device_status.tpl = tpl ->valueint;
|
|
|
+ device_status.tpl = atoi(tpl->valuestring);
|
|
|
ef_set_env_blob("tpl", &device_status.tpl, sizeof(device_status.tpl)); //低温保护
|
|
|
- rt_kprintf("低温保护tpl:%d\n",tpl->valueint);
|
|
|
+ rt_kprintf("低温保护tpl:%d\n",atoi(tpl->valuestring));
|
|
|
}
|
|
|
- if(tph ->valueint>=50&&tph ->valueint<=80&&tph!=NULL)
|
|
|
+ if(atoi(tph->valuestring)>=50&&atoi(tpl->valuestring)<=80&&tph!=NULL)
|
|
|
{
|
|
|
- device_status.tph = tph ->valueint;
|
|
|
+ device_status.tph = atoi(tph->valuestring);
|
|
|
ef_set_env_blob("tph", &device_status.tph, sizeof(device_status.tph)); //高温保护
|
|
|
- rt_kprintf("高温保护tph:%d\n",tph->valueint);
|
|
|
+ rt_kprintf("高温保护tph:%d\n",atoi(tph->valuestring));
|
|
|
}
|
|
|
- if(ds ->valueint>=0&&ds->valueint <=1&&ds!=NULL)
|
|
|
+ if(atoi(ds->valuestring)>=0&&atoi(ds->valuestring) <=1&&ds!=NULL)
|
|
|
{
|
|
|
- device_status.ds = ds ->valueint;
|
|
|
+ device_status.ds = atoi(ds->valuestring);
|
|
|
ef_set_env_blob("ds", &device_status.ds, sizeof(device_status.ds));
|
|
|
- rt_kprintf("开关机状态:%d\n",ds->valueint);
|
|
|
+ rt_kprintf("开关机状态:%d\n",atoi(ds->valuestring));
|
|
|
}
|
|
|
- if(vt->valueint>=0&&vt->valueint<=10&&vt!=NULL)
|
|
|
+ if(atoi(vt->valuestring)>=0&&atoi(vt->valuestring)<=10&&vt!=NULL)
|
|
|
{
|
|
|
- device_status.version_type = vt->valueint;
|
|
|
+ device_status.version_type = atoi(vt->valuestring);
|
|
|
ef_set_env_blob("version_type", &device_status.version_type, sizeof(device_status.version_type));
|
|
|
- rt_kprintf("版本类型vt:%d\n",vt->valueint);
|
|
|
+ rt_kprintf("版本类型vt:%d\n",atoi(vt->valuestring));
|
|
|
}
|
|
|
MA_save();
|
|
|
rt_thread_delay(2000);
|
|
|
@@ -800,35 +845,37 @@ void parseDtu(char *json_string)
|
|
|
}
|
|
|
if(item_data!=NULL)
|
|
|
{
|
|
|
- account_status = cJSON_GetObjectItem(item_data,"account_status");
|
|
|
- data_plan = cJSON_GetObjectItem(item_data,"data_plan");
|
|
|
- data_usage = cJSON_GetObjectItem(item_data,"data_usage");
|
|
|
- expiry_date = cJSON_GetObjectItem(item_data,"expiry_date");
|
|
|
- iccid = cJSON_GetObjectItem(item_data,"iccid");
|
|
|
- device_status.account_status = account_status->valueint;
|
|
|
- device_status.data_plan = data_plan->valueint;
|
|
|
- char data_usage_f[6];
|
|
|
- struct tm t;
|
|
|
- time_t expiry_date_time = expiry_date->valueint;
|
|
|
- t= *localtime(&expiry_date_time);
|
|
|
- rt_kprintf("expiry_date:%04d-%02d-%02d %02d:%02d:%02d\r\n",t.tm_year+1900,t.tm_mon+1,t.tm_mday,t.tm_hour+8,t.tm_min,t.tm_sec);
|
|
|
- rt_kprintf("account_status:%d\n",account_status->valueint);
|
|
|
- rt_kprintf("expiry_date:%d\n",expiry_date->valueint);
|
|
|
- rt_kprintf("data_plan:%d\n",data_plan->valueint);
|
|
|
- HMI_WRITE("sim.iccid.txt=\"%s\"",iccid->valuestring);
|
|
|
- HMI_WRITE("sim.account_status.txt=\"%d\"",device_status.account_status);
|
|
|
- HMI_WRITE("sim.data_plan.txt=\"%d\"",device_status.data_plan);
|
|
|
- sprintf(data_usage_f,"%.5f",data_usage->valuedouble);
|
|
|
- rt_kprintf("data_usage_f:%s\n",data_usage_f);
|
|
|
- HMI_WRITE("sim.data_usage.txt=\"%s\"",data_usage_f);
|
|
|
- HMI_WRITE("sim.expiry_date.txt=\"%04d-%02d-%02d %02d:%02d:%02d\"",t.tm_year+1900,t.tm_mon+1,t.tm_mday,t.tm_hour+8,t.tm_min,t.tm_sec);
|
|
|
+// account_status = cJSON_GetObjectItem(item_data,"account_status");
|
|
|
+// data_plan = cJSON_GetObjectItem(item_data,"data_plan");
|
|
|
+// data_usage = cJSON_GetObjectItem(item_data,"data_usage");
|
|
|
+// expiry_date = cJSON_GetObjectItem(item_data,"expiry_date");
|
|
|
+// iccid = cJSON_GetObjectItem(item_data,"iccid");
|
|
|
+// device_status.account_status = account_status->valueint;
|
|
|
+// device_status.data_plan = data_plan->valueint;
|
|
|
+// char data_usage_f[6];
|
|
|
+// struct tm t;
|
|
|
+// time_t expiry_date_time = expiry_date->valueint;
|
|
|
+// t= *localtime(&expiry_date_time);
|
|
|
+// rt_kprintf("expiry_date:%04d-%02d-%02d %02d:%02d:%02d\r\n",t.tm_year+1900,t.tm_mon+1,t.tm_mday,t.tm_hour+8,t.tm_min,t.tm_sec);
|
|
|
+// rt_kprintf("account_status:%d\n",account_status->valueint);
|
|
|
+// rt_kprintf("expiry_date:%d\n",expiry_date->valueint);
|
|
|
+// rt_kprintf("data_plan:%d\n",data_plan->valueint);
|
|
|
+// HMI_WRITE("sim.iccid.txt=\"%s\"",iccid->valuestring);
|
|
|
+// HMI_WRITE("sim.account_status.txt=\"%d\"",device_status.account_status);
|
|
|
+// HMI_WRITE("sim.data_plan.txt=\"%d\"",device_status.data_plan);
|
|
|
+// sprintf(data_usage_f,"%.5f",data_usage->valuedouble);
|
|
|
+// rt_kprintf("data_usage_f:%s\n",data_usage_f);
|
|
|
+// HMI_WRITE("sim.data_usage.txt=\"%s\"",data_usage_f);
|
|
|
+// HMI_WRITE("sim.expiry_date.txt=\"%04d-%02d-%02d %02d:%02d:%02d\"",t.tm_year+1900,t.tm_mon+1,t.tm_mday,t.tm_hour+8,t.tm_min,t.tm_sec);
|
|
|
}
|
|
|
cJSON_Delete(root);
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
void UpLoad_Data(void)
|
|
|
{
|
|
|
+
|
|
|
char *updata = makeJson();
|
|
|
rt_kprintf("upload data:%d\n%s\n",rt_strlen(updata),updata);
|
|
|
DTU_Write("%s",updata);
|