|
|
@@ -569,6 +569,14 @@ void parseDtu(char *json_string)
|
|
|
rt_free(photo);
|
|
|
rt_thread_delay(2000);
|
|
|
}
|
|
|
+ else if (strstr(item_cmd->valuestring,"shake")!=RT_NULL)
|
|
|
+ {
|
|
|
+ ctr_shake(ON, 30);
|
|
|
+ char *shake = makeJson_Warn("shake","control");
|
|
|
+ DTU_Write("%s",shake);
|
|
|
+ rt_free(shake);
|
|
|
+ rt_thread_delay(2000);
|
|
|
+ }
|
|
|
//远程给rtu重新上电
|
|
|
else if (strstr(item_cmd->valuestring,"ctrl")!=RT_NULL)
|
|
|
{
|
|
|
@@ -788,97 +796,183 @@ void parseDtu(char *json_string)
|
|
|
htim = cJSON_GetObjectItem(item_ext,"htim");
|
|
|
ds = cJSON_GetObjectItem(item_ext,"ds");
|
|
|
vt = cJSON_GetObjectItem(item_ext,"vt");
|
|
|
- if(atoi(hst->valuestring)>10&&atoi(hst->valuestring)<150&&hst!=NULL)
|
|
|
+ if(hst!=NULL)
|
|
|
{
|
|
|
- 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(hst->valuestring)>10&&atoi(hst->valuestring)<150)
|
|
|
+ {
|
|
|
+ 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));
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ rt_kprintf("加热温度hst设置失败参数错误!!!\n");
|
|
|
+ }
|
|
|
}
|
|
|
- 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 (st!=NULL)
|
|
|
+ {
|
|
|
+ if(atoi(st->valuestring)>=0&&atoi(st->valuestring)<=23)
|
|
|
+ {
|
|
|
+ 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 {
|
|
|
+ rt_kprintf("开始时间st设置失败参数错误!!!\n");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- 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(et!=NULL)
|
|
|
+ {
|
|
|
+ if(atoi(et->valuestring)>=0&&atoi(et->valuestring)<=23)
|
|
|
+ {
|
|
|
+ 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));
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ rt_kprintf("结束时间et设置失败参数错误!!!\n");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- 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",atoi(collt->valuestring));
|
|
|
+ if(collt!=NULL)
|
|
|
+ {
|
|
|
+ if(atoi(collt->valuestring)>=1&&atoi(collt->valuestring)<=60)
|
|
|
+ {
|
|
|
+ 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",atoi(collt->valuestring));
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ rt_kprintf("收集时间collt设置失败参数错误!!!\n");
|
|
|
+ }
|
|
|
}
|
|
|
- if(atoi(datt->valuestring)>=1&&atoi(datt->valuestring)<=60&&datt!=NULL)
|
|
|
+ if(datt!=NULL)
|
|
|
{
|
|
|
- device_status.dattim = atoi(datt->valuestring);
|
|
|
- ef_set_env_blob("dattim", &device_status.dattim, sizeof(device_status.dattim)); //数据上传间隔
|
|
|
- rt_kprintf("数据上传间隔datt:%d\n",atoi(datt->valuestring));
|
|
|
+ if(atoi(datt->valuestring)>=1&&atoi(datt->valuestring)<=60)
|
|
|
+ {
|
|
|
+ device_status.dattim = atoi(datt->valuestring);
|
|
|
+ ef_set_env_blob("dattim", &device_status.dattim, sizeof(device_status.dattim)); //数据上传间隔
|
|
|
+ rt_kprintf("数据上传间隔datt:%d\n",atoi(datt->valuestring));
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ rt_kprintf("数据上传间隔datt设置失败参数错误!!!\n");
|
|
|
+ }
|
|
|
}
|
|
|
- if(atoi(shake_sec->valuestring)>=1&&atoi(shake_sec->valuestring)<=10&&shake_sec!=NULL)
|
|
|
+ if(shake_sec!=NULL)
|
|
|
{
|
|
|
- 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",atoi(shake_sec->valuestring));
|
|
|
+ if(atoi(shake_sec->valuestring)>=1&&atoi(shake_sec->valuestring)<=10)
|
|
|
+ {
|
|
|
+ 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",atoi(shake_sec->valuestring));
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ rt_kprintf("震动时间shake_sec设置失败参数错误!!!\n");
|
|
|
+ }
|
|
|
}
|
|
|
- if((atoi(shake->valuestring)==0||atoi(shake->valuestring)==1)&&shake!=NULL)
|
|
|
+ if(shake!=NULL)
|
|
|
{
|
|
|
- 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",atoi(shake->valuestring));
|
|
|
+ if(atoi(shake->valuestring)==0||atoi(shake->valuestring)==1)
|
|
|
+ {
|
|
|
+ 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",atoi(shake->valuestring));
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ rt_kprintf("震动开关shake设置失败参数错误!!!\n");
|
|
|
+ }
|
|
|
}
|
|
|
- if(atoi(tt->valuestring)>=1&&atoi(tt->valuestring)<=10&&tt!=NULL)
|
|
|
+ if(tt!=NULL)
|
|
|
{
|
|
|
-
|
|
|
- device_status.sunBar = atoi(tt->valuestring);
|
|
|
- ef_set_env_blob("sunBar", &device_status.sunBar, sizeof(device_status.sunBar)); //光控定时
|
|
|
- rt_kprintf("光控定时tt:%d\n",atoi(tt->valuestring));
|
|
|
+ if(atoi(tt->valuestring)>=1&&atoi(tt->valuestring)<=10)
|
|
|
+ {
|
|
|
+ device_status.sunBar = atoi(tt->valuestring);
|
|
|
+ ef_set_env_blob("sunBar", &device_status.sunBar, sizeof(device_status.sunBar)); //光控定时
|
|
|
+ rt_kprintf("光控定时tt:%d\n",atoi(tt->valuestring));
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ rt_kprintf("光控定时tt设置失败参数错误!!!\n");
|
|
|
+ }
|
|
|
}
|
|
|
- if(atoi(htim->valuestring)>=1&&atoi(htim->valuestring)<=30&&htim!=NULL)
|
|
|
+ if(htim!=NULL)
|
|
|
{
|
|
|
- device_status.heattime = atoi(htim->valuestring);
|
|
|
- ef_set_env_blob("jtime", &device_status.heattime, sizeof(device_status.heattime)); //加热时间
|
|
|
- rt_kprintf("加热时长htim:%d\n",atoi(htim->valuestring));
|
|
|
+ if(atoi(htim->valuestring)>=1&&atoi(htim->valuestring)<=30)
|
|
|
+ {
|
|
|
+ device_status.heattime = atoi(htim->valuestring);
|
|
|
+ ef_set_env_blob("jtime", &device_status.heattime, sizeof(device_status.heattime)); //加热时间
|
|
|
+ rt_kprintf("加热时长htim:%d\n",atoi(htim->valuestring));
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ rt_kprintf("加热时长htim设置失败参数错误!!!\n");
|
|
|
+ }
|
|
|
}
|
|
|
- if((atoi(ts->valuestring)==0||atoi(ts->valuestring)==1)&&ts!=NULL)
|
|
|
+ if(ts!=NULL)
|
|
|
{
|
|
|
- device_status.timeSwitch = atoi(ts->valuestring);
|
|
|
- ef_set_env_blob("timeSwitch", &device_status.timeSwitch, sizeof(device_status.timeSwitch)); //工作模式
|
|
|
- time_t now;
|
|
|
- time(&now);
|
|
|
- static struct tm nowstamp;
|
|
|
- nowstamp =*localtime(&now);
|
|
|
- nowstamp.tm_hour = nowstamp.tm_hour - 8;
|
|
|
- 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",atoi(ts->valuestring));
|
|
|
+ if(atoi(ts->valuestring)==0||atoi(ts->valuestring)==1)
|
|
|
+ {
|
|
|
+ device_status.timeSwitch = atoi(ts->valuestring);
|
|
|
+ ef_set_env_blob("timeSwitch", &device_status.timeSwitch, sizeof(device_status.timeSwitch)); //工作模式
|
|
|
+ time_t now;
|
|
|
+ time(&now);
|
|
|
+ static struct tm nowstamp;
|
|
|
+ nowstamp =*localtime(&now);
|
|
|
+ nowstamp.tm_hour = nowstamp.tm_hour - 8;
|
|
|
+ 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",atoi(ts->valuestring));
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ rt_kprintf("定时模式ts设置失败参数错误!!!\n");
|
|
|
+ }
|
|
|
}
|
|
|
- if(atoi(tpl->valuestring)>=-50&&atoi(tpl->valuestring)<=50&&tpl!=NULL)
|
|
|
+ if(tpl!=NULL)
|
|
|
{
|
|
|
- device_status.tpl = atoi(tpl->valuestring);
|
|
|
- ef_set_env_blob("tpl", &device_status.tpl, sizeof(device_status.tpl)); //低温保护
|
|
|
- rt_kprintf("低温保护tpl:%d\n",atoi(tpl->valuestring));
|
|
|
+ if(atoi(tpl->valuestring)>=-50&&atoi(tpl->valuestring)<=50)
|
|
|
+ {
|
|
|
+ device_status.tpl = atoi(tpl->valuestring);
|
|
|
+ ef_set_env_blob("tpl", &device_status.tpl, sizeof(device_status.tpl)); //低温保护
|
|
|
+ rt_kprintf("低温保护tpl:%d\n",atoi(tpl->valuestring));
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ rt_kprintf("低温保护tpl设置失败参数错误!!!\n");
|
|
|
+ }
|
|
|
}
|
|
|
- if(atoi(tph->valuestring)>=50&&atoi(tpl->valuestring)<=80&&tph!=NULL)
|
|
|
+ if(tph!=NULL)
|
|
|
{
|
|
|
- device_status.tph = atoi(tph->valuestring);
|
|
|
- ef_set_env_blob("tph", &device_status.tph, sizeof(device_status.tph)); //高温保护
|
|
|
- rt_kprintf("高温保护tph:%d\n",atoi(tph->valuestring));
|
|
|
+ if(atoi(tph->valuestring)>=50&&atoi(tpl->valuestring)<=80)
|
|
|
+ {
|
|
|
+ device_status.tph = atoi(tph->valuestring);
|
|
|
+ ef_set_env_blob("tph", &device_status.tph, sizeof(device_status.tph)); //高温保护
|
|
|
+ rt_kprintf("高温保护tph:%d\n",atoi(tph->valuestring));
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ rt_kprintf("高温保护tph设置失败参数错误!!!\n");
|
|
|
+ }
|
|
|
}
|
|
|
- if(atoi(ds->valuestring)>=0&&atoi(ds->valuestring) <=1&&ds!=NULL)
|
|
|
+ if(ds!=NULL)
|
|
|
{
|
|
|
- device_status.ds = atoi(ds->valuestring);
|
|
|
- ef_set_env_blob("ds", &device_status.ds, sizeof(device_status.ds));
|
|
|
- rt_kprintf("开关机状态:%d\n",atoi(ds->valuestring));
|
|
|
+ if(atoi(ds->valuestring)>=0&&atoi(ds->valuestring) <=1)
|
|
|
+ {
|
|
|
+ device_status.ds = atoi(ds->valuestring);
|
|
|
+ ef_set_env_blob("ds", &device_status.ds, sizeof(device_status.ds));
|
|
|
+ rt_kprintf("开关机状态:%d\n",atoi(ds->valuestring));
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ rt_kprintf("开关机状态设置失败参数错误!!!\n");
|
|
|
+ }
|
|
|
}
|
|
|
- if(atoi(vt->valuestring)>=0&&atoi(vt->valuestring)<=10&&vt!=NULL)
|
|
|
+ if(vt!=NULL)
|
|
|
{
|
|
|
- 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",atoi(vt->valuestring));
|
|
|
+ if(atoi(vt->valuestring)>=0&&atoi(vt->valuestring)<=10)
|
|
|
+ {
|
|
|
+ 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",atoi(vt->valuestring));
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ rt_kprintf("版本类型设置失败参数错误!!!\n");
|
|
|
+ }
|
|
|
}
|
|
|
MA_save();
|
|
|
rt_thread_delay(2000);
|