物通博联MQTT网关阿里云服务器配置

静态网络配置

修改上传up的速度,采集周期设置2s

 

下载地址 http://www.jensd.de/apps/mqttfx/1.7.1/

publish:

/WG585OWAN20102200356/down

{"cmdId":91,"execmd":"wtbl_gostatus text"}

{"cmdId":87,"writeValue":"100","devId":1098,"varId":253}

{"cmdId":85,"devId":115,"varId":2566}

sub:

/sys/WG585OWAN20102200356/up

php代码如下:

<?php

require('../phpMQTT.php');

$server = '192.168.2.187';     // change if necessary
$port = 61613;                     // change if necessary
$username = 'admin';                   // set your username
$password = 'password';                   // set your password
$client_id = '6dd1bb3392b64e1982c1da5b34239c05'; // make sure this is unique for connecting to sever - you could use uniqid()

$mqtt = new Bluerhinos\phpMQTT($server, $port, $client_id);

if ($mqtt->connect(true, NULL, $username, $password)) {
	$mqtt->publish('/WG585OWAN20102200356/down', '{"cmdId":87,"writeValue":"15","devId":1098,"varId":532}', 0, false);
	$mqtt->close();
	echo "success!!\n";
} else {
    echo "Time out!\n";
}
<?php

require('../phpMQTT.php');


$server = '192.168.2.187';     // change if necessary
$port = 61613;                     // change if necessary
$username = 'admin';                   // set your username
$password = 'password';                   // set your password
$client_id = '6dd1bb3392b64e1982c1da5b34239c05'; // make sure this is unique for connecting to sever - you could use uniqid()

$mqtt = new Bluerhinos\phpMQTT($server, $port, $client_id);
if(!$mqtt->connect(true, NULL, $username, $password)) {
	exit(1);
}

$mqtt->debug = true;

$topics['sys/WG585OWAN20102200356/up'] = array('qos' => 0, 'function' => 'procMsg');
$mqtt->subscribe($topics, 0);
$topics1['/sys/WG585OWAN20102200356/up'] = array('qos' => 0, 'function' => 'procMsg');
$mqtt->subscribe($topics1, 0);

while($mqtt->proc()) {

}

$mqtt->close();

function procMsg($topic, $msg){
		echo 'Msg Recieved: ' . date('r') . "\n";
		echo "Topic: {$topic}\n\n";
		echo "\t$msg\n\n";
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值