|
@@ -57,68 +57,78 @@ void data_task(void *pdata)
|
|
|
get= get_gateway_config_params();
|
|
|
int deviceIndex=0;
|
|
|
DEVICE_PARAMS *current_device=get->device_params;
|
|
|
-
|
|
|
// Config_485_Port(get->baudrate, get->dataBits, get->stopBit, get->parity, get->flowControl);
|
|
|
-
|
|
|
while (current_device!=NULL)
|
|
|
{
|
|
|
uint8_t err;
|
|
|
- StringInfo *message=NULL; //���ն�����Ϣ�ṹ��
|
|
|
- message=(StringInfo *)OSQPend(JsonQ,1000,&err);
|
|
|
- if(commd)
|
|
|
- {
|
|
|
- READ_DATA(current_device, buf);
|
|
|
- if(current_device->nextDevice!=NULL)
|
|
|
- {
|
|
|
- current_device=current_device->nextDevice;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- sprintf(buf + strlen(buf) - 1, "}");
|
|
|
- time1 = OSTimeGet();
|
|
|
- if( jsoncunt || time2 <= time1 - 20000)
|
|
|
- {
|
|
|
- memset(pubJsonStringCopy,0, strlen(pubJsonStringCopy));
|
|
|
- memcpy(pubJsonStringCopy + strlen(pubJsonStringCopy), buf, strlen(buf));//������һ�ε�����
|
|
|
- sprintf(pubJsonString,"{\"DEVICEID\":\"%s\",\"data\":[%s]",get->deviceId, buf);
|
|
|
- int msg = MBOX_USER_PUBLISHQOS2;
|
|
|
- if(mqtt_connectFlag==1) OSMboxPost(mqtt_sendMseeageMbox, &msg);
|
|
|
- current_device=get->device_params;
|
|
|
- jsoncunt = 0;
|
|
|
- time2 = OSTimeGet();
|
|
|
- }//20s����һ��
|
|
|
-
|
|
|
- else
|
|
|
- {
|
|
|
- if(strcmp(buf,pubJsonStringCopy))
|
|
|
- {
|
|
|
- memset(string, 0 , strlen(string));
|
|
|
- findDifference(buf, pubJsonStringCopy, string);
|
|
|
- memset(pubJsonString,0, strlen(pubJsonString));
|
|
|
- sprintf(pubJsonString,"{\"deviceId\":\"%s\",\"data\":[{%s}]}",get->deviceId, string);
|
|
|
- memset(pubJsonStringCopy,0, strlen(pubJsonStringCopy));
|
|
|
- sprintf(pubJsonStringCopy, buf, strlen(buf));
|
|
|
-
|
|
|
- int msg = MBOX_USER_PUBLISHQOS2;
|
|
|
- if(mqtt_connectFlag==1) OSMboxPost(mqtt_sendMseeageMbox, &msg);
|
|
|
- }
|
|
|
- }
|
|
|
- memset(buf,0,strlen(buf));
|
|
|
- current_device=get->device_params;
|
|
|
- }
|
|
|
+ StringInfo *message=NULL;
|
|
|
+ message=OSQPend(JsonQ,1000,&err);
|
|
|
+ if(message==NULL)//没有消息
|
|
|
+ {
|
|
|
+ OSTimeDly(1000);
|
|
|
+ }
|
|
|
+ else //包含消息
|
|
|
+ {
|
|
|
+ myfree(SRAMIN ,message->p);//释放内部数据
|
|
|
+ myfree(SRAMIN,message);
|
|
|
+ OSTimeDly(1000);
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- if(message != NULL)
|
|
|
- {
|
|
|
- WRITE_MODBUS_DATA(message->p);
|
|
|
- }
|
|
|
- printf("sx1278_task_recv : %s",message->p);
|
|
|
- myfree(SRAMIN ,message->p);
|
|
|
|
|
|
- commd = 1;
|
|
|
- }
|
|
|
- OSTimeDly(1000);
|
|
|
+// uint8_t err;
|
|
|
+// StringInfo *message=NULL; //���ն�����Ϣ�ṹ��
|
|
|
+// message=OSQPend(JsonQ,1000,&err);
|
|
|
+// if(message==NULL)
|
|
|
+// {
|
|
|
+// READ_DATA(current_device, buf);
|
|
|
+// if(current_device->nextDevice!=NULL)
|
|
|
+// {
|
|
|
+// current_device=current_device->nextDevice;
|
|
|
+// }
|
|
|
+// else
|
|
|
+// {
|
|
|
+// sprintf(buf + strlen(buf) - 1, "}");
|
|
|
+// time1 = OSTimeGet();
|
|
|
+// if( jsoncunt || time2 <= time1 - 20000)
|
|
|
+// {
|
|
|
+// memset(pubJsonStringCopy,0, strlen(pubJsonStringCopy));
|
|
|
+// memcpy(pubJsonStringCopy + strlen(pubJsonStringCopy), buf, strlen(buf));//������һ�ε�����
|
|
|
+// sprintf(pubJsonString,"{\"DEVICEID\":\"%s\",\"data\":[%s]",get->deviceId, buf);
|
|
|
+// int msg = MBOX_USER_PUBLISHQOS2;
|
|
|
+// if(mqtt_connectFlag==1) OSMboxPost(mqtt_sendMseeageMbox, &msg);
|
|
|
+// current_device=get->device_params;
|
|
|
+// jsoncunt = 0;
|
|
|
+// time2 = OSTimeGet();
|
|
|
+// }//20s����һ��
|
|
|
+//
|
|
|
+// else
|
|
|
+// {
|
|
|
+// if(strcmp(buf,pubJsonStringCopy))
|
|
|
+// {
|
|
|
+// memset(string, 0 , strlen(string));
|
|
|
+// findDifference(buf, pubJsonStringCopy, string);
|
|
|
+// memset(pubJsonString,0, strlen(pubJsonString));
|
|
|
+// sprintf(pubJsonString,"{\"deviceId\":\"%s\",\"data\":[{%s}]}",get->deviceId, string);
|
|
|
+// memset(pubJsonStringCopy,0, strlen(pubJsonStringCopy));
|
|
|
+// sprintf(pubJsonStringCopy, buf, strlen(buf));
|
|
|
+//
|
|
|
+// int msg = MBOX_USER_PUBLISHQOS2;
|
|
|
+// if(mqtt_connectFlag==1) OSMboxPost(mqtt_sendMseeageMbox, &msg);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// memset(buf,0,strlen(buf));
|
|
|
+// current_device=get->device_params;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// else
|
|
|
+// {
|
|
|
+// WRITE_MODBUS_DATA(message->p);
|
|
|
+// printf("sx1278_task_recv : %s",message->p);
|
|
|
+// myfree(SRAMIN ,message->p);
|
|
|
+// myfree(SRAMIN,message);
|
|
|
+//
|
|
|
+// commd = 1;
|
|
|
+// }
|
|
|
+// OSTimeDly(1000);
|
|
|
}
|
|
|
}
|
|
|
|