藍(lán)牙芯片收到另外藍(lán)牙芯片傳來(lái)的信息(一個(gè)長(zhǎng)度為4個(gè)數(shù)組),現(xiàn)在想通過(guò)FS800把這些數(shù)據(jù)發(fā)給阿里云,想通過(guò)串口把數(shù)據(jù)輸出給FS800模塊,但是代碼有些問(wèn)題。請(qǐng)問(wèn)有相關(guān)參考嗎?
?if(ctx->addr==0x0002) ????????{ ????????????//?自定義隨機(jī)數(shù)據(jù)發(fā)送版本 ????????????uint8_t?*received_data?=?val->vendor_model_srv_Event.trans.pdata; ????????????int?len?=?val->vendor_model_srv_Event.trans.len; ????????????if(len?>=?4)??//?假設(shè)數(shù)據(jù)至少有4字節(jié) ????????????{ ????????????????//?解析數(shù)據(jù) ????????????????char?dataStr[200]; ????????????????int?offset?=?sprintf(dataStr,?"data={"); ????????????????for(int?i?=?0;?i?<?len;?i++)?{ ????????????????????offset?+=?sprintf(dataStr?+?offset,?"%d",?received_data[i]); ????????????????????if(i?<?len?-?1) ????????????????????????offset?+=?sprintf(dataStr?+?offset,?","); ????????????????} ????????????????sprintf(dataStr?+?offset,?"},src:0x%04x",?ctx->addr); ????????????????APP_DBG("%s\n",?dataStr); ????????????????float?Temperature?=?received_data[0]?*?1.0;?? ????????????????float?Humidity?=?received_data[1]?*?1.0; ????????????????float?co2?=?received_data[2]?*?1.0; ????????????????float?WindSpeed?=?received_data[3]?*?1.0; ????????????????//?發(fā)送帶有CO2,?風(fēng)速,?濕度,?溫度的JSON數(shù)據(jù) ????????????????Serial_Printf(USART2, ????????????????????"{\"method\":\"thing.event.property.post\"," ????????????????????"\"id\":\"******\"," ????????????????????"\"params\":{" ????????????????????????"\"co2\":%.1f," ????????????????????????"\"WindSpeed\":%.1f," ????????????????????????"\"Humidity\":%.1f," ????????????????????????"\"temperature\":%.1f" ????????????????????"}," ????????????????????"\"version\":\"1.0\"}", ????????????????????co2,?WindSpeed,?Humidity,?Temperature);
熱門產(chǎn)品 :
CH182: 以太網(wǎng)PHY收發(fā)器芯片