Socket.IO Document
Overview
This document is the API provided by UbiTrack. It is for reference only. Developers can refer to the development guide for socket.io document development.
Socket.IO Port
3000
Responses
Additional Info.
{
"datatype": 109,
"tagaddr": "2025",
"in_datatype": 21,
"zoneid": "2",
"type": "msg",
"timestamp": 1640314655922,
"s": 1
}
Response | Description |
---|---|
datatype | Fixed value: 109 |
tagaddr | Tag SerialNo. |
in_datatype | Fixed value:20,21(20:TDOA,21:TWR) |
zoneid | Zone ID |
type | Fixed value:msg |
timestamp | Timestamp |
s | Key: s,utctime; When key is "s",value will return 1; When key is "utctime", value will return "2021-12-24T11:11:31Z" |
TWR, TDOA Info.
{
"datatype": 80,
"pno": "179",
"type": "normal1",
"tagaddr": "2025",
"x": 14.40491,
"y": 3.4,
"tagtime": 1640314973302,
"zoneid": "2",
"object_id": 1,
"in_fence": [10,12],
"sourcedata": {"a233":9.865,"a258":5.868}
}
Response | Description |
---|---|
datatype | Fixed value:80,81(TWR:80,TDOA:81) |
pno | Data batch No. |
type | Data type(timeout:Timeout, normal:2D, normal2:1D, normal11:0D, error23:Error) |
tagaddr | Tag SerialNo. |
x | X coordinate;Return when type is normal,normal2,normal11 |
y | Y coordinate;Return when type is normal,normal2,normal11 |
tagtime | Server time |
zoneid | Zone ID |
object_id | Object ID;Return when there is data |
in_fence | E-fence Info. |
sourcedata | Original Data |
Warnning Info.
{
"datatype": 105,
"type": "warn",
"tagaddr": "2025",
"timestamp": 1640314973302,
"zoneid": "2",
"sub_type": "energy",
"sub_type_val": 3.7,
"socket_id": "6IPpNfOCH5R5dJi2AABJ"
}
Response | Description |
---|---|
datatype | Fixed value:105 |
type | Data type(warn, warn_back) |
tagaddr | Tag SerialNo. |
timestamp | Timestamp |
zoneid | Zone ID |
sub_type | Warnning Type (heartrate,energy,isclosed,offline,cross,call,help,easy_call) |
sub_type_val | Additional Info.When sub_type is "heartrate",return current heart rate value; When sub_type is "energy", return current battery |
socket_id | Socket ID |
Socket.IO Sample Code
<script scr="socket.io.js"></script>
<script>
var zoneid = '2'; //Zone ID
var algorithm = '80'; //Algorithm(TWR:80;TDOA:81)
var socket = io.connect('http://192.168.1.8:3000?token=mdpscloudforce');
socket.on('connect', function () {
socket.emit('join', algorithm + "_" + zone_id );
});
socket.on('say', function (data) {
console.log(data);
});
</script>