Browse Source

no message

DESKTOP-9JTA2JJ\HP 5 years ago
parent
commit
e4e62f8ea2
1 changed files with 5 additions and 4 deletions
  1. 5 4
      api/application/helpers/function_helper.php

+ 5 - 4
api/application/helpers/function_helper.php

@@ -94,16 +94,16 @@ function lampMqttCmd($sendTopic,$backTopic,$sendData,$timeout = 5,$seq = ''){
     $mqtt = new Mqtt($server, $port, $client_id);
     $mqtt = new Mqtt($server, $port, $client_id);
 
 
     if($mqtt->connect(true, NULL, $username, $password)) { //链接不成功再重复执行监听连接
     if($mqtt->connect(true, NULL, $username, $password)) { //链接不成功再重复执行监听连接
-        $mqtt->publish($sendTopic, $sendData, 0);
+        $mqtt->publish($sendTopic, $sendData, 2);
         // $mqtt->publish('/WEGW/ReadIn/865860046894466', pack('H*','010AA00B'), 2);
         // $mqtt->publish('/WEGW/ReadIn/865860046894466', pack('H*','010AA00B'), 2);
     }else{
     }else{
         return '';
         return '';
     }
     }
 
 
-    $topics[$backTopic] = array("qos" => 0,"function" => "procmsg");
+    $topics[$backTopic] = array("qos" => 2,"function" => "procmsg");
     // $topics['/WEGW/ReadOut/865860046894466'] = array("qos" => 2, "function" => "procmsg");
     // $topics['/WEGW/ReadOut/865860046894466'] = array("qos" => 2, "function" => "procmsg");
     // 订阅主题
     // 订阅主题
-    $mqtt->subscribe($topics, 0);
+    $mqtt->subscribe($topics, 2);
     $true = 1;
     $true = 1;
     $t = time();
     $t = time();
     while($true == 1){
     while($true == 1){
@@ -117,6 +117,7 @@ function lampMqttCmd($sendTopic,$backTopic,$sendData,$timeout = 5,$seq = ''){
         }
         }
     }
     }
     $mqtt->close();
     $mqtt->close();
+    $true['msg'] = substr($true['msg'], 2);
     return $true;
     return $true;
 }
 }
 
 
@@ -647,7 +648,7 @@ function send_websocket($clientid,$data = array(),$resType='cmd')
 {
 {
     if (!empty($clientid)) {
     if (!empty($clientid)) {
         $CI =& get_instance();
         $CI =& get_instance();
-        if (isset($data['data'])) $data['data']['status'] = 2;
+        // if (isset($data['data'])) $data['data']['status'] = 2;
         $CI->db->insert('message',['client'=>$clientid,'msg'=>json_encode($data)]);
         $CI->db->insert('message',['client'=>$clientid,'msg'=>json_encode($data)]);
     }
     }