|
|
@@ -28,7 +28,7 @@
|
|
|
#define DBG_ENABLE
|
|
|
#define DBG_COLOR
|
|
|
#define DBG_TAG "dtu"
|
|
|
-#define DBG_LEVEL DBG_LOG
|
|
|
+#define DBG_LEVEL DBG_LOG
|
|
|
#include <rtdbg.h> //must after of DBG_LVL, DBG_TAG or other options
|
|
|
|
|
|
|
|
|
@@ -128,7 +128,6 @@ static int DTU_uart2_init(void)
|
|
|
/*数据发送*/
|
|
|
void DTU_Write(char *fmt, ...)
|
|
|
{
|
|
|
- //static const char dtu_conf[4] = {device_status.vol,0x00,0x00,0x00};
|
|
|
va_list ap;
|
|
|
static char dtu_str[1024];
|
|
|
rt_size_t str_length;
|
|
|
@@ -139,15 +138,7 @@ void DTU_Write(char *fmt, ...)
|
|
|
if (str_length > 1024 - 1)
|
|
|
str_length = 1024 - 1;
|
|
|
rt_device_write(dtuserial, 0, dtu_str, str_length);
|
|
|
- rt_thread_mdelay(100);
|
|
|
-// if(strstr(dtu_str,"volume")!=RT_NULL)
|
|
|
-// {
|
|
|
-// rt_device_write(dtuserial,0,dtu_conf,4);
|
|
|
-// }
|
|
|
-// else if (strstr(dtu_str,"reset")!=RT_NULL) {
|
|
|
-// const char dtu_conf[4] = {7,0x00,0x00,0x00};
|
|
|
-// rt_device_write(dtuserial,0,dtu_conf,4);
|
|
|
-// }
|
|
|
+ LOG_D("DTU_Write:%s",dtu_str);
|
|
|
}
|
|
|
/* 接收数据回调函数 */
|
|
|
static rt_err_t dtu_input(rt_device_t dev, rt_size_t size)
|
|
|
@@ -451,7 +442,6 @@ static void dtu_thread_entry_send(void *parameter)
|
|
|
}
|
|
|
else {
|
|
|
char *readinfo = makeJson_ReadInfo();
|
|
|
- rt_kprintf("upload data:%s\n",readinfo);
|
|
|
DTU_Write("%s",readinfo);
|
|
|
rt_free(readinfo);
|
|
|
rt_thread_delay(1000);
|
|
|
@@ -1588,6 +1578,7 @@ int parseDtu(char *json_string)
|
|
|
else if (strstr(item_cmd->valuestring,"ctrl")!=RT_NULL)
|
|
|
{
|
|
|
type = cJSON_GetObjectItem(item_ext,"type");
|
|
|
+ cJSON *time_s = cJSON_GetObjectItem(item_ext,"time");
|
|
|
if(strstr(type->valuestring,"rtu_off_on")!=RT_NULL)
|
|
|
{
|
|
|
LOG_W("DTU 12V Power down");
|
|
|
@@ -1660,6 +1651,15 @@ int parseDtu(char *json_string)
|
|
|
{
|
|
|
ctr_led(OFF);
|
|
|
}
|
|
|
+ //{"ext": {"type": "route_off","time": 5}, "cmd": "ctrl"} //远程关闭路由器电源
|
|
|
+ else if (strstr(type->valuestring,"route_off")!=RT_NULL)
|
|
|
+ {
|
|
|
+ if(time_s!=RT_NULL)
|
|
|
+ {
|
|
|
+ device_status.route_off_t = time_s->valueint;
|
|
|
+ LOG_I("设置路由器断电时间:%d",device_status.route_off_t);
|
|
|
+ }
|
|
|
+ }
|
|
|
else if(strstr(type->valuestring,"selfcheck")!=RT_NULL)
|
|
|
{
|
|
|
if(device_status.selfcheck_ws == 2)
|
|
|
@@ -1674,16 +1674,6 @@ int parseDtu(char *json_string)
|
|
|
}
|
|
|
LOG_I("收到自检指令:%d",device_status.selfcheck_ws);
|
|
|
}
|
|
|
- else if(strstr(type->valuestring,"insect_kill")!=RT_NULL)
|
|
|
- {
|
|
|
- device_status.autotakepic = 10;
|
|
|
- LOG_W("收到害虫信号!");
|
|
|
- }
|
|
|
- else if(strstr(type->valuestring,"insect_save")!=RT_NULL)
|
|
|
- {
|
|
|
- device_status.autotakepic = 11;
|
|
|
- LOG_W("收到益虫信号!");
|
|
|
- }
|
|
|
}
|
|
|
//切换平台
|
|
|
else if (strstr(item_cmd->valuestring,"platform")!=RT_NULL)
|
|
|
@@ -1967,29 +1957,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);
|
|
|
@@ -2674,11 +2641,8 @@ int parseDtu(char *json_string)
|
|
|
void UpLoad_Data(void)
|
|
|
{
|
|
|
char *updata = makeJson();
|
|
|
- LOG_I("upload data:%d %s",rt_strlen(updata),updata);
|
|
|
+ DTU_Write(updata);
|
|
|
rt_free(updata);
|
|
|
- #if Color_EN ==0
|
|
|
- DTU_Write("%s",updata);
|
|
|
- #endif
|
|
|
//list_mem();
|
|
|
//播放数据上传中语音
|
|
|
}
|