PHPMQTT v1.4.1 版本公布,在此版本中次要是新增了一个协定调试工具。 提供了 5 种办法来调试二进制数据,实际上就是一个二进制数据查看工具。

次要是将二进制数据转为 ASCII、十六进制的格局进行查看,能够用来调试 TCP、WebSocket、UDP 等。

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字符显示

应用

能够通过实例化Simps\MQTT\Tools\Debug或者Simps\MQTT\Tools\Common/Simps\MQTT\Tools\UnPackTool动态调用:

  • 实例化
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();
  • 动态调用
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/use00000010    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, mq00000030    74 74 22 0a 7d                                     tt".}

在 Client 中应用

调用配置对象的setVerbose办法,设置须要的调试级别即可。

更新日志

  • 增加调试工具 (#56)
  • 增加 mqtt 相干常量 (#58)
  • 优化 CI (#60) (#61) (#64)
  • 为 Client 增加调试工具 (#65)