瀏覽代碼

test

station_14109
altob.rd 8 年之前
父節點
當前提交
3034eefb22
共有 1 個文件被更改,包括 4 次插入3 次删除
  1. +4
    -3
      coworker/mqtt_service.php

+ 4
- 3
coworker/mqtt_service.php 查看文件

@@ -63,8 +63,9 @@ $mqtt = new phpMQTT($mqtt_ip, $mqtt_port, uniqid());
if(!$mqtt->connect()){ die ('Could not connect mqtt'); }

// 場站資料庫資訊
$topics['#'] = array('qos'=>2, 'function'=>'procmsg');
$mqtt->subscribe($topics, 2);
$topics['#'] = array('qos'=> 0, 'function'=>'procmsg');
$mqtt->subscribe($topics, 0);
trigger_error("..mqtt subscribe..".print_r($topics, true));

while($mqtt->proc()){ }
$mqtt->close();
@@ -80,5 +81,5 @@ function procmsg($topic, $msg)
curl_setopt($ch, CURLOPT_URL, 'http://localhost/carpark.html/mqtt_service/');
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
$result = curl_exec($ch);
trigger_error( __FUNCTION__ . "..{$topic}|{$msg}..curl:{$result}..");
trigger_error("..{$topic}|{$msg}..curl:{$result}..");
}

Loading…
取消
儲存