task.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. #include "task.h"
  2. #include "cjson.h"
  3. #include "myFile.h"
  4. #include "gateway_message.h"
  5. #include "log.h"
  6. #include "malloc.h"
  7. #include "sx1276.h"
  8. #include "dlt645.h"
  9. #include "usart.h"
  10. #include "node_data_acquisition.h"
  11. #include "sys_mqtt.h"
  12. #include "sys_http.h"
  13. #include "node_message.h"
  14. #include "usart.h"
  15. #include "mmodbus.h"
  16. #include "sys_mqtt.h"
  17. #include "gateway_message.h"
  18. #include "MQTTClient.h"
  19. #include "cJSON.h"
  20. #include "time_count.h"
  21. #include "dlt645_1997_private.h"
  22. char string[512];
  23. uint8_t read_cnt = 0;
  24. uint8_t count = 0;
  25. uint8_t jsonCunt = 1;
  26. /*
  27. *********************************************************************************************************
  28. * 函 数 �: void data_task(void *pdata)
  29. * 功能说明: 主�是data_task处�线程,优先级高。其�行逻辑是将nandflash中的数�解�出�轮询��数�
  30. * 形 �:无
  31. * 返 回 值: 无
  32. *********************************************************************************************************
  33. */
  34. void data_task(void *pdata)
  35. {
  36. <<<<<<< HEAD
  37. OS_CPU_SR cpu_sr;
  38. pdata = pdata;
  39. uint16_t data;
  40. mmodbus_readHoldingRegister16i(0x01,0x00,&data);
  41. Radio = RadioDriverInit();
  42. Radio->Init();
  43. #if 0
  44. char *lora_config_json = mymalloc(SRAMEX, 9 * 1024);
  45. read_file("lora_json.txt", lora_config_json);
  46. addGatewayParams(lora_config_json);
  47. myfree(SRAMEX, lora_config_json);
  48. GATEWAY_PARAMS *get;
  49. get= get_gateway_config_params();
  50. int nodeIndex=0;
  51. NODE_PARAMS *current_node=get->node_params;
  52. uint8_t string[256];
  53. uint16_t bufferLength;
  54. OS_Q_DATA Qnum;
  55. StringInfo message;
  56. char *mqttRecv;
  57. uint8_t err;
  58. while (current_node!=NULL)
  59. {
  60. while(!masterSendNodeString(nodeIndex,string,&bufferLength)) //ÂÖѯ¶Á³ö
  61. {
  62. master_task(string,bufferLength);
  63. }
  64. OSQQuery(JsonQ,&Qnum);
  65. //Èç¹û¶ÓÁÐΪ¿Õ
  66. if(Qnum.OSNMsgs!=0)
  67. {
  68. mqttRecv=malloc(250);
  69. message=*(StringInfo *)OSQPend(JsonQ,0, &err);
  70. while(Qnum.OSNMsgs!=0)
  71. =======
  72. OS_CPU_SR cpu_sr;
  73. pdata = pdata;
  74. dlt645_init(100);
  75. mmodbus_init(1);
  76. char *device_config_json = mymalloc(SRAMEX, 9 * 1024);
  77. read_file("device.txt", device_config_json);
  78. addGatewayParams(device_config_json);
  79. myfree(SRAMEX, device_config_json);
  80. GATEWAY_PARAMS *get;
  81. get= get_gateway_config_params();
  82. DEVICE_PARAMS *current_device=get->device_params;
  83. // Config_485_Port(get->baudrate, get->dataBits, get->stopBit, get->parity, get->flowControl);
  84. <<<<<<< HEAD
  85. char *buf = mymalloc(SRAMEX, 9 * 1024); // ½ÓÊÕ¶ÁÈ¡µÄÊý¾Ý
  86. memset(buf, 0, 9 * 1024);
  87. while (current_device!=NULL)
  88. {
  89. time1 = GetCurrentTime();
  90. if(mqtt_connectFlag)
  91. >>>>>>> d2b00294f64b161364915ae9082f104a2f26e39c
  92. {
  93. if(jsonCunt || time2 <= time1 - (10 * 1000))// 10s½øÐÐÒ»´ÎÈ«Êý¾Ý·¢ËÍ
  94. {
  95. read_device_data1(current_device, buf);
  96. send_mqtt(buf);
  97. jsonCunt = 0;
  98. memset(buf,0,strlen(buf));
  99. current_device=get->device_params;
  100. time2 = GetCurrentTime();
  101. // LogPrint(LOG_INFO,__FILE__, __FUNCTION__, __LINE__, "data for all");
  102. }
  103. else
  104. {
  105. read_device_data2(current_device, buf);
  106. if(count > 0)// count¼ì²âbufÄÚÊÇ·ñº¬ÓÐÊý¾Ý
  107. {
  108. send_mqtt(buf);
  109. memset(buf,0,strlen(buf));
  110. current_device=get->device_params;
  111. count = 0;
  112. // LogPrint(LOG_INFO,__FILE__, __FUNCTION__, __LINE__, "different data");
  113. }
  114. }
  115. }
  116. OSTimeDly(100);
  117. =======
  118. char *buf = mymalloc(SRAMEX, 9 * 1024); // 接收读�的数�
  119. memset(buf, 0, 9 * 1024);
  120. while (current_device!=NULL)
  121. {
  122. read_device_data(current_device, buf); //读�数�
  123. send_mqtt(buf, jsonCunt); //��数�
  124. jsonCunt = 0;
  125. memset(buf,0,strlen(buf));
  126. current_device=get->device_params;
  127. OSTimeDly(1);
  128. >>>>>>> d12097fdeb13131a2d24b22a2181d1fbd191264d
  129. }
  130. myfree(SRAMEX, buf);
  131. }
  132. /*
  133. *********************************************************************************************************
  134. * 函 数 �: void mqtt_to_device()
  135. * 功能说明: 将接收到的数���至设备
  136. * 形 �:
  137. * 返 回 值:
  138. *********************************************************************************************************
  139. */
  140. void mqtt_to_device(){
  141. uint8_t err;
  142. StringInfo *message;
  143. message = (StringInfo*)OSMboxPend(mqtt_recvMseeageMbox, 1000, &err);
  144. if(message != NULL) //包�消�
  145. {
  146. write_modbus_data(message->p); //写入数�
  147. myfree(SRAMEX ,message->p);//释放内部数�
  148. //OSTimeDly(1000);
  149. }
  150. }
  151. void find_diff(char* buf, char* string) {
  152. }
  153. /*
  154. *********************************************************************************************************
  155. * 函 数 �: int READ_MODBUS_DATA(DEVICE_PARAMS *device)
  156. * 功能说明: 读�当�节点上的modbus数�
  157. * 形 �: DEVICE_PARAMS *device 当�设备
  158. * 返 回 值: 1: �功 0:失败
  159. *********************************************************************************************************
  160. */
  161. int read_device_data1(DEVICE_PARAMS *device, char* buf)
  162. {
  163. DEVICE_PARAMS *current_device=device;
  164. GATEWAY_READ_MODBUS_COMMAND *currentModbusParams = current_device->params->gateway_read_modbus_command;
  165. GATEWAY_READ_DLT645_COMMAND *currentDLT645Params = current_device->params->gateway_read_dlt645_command;
  166. while(current_device->params != NULL)
  167. {
  168. if (current_device->protocol == MODBUS_READ)
  169. {
  170. protocol_485=1;
  171. uint16_t data[currentModbusParams->registerByteNum /2]; // modbus寄存器长度
  172. mmodbus_set16bitOrder(current_device->MDBbigLittleFormat);
  173. if (currentModbusParams->functionCode == 0x03 | currentModbusParams->functionCode == 0x01)
  174. {
  175. bool success = mmodbus_readHoldingRegisters16i(currentModbusParams->slaveAddress,
  176. currentModbusParams->registerAddress,
  177. currentModbusParams->registerByteNum /2,
  178. data);
  179. if (success)
  180. {
  181. uint32_t value;
  182. if (currentModbusParams->registerByteNum == 4)
  183. {
  184. value = (uint32_t)data[0] | data[1];
  185. }
  186. else if (currentModbusParams->registerByteNum == 2)
  187. {
  188. value = data[0];
  189. }
  190. if (currentModbusParams->decimalPoint == 0)
  191. {
  192. currentModbusParams->value = value;
  193. }
  194. else
  195. {
  196. float convertedValue = (float)value / pow(10, currentModbusParams->decimalPoint);
  197. currentModbusParams->value=convertedValue;
  198. }
  199. sprintf(buf + strlen(buf), "{\"deviceId\":\"%s\",\"%s\":%d},",
  200. current_device->deviceID, currentModbusParams->keyword, value);
  201. }
  202. // else
  203. // {
  204. // printf("read modbus register fail\n");
  205. // return 0;
  206. // }
  207. /* �读完一个寄存器,进行message判断 */
  208. mqtt_to_device();
  209. currentModbusParams = currentModbusParams->nextParams;
  210. if (currentModbusParams == NULL)
  211. {
  212. current_device = current_device->nextDevice;
  213. currentModbusParams = current_device->params->gateway_read_modbus_command;
  214. if(current_device == NULL)
  215. {
  216. sprintf(buf + strlen(buf) - 1, "");
  217. return 1;
  218. }
  219. }
  220. }
  221. }
  222. else if (current_device->protocol == DLT645_2007 || current_device->protocol == DLT645_97)
  223. {
  224. protocol_485=2;
  225. uint8_t read_buf[10];
  226. uint32_t dltValue;
  227. currentDLT645Params->rxLen = 0;
  228. memset(read_buf, 0, 10);
  229. memset(currentDLT645Params->data, 0, 10);
  230. dlt645_set_addr(&dlt645, currentDLT645Params->deviceID645);
  231. int8_t rs;
  232. if (current_device->protocol == DLT645_2007)
  233. {
  234. rs = dlt645_read_data(&dlt645, currentDLT645Params->Identification, read_buf, DLT645_2007);
  235. }
  236. else if (current_device->protocol == DLT645_1997)
  237. {
  238. rs = dlt645_read_data(&dlt645, currentDLT645Params->Identification, read_buf, DLT645_1997);
  239. }
  240. if (rs != -1)
  241. {
  242. if (rs <= 4)
  243. {
  244. memcpy(currentDLT645Params->data, read_buf, 4);
  245. currentDLT645Params->rxLen = 4;
  246. }
  247. else if (rs == 5)
  248. {
  249. memcpy(currentDLT645Params->data, read_buf, 5);
  250. currentDLT645Params->rxLen = 5;
  251. }
  252. else if (rs > 5)
  253. {
  254. memcpy(currentDLT645Params->data, read_buf, 9);
  255. currentDLT645Params->rxLen = 9;
  256. }
  257. dltValue = currentDLT645Params->data[0] << 24 | currentDLT645Params->data[1] << 16|
  258. currentDLT645Params->data[2] << 8 | currentDLT645Params->data[3];
  259. sprintf(buf + strlen(buf), "{\"identifier\":\"%s\",\"deviceID645\":\"%02x%02x%02x%02x%02x%02x\",\"identifier645\":%d,\"value\":%X}",
  260. currentDLT645Params->keyword, currentDLT645Params->deviceID645[0],
  261. currentDLT645Params->deviceID645[1],currentDLT645Params->deviceID645[2],
  262. currentDLT645Params->deviceID645[3],currentDLT645Params->deviceID645[4],
  263. currentDLT645Params->deviceID645[5],currentDLT645Params->Identification,dltValue);
  264. }
  265. // else
  266. // {
  267. // currentDLT645Params->rxLen = 0;
  268. // printf("read DLT current data fail\n");
  269. <<<<<<< HEAD
  270. // }
  271. =======
  272. // }
  273. /* �读完一个寄存器,进行message判断 */
  274. mqtt_to_device();
  275. >>>>>>> d12097fdeb13131a2d24b22a2181d1fbd191264d
  276. currentDLT645Params = currentDLT645Params->nextParams;
  277. if (currentDLT645Params == NULL)
  278. {
  279. current_device = current_device->nextDevice;
  280. currentDLT645Params = current_device->params->gateway_read_dlt645_command;
  281. if(current_device == NULL)
  282. {
  283. sprintf(buf + strlen(buf) - 1, "");
  284. return 1;
  285. }
  286. }
  287. }
  288. }
  289. return 1;
  290. }
  291. int read_device_data2(DEVICE_PARAMS *device, char* buf)
  292. {
  293. DEVICE_PARAMS *current_device=device;
  294. GATEWAY_READ_MODBUS_COMMAND *currentModbusParams = current_device->params->gateway_read_modbus_command;
  295. GATEWAY_READ_DLT645_COMMAND *currentDLT645Params = current_device->params->gateway_read_dlt645_command;
  296. while(current_device->params != NULL)
  297. {
  298. if (current_device->protocol == MODBUS_READ)
  299. {
  300. protocol_485=1;
  301. uint16_t data[currentModbusParams->registerByteNum /2]; // modbus¼Ä´æÆ÷³¤¶È
  302. mmodbus_set16bitOrder(current_device->MDBbigLittleFormat);
  303. if (currentModbusParams->functionCode == 0x03 | currentModbusParams->functionCode == 0x01)
  304. {
  305. bool success = mmodbus_readHoldingRegisters16i(currentModbusParams->slaveAddress,
  306. currentModbusParams->registerAddress,
  307. currentModbusParams->registerByteNum /2,
  308. data);
  309. if (success)
  310. {
  311. uint32_t value;
  312. if (currentModbusParams->registerByteNum == 4)
  313. {
  314. value = (uint32_t)data[0] | data[1];
  315. }
  316. else if (currentModbusParams->registerByteNum == 2)
  317. {
  318. value = data[0];
  319. }
  320. if((value - currentModbusParams->value) != 0)
  321. {
  322. sprintf(buf + strlen(buf), "{\"deviceId\":\"%s\",\"%s\":%d},",
  323. current_device->deviceID, currentModbusParams->keyword, value);
  324. count++;
  325. }
  326. if (currentModbusParams->decimalPoint == 0)
  327. {
  328. currentModbusParams->value = value;
  329. }
  330. else
  331. {
  332. float convertedValue = (float)value / pow(10, currentModbusParams->decimalPoint);
  333. currentModbusParams->value=convertedValue;
  334. }
  335. }
  336. currentModbusParams = currentModbusParams->nextParams;
  337. if (currentModbusParams == NULL)
  338. {
  339. current_device = current_device->nextDevice;
  340. currentModbusParams = current_device->params->gateway_read_modbus_command;
  341. if(current_device == NULL)
  342. {
  343. sprintf(buf + strlen(buf) - 1, "");
  344. return 1;
  345. }
  346. }
  347. }
  348. }
  349. else if (current_device->protocol == DLT645_2007 || current_device->protocol == DLT645_97)
  350. {
  351. protocol_485=2;
  352. uint8_t read_buf[10];
  353. uint32_t dltValue;
  354. currentDLT645Params->rxLen = 0;
  355. memset(read_buf, 0, 10);
  356. memset(currentDLT645Params->data, 0, 10);
  357. dlt645_set_addr(&dlt645, currentDLT645Params->deviceID645);
  358. int8_t rs;
  359. if (current_device->protocol == DLT645_2007)
  360. {
  361. rs = dlt645_read_data(&dlt645, currentDLT645Params->Identification, read_buf, DLT645_2007);
  362. }
  363. else if (current_device->protocol == DLT645_1997)
  364. {
  365. rs = dlt645_read_data(&dlt645, currentDLT645Params->Identification, read_buf, DLT645_1997);
  366. }
  367. if (rs != -1)
  368. {
  369. if (rs <= 4)
  370. {
  371. memcpy(currentDLT645Params->data, read_buf, 4);
  372. currentDLT645Params->rxLen = 4;
  373. }
  374. else if (rs == 5)
  375. {
  376. memcpy(currentDLT645Params->data, read_buf, 5);
  377. currentDLT645Params->rxLen = 5;
  378. }
  379. else if (rs > 5)
  380. {
  381. memcpy(currentDLT645Params->data, read_buf, 9);
  382. currentDLT645Params->rxLen = 9;
  383. }
  384. dltValue = currentDLT645Params->data[0] << 24 | currentDLT645Params->data[1] << 16|
  385. currentDLT645Params->data[2] << 8 | currentDLT645Params->data[3];
  386. sprintf(buf + strlen(buf), "{\"identifier\":\"%s\",\"deviceID645\":\"%02x%02x%02x%02x%02x%02x\",\"identifier645\":%d,\"value\":%X}",
  387. currentDLT645Params->keyword, currentDLT645Params->deviceID645[0],
  388. currentDLT645Params->deviceID645[1],currentDLT645Params->deviceID645[2],
  389. currentDLT645Params->deviceID645[3],currentDLT645Params->deviceID645[4],
  390. currentDLT645Params->deviceID645[5],currentDLT645Params->Identification,dltValue);
  391. }
  392. currentDLT645Params = currentDLT645Params->nextParams;
  393. if (currentDLT645Params == NULL)
  394. {
  395. current_device = current_device->nextDevice;
  396. currentDLT645Params = current_device->params->gateway_read_dlt645_command;
  397. if(current_device == NULL)
  398. {
  399. sprintf(buf + strlen(buf) - 1, "");
  400. return 1;
  401. }
  402. }
  403. }
  404. }
  405. return 1;
  406. }
  407. /*
  408. *********************************************************************************************************
  409. * 函 数 �:void WRITE_MODBUS_DATA(char* cJSONstring)
  410. * 功能说明: 接收mqtt数�并写入modbus寄存器
  411. * 形 �:char* cJSONstring mqtt接收到的数�
  412. * 返 回 值: 无
  413. *********************************************************************************************************
  414. */
  415. void write_modbus_data(char* cJSONstring)
  416. {
  417. GATEWAY_PARAMS* get;
  418. get = get_gateway_config_params();
  419. DEVICE_PARAMS* current_device = get->device_params;
  420. /* ÀûÓÃcJSOn_Parse½âÎöÊý¾Ý£¬»ñÈ¡¸÷ÀàÐÍÊý¾Ý */
  421. cJSON *root = cJSON_Parse(cJSONstring);
  422. const char *deviceId = cJSON_GetStringValue(cJSON_GetObjectItem(root, "deviceId"));
  423. const cJSON *power = cJSON_GetObjectItemCaseSensitive(root, "power");
  424. const cJSON *temp = cJSON_GetObjectItemCaseSensitive(root, "temp");
  425. const cJSON *mode = cJSON_GetObjectItemCaseSensitive(root, "mode");
  426. const cJSON *fan = cJSON_GetObjectItemCaseSensitive(root, "fan");
  427. while(current_device)
  428. {
  429. char* device_ID = (char*)current_device->deviceID;
  430. GATEWAY_WRITE_MODBUS_COMMAND *currentModbusParams = current_device->params->gateway_write_modbus_command;
  431. if(!strcmp(device_ID,deviceId)) //Æ¥ÅäID
  432. {
  433. OSTimeDly(100);
  434. /* дÈë¼Ä´æÆ÷²Ù×÷ */
  435. if(power)
  436. {
  437. mmodbus_writeHoldingRegister16i(currentModbusParams->slaveAddress,
  438. currentModbusParams->registerAddress,
  439. power->valueint);
  440. }
  441. OSTimeDly(100);
  442. if(temp)
  443. {
  444. currentModbusParams = currentModbusParams->nextParams;
  445. mmodbus_writeHoldingRegister16i(currentModbusParams->slaveAddress,
  446. currentModbusParams->registerAddress,
  447. temp->valueint);
  448. }
  449. OSTimeDly(100);
  450. if(mode)
  451. {
  452. currentModbusParams = currentModbusParams->nextParams;
  453. mmodbus_writeHoldingRegister16i(currentModbusParams->slaveAddress,
  454. currentModbusParams->registerAddress,
  455. mode->valueint);
  456. }
  457. OSTimeDly(100);
  458. if(fan)
  459. {
  460. currentModbusParams = currentModbusParams->nextParams;
  461. mmodbus_writeHoldingRegister16i(currentModbusParams->slaveAddress,
  462. currentModbusParams->registerAddress,
  463. fan->valueint);
  464. }
  465. }
  466. current_device = current_device->nextDevice;
  467. }
  468. cJSON_Delete(root);
  469. }
  470. /*
  471. *********************************************************************************************************
  472. * 函 数 �: void find_difference(char* buf, char* pubJsonStringCopy, char* string)
  473. * 功能说明: 比较出�数1和�数2的��处
  474. * 形 �: �数1:新数� �数2:旧数� �数3:输出�数
  475. * 返 回 值: 无
  476. *********************************************************************************************************
  477. */
  478. void find_difference(char* buf, char* pubJsonStringCopy, char* string)
  479. {
  480. const char* delimiter = "{}";
  481. char* saveptr1;
  482. char* saveptr2;
  483. char* data1 = mymalloc(SRAMEX, strlen(buf));
  484. char* data2 = mymalloc(SRAMEX, strlen(pubJsonStringCopy));
  485. memcpy(data1, buf, strlen(buf));
  486. memcpy(data2, pubJsonStringCopy, strlen(pubJsonStringCopy));
  487. // 利用strtok_r函数分割字符串,并�一比较
  488. char* token1 = strtok_r((char*)data1, delimiter, &saveptr1);
  489. char* token2 = strtok_r((char*)data2, delimiter, &saveptr2);
  490. while (token1 != NULL && token2 != NULL)
  491. {
  492. if (strcmp(token1, token2) != 0)
  493. {
  494. memcpy(string + strlen(string), token1, strlen(token1));
  495. }
  496. token1 = strtok_r(NULL, delimiter, &saveptr1);
  497. token2 = strtok_r(NULL, delimiter, &saveptr2);
  498. }
  499. // // 如果有剩余字符串未比较,则打�剩余字符串
  500. // while (token1 != NULL) {
  501. // sprintf(string + strlen(string),"%s,", token1);
  502. // token1 = strtok_r(NULL, delimiter, &saveptr1);
  503. // }
  504. // while (token2 != NULL) {
  505. // //sprintf(string + strlen(string),"{%s},", token2);
  506. // token2 = strtok_r(NULL, delimiter, &saveptr2);
  507. // }
  508. myfree(SRAMEX, data1);
  509. myfree(SRAMEX, data2);
  510. }
  511. /*
  512. *********************************************************************************************************
  513. * 函 数 �: void send_mqtt(char*buf, int jsonCunt)
  514. * 功能说明: 将数���到mqtt
  515. * 形 �: �数1:读�数� �数2:第一次��标志
  516. * 返 回 值: 无
  517. *********************************************************************************************************
  518. */
  519. void send_mqtt(char*buf){
  520. GATEWAY_PARAMS *get;
  521. get= get_gateway_config_params();
  522. <<<<<<< HEAD
  523. sprintf(pubJsonString,"{\"DEVICEID\":\"%s\",\"data\":[%s]}",get->deviceId, buf); // ×é³ÉÒª·¢Ë͵ÄjsonÓï¾ä
  524. int msg = MBOX_USER_PUBLISHQOS0;
  525. if(mqtt_connectFlag==1) OSMboxPost(mqtt_sendMseeageMbox, &msg);
  526. =======
  527. time1 = GetCurrentTime();
  528. if(jsonCunt || time2 <= time1 - (3 * 1000)) // 20s进行一次
  529. {
  530. memset(pubJsonStringCopy,0, strlen(pubJsonStringCopy));
  531. memcpy(pubJsonStringCopy + strlen(pubJsonStringCopy), buf, strlen(buf));//备份上一次的数�
  532. sprintf(pubJsonString,"{\"DEVICEID\":\"%s\",\"data\":[%s]",get->deviceId, buf);
  533. int msg = MBOX_USER_PUBLISHQOS0;
  534. if(mqtt_connectFlag==1) OSMboxPost(mqtt_sendMseeageMbox, &msg);
  535. time2 = GetCurrentTime();
  536. }
  537. else
  538. {
  539. if(strcmp(buf,pubJsonStringCopy))
  540. {
  541. memset(string, 0 , strlen(string));
  542. find_difference(buf, pubJsonStringCopy, string);
  543. memset(pubJsonString,0, strlen(pubJsonString));
  544. sprintf(pubJsonString,"{\"deviceId\":\"%s\",\"data\":[{%s}]}",get->deviceId, string);
  545. memset(pubJsonStringCopy,0, strlen(pubJsonStringCopy));
  546. sprintf(pubJsonStringCopy, buf, strlen(buf));
  547. int msg = MBOX_USER_PUBLISHQOS0;
  548. if(mqtt_connectFlag==1) OSMboxPost(mqtt_sendMseeageMbox, &msg);
  549. }
  550. }
  551. >>>>>>> d12097fdeb13131a2d24b22a2181d1fbd191264d
  552. }