1
2
3
4
|
apt-add-repository ppa:mosquitto-dev/mosquitto-ppa
apt-get update
apt-get install mosquitto
apt-get install mosquitto-clients
|
1
2
|
listener 8001
protocol websockets
|
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
<!doctype html>
<html>
<head>
<title>start page</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<script src="mqttws31.js"></script>
</head>
<body>
<label>当前温度</label>
<meter max="100" low="60" high="80" value="30" id="meter"></meter>
<script>
var client = new paho.mqtt.client("host", 8001, "clientid");
client.onmessagearrived = function (msg) {
document.queryselector("#meter").value = msg.payloadstring;
};
client.connect({
onsuccess: function () {
client.subscribe("floor-5/temperature");
}
});
</script>
</body>
</html>
|
1
|
mosquitto_pub -d -q 2 -t 'floor-5/temperature' -m '95'
|
如对本文有疑问, 点击进行留言回复!!
【奥鹏作业答案库网】大工20春《应用统计》在线作业1【奥鹏作业答案】
网友评论