tongshanglei il y a 1 an
Parent
commit
cecb57a733
1 fichiers modifiés avec 12 ajouts et 12 suppressions
  1. 12 12
      task_script/LIVESTOCK_MQTT_CLIENT.php

+ 12 - 12
task_script/LIVESTOCK_MQTT_CLIENT.php

@@ -4,14 +4,14 @@ use \PhpMqtt\Client\MqttClient;
 use \PhpMqtt\Client\ConnectionSettings;
 use think\facade\Cache;
 date_default_timezone_set("PRC");
-define('HOST', 'r-bp1eebab79320044pd.redis.rds.aliyuncs.com');
-define('PORT', '6379');
-define('PASSWORD', '7e2b5c91e438be3c!');
-define('DATABASE', 4);
-// define('HOST', '127.0.0.1');
+// define('HOST', 'r-bp1eebab79320044pd.redis.rds.aliyuncs.com');
 // define('PORT', '6379');
-// define('PASSWORD', '123456');
-// define('DATABASE', 2);
+// define('PASSWORD', '7e2b5c91e438be3c!');
+// define('DATABASE', 4);
+define('HOST', '127.0.0.1');
+define('PORT', '6379');
+define('PASSWORD', '123456');
+define('DATABASE', 2);
 
 function app_redis()
 {
@@ -207,7 +207,7 @@ function loop()
 {
     $server   = '116.62.220.88';
     $port     = 1883;
-    $clientId = 'mqtt_livestock_cli';
+    $clientId = 'local_mqtt_livestock_cli';
     $username = 'rl517';
     $password = "rlian2022";
     $clean_session = false;
@@ -253,19 +253,19 @@ function loop()
         mqttToRedis(json_encode($data));
     }, 1);
     $mqtt->subscribe('earings/+/cloudResp', function ($topic, $message) use($mqtt) {
-        rlog("coludResp", 'recv', $topic, $message);
+        rlog("cloudResp", 'recv', $topic, $message);
         $topicArr=explode('/',$topic);
         $data=json_decode($message,true);
         $data['deviceId']=$topicArr[1];
-        $data['data_type']='coludResp';
+        $data['data_type']='cloudResp';
         mqttToRedis(json_encode($data));
     }, 1);
     $mqtt->subscribe('earings/+/cloudControl', function ($topic, $message) use($mqtt) {
-        rlog("coludControl", 'recv', $topic, $message);
+        rlog("cloudControl", 'recv', $topic, $message);
         $topicArr=explode('/',$topic);
         $data=json_decode($message,true);
         $data['deviceId']=$topicArr[1];
-        $data['data_type']='coludControl';
+        $data['data_type']='cloudControl';
         mqttToRedis(json_encode($data));
     }, 1);
     $mqtt->loop(true);