Skip to content

Commit

Permalink
Merge pull request #521 from hxy7yx/2.10
Browse files Browse the repository at this point in the history
[v2.10]update mqtt configuration
  • Loading branch information
QQDQ authored Oct 12, 2024
2 parents ac5b273 + 2e53b2a commit 3889949
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 7 deletions.
42 changes: 40 additions & 2 deletions en_US/configuration/north-apps/mqtt/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ Tag value is returned only when the tag is read successfully. If something goes
You could write a tag by sending requests in JSON to the MQTT topic designated by the **Write Request Topic** parameter.

::: tip
Before Neuron version 2.4.5, the write request topic was hard-coded to **/neuron/{node_name}/write/req**.
Before Neuron version 2.4.5, the write request topic was hard-coded to **/neuron/{random_str}/write/req**.
:::

#### Body
Expand Down Expand Up @@ -197,7 +197,7 @@ Below is an example write request:
Write response will be published to the MQTT topic designated by the **Write Response Topic** parameter.

::: tip
Before Neuron version 2.4.5, the write response topic was hard-coded to **/neuron/{node_name}/write/resp**.
Before Neuron version 2.4.5, the write response topic was hard-coded to **/neuron/{random_str}//write/resp**.
:::

#### Body
Expand All @@ -214,3 +214,41 @@ Below is an example of write response:
"error": 0
}
```

## Driver Status Report

Reports status of all the southbound nodes to the specified topic.

### Status Report Topic

The status report topic is specified in the northbound node configuration. Its default value is **/neuron/{random_str}/state/update**.

### Status Report Interval

The status report interval is specified in the northbound node configuration, indicating the number of seconds between each message. The default value is 1, with an allowed range of 1-3600.

### Reporting Message Format

The reported data consists of the following fields:
* `timestamp`: The UNIX timestamp when the data was collected.
* `states`: An array of node status information.

Below is an example of a driver status reporting message.

```json
{
"timestamp": 1658134132237,
"states": [
{
"node": "modbus-tcp",
"link": 2,
"running": 3
},
{
"node": "modbus-rtu",
"link": 2,
"running": 3
}
]
}
```
6 changes: 5 additions & 1 deletion en_US/configuration/north-apps/mqtt/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@ See the table below for the configuration parameters.

| Parameter | Description |
| ------------------------------- | ------------------------------------------------------------ |
| **MQTT Version** | The version of MQTT protocol. The default is v3.1.1. |
| **Client ID** | MQTT client id for communication, a required field. |
| **QoS Level** | MQTT QoS level for message delivery, optional, default QoS 0. (since 2.4.0) |
| **Upload Format** | JSON format of reported data, a required field: <br /><br /> - *values-format*, data are split into `values` and `errors` sub-objects. <br />- *tags-format*, tag data are put in a single array. <br /><br />For data communication format, see [Upstream/Downstream Data Format](./api.md#write-tag) |
| **Write Request Topic** | MQTT topic to which the plugin subscribes for write requests. For data communication format, see [Upstream/Downstream Data Format](./api.md#write-tag) (since 2.4.5) |
| **Write Request Topic** | MQTT topic to which the plugin subscribes for write requests. For data communication format, see [Upstream/Downstream Data Format](./api.md#write-tag) (since 2.4.5). If tracing is enabled, configure the user properties `traceparent` and `tracestate` according to the W3C standard. |
| **Write Response Topic** | MQTT topic to which the plugin sends write responses. (since 2.4.5) |
| **Driver Status Report** | Reports status of all the southbound nodes to the specified topic. |
| **Status Report Topic** | The topic for status reporting. |
| **Status Report Interval** | The time interval for reporting the status of the southbound node, in seconds. The range is 1-3600, with a default of 1. |
| **Offline Data Caching** | Offline data caching switch. Cache MQTT messages when offline, and sync cached messages when back online. (Since 2.4.3) |
| **Cache Memory Size** | In-memory cache limit (MB) in case of communication failure, a required field. Range in [0, 1024]. Should not be larger than *Cache Disk Size*. For details about the cache feature, see [Offline Data Caching](#offline-data-caching) |
| **Cache Disk Size** | In-disk cache limit (MB) in case of communication failure, a required field. Range in [0, 10240]. If nonzero, *cache-mem-size* should also be nonzero. |
Expand Down
42 changes: 40 additions & 2 deletions zh_CN/configuration/north-apps/mqtt/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ Neuron MQTT 插件将采集到的数据以 JSON 形式发布到指定的主题

### 请求

通过发送 JSON 形式的请求到**写请求主题**参数指定的 MQTT 主题,您可以写一个点位数据。可在 MQTT 参数配置中配置写请求的主题,默认为为 **/neuron/{node_name}/write/req**
通过发送 JSON 形式的请求到**写请求主题**参数指定的 MQTT 主题,您可以写一个点位数据。可在 MQTT 参数配置中配置写请求的主题,默认为为 **/neuron/{random_str}/write/req**


#### 请求体
Expand Down Expand Up @@ -191,7 +191,7 @@ Neuron 提供了对多点位写入的支持。要在一次请求中可以写入

### 响应

写响应会发布到**写响应主题**参数指定的 MQTT 主题。默认**写响应主题**参数为 **/neuron/{node_name}/write/resp**
写响应会发布到**写响应主题**参数指定的 MQTT 主题。默认**写响应主题**参数为 **/neuron/{random_str}//write/resp**

#### 响应体

Expand All @@ -206,3 +206,41 @@ Neuron 提供了对多点位写入的支持。要在一次请求中可以写入
"error": 0
}
```

## 驱动状态上报

上报所有南向驱动状态到指定的 MQTT 主题。

### 状态上报主题

上报主题在北向节点配置中指定,其默认值为 **/neuron/{random_str}/state/update**

### 状态上报间隔

状态上报间隔在北向节点配置中指定,指每条消息之间间隔的秒数,其默认值为 1,允许的范围为 1-3600。

### 上报消息格式

上报的数据由以下字段构成:
* `timestamp` : 数据采集时的 UNIX 时间戳。
* `states` : 节点状态信息的数组。

以下是一个驱动状态上报消息样例。

```json
{
"timestamp": 1658134132237,
"states": [
{
"node": "modbus-tcp",
"link": 2,
"running": 3
},
{
"node": "modbus-rtu",
"link": 2,
"running": 3
}
]
}
```
8 changes: 6 additions & 2 deletions zh_CN/configuration/north-apps/mqtt/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ Neuron 支持 MQTT 插件作为其数据汇聚上报的方式之一,Neuron MQT

| 字段 | 说明 |
| ------------------ | ------------------------------------------------------------ |
| **MQTT 版本** | MQTT 协议的版本,默认为 v3.1.1。 |
| **客户端 ID** | MQTT 通信的客户端 id,必填。 |
| **QoS 等级** | MQTT 通信的服务质量等级,可选,默认为 QoS 0 。 |
| **上报数据格式** | 上报数据的 JSON 格式:<br />· *values-format*:数据被分成 `values``errors` 的子对象。<br />· *tags-format*:数据被放在一个数组中。关于通信数据格式,见 [数据上下行格式](./api.md#数据上报) |
| **写请求主题** | 接收点位写入请求的 MQTT 主题。关于通信数据格式,见 [数据上下行格式](./api.md#写-tag) |
| **写响应主题** | 发送点位写入响应的 MQTT 主题。 |
| **写请求主题** | 接收点位写入请求的 MQTT 主题。关于通信数据格式,见 [数据上下行格式](./api.md#写-tag)。如开启链路追踪,请按 W3C 标准配置用户属性 `traceparent``tracestate`|
| **写响应主题** | 发送点位写入响应的 MQTT 主题。 |
| **驱动状态上报** | 上报所有南向驱动状态到指定的 MQTT 主题。 |
| **状态上报主题** | 状态上报的主题。 |
| **状态上报间隔** | 上报南向节点状态的时间间隔,单位为秒,可填范围为 1-3600,默认1 |
| **离线缓存** | 离线缓存开关。连接断开时缓存 MQTT 消息,连接重建时同步缓存的消息到MQTT服务器。(2.4.3 版新增),关于离线缓存功能的详细介绍,见[离线数据缓存](#离线数据缓存) |
| **缓存内存大小** | 通信失败时内存消息缓存大小 (MB) 限制,必填;范围:[0, 1024],不能大于缓存磁盘大小。 |
| **缓存磁盘大小** | 通信失败时磁盘消息缓存大小 (MB) 限制,必填,范围:[0, 10240]。<br />设为非零值时,缓存内存大小 也须为非零值。 |
Expand Down

0 comments on commit 3889949

Please sign in to comment.