|
|
@@ -36,6 +36,7 @@
|
|
|
|
|
|
|
|
|
Device_Status_typedef device_status;
|
|
|
+Device_slide_typedef slide_para;
|
|
|
DataTemp data_arry;
|
|
|
|
|
|
void list_mem(void);
|
|
|
@@ -148,20 +149,6 @@ static void dtu_thread_entry_recv(void *parameter)
|
|
|
rx_length = rt_device_read(msg.dev, 0, &rx_buffer[0], rx_length);
|
|
|
rx_buffer[rx_length] = '\0';
|
|
|
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);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
//过滤异常数据
|
|
|
char str_check_head[2];
|
|
|
char str_check_end[2];
|
|
|
@@ -191,33 +178,9 @@ static void dtu_thread_entry_recv(void *parameter)
|
|
|
//rt_kprintf("%s",rx_buffer);
|
|
|
}
|
|
|
}
|
|
|
- else {
|
|
|
- rx_err ++;
|
|
|
- if(rx_err==54000)//90分钟未接收到数据
|
|
|
- {
|
|
|
- if(device_status.version_type==6)
|
|
|
- {
|
|
|
- LOG_E("RK3399 transter Error!");
|
|
|
- ctr_photo(OFF);
|
|
|
- }
|
|
|
- else {
|
|
|
- ctr_RTU_DTU(OFF);
|
|
|
- }
|
|
|
- }
|
|
|
- else if (rx_err==54100&&device_status.bat_status==0)
|
|
|
- {
|
|
|
- LOG_W("通信中断,RTU重新上电");
|
|
|
- rx_err = 0;
|
|
|
- ctr_RTU_DTU(ON);
|
|
|
- ctr_photo(ON);
|
|
|
- }
|
|
|
- }
|
|
|
- //rt_kprintf("%s\n",rx_json_buffer);
|
|
|
- // 将内容写回到串口1
|
|
|
- //rt_device_write(dtuserial, 0, &rx_json_buffer[0], rx_length);
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
+#if 0
|
|
|
/*入口函数-指令发送*/
|
|
|
static void dtu_thread_entry_send(void *parameter)
|
|
|
{
|
|
|
@@ -335,7 +298,7 @@ static void dtu_thread_entry_send(void *parameter)
|
|
|
rt_thread_mdelay(1000);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+#endif
|
|
|
/* 创建线程 */
|
|
|
int dtu_data_play(void)
|
|
|
{
|
|
|
@@ -352,6 +315,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_thread_entry_send,RT_NULL,
|
|
|
@@ -359,6 +323,7 @@ int dtu_data_play(void)
|
|
|
3, //优先级高是为了保证数据上传的频率的精确度
|
|
|
20 //时间片
|
|
|
);
|
|
|
+ #endif
|
|
|
/* 创建线程-指令接收解析*/
|
|
|
dtu_recv_data = rt_thread_create("DTU_Uart_thread_recv",
|
|
|
dtu_thread_entry_recv, RT_NULL,
|
|
|
@@ -366,8 +331,8 @@ int dtu_data_play(void)
|
|
|
DTU_THREAD_PRIORITY,
|
|
|
DTU_THREAD_TIMESLICE);
|
|
|
/* 如果获得线程控制块,启动这个线程 */
|
|
|
- if(dtu_send_data!=RT_NULL)
|
|
|
- rt_thread_startup(dtu_send_data);
|
|
|
+// if(dtu_send_data!=RT_NULL)
|
|
|
+// rt_thread_startup(dtu_send_data);
|
|
|
/* 如果获得线程控制块,启动这个线程 */
|
|
|
if (dtu_recv_data != RT_NULL)
|
|
|
rt_thread_startup(dtu_recv_data);
|
|
|
@@ -676,10 +641,9 @@ char *makeJson_C01_Warn(uint16_t code,double process)
|
|
|
char * makeJson()
|
|
|
{
|
|
|
char utos[5];
|
|
|
- if(device_status.gps==NULL)
|
|
|
- rt_sprintf(device_status.gps, "0");
|
|
|
+
|
|
|
//如果设备工作并且电流小于500,并且不是上电启动灯管异常
|
|
|
- if(atoi(device_status.power)<400&&atoi(device_status.power)!=0&&device_status.work_status==1&&makejson_sta!=0)
|
|
|
+ if(atoi(device_status.power)<400&&device_status.work_status==1&&makejson_sta!=0)
|
|
|
{
|
|
|
#if LAMP_EN == 0
|
|
|
LOG_I("Current is:%d",atoi(device_status.power));
|
|
|
@@ -687,9 +651,7 @@ char * makeJson()
|
|
|
device_status.lamp_status = 1;
|
|
|
#endif
|
|
|
}
|
|
|
- else {
|
|
|
- device_status.lamp_status = 0;
|
|
|
- }
|
|
|
+
|
|
|
if(atoi(device_status.power)>5000)
|
|
|
rt_sprintf(device_status.power,"0.01");
|
|
|
|
|
|
@@ -723,26 +685,7 @@ char * makeJson()
|
|
|
return NULL;
|
|
|
}
|
|
|
memset(device_status.driver,0,sizeof(device_status.driver));
|
|
|
- if(device_status.version_type==1)
|
|
|
- {
|
|
|
- rt_sprintf(device_status.driver,"%s-%s",VERSION_ZP,device_status.driver_4g);
|
|
|
- }
|
|
|
- else if (device_status.version_type==4) {
|
|
|
- rt_sprintf(device_status.driver,"%s-%s",VERSION_HK_2000W,device_status.driver_4g);
|
|
|
- }
|
|
|
- else if (device_status.version_type==41) {
|
|
|
- rt_sprintf(device_status.driver,"%s-%s",VERSION_HK,device_status.driver_4g);
|
|
|
- }
|
|
|
- else if (device_status.version_type==11) {
|
|
|
- rt_sprintf(device_status.driver,"%s-%s",VERSION_GK,device_status.driver_4g);
|
|
|
- }
|
|
|
- else if (device_status.version_type==5) {
|
|
|
- rt_sprintf(device_status.driver,"%s-%s",VERSION_V5,device_status.driver_4g);
|
|
|
- }
|
|
|
- else if (device_status.version_type==6) {
|
|
|
- rt_sprintf(device_status.driver,"%s-%s",VERSION_XCT,device_status.driver_4g);
|
|
|
- }
|
|
|
- else if (device_status.version_type==7) {
|
|
|
+ if (device_status.version_type==7) {
|
|
|
rt_sprintf(device_status.driver,"%s-%s",VERSION_BZY,device_status.driver_4g);
|
|
|
}
|
|
|
if(device_status.sensor_485_sta!=0)
|
|
|
@@ -756,159 +699,39 @@ char * makeJson()
|
|
|
//设备类型
|
|
|
rt_sprintf(utos, "%d",device_status.dtype);
|
|
|
cJSON_AddStringToObject(pSubJson,"dtype",utos);
|
|
|
- //类型细分
|
|
|
- if(device_status.version_type==4) //水稻
|
|
|
- {
|
|
|
- rt_sprintf(utos,"4");
|
|
|
- cJSON_AddStringToObject(pSubJson,"vtype",utos);
|
|
|
- }
|
|
|
- else if (device_status.version_type==1) { //1.0
|
|
|
- rt_sprintf(utos,"1");
|
|
|
- cJSON_AddStringToObject(pSubJson,"vtype",utos);
|
|
|
- }
|
|
|
- else if (device_status.version_type==11) { //高空
|
|
|
- rt_sprintf(utos,"11");
|
|
|
- cJSON_AddStringToObject(pSubJson,"vtype",utos);
|
|
|
- }
|
|
|
- else if (device_status.version_type==5) { //5.0
|
|
|
- rt_sprintf(utos,"5");
|
|
|
- cJSON_AddStringToObject(pSubJson,"vtype",utos);
|
|
|
- }
|
|
|
- else if (device_status.version_type==6) { //吸虫塔
|
|
|
- rt_sprintf(utos,"6");
|
|
|
- cJSON_AddStringToObject(pSubJson,"vtype",utos);
|
|
|
- }
|
|
|
- if(device_status.version_type!=6&&device_status.dtype!=7)
|
|
|
- {
|
|
|
- //光控定时
|
|
|
- rt_sprintf(utos, "%d",device_status.sunBar);
|
|
|
- cJSON_AddStringToObject(pSubJson,"tt",utos);
|
|
|
- //定时模式
|
|
|
- rt_sprintf(utos, "%d",device_status.timeSwitch);
|
|
|
- cJSON_AddStringToObject(pSubJson,"ts",utos);
|
|
|
- //温控
|
|
|
- rt_sprintf(utos, "%d",device_status.temp_status);
|
|
|
- cJSON_AddStringToObject(pSubJson,"tps",utos);
|
|
|
- //光控状态
|
|
|
- rt_sprintf(utos, "%d",device_status.sun_status);
|
|
|
- cJSON_AddStringToObject(pSubJson,"lps",utos);
|
|
|
- //雨控状态
|
|
|
- rt_sprintf(utos, "%d",device_status.rain_status);
|
|
|
- cJSON_AddStringToObject(pSubJson,"rps",utos);
|
|
|
- //电池状态
|
|
|
- rt_sprintf(utos, "%d",device_status.bat_status);
|
|
|
- cJSON_AddStringToObject(pSubJson,"batStatus",utos);
|
|
|
- //灯管状态
|
|
|
- rt_sprintf(utos, "%d",device_status.lamp_status);
|
|
|
- cJSON_AddStringToObject(pSubJson,"lamp",utos);
|
|
|
- //上仓门状态 1-打开,0-关闭-(通道) 打开为落虫,关闭为排水
|
|
|
- rt_sprintf(utos, "%d",device_status.up_status);
|
|
|
- cJSON_AddStringToObject(pSubJson,"upds",utos);
|
|
|
- //下仓门状态 1-打开,0-关闭
|
|
|
- rt_sprintf(utos, "%d",device_status.down_status);
|
|
|
- cJSON_AddStringToObject(pSubJson,"dnds",utos);
|
|
|
- //加热仓温度
|
|
|
- if(device_status.run_sta>device_status.heattem)
|
|
|
- {
|
|
|
- rt_sprintf(utos, "%d",device_status.run_sta);
|
|
|
- device_status.run_sta = 0;
|
|
|
- }
|
|
|
- else {
|
|
|
- rt_sprintf(utos, "%d",device_status.heattem);
|
|
|
- }
|
|
|
- cJSON_AddStringToObject(pSubJson,"hrt",utos);
|
|
|
- //加热状态
|
|
|
- rt_sprintf(utos, "%d",device_status.heat_status);
|
|
|
- cJSON_AddStringToObject(pSubJson,"hs",utos);
|
|
|
- //收集时间(参数)
|
|
|
- rt_sprintf(utos, "%d",device_status.clt_time);
|
|
|
- cJSON_AddStringToObject(pSubJson,"collt",utos);
|
|
|
- //加热时间(参数)
|
|
|
- rt_sprintf(utos, "%d",device_status.heattime);
|
|
|
- cJSON_AddStringToObject(pSubJson,"htim",utos);
|
|
|
- //加热温度(参数)
|
|
|
- rt_sprintf(utos, "%d",device_status.heatvalue);
|
|
|
- cJSON_AddStringToObject(pSubJson,"hst",utos);
|
|
|
- //高温保护
|
|
|
- rt_sprintf(utos, "%d",device_status.tph);
|
|
|
- cJSON_AddStringToObject(pSubJson,"tph",utos);
|
|
|
- //低温保护
|
|
|
- rt_sprintf(utos, "%d",device_status.tpl);
|
|
|
- cJSON_AddStringToObject(pSubJson,"tpl",utos);
|
|
|
- }
|
|
|
- if(device_status.dtype==3)
|
|
|
- {
|
|
|
- //工作状态
|
|
|
- rt_sprintf(utos, "%d",device_status.work_status);
|
|
|
- cJSON_AddStringToObject(pSubJson,"ws",utos);
|
|
|
- //保险丝电压
|
|
|
- cJSON_AddStringToObject(pSubJson,"fuse_voltage",device_status.fuse_voltage);
|
|
|
- //开始时间
|
|
|
- rt_sprintf(utos, "%d",device_status.startBar);
|
|
|
- cJSON_AddStringToObject(pSubJson,"st",utos);
|
|
|
- //结束时间
|
|
|
- rt_sprintf(utos, "%d",device_status.stopBar);
|
|
|
- cJSON_AddStringToObject(pSubJson,"et",utos);
|
|
|
- }
|
|
|
- else if(device_status.dtype==7)
|
|
|
+
|
|
|
+ if(device_status.dtype==7)
|
|
|
{
|
|
|
- char ct1[10],ct2[10];
|
|
|
+ char ct1[10],ct2[10],ct3[10];
|
|
|
rt_sprintf(ct1,"%d-%d",device_status.collecting_sh1,device_status.collecting_eh1);
|
|
|
rt_sprintf(ct2,"%d-%d",device_status.collecting_sh2,device_status.collecting_eh2);
|
|
|
+ rt_sprintf(ct3,"%d-%d",device_status.collecting_sh3,device_status.collecting_eh3);
|
|
|
rt_kprintf("ct1-ct2:%s\n",ct1);
|
|
|
device_status.coll_time[0] = ct1;
|
|
|
device_status.coll_time[1] = ct2;
|
|
|
+ device_status.coll_time[2] = ct3;
|
|
|
cJSON *data_clt = NULL;
|
|
|
- data_clt = cJSON_CreateStringArray(device_status.coll_time,2);
|
|
|
+ data_clt = cJSON_CreateStringArray(device_status.coll_time,3);
|
|
|
//工作状态
|
|
|
rt_sprintf(utos, "%d",device_status.work_status);
|
|
|
cJSON_AddStringToObject(pSubJson,"work_sta",utos);
|
|
|
- //运行状态
|
|
|
- rt_sprintf(utos, "%d",device_status.run_sta);
|
|
|
- cJSON_AddStringToObject(pSubJson,"run_sta",utos);
|
|
|
- //箱体温度-box_tem
|
|
|
- rt_sprintf(utos, "%d",device_status.box_temp);
|
|
|
- cJSON_AddStringToObject(pSubJson,"box_tem",utos);
|
|
|
- //培养时间-cul_time
|
|
|
- rt_sprintf(utos, "%d",device_status.cul_time);
|
|
|
- cJSON_AddStringToObject(pSubJson,"cul_time",utos);
|
|
|
- //制冷状态
|
|
|
- rt_sprintf(utos, "%d",device_status.cold_sw);
|
|
|
- cJSON_AddStringToObject(pSubJson,"cold_sw",utos);
|
|
|
+
|
|
|
//电压状态-batStatus
|
|
|
rt_sprintf(utos, "%d",device_status.bat_status);
|
|
|
cJSON_AddStringToObject(pSubJson,"batStatus",utos);
|
|
|
- //已培养时间-staytime
|
|
|
- rt_sprintf(utos, "%d",device_status.stay_time);
|
|
|
- cJSON_AddStringToObject(pSubJson,"stay_time",utos);
|
|
|
+
|
|
|
//风机开关
|
|
|
rt_sprintf(utos, "%d",device_status.wind_sw);
|
|
|
cJSON_AddStringToObject(pSubJson,"wind_sw",utos);
|
|
|
- //培养仓温度
|
|
|
- rt_sprintf(utos, "%d",device_status.pre_temp);
|
|
|
- cJSON_AddStringToObject(pSubJson,"pre_temp",utos);
|
|
|
//分辨率
|
|
|
cJSON_AddStringToObject(pSubJson,"imgres","0");
|
|
|
//usb
|
|
|
cJSON_AddStringToObject(pSubJson,"usb_sta","0");
|
|
|
- //雨控状态-rps
|
|
|
- rt_sprintf(utos, "%d",device_status.rain_status);
|
|
|
- cJSON_AddStringToObject(pSubJson,"rps",utos);
|
|
|
+
|
|
|
//收集时间
|
|
|
cJSON_AddItemToObject(pSubJson,"coll_time",data_clt);
|
|
|
- //设定温度
|
|
|
- rt_sprintf(utos, "%d",device_status.heatvalue);
|
|
|
- cJSON_AddStringToObject(pSubJson,"set_temp",utos);
|
|
|
}
|
|
|
- if(device_status.dtype!=7)
|
|
|
- {
|
|
|
- //震动开关
|
|
|
- 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); //定位状态
|
|
|
//开关状态
|
|
|
rt_sprintf(utos, "%d",device_status.ds);
|
|
|
@@ -935,10 +758,6 @@ char * makeJson()
|
|
|
cJSON_AddStringToObject(pSubJson,"dat_f",utos);
|
|
|
//信号强度
|
|
|
cJSON_AddStringToObject(pSubJson,"csq",device_status.csq);
|
|
|
- #if 0
|
|
|
- //太阳能板电压
|
|
|
- cJSON_AddStringToObject(pSubJson,"cv",device_status.voltage_sun);
|
|
|
- #endif
|
|
|
char *p = cJSON_PrintUnformatted(pJsonRoot);
|
|
|
if(NULL == p)
|
|
|
{
|
|
|
@@ -950,6 +769,7 @@ char * makeJson()
|
|
|
return p;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
int Parse_Cam_Param(cJSON *param_msg)
|
|
|
{
|
|
|
cJSON* item_ext=cJSON_GetObjectItem(param_msg,"ext");
|
|
|
@@ -1006,9 +826,8 @@ int parseDtu(char *json_string)
|
|
|
extern int rt_hw_rtc_init(void);
|
|
|
char* json_s = NULL;
|
|
|
cJSON* item_cmd = NULL; //嵌套ext
|
|
|
+ cJSON* item_focus = NULL;
|
|
|
cJSON* item_ext = NULL; //嵌套ext
|
|
|
- cJSON* item_checkself = NULL;
|
|
|
- cJSON* photolink = NULL;
|
|
|
cJSON* photo_sta = NULL;
|
|
|
cJSON* hst = NULL; //加热温度
|
|
|
cJSON* collt = NULL; //收集时间
|
|
|
@@ -1036,10 +855,6 @@ int 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* mqttcfg1 = NULL;
|
|
|
cJSON* mqttcfg2 = NULL;
|
|
|
cJSON* type =NULL;
|
|
|
@@ -1047,7 +862,11 @@ int parseDtu(char *json_string)
|
|
|
cJSON* tmp = NULL;
|
|
|
cJSON* link_sta = NULL;
|
|
|
cJSON* value_commn= NULL;
|
|
|
- rt_kprintf("%s\n",json_string);
|
|
|
+ cJSON* movx = NULL;
|
|
|
+ cJSON* movy = NULL;
|
|
|
+ cJSON* movz = NULL;
|
|
|
+ cJSON* speed = NULL;
|
|
|
+ //rt_kprintf("%s\n",json_string);
|
|
|
cJSON *root = cJSON_Parse(json_string);
|
|
|
if(!root)
|
|
|
{
|
|
|
@@ -1058,83 +877,106 @@ int parseDtu(char *json_string)
|
|
|
else
|
|
|
{
|
|
|
item_cmd = cJSON_GetObjectItem(root,"cmd");
|
|
|
- item_checkself = cJSON_GetObjectItem(root,"selfcheck");
|
|
|
- photolink = cJSON_GetObjectItem(root,"photolink");
|
|
|
- cJSON* ledsta = cJSON_GetObjectItem(root,"ledsta");
|
|
|
- cJSON* cam_cmd= cJSON_GetObjectItem(root,"cam_code");
|
|
|
item_ext=cJSON_GetObjectItem(root,"ext");
|
|
|
- if(cam_cmd!=NULL){
|
|
|
- //先检查定时器状态,否则会崩溃
|
|
|
- rt_timer_stop(timer_uart2);
|
|
|
- LOG_I("cam_code");
|
|
|
- if(cam_cmd->valueint==0){
|
|
|
- ctr_led(ON);
|
|
|
- HMI_WRITE("sysSet.va0.txt=\"相机已连接!\"");
|
|
|
- }else{
|
|
|
- HMI_WRITE("sysSet.va0.txt=\"相机连接失败:%d!\"",cam_cmd->valueint);
|
|
|
- }
|
|
|
- if(item_ext!=NULL)
|
|
|
- Parse_Cam_Param(root);
|
|
|
+ item_focus = cJSON_GetObjectItem(root,"focus");
|
|
|
+ if(item_focus!=RT_NULL){
|
|
|
+ device_status.focus_value = item_focus->valuedouble;
|
|
|
}
|
|
|
|
|
|
- if(ledsta!=NULL)
|
|
|
+ if(item_cmd!=RT_NULL)
|
|
|
{
|
|
|
- rt_timer_stop(timer_takephoto);
|
|
|
- HMI_WRITE("selfcheck.t3.bco=2024");
|
|
|
- device_status.C01 &= ~(1<<2);
|
|
|
- if(ledsta->valueint==0)
|
|
|
- {
|
|
|
- HMI_WRITE("selfcheck.t4.bco=2024");
|
|
|
- device_status.C01 &= ~(1<<3);
|
|
|
+ if(strstr(item_cmd->valuestring,"autotest")!=RT_NULL){
|
|
|
+ device_status.auto_test_sw=1;
|
|
|
+ }else if (strstr(item_cmd->valuestring,"auto_focus")!=RT_NULL) {
|
|
|
+ device_status.autotakepic = 2;
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- HMI_WRITE("selfcheck.t4.bco=63488");
|
|
|
- device_status.C01 |= (1<<3);
|
|
|
+ //补光灯开灯和关灯
|
|
|
+ if(strstr(item_cmd->valuestring,"ledon")!=RT_NULL){
|
|
|
+ ctr_Cold(ON);
|
|
|
}
|
|
|
-
|
|
|
- device_status.led_sta = ledsta->valueint;
|
|
|
- LOG_I("补光灯报警状态:%d",device_status.led_sta);
|
|
|
- }
|
|
|
- if(photolink!=NULL){
|
|
|
- device_status.camsta = 0; //拍照正常
|
|
|
- device_status.ctr_up_motor = 0; //关闭
|
|
|
- device_status.ctr_down_motor = 0; //关闭
|
|
|
- rt_sprintf(device_status.photolink,"%s",photolink->valuestring);
|
|
|
- LOG_I("接收到图片地址:%s",device_status.photolink);
|
|
|
- //上报自检结果
|
|
|
- if(strlen(device_status.qianming)>=2){
|
|
|
- char *json_temp = makeJson_selfCheck_(1);
|
|
|
- DTU_Write("%s",json_temp);
|
|
|
- free(json_temp);
|
|
|
+ if(strstr(item_cmd->valuestring,"ledoff")!=RT_NULL){
|
|
|
+ ctr_Cold(OFF);
|
|
|
+ slidelock();
|
|
|
}
|
|
|
-
|
|
|
- }
|
|
|
- if(item_checkself!=NULL){//自检签名
|
|
|
- memset(device_status.qianming,0,sizeof(device_status.qianming));
|
|
|
- device_status.photo_ws = 1;
|
|
|
- LOG_I("自检签名:%s",item_checkself->valuestring);
|
|
|
- sprintf(device_status.qianming,"%s",item_checkself->valuestring);
|
|
|
- //生成自检应答json
|
|
|
- char *json_temp = makeJson_selfCheck_(0);
|
|
|
- DTU_Write("%s",json_temp);
|
|
|
- free(json_temp);
|
|
|
- ctr_lamp(ON, 1);
|
|
|
- ctr_Heat(OFF);
|
|
|
- //执行自检
|
|
|
- device_status.selfcheck_ws = 1;
|
|
|
- }
|
|
|
- //item_data = cJSON_GetObjectItem(root,"data");
|
|
|
- if(item_cmd!=RT_NULL)
|
|
|
- {
|
|
|
- if(strstr(item_cmd->valuestring,"takephoto")!=RT_NULL)
|
|
|
+ //采集风机开和关
|
|
|
+ if(strstr(item_cmd->valuestring,"windon")!=RT_NULL){
|
|
|
+ ctr_router(ON);
|
|
|
+ }
|
|
|
+ if(strstr(item_cmd->valuestring,"windoff")!=RT_NULL){
|
|
|
+ ctr_router(OFF);
|
|
|
+ }
|
|
|
+ //卷带电机执行旋转一次
|
|
|
+ if(strstr(item_cmd->valuestring,"translate")!=RT_NULL){
|
|
|
+ turnlimit();
|
|
|
+ }
|
|
|
+ //读取滑台控制指令
|
|
|
+ if (strstr(item_cmd->valuestring,"slide")!=RT_NULL)
|
|
|
{
|
|
|
- //HK_TakePhoto();
|
|
|
- device_status.photo_ws=1;
|
|
|
- char *photo = makeJson_Warn("takephoto","control");
|
|
|
- DTU_Write("%s",photo);
|
|
|
- rt_free(photo);
|
|
|
- rt_thread_delay(2000);
|
|
|
+ char dest[5]={0};
|
|
|
+ movx = cJSON_GetObjectItem(item_ext,"movx");
|
|
|
+ movy = cJSON_GetObjectItem(item_ext,"movy");
|
|
|
+ movz = cJSON_GetObjectItem(item_ext,"movz");
|
|
|
+ speed = cJSON_GetObjectItem(item_ext,"speed");
|
|
|
+
|
|
|
+ if(speed!=RT_NULL){
|
|
|
+ if(speed->type==cJSON_Number)
|
|
|
+ slide_para.pulse_period = 1;//speed->valueint;
|
|
|
+ LOG_D("设置滑台速度:%d",slide_para.pulse_period);
|
|
|
+ }
|
|
|
+ if(movx!=RT_NULL)
|
|
|
+ {
|
|
|
+ if(movx->type==cJSON_String)
|
|
|
+ {
|
|
|
+ LOG_D("MOVX:%d",strlen(movx->valuestring));
|
|
|
+ if(strlen(movx->valuestring)==1) { //如果字符串数值只有一位,则进行归零操作
|
|
|
+ slide_para.en_slide = 3;
|
|
|
+ }else{
|
|
|
+ if(strstr(movx->valuestring,"f")!=RT_NULL) slide_para.xdir = 0; //1位反向,0位正向;
|
|
|
+
|
|
|
+ if(strstr(movx->valuestring,"b")!=RT_NULL) slide_para.xdir = 1; //1位反向,0位正向;
|
|
|
+
|
|
|
+ strncpy(dest,movx->valuestring+1,strlen(movx->valuestring)-1);
|
|
|
+ slide_para.xdis = atoi(dest)/2;
|
|
|
+ rt_kprintf("步进x:%d\n",slide_para.xdis);
|
|
|
+ slide_para.en_slide = 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(movy!=RT_NULL)
|
|
|
+ {
|
|
|
+ if(movy->type==cJSON_String)
|
|
|
+ {
|
|
|
+ LOG_D("MOVY LEN:%d",strlen(movy->valuestring));
|
|
|
+ if(strlen(movy->valuestring)==1){
|
|
|
+ slide_para.en_slide = 7; //如果字符串数值只有一位,则进行归零操作
|
|
|
+ }else {
|
|
|
+ if(strstr(movy->valuestring,"f")!=RT_NULL) slide_para.ydir = 0; //1位反向,0位正向;
|
|
|
+ if(strstr(movy->valuestring,"b")!=RT_NULL) slide_para.ydir = 1; //1位反向,0位正向;
|
|
|
+
|
|
|
+ strncpy(dest,movy->valuestring+1,strlen(movy->valuestring)-1);
|
|
|
+ slide_para.ydis = atoi(dest)/2;
|
|
|
+ LOG_I("MOV Y STEP:%d",slide_para.ydis);
|
|
|
+ slide_para.en_slide = 6;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(movz!=RT_NULL)
|
|
|
+ {
|
|
|
+ if(movz->type==cJSON_String)
|
|
|
+ {
|
|
|
+ LOG_D("MOVZ:%d",sizeof(movz->valuestring));
|
|
|
+ if(strlen(movz->valuestring)==1) {
|
|
|
+ slide_para.en_slide = 4; //如果字符串数值只有一位,则进行归零操作
|
|
|
+ }else{
|
|
|
+ if(strstr(movz->valuestring,"f")!=RT_NULL) slide_para.zdir = 0; //1位反向,0位正向;
|
|
|
+ if(strstr(movz->valuestring,"b")!=RT_NULL) slide_para.zdir = 1; //1位反向,0位正向;
|
|
|
+ strncpy(dest,movz->valuestring+1,strlen(movz->valuestring)-1);
|
|
|
+ slide_para.zdis = atoi(dest)/2;
|
|
|
+ rt_kprintf("步进z:%d\n",slide_para.zdis);
|
|
|
+ slide_para.en_slide = 2;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
else if (strstr(item_cmd->valuestring,"json_w_clock")!=RT_NULL) {
|
|
|
rt_kprintf("查询时间配置!\n");
|
|
|
@@ -1194,26 +1036,6 @@ int parseDtu(char *json_string)
|
|
|
rt_free(photo);
|
|
|
rt_thread_delay(2000);
|
|
|
}
|
|
|
- //{"ext": {"type": "turn"}, "cmd": "ctrl"} 转仓
|
|
|
- else if(strstr(type->valuestring,"turn")!=RT_NULL)
|
|
|
- {
|
|
|
- #if Color_EN == 0
|
|
|
- char *turn_zp = makeJson_Warn("send cmd success:turn_zp","control");
|
|
|
- DTU_Write("%s",turn_zp);
|
|
|
- rt_free(turn_zp);
|
|
|
- ctr_turn(90, 0);
|
|
|
- #else
|
|
|
- DTU_Write("黄板复位:%d",ctr_Color_board(RESET, 800));
|
|
|
- #endif
|
|
|
- }
|
|
|
- //{"ext": {"type": "paichong"}, "cmd": "ctrl"} 排虫
|
|
|
- else if (strstr(type->valuestring,"paichong")!=RT_NULL) {
|
|
|
- char *turn_zp = makeJson_Warn("send cmd success:paichong","control");
|
|
|
- DTU_Write("%s",turn_zp);
|
|
|
- rt_free(turn_zp);
|
|
|
- if(device_status.vol==0)
|
|
|
- device_status.vol = 111;
|
|
|
- }
|
|
|
else if (strstr(type->valuestring,"led_on")!=RT_NULL)
|
|
|
{
|
|
|
ctr_led(ON);
|
|
|
@@ -1335,10 +1157,6 @@ int parseDtu(char *json_string)
|
|
|
ef_set_env_blob("ds",&device_status.ds,sizeof(device_status.ds)); //
|
|
|
UpLoad_Data();
|
|
|
}
|
|
|
-// else if (strstr(item_cmd->valuestring,"log")!=RT_NULL) {
|
|
|
-// rt_thread_mdelay(2000);
|
|
|
-// //read_all_flash_log();
|
|
|
-// }
|
|
|
//设置温湿度
|
|
|
else if (strstr(item_cmd->valuestring,"sensor")!=RT_NULL) {
|
|
|
//2022-04-12add:485传感器正常,不再解析服务器下发的温湿度数据
|
|
|
@@ -1390,16 +1208,6 @@ int parseDtu(char *json_string)
|
|
|
}
|
|
|
else if (strstr(item_cmd->valuestring,"synchronization")!=RT_NULL)
|
|
|
{
|
|
|
-// #if Color_EN == 0
|
|
|
-// if(device_status.dtype==7)
|
|
|
-// {
|
|
|
-// DTU_Write("%s","SwversionV7");
|
|
|
-// }
|
|
|
-// else if (device_status.dtype==3)
|
|
|
-// {
|
|
|
-// DTU_Write("%s","SwversionV4");
|
|
|
-// }
|
|
|
-// #endif
|
|
|
device_status.refresh_timeout=0;
|
|
|
//driver_4g = cJSON_GetObjectItem(item_ext,"version");
|
|
|
driver_4g = cJSON_GetObjectItem(item_ext,"dver");
|
|
|
@@ -1474,29 +1282,6 @@ int parseDtu(char *json_string)
|
|
|
LOG_E("set_date failed!");
|
|
|
}
|
|
|
}
|
|
|
-// static 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);
|
|
|
-// strncpy(month_s,datetime->valuestring+4,2);
|
|
|
-// strncpy(day_s,datetime->valuestring+6,2);
|
|
|
-// strncpy(hour_s,datetime->valuestring+8,2);
|
|
|
-// strncpy(min_s,datetime->valuestring+10,2);
|
|
|
-// strncpy(sec_s,datetime->valuestring+12,2);
|
|
|
-// if(atoi(year_s)>=2024&&atoi(year_s)<3000&&atoi(month_s)>0&&atoi(month_s)<13&&atoi(day_s)>0&&atoi(day_s)<32)
|
|
|
-// {
|
|
|
-// if(set_date(atoi(year_s),atoi(month_s),atoi(day_s))==RT_EOK)
|
|
|
-// {
|
|
|
-// LOG_I("设置日期:%d年%d月%d日",atoi(year_s),atoi(month_s),atoi(day_s));
|
|
|
-// 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)
|
|
|
-// {
|
|
|
-// LOG_I("设置时间:%d时%d分%d秒",atoi(hour_s),atoi(min_s),atoi(sec_s));
|
|
|
-// set_time(atoi(hour_s),atoi(min_s),atoi(sec_s));
|
|
|
-// }
|
|
|
-// }
|
|
|
-// else {
|
|
|
-// LOG_E("set_date failed!");
|
|
|
-// rt_hw_rtc_init();
|
|
|
-// }
|
|
|
-// }
|
|
|
}
|
|
|
|
|
|
LOG_I("参数同步:lat:%s lng:%s",lat->valuestring,lng->valuestring);
|
|
|
@@ -1621,7 +1406,7 @@ int parseDtu(char *json_string)
|
|
|
}
|
|
|
else if(device_status.num_updata!=0&&device_status.hmi_fresh==2)
|
|
|
{
|
|
|
- if(strstr(device_status.project,"A7_DTU_V3")!=RT_NULL)
|
|
|
+ if(strstr(device_status.project,"A7_DTU_V3")!=RT_NULL||strstr(device_status.project,"Android11")!=RT_NULL)
|
|
|
{
|
|
|
UpLoad_Data();
|
|
|
}
|
|
|
@@ -1933,61 +1718,6 @@ int parseDtu(char *json_string)
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- if(tt!=NULL)
|
|
|
- {
|
|
|
- if(tt->type==cJSON_Number)
|
|
|
- {
|
|
|
- if(tt->valueint>=1&&tt->valueint<=10)
|
|
|
- {
|
|
|
- #if LAMP_EN == 0
|
|
|
- device_status.sunBar = tt->valueint;
|
|
|
- ef_set_env_blob("sunBar", &device_status.sunBar, sizeof(device_status.sunBar)); //光控定时
|
|
|
- rt_kprintf("光控定时tt:%d\n",tt->valueint);
|
|
|
- #else
|
|
|
- if(tt->valueint==3||tt->valueint==6||tt->valueint==9)
|
|
|
- {
|
|
|
- device_status.sunBar = tt->valueint;
|
|
|
- ef_set_env_blob("sunBar", &device_status.sunBar, sizeof(device_status.sunBar)); //光控定时
|
|
|
- rt_kprintf("光控定时tt:%d\n",tt->valueint);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- device_status.sunBar = 3;
|
|
|
- rt_kprintf("三光源模式,禁止设置定时时长!!!\n");
|
|
|
- }
|
|
|
- #endif
|
|
|
- }
|
|
|
- else {
|
|
|
- rt_kprintf("光控定时tt设置失败参数错误!!!\n");
|
|
|
- }
|
|
|
- }
|
|
|
- else if (tt->type==cJSON_String) {
|
|
|
- if(atoi(tt->valuestring)>=1&&atoi(tt->valuestring)<=10)
|
|
|
- {
|
|
|
- #if LAMP_EN == 0
|
|
|
- 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
|
|
|
- if(atoi(tt->valuestring)%3==0)
|
|
|
- {
|
|
|
- device_status.sunBar = atoi(tt->valuestring);
|
|
|
- ef_set_env_blob("sunBar", &device_status.sunBar, sizeof(device_status.sunBar)); //光控定时
|
|
|
- LOG_I("光控定时tt:%d",atoi(tt->valuestring));
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- device_status.sunBar = 3;
|
|
|
- LOG_W("三光源模式,禁止设置定时时长!!!");
|
|
|
- }
|
|
|
- #endif
|
|
|
- }
|
|
|
- else {
|
|
|
- LOG_E("光控定时tt设置失败参数错误!!!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
if(htim!=NULL)
|
|
|
{
|
|
|
if(htim->type==cJSON_Number)
|