MQTT端口号:1883
Topic |
备注 |
ubitrack/80_${zoneid} |
获取TWR定位数据 |
ubitrack/81_${zoneid} |
获取TDOA定位数据 |
返回数据格式
TWR,TDOA信息
|
{ "datatype": 80, "pno": "179", "type": "normal1", "tagaddr": "2025", "x": 14.40491, "y": 3.4, "tagtime": 1547175424534, "zoneid": "2", "object_id": 1, "in_fence": [10,12], "sourcedata": {"a233":9.865,"a258":5.868} } |
名称 |
描述 |
datatype |
固定值:80,81(TWR:80,TDOA:81) |
pno |
批次号 |
type |
数据类型(timeout:超时, normal:二维, normal2:一维, normal11:零维, error23:定位错误) |
tagaddr |
标签编号 |
x |
X轴坐标 |
y |
Y轴坐标 |
tagtime |
数据生成服务器时间 |
zoneid |
区域ID |
object_id |
对象ID;有数据时返回 |
in_fence |
当前标签在哪个电子围栏区域 |
sourcedata |
原始数据 |
MQTT示例代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
const mqtt = require('mqtt'); // https://github.com/mqttjs/MQTT.js const host = '192.168.1.8'; const port = '1883'; const clientId = `mqtt_${Math.random().toString(16).slice(3)}`; const connectUrl = `mqtt://${host}:${port}`; const topic = 'ubitrack/81_1'; // (80: twr data ; 81: tdoa data | 1: zone id exports.mqtt_client = mqtt_client = mqtt.connect(connectUrl, { clientId, clean: true, connectTimeout: 4000, username: 'emqx', password: 'public', reconnectPeriod: 1000, }); mqtt_client.on('connect', () => { console.log('connect'); mqtt_client.subscribe([topic]); }); mqtt_client.on('message', (topic, payload) => { console.log(topic, payload.toString()); }); |