|
@@ -12,7 +12,7 @@
|
|
|
#include <board.h>
|
|
#include <board.h>
|
|
|
#include <rtdevice.h>
|
|
#include <rtdevice.h>
|
|
|
#include "stdarg.h"
|
|
#include "stdarg.h"
|
|
|
-#include "string.h"
|
|
|
|
|
|
|
+#include "string.h"version_type
|
|
|
#include "stdio.h"
|
|
#include "stdio.h"
|
|
|
#include "dtu_uart2.h"
|
|
#include "dtu_uart2.h"
|
|
|
#include <cJSON.h>
|
|
#include <cJSON.h>
|
|
@@ -22,6 +22,7 @@
|
|
|
#include "sound.h"
|
|
#include "sound.h"
|
|
|
#include <ymodem.h>
|
|
#include <ymodem.h>
|
|
|
#include "beep.h"
|
|
#include "beep.h"
|
|
|
|
|
+#include "selfcheck.h"
|
|
|
#define DBG_ENABLE
|
|
#define DBG_ENABLE
|
|
|
#define DBG_COLOR
|
|
#define DBG_COLOR
|
|
|
#define DBG_TAG "dtu"
|
|
#define DBG_TAG "dtu"
|
|
@@ -537,6 +538,37 @@ char *makeJson_selfCheck_(uint8_t sta) //sta==0 应答,sta==1结果
|
|
|
return t;
|
|
return t;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+char *makeJson_C01_Warn(uint16_t code,double process)
|
|
|
|
|
+{
|
|
|
|
|
+ cJSON * pJsonRoot = NULL;
|
|
|
|
|
+ pJsonRoot = cJSON_CreateObject();
|
|
|
|
|
+ if(NULL==pJsonRoot)
|
|
|
|
|
+ {
|
|
|
|
|
+ LOG_E("cJSON pJsonRoot NULL!!!");
|
|
|
|
|
+ return NULL;
|
|
|
|
|
+ }
|
|
|
|
|
+ cJSON_AddStringToObject(pJsonRoot, "cmd", "selfcheck");
|
|
|
|
|
+ cJSON * pubstring = NULL;
|
|
|
|
|
+ pubstring = cJSON_CreateObject();
|
|
|
|
|
+ if(NULL==pubstring)
|
|
|
|
|
+ {
|
|
|
|
|
+ rt_kprintf("cJSON pubstring NULL!!!\n");
|
|
|
|
|
+ return NULL;
|
|
|
|
|
+ }
|
|
|
|
|
+ cJSON_AddItemToObject(pJsonRoot, "ext", pubstring);
|
|
|
|
|
+ cJSON_AddNumberToObject(pubstring, "C01", code);//
|
|
|
|
|
+ cJSON_AddNumberToObject(pubstring, "process", process);//
|
|
|
|
|
+ char * w = cJSON_PrintUnformatted(pJsonRoot);
|
|
|
|
|
+ if(NULL == w)
|
|
|
|
|
+ {
|
|
|
|
|
+ cJSON_Delete(pJsonRoot);
|
|
|
|
|
+ LOG_E("wJsonRoot cJSON_Delete NULL!!!\n");
|
|
|
|
|
+ return NULL;
|
|
|
|
|
+ }
|
|
|
|
|
+ cJSON_Delete(pJsonRoot);
|
|
|
|
|
+ return w;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
|
|
|
char * makeJson_Rtutakephoto()
|
|
char * makeJson_Rtutakephoto()
|
|
|
{
|
|
{
|
|
@@ -689,6 +721,11 @@ char * makeJson()
|
|
|
else if (device_status.version_type==11) {
|
|
else if (device_status.version_type==11) {
|
|
|
rt_sprintf(device_status.driver,"%s-%s",VERSION_GK,device_status.driver_4g);
|
|
rt_sprintf(device_status.driver,"%s-%s",VERSION_GK,device_status.driver_4g);
|
|
|
}
|
|
}
|
|
|
|
|
+ else if (device_status.version_type==12) {
|
|
|
|
|
+ rt_sprintf(device_status.driver,"%s-%s",VERSION_GK,device_status.driver_4g);
|
|
|
|
|
+ cJSON_AddStringToObject(pSubJson,"lux",device_status.lux);
|
|
|
|
|
+ cJSON_AddStringToObject(pSubJson,"ap",device_status.ap);
|
|
|
|
|
+ }
|
|
|
else if (device_status.version_type==5) {
|
|
else if (device_status.version_type==5) {
|
|
|
rt_sprintf(device_status.driver,"%s-%s",VERSION_V5,device_status.driver_4g);
|
|
rt_sprintf(device_status.driver,"%s-%s",VERSION_V5,device_status.driver_4g);
|
|
|
}
|
|
}
|
|
@@ -698,6 +735,9 @@ char * makeJson()
|
|
|
else if (device_status.version_type==7) {
|
|
else if (device_status.version_type==7) {
|
|
|
rt_sprintf(device_status.driver,"%s-%s",VERSION_BZY,device_status.driver_4g);
|
|
rt_sprintf(device_status.driver,"%s-%s",VERSION_BZY,device_status.driver_4g);
|
|
|
}
|
|
}
|
|
|
|
|
+ else if (device_status.version_type==42) {
|
|
|
|
|
+ rt_sprintf(device_status.driver,"%s-%s",VERSION_HK_2000W,device_status.driver_4g);
|
|
|
|
|
+ }
|
|
|
if(device_status.sensor_485_sta!=0)
|
|
if(device_status.sensor_485_sta!=0)
|
|
|
{
|
|
{
|
|
|
if(strstr(device_status.driver,"485")==RT_NULL)
|
|
if(strstr(device_status.driver,"485")==RT_NULL)
|
|
@@ -722,6 +762,7 @@ char * makeJson()
|
|
|
else if (device_status.version_type==11) { //高空
|
|
else if (device_status.version_type==11) { //高空
|
|
|
rt_sprintf(utos,"11");
|
|
rt_sprintf(utos,"11");
|
|
|
cJSON_AddStringToObject(pSubJson,"vtype",utos);
|
|
cJSON_AddStringToObject(pSubJson,"vtype",utos);
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
else if (device_status.version_type==5) { //5.0
|
|
else if (device_status.version_type==5) { //5.0
|
|
|
rt_sprintf(utos,"5");
|
|
rt_sprintf(utos,"5");
|
|
@@ -731,6 +772,10 @@ char * makeJson()
|
|
|
rt_sprintf(utos,"6");
|
|
rt_sprintf(utos,"6");
|
|
|
cJSON_AddStringToObject(pSubJson,"vtype",utos);
|
|
cJSON_AddStringToObject(pSubJson,"vtype",utos);
|
|
|
}
|
|
}
|
|
|
|
|
+ else if (device_status.version_type==42) { //测报灯低端款
|
|
|
|
|
+ rt_sprintf(utos,"42");
|
|
|
|
|
+ cJSON_AddStringToObject(pSubJson,"vtype",utos);
|
|
|
|
|
+ }
|
|
|
if(device_status.version_type!=6&&device_status.dtype!=7)
|
|
if(device_status.version_type!=6&&device_status.dtype!=7)
|
|
|
{
|
|
{
|
|
|
//光控定时
|
|
//光控定时
|
|
@@ -1019,7 +1064,6 @@ int parseDtu(char *json_string)
|
|
|
if(cam_cmd!=NULL){
|
|
if(cam_cmd!=NULL){
|
|
|
//先检查定时器状态,否则会崩溃
|
|
//先检查定时器状态,否则会崩溃
|
|
|
rt_timer_stop(timer_uart2);
|
|
rt_timer_stop(timer_uart2);
|
|
|
-
|
|
|
|
|
LOG_I("cam_code");
|
|
LOG_I("cam_code");
|
|
|
if(cam_cmd->valueint==0){
|
|
if(cam_cmd->valueint==0){
|
|
|
ctr_led(ON);
|
|
ctr_led(ON);
|
|
@@ -1033,11 +1077,23 @@ int parseDtu(char *json_string)
|
|
|
|
|
|
|
|
if(ledsta!=NULL)
|
|
if(ledsta!=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);
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ HMI_WRITE("selfcheck.t4.bco=63488");
|
|
|
|
|
+ device_status.C01 |= (1<<3);
|
|
|
|
|
+ }
|
|
|
device_status.led_sta = ledsta->valueint;
|
|
device_status.led_sta = ledsta->valueint;
|
|
|
LOG_I("补光灯报警状态:%d",device_status.led_sta);
|
|
LOG_I("补光灯报警状态:%d",device_status.led_sta);
|
|
|
}
|
|
}
|
|
|
if(photolink!=NULL){
|
|
if(photolink!=NULL){
|
|
|
- device_status.selfcheck_ws = 0;
|
|
|
|
|
device_status.camsta = 0; //拍照正常
|
|
device_status.camsta = 0; //拍照正常
|
|
|
device_status.ctr_up_motor = 0; //关闭
|
|
device_status.ctr_up_motor = 0; //关闭
|
|
|
device_status.ctr_down_motor = 0; //关闭
|
|
device_status.ctr_down_motor = 0; //关闭
|
|
@@ -1155,15 +1211,119 @@ int parseDtu(char *json_string)
|
|
|
if(device_status.vol==0)
|
|
if(device_status.vol==0)
|
|
|
device_status.vol = 111;
|
|
device_status.vol = 111;
|
|
|
}
|
|
}
|
|
|
- else if (strstr(type->valuestring,"led_on")!=RT_NULL)
|
|
|
|
|
|
|
+ else if (strstr(type->valuestring,"led_on")!=RT_NULL) //打开补光灯
|
|
|
{
|
|
{
|
|
|
|
|
+ LOG_I("远程打开补光灯!");
|
|
|
ctr_led(ON);
|
|
ctr_led(ON);
|
|
|
|
|
+ char *ctr_c = makeJson_Warn("打开补光灯","control");
|
|
|
|
|
+ DTU_Write("%s",ctr_c);
|
|
|
|
|
+ rt_free(ctr_c);
|
|
|
|
|
+ rt_thread_delay(2000);
|
|
|
}
|
|
}
|
|
|
else if (strstr(type->valuestring,"led_off")!=RT_NULL)
|
|
else if (strstr(type->valuestring,"led_off")!=RT_NULL)
|
|
|
{
|
|
{
|
|
|
|
|
+ LOG_I("远程关闭补光灯!");
|
|
|
ctr_led(OFF);
|
|
ctr_led(OFF);
|
|
|
device_status.photo_ws = 0;
|
|
device_status.photo_ws = 0;
|
|
|
}
|
|
}
|
|
|
|
|
+ else if (strstr(type->valuestring,"lamp_on")!=RT_NULL)
|
|
|
|
|
+ {
|
|
|
|
|
+ LOG_I("远程打开镇流器!");
|
|
|
|
|
+ ctr_lamp(ON,1);
|
|
|
|
|
+ char *ctr_c = makeJson_Warn("打开镇流器","control");
|
|
|
|
|
+ DTU_Write("%s",ctr_c);
|
|
|
|
|
+ rt_free(ctr_c);
|
|
|
|
|
+ rt_thread_delay(2000);
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (strstr(type->valuestring,"lamp_off")!=RT_NULL)
|
|
|
|
|
+ {
|
|
|
|
|
+ LOG_I("远程关闭镇流器!");
|
|
|
|
|
+ ctr_lamp(OFF,1);
|
|
|
|
|
+ char *ctr_c = makeJson_Warn("关闭镇流器","control");
|
|
|
|
|
+ DTU_Write("%s",ctr_c);
|
|
|
|
|
+ rt_free(ctr_c);
|
|
|
|
|
+ rt_thread_delay(2000);
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (strstr(type->valuestring,"up_m_open")!=RT_NULL)
|
|
|
|
|
+ {
|
|
|
|
|
+ LOG_I("远程打开上仓门!");
|
|
|
|
|
+ device_status.ctr_up_motor = 1;
|
|
|
|
|
+ char *ctr_c = makeJson_Warn("打开上仓门","control");
|
|
|
|
|
+ DTU_Write("%s",ctr_c);
|
|
|
|
|
+ rt_free(ctr_c);
|
|
|
|
|
+ rt_thread_delay(2000);
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (strstr(type->valuestring,"up_m_close")!=RT_NULL)
|
|
|
|
|
+ {
|
|
|
|
|
+ LOG_I("远程关闭上仓门!");
|
|
|
|
|
+ device_status.ctr_up_motor = 2;
|
|
|
|
|
+ char *ctr_c = makeJson_Warn("关闭上仓门","control");
|
|
|
|
|
+ DTU_Write("%s",ctr_c);
|
|
|
|
|
+ rt_free(ctr_c);
|
|
|
|
|
+ rt_thread_delay(2000);
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (strstr(type->valuestring,"down_m_open")!=RT_NULL)
|
|
|
|
|
+ {
|
|
|
|
|
+ LOG_I("远程打开下仓门!");
|
|
|
|
|
+ device_status.ctr_down_motor = 1;
|
|
|
|
|
+ char *ctr_c = makeJson_Warn("打开下仓门","control");
|
|
|
|
|
+ DTU_Write("%s",ctr_c);
|
|
|
|
|
+ rt_free(ctr_c);
|
|
|
|
|
+ rt_thread_delay(2000);
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (strstr(type->valuestring,"down_m_close")!=RT_NULL)
|
|
|
|
|
+ {
|
|
|
|
|
+ LOG_I("远程关闭下仓门!");
|
|
|
|
|
+ device_status.ctr_down_motor = 2;
|
|
|
|
|
+ char *ctr_c = makeJson_Warn("关闭下仓门","control");
|
|
|
|
|
+ DTU_Write("%s",ctr_c);
|
|
|
|
|
+ rt_free(ctr_c);
|
|
|
|
|
+ rt_thread_delay(2000);
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (strstr(type->valuestring,"heat_on")!=RT_NULL)
|
|
|
|
|
+ {
|
|
|
|
|
+ LOG_I("远程打开加热!");
|
|
|
|
|
+ ctr_Heat(ON);
|
|
|
|
|
+ char *ctr_c = makeJson_Warn("打开加热","control");
|
|
|
|
|
+ DTU_Write("%s",ctr_c);
|
|
|
|
|
+ rt_free(ctr_c);
|
|
|
|
|
+ rt_thread_delay(2000);
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (strstr(type->valuestring,"heat_off")!=RT_NULL)
|
|
|
|
|
+ {
|
|
|
|
|
+ LOG_I("远程关闭加热!");
|
|
|
|
|
+ ctr_Heat(ON);
|
|
|
|
|
+ char *ctr_c = makeJson_Warn("关闭加热","control");
|
|
|
|
|
+ DTU_Write("%s",ctr_c);
|
|
|
|
|
+ rt_free(ctr_c);
|
|
|
|
|
+ rt_thread_delay(2000);
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (strstr(type->valuestring,"clear_on")!=RT_NULL)
|
|
|
|
|
+ {
|
|
|
|
|
+ LOG_I("远程打开清扫!");
|
|
|
|
|
+ device_status.clear_status = 1;
|
|
|
|
|
+ char *ctr_c = makeJson_Warn("打开清扫","control");
|
|
|
|
|
+ DTU_Write("%s",ctr_c);
|
|
|
|
|
+ rt_free(ctr_c);
|
|
|
|
|
+ rt_thread_delay(2000);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ else if(strstr(type->valuestring,"selfcheck")!=RT_NULL)
|
|
|
|
|
+ {
|
|
|
|
|
+ if(device_status.selfcheck_ws == 2)
|
|
|
|
|
+ {
|
|
|
|
|
+ char *js = makeJson_C01_Warn(device_status.C01,device_status.process);
|
|
|
|
|
+ DTU_Write("%s",js);
|
|
|
|
|
+ free(js);
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ device_status.selfcheck_ws = 2;
|
|
|
|
|
+ }
|
|
|
|
|
+ LOG_I("收到自检指令:%d",device_status.selfcheck_ws);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
//切换平台
|
|
//切换平台
|
|
|
else if (strstr(item_cmd->valuestring,"platform")!=RT_NULL)
|
|
else if (strstr(item_cmd->valuestring,"platform")!=RT_NULL)
|