|
@@ -247,10 +247,14 @@ function loop()
|
|
|
$mqtt->subscribe('earings/+/reportData', function ($topic, $message) use($mqtt) {
|
|
|
rlog("reportData", 'recv', $topic, $message);
|
|
|
$topicArr=explode('/',$topic);
|
|
|
- $data=json_decode($message,true);
|
|
|
- $data['deviceId']=$topicArr[1];
|
|
|
- $data['data_type']='reportData';
|
|
|
- mqttToRedis(json_encode($data));
|
|
|
+ $arr=explode(';',$message);
|
|
|
+ var_dump($data);
|
|
|
+ foreach($arr as $val){
|
|
|
+ $data=json_decode($val,true);
|
|
|
+ $data['deviceId']=$topicArr[1];
|
|
|
+ $data['data_type']='reportData';
|
|
|
+ mqttToRedis(json_encode($data));
|
|
|
+ }
|
|
|
}, 1);
|
|
|
$mqtt->subscribe('earings/+/cloudResp', function ($topic, $message) use($mqtt) {
|
|
|
rlog("cloudResp", 'recv', $topic, $message);
|
|
@@ -295,5 +299,5 @@ while (1) {
|
|
|
}
|
|
|
sleep(3);
|
|
|
}
|
|
|
-// $text='{"idESim":"460087239103989","stepCount":52,"EnvironmentTemperature":"0.0","earTemperature":"0.0","latitude":30.191936999999999,"longitude":120.201123,"charging":0,"lastCharge":1693497600,"measurementTimestamp":1698633903,"deviceId":"869154043496145-999202300000099","data_type":"reportData"}';
|
|
|
+// $text='{"idESim":"460087239103989","stepCount":985,"EnvironmentTemperature":"0.0","earTemperature":"0.0","latitude":30.191936999999999,"longitude":120.201123,"charging":0,"lastCharge":1693497600,"measurementTimestamp":1698633903,"deviceId":"869154043484299-123456789abcdef","data_type":"reportData"}';
|
|
|
// app_redis()->lpush("mqtt_data_livestock",$text);
|