Skip to content

Commit

Permalink
Update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
sy-records committed Jan 17, 2025
1 parent 7a2953c commit b28d880
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 54 deletions.
21 changes: 12 additions & 9 deletions docs/en/_sidebar.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
* MQTT Coroutine Client
* [Client API](en/client)
* [WebSocket Client API](en/websocket)
- MQTT Coroutine Client
- [Client API](en/client)
- [WebSocket Client API](en/websocket)

* MQTT Protocol Analysis
* [Protocol API](en/protocol)
- MQTT Protocol Analysis
- [Protocol API](en/protocol)

* MQTT Message
* [Message API](en/message)
- MQTT Message
- [Message API](en/message)

* Upgrade Guide
* [1.2 Upgrade Guide](en/upgrade/1.2.md)
- Upgrade Guide
- [1.2 Upgrade Guide](en/upgrade/1.2)

- Tools
- [Debug Tools](en/debug)
16 changes: 8 additions & 8 deletions docs/en/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,6 @@ New AUTH type added in MQTT5. Authentication exchange.
Simps\MQTT\Client->auth(int $code = ReasonCode::SUCCESS, array $properties = [])
```

## recv()

Receive messages

```php
Simps\MQTT\Client->recv(): bool|arary|string
```

## send()

Send messages
Expand All @@ -181,6 +173,14 @@ Simps\MQTT\Client->send(array $data, $response = true)

Are acknowledgements required. If `true`, `recv()` is called once

## recv()

Receive messages

```php
Simps\MQTT\Client->recv(): bool|arary|string
```

## ping()

Send a heartbeat
Expand Down
52 changes: 52 additions & 0 deletions docs/en/debug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Debug Tools

The tool provides 5 methods for debugging binary data, essentially functioning as a binary data viewer.

It primarily converts binary data into ASCII or hexadecimal formats for viewing, useful for debugging TCP, WebSocket, UDP, and other protocols.

```php
public function hexDump(): string // Display in hexadecimal
public function hexDumpAscii(): string // Display in both hexadecimal and corresponding ASCII characters
public function printableText(): string // Printable characters
public function hexStream(): string // Hexadecimal stream
public function ascii(): string // Display in ASCII characters
```

You can call these methods statically or instantiate `Simps\MQTT\Tools\Debug` or `Simps\MQTT\Tools\Common`/`Simps\MQTT\Tools\UnPackTool`:

- Instantiation

```php
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

```php
use Simps\MQTT\Tools\UnPackTool;

echo UnPackTool::hexDumpAscii('0:simps-mqtt/user001/update{
"msg": "hello, mqtt"
}');
```

```text
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".}
```
16 changes: 8 additions & 8 deletions docs/en/websocket.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,6 @@ New AUTH type added in MQTT5. Authentication exchange.
Simps\MQTT\WebSocketClient->auth(int $code = ReasonCode::SUCCESS, array $properties = [])
```

## recv()

Receive messages

```php
Simps\MQTT\WebSocketClient->recv(): bool|arary|string
```

## send()

Send messages
Expand All @@ -181,6 +173,14 @@ Simps\MQTT\WebSocketClient->send(array $data, $response = true)

Are acknowledgements required. If `true`, `recv()` is called once

## recv()

Receive messages

```php
Simps\MQTT\WebSocketClient->recv(): bool|arary|string
```

## ping()

Send a heartbeat
Expand Down
25 changes: 12 additions & 13 deletions docs/zh-cn/_sidebar.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
* MQTT 协程客户端
* [Client API](zh-cn/client)
* [WebSocket Client API](zh-cn/websocket)
- MQTT 协程客户端
- [Client API](zh-cn/client)
- [WebSocket Client API](zh-cn/websocket)

* MQTT 协议解析
* [Protocol API](zh-cn/protocol)
- MQTT 协议解析
- [Protocol API](zh-cn/protocol)

* MQTT Message
* [Message API](zh-cn/message)
- MQTT Message
- [Message API](zh-cn/message)

* 版本升级指南
* [1.2 升级指南](zh-cn/upgrade/1.2.md)
- 版本升级指南
- [1.2 升级指南](zh-cn/upgrade/1.2)

* Tools

- [Debug Tools](zh-cn/debug.md)
- [自适应协议等级](zh-cn/level.md)
- Tools
- [Debug Tools](zh-cn/debug)
- [自适应协议等级](zh-cn/level)
16 changes: 8 additions & 8 deletions docs/zh-cn/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,6 @@ MQTT5 中新增的认证交换机制。
Simps\MQTT\Client->auth(int $code = ReasonCode::SUCCESS, array $properties = [])
```

## recv()

接收消息

```php
Simps\MQTT\Client->recv(): bool|arary|string
```

## send()

发送消息
Expand All @@ -200,6 +192,14 @@ Simps\MQTT\Client->send(array $data, $response = true)

是否需要回执。如果为`true`,会调用一次`recv()`

## recv()

接收消息

```php
Simps\MQTT\Client->recv(): bool|arary|string
```

## ping()

发送心跳包
Expand Down
16 changes: 8 additions & 8 deletions docs/zh-cn/websocket.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,6 @@ MQTT5 中新增的认证交换机制。
Simps\MQTT\WebSocketClient->auth(int $code = ReasonCode::SUCCESS, array $properties = [])
```

## recv()

接收消息

```php
Simps\MQTT\WebSocketClient->recv(): bool|arary|string
```

## send()

发送消息
Expand All @@ -200,6 +192,14 @@ Simps\MQTT\WebSocketClient->send(array $data, $response = true)

是否需要回执。如果为`true`,会调用一次`recv()`

## recv()

接收消息

```php
Simps\MQTT\WebSocketClient->recv(): bool|arary|string
```

## ping()

发送心跳包
Expand Down

0 comments on commit b28d880

Please sign in to comment.