diam4ik / teltonika-fm-parser
Teltonika FMXXXX 解析库
1.0.4
2019-04-30 14:39 UTC
Requires
- php: >=7.0
Requires (Dev)
- phpunit/phpunit: ^5.7
This package is auto-updated.
Last update: 2024-09-29 05:21:40 UTC
README
这是一个面向对象的库,用于翻译Teltonika协议。
您可以在服务器中使用这个库,它将帮助您与Teltonika设备通信。
它是基于Teltonika协议v2.10文档构建的。
需求
{ "require": { "php": ">=7.0" }, "require-dev": { "phpunit/phpunit": "^5.7" } }
用法
身份验证解码
// Recieve data from tcp socket $payloadFromDevice = "000F313233343536373839303132333435"; // Decode recieved data $decoder = new TcpDecoder(); // Check if data which we recieved are authentication or Gps records if($decoder->isAuthentication($payloadFromDevice)){ // returns true; $imei = $decoder->decodeAuthentication($payloadFromDevice); echo json_encode(imei); // Check if device is authenticated in your system, and then encode response for device $encoder = new TcpEncoder(); $payload = $encoder->encodeAuthentication(true); // Yes, device was authenticated successfully // send $payload though the socket. }
回显将返回
{ "imei": "862259588834290" }
// Now we need to wait for next data from the device // Recieve next payload from the socket (now with data) $tcpPayloadFromDevice = "00000000000000FE080400000113fc208dff000f14f650209cca80006f..."; // Decode it $data = $this->decoder->decodeData($payload); echo json_encode(data);
回显将返回
[{ "dateTime": { "date": "2007-07-25 06:46:38.000000", "timezone_type": 3, "timezone": "UTC" }, "priority": 0, "gpsData": { "longitude": 25.3032016, "latitude": 54.7146368, "altitude": 111, "angle": 214, "satellites": 4, "speed": 4, "hasGpsFix": true } }, { "dateTime": { "date": "2007-07-25 06:46:38.000000", "timezone_type": 3, "timezone": "UTC" }, "priority": 0, "gpsData": { "longitude": 25.3032016, "latitude": 54.7146368, "altitude": 111, "angle": 214, "satellites": 4, "speed": 4, "hasGpsFix": true } }]
查看测试以获取更多示例!
待办事项
- 实现TCP协议(编码和解码)
- 实现GPS传感器数据(IOElement)
- 实现UDP协议(编码和解码)
- 实现短信协议