jundayw / jtt-808-php-sdk
JT/T808 PHP SDK
v0.0.1
2023-11-22 02:28 UTC
Requires
- php: >=7.4.0
- jundayw/socket: ^0.7.0
This package is auto-updated.
Last update: 2024-11-22 04:47:10 UTC
README
命令行下, 执行 composer 命令安装:
composer require jundayw/jtt-808-php-sdk
上行消息对照表
下行消息对照表
演示案例
use Jundayw\JTT808\Message; use Jundayw\JTT808\MessageRequest\Message0100Request; use Jundayw\JTT808\MessageRequest\Message0200Request; use Jundayw\JTT808\MessageResponse\Message8001Response; use Jundayw\JTT808\MessageResponse\Message8100Response; $bytes = hex2bin('7E0100002D01234567891200B800010002313233000034353600000000000000000000000000000000003132333435000002B2E2413132333435187E'); $bytes = hex2bin('7E8100000D0123456789124B3000B80031323334353637383930D57E'); $bytes = hex2bin('7E0200002601234567891200B900000000000000030261136106F0124D0058029400002304261530320104000004CE02020000AA7E'); $bytes = hex2bin('7E800100050123456789124B3E00B9020000D17E'); $bytes = hex2bin('7E0200003001234567891200B900000010000000030261136106F0124D0058029400002304261530320104000004ce020200372504000000052a020001967E'); try { $message = new Message(); $message->decode($bytes); switch ($message->getMsgId()) { case '0100': // 终端注册 $request = new Message0100Request($message); var_dump([ '制造商ID' => $request->manufacturerId, '终端型号' => $request->terminalModel, '终端ID' => $request->terminalId, '车牌颜色' => $request->plateColor, '车辆标识' => $request->plateNumber, ]); // 终端注册应答 $response = new Message8100Response($message); $response->response(0, '123456'); var_dump(bin2hex($message->encode($response))); break; case '0200': // 位置信息汇报 $request = new Message0200Request($message); var_dump([ '报警信息' => $request->alarmList, '状态位信息' => $request->statusList, '纬度' => $request->latitude, '经度' => $request->longitude, '高程' => $request->height, '速度' => $request->speed, '时间' => $request->time, '扩展信息' => $request->extendList, ]); // 平台通用应答 $response = new Message8001Response($message); $response->response(0); var_dump(bin2hex($message->encode($response))); break; } } catch (Exception $e) { var_dump('Eexception', $e->getMessage()); die; }