|
|
@@ -63,6 +63,29 @@ static uint8_t makejson_sta = 0;
|
|
|
|
|
|
extern eMBMasterReqErrCode _485_play(USHORT *Buffer,USHORT NREGS);
|
|
|
|
|
|
+// 昆虫名称查找表
|
|
|
+const char* insect_names[] = {
|
|
|
+ "玉米黏虫", // CORN_ARMYWORM 0
|
|
|
+ "草地贪夜蛾", // FALL_WARM 1
|
|
|
+ "棉铃虫", // COTTON_BOLLWORM 2
|
|
|
+ "玉米螟", // CORN_BORER 3
|
|
|
+ "桃蛀螟", // PEACH_BORER 4
|
|
|
+ "小地老虎", // BLACK_CUTWORM 5
|
|
|
+ "黄地老虎", // YELLOW_CUTWORM 6
|
|
|
+ "燕青地老虎", // CUTWORM 7
|
|
|
+ "点蜂缘蝽", // COREID_BUG 8
|
|
|
+ "豆荚螟", // POD_BORER 9
|
|
|
+ "大豆食心虫", // SOYBEAN_POD_BORER 10
|
|
|
+ "棉铃虫", // BOLLWORM 11
|
|
|
+ "斜纹夜蛾", // LEAFWORM 12
|
|
|
+ "甜菜夜蛾", // BEET_ARMYWORM 13
|
|
|
+ "二化螟", // RICE_STEM_BORER 14
|
|
|
+ "稻纵卷叶螟", // RICE_LEAF_ROLLER 15
|
|
|
+ "大螟", // PINK_RICE_BORER 16
|
|
|
+ "三化螟" // YELLOW_RICE_BORER 17
|
|
|
+};
|
|
|
+
|
|
|
+
|
|
|
static int DTU_uart2_init(void)
|
|
|
{
|
|
|
dtuserial = rt_device_find(DTU_UART_NAME);
|
|
|
@@ -246,15 +269,19 @@ static void dtu_thread_entry_send(void *parameter)
|
|
|
{
|
|
|
HMI_WRITE("sleep=%d",1);
|
|
|
}
|
|
|
-// if(device_status.sleep_mode == 1) {
|
|
|
-// LOG_I("启动联网模块剩余:%d -120",device_status.num_updata);
|
|
|
-// if(device_status.num_updata==120&&device_status.work_status==0)
|
|
|
-// {
|
|
|
-// device_status.dattim = 120; //省电,设置上传间隔为2H
|
|
|
-// ctr_router(ON);
|
|
|
-// ctr_RTU_DTU(ON);
|
|
|
-// }
|
|
|
-// }
|
|
|
+ if(device_status.sleep_mode == 1) {
|
|
|
+ LOG_I("启动联网模块剩余:%d -120",device_status.num_updata);
|
|
|
+ if(device_status.num_updata==120&&device_status.work_status==0)
|
|
|
+ {
|
|
|
+ device_status.dattim = 60; //省电,设置上传间隔为1H
|
|
|
+ ctr_RTU_12V(ON);
|
|
|
+ ctr_hmi_5v(ON);
|
|
|
+ }
|
|
|
+ if(device_status.num_updata==3420&&device_status.work_status==0){
|
|
|
+ ctr_RTU_12V(OFF);
|
|
|
+ ctr_hmi_5v(OFF);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
else {
|
|
|
char *readinfo = makeJson_ReadInfo();
|
|
|
@@ -268,12 +295,12 @@ static void dtu_thread_entry_send(void *parameter)
|
|
|
}
|
|
|
else {
|
|
|
wait_i ++;
|
|
|
-// if(device_status.sleep_mode == 1){
|
|
|
-// if(wait_i==3500){
|
|
|
-// ctr_router(ON);
|
|
|
-// ctr_RTU_DTU(ON);
|
|
|
-// }
|
|
|
-// }
|
|
|
+ if(device_status.sleep_mode == 1){
|
|
|
+ if(wait_i==3500){
|
|
|
+ ctr_RTU_12V(ON);
|
|
|
+ ctr_hmi_5v(ON);
|
|
|
+ }
|
|
|
+ }
|
|
|
LOG_I("wait connect internet......%d",wait_i);
|
|
|
}
|
|
|
rt_thread_mdelay(1000);
|
|
|
@@ -767,7 +794,8 @@ char * makeJson()
|
|
|
cJSON_AddStringToObject(pSubJson,"lat",device_status.lat);
|
|
|
//是否为上电开机
|
|
|
cJSON_AddNumberToObject(pSubJson,"rcnt",device_status.rebootcnt);
|
|
|
-
|
|
|
+ //诱芯名称/昆虫种类
|
|
|
+ cJSON_AddStringToObject(pSubJson,"lurecore",insect_names[device_status.InsectSpecies]);
|
|
|
//数据上传间隔
|
|
|
rt_sprintf(utos, "%d",device_status.dattim);
|
|
|
cJSON_AddStringToObject(pSubJson,"dat_f",utos);
|
|
|
@@ -1017,24 +1045,18 @@ int parseDtu(char *json_string)
|
|
|
{
|
|
|
ctr_hmi_5v(OFF);
|
|
|
}
|
|
|
- //{"ext": {"type": "sleep_mode"}, "cmd": "ctrl"}
|
|
|
+ //{"ext": {"type": "sleep_mode","value": 0}, "cmd": "ctrl"}
|
|
|
else if(strstr(type->valuestring,"sleep_mode")!=RT_NULL)
|
|
|
{
|
|
|
- device_status.sleep_mode = 1;
|
|
|
- ef_set_env_blob("sleep_mode", &device_status.sleep_mode, sizeof(device_status.sleep_mode)); //
|
|
|
- LOG_I("收到设置休眠指令:%d",device_status.sleep_mode);
|
|
|
- char *sleep = makeJson_Warn("set sleep mode enable","control");
|
|
|
- DTU_Write("%s",sleep);
|
|
|
- rt_free(sleep);
|
|
|
- }
|
|
|
- else if(strstr(type->valuestring,"sleep_off")!=RT_NULL)
|
|
|
- {
|
|
|
- device_status.sleep_mode = 0;
|
|
|
- ef_set_env_blob("sleep_mode", &device_status.sleep_mode, sizeof(device_status.sleep_mode)); //
|
|
|
- LOG_I("收到设置休眠指令:%d",device_status.sleep_mode);
|
|
|
- char *sleep = makeJson_Warn("set sleep mode disable","control");
|
|
|
- DTU_Write("%s",sleep);
|
|
|
- rt_free(sleep);
|
|
|
+ cJSON* value_commn = cJSON_GetObjectItem(item_ext,"value");
|
|
|
+ if(value_commn!=RT_NULL){
|
|
|
+ device_status.sleep_mode = value_commn->valueint;
|
|
|
+ ef_set_env_blob("sleep_mode", &device_status.sleep_mode, sizeof(device_status.sleep_mode)); //
|
|
|
+ LOG_I("收到设置休眠指令:%d",device_status.sleep_mode);
|
|
|
+ char *sleep = makeJson_Warn("set sleep mode enable","control");
|
|
|
+ DTU_Write("%s",sleep);
|
|
|
+ rt_free(sleep);
|
|
|
+ }
|
|
|
}
|
|
|
//{"ext": {"type": "clear"}, "cmd": "ctrl"}
|
|
|
else if(strstr(type->valuestring,"clear")!=RT_NULL)
|
|
|
@@ -1409,6 +1431,7 @@ int parseDtu(char *json_string)
|
|
|
cJSON *data_tim = cJSON_GetObjectItem(item_ext,"data_tim");
|
|
|
cJSON *power = cJSON_GetObjectItem(item_ext,"power");
|
|
|
cJSON *clt_tim = cJSON_GetObjectItem(item_ext,"clt_tim");
|
|
|
+ cJSON *lurecore = cJSON_GetObjectItem(item_ext,"lurecore");
|
|
|
|
|
|
if(device_status.dtype==3)
|
|
|
hst = cJSON_GetObjectItem(item_ext,"hst");
|
|
|
@@ -1440,6 +1463,15 @@ int parseDtu(char *json_string)
|
|
|
|
|
|
cJSON* cul_time = cJSON_GetObjectItem(item_ext,"cul_time"); //培养时间1~24
|
|
|
cJSON* drop_sec = cJSON_GetObjectItem(item_ext,"drop_time");
|
|
|
+
|
|
|
+ if(lurecore!=RT_NULL){
|
|
|
+ if(lurecore->type==cJSON_Number){
|
|
|
+ device_status.InsectSpecies = lurecore->valueint;
|
|
|
+ ef_set_env_blob("InsectSpecies", &device_status.InsectSpecies, sizeof(device_status.InsectSpecies)); //诱芯序号
|
|
|
+ LOG_I("下发设置诱芯序号:%d",device_status.InsectSpecies);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if(work_tim!=RT_NULL){
|
|
|
device_status.timeSwitch = 1;
|
|
|
st = cJSON_GetObjectItem(work_tim,"st");
|