PHPMQTT v1.4.1 is released. In this version, a protocol debugging tool is added. Provides 5 methods to debug binary data, which is actually a binary data viewing tool.
It is mainly to convert binary data into ASCII and hexadecimal format for viewing, which can be used to debug TCP, WebSocket, UDP, etc.
public function hexDump(): string // 以16进制显示
public function hexDumpAscii(): string // 以16进制和相应的ASCII字符显示
public function printableText(): string // 可打印字符
public function hexStream(): string // 16进制流
public function ascii(): string // 以ASCII字符显示
use
It can be called statically Simps\MQTT\Tools\Debug
or Simps\MQTT\Tools\Common
/ Simps\MQTT\Tools\UnPackTool
- Instantiate
use Simps\MQTT\Tools\Debug;
$debug = new Debug('0:simps-mqtt/user001/update{
"msg": "hello, mqtt"
}');
//$debug = (new Debug())->setEncode('0:simps-mqtt/user001/update{
// "msg": "hello, mqtt"
//}');
echo $debug->hexDump(), PHP_EOL;
echo $debug->hexDumpAscii(), PHP_EOL;
echo $debug->printableText(), PHP_EOL;
echo $debug->hexStream(), PHP_EOL;
echo $debug->ascii();
- Static call
use Simps\MQTT\Tools\UnPackTool;
echo UnPackTool::hexDumpAscii('0:simps-mqtt/user001/update{
"msg": "hello, mqtt"
}');
00000000 30 3a 73 69 6d 70 73 2d 6d 71 74 74 2f 75 73 65 0:simps-mqtt/use
00000010 72 30 30 31 2f 75 70 64 61 74 65 7b 0a 20 20 22 r001/update{. "
00000020 6d 73 67 22 3a 20 22 68 65 6c 6c 6f 2c 20 6d 71 msg": "hello, mq
00000030 74 74 22 0a 7d tt".}
Use in Client
Call the setVerbose
method of the configuration object and set the required debugging level.
Update log
- Add debugging tools (#56)
- Add mqtt related constants (#58)
- Optimize CI (#60) (#61) (#64)
- Add debugging tools for Client (#65)
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。