/etc/thingsboard-gateway/config - Configuration folder. tb_gateway.yaml - Main configuration file for Gateway. logs.conf - Configuration file for logging. modbus.json - Modbus connector configuration. mqtt.json - MQTT connector configuration. ble.json - BLE connector configuration. opcua.json - OPC-UA connector configuration. request.json - Request connector configuration. can.json - CAN connector configuration. ... /var/lib/thingsboard_gateway/extensions - Folder for custom connectors/converters. modbus - Folder for Modbus custom connectors/converters. mqtt - Folder for MQTT custom connectors/converters. __init__.py - Default python package file, needed for correct imports. custom_uplink_mqtt_converter.py - Custom Mqtt converter example. ... opcua - Folder for OPC-UA custom connectors/converters. ble - Folder for BLE custom connectors/converters. request - Folder for Request custom connectors/converters. can - Folder for CAN custom connectors/converters. /var/log/thingsboard-gateway - Logs folder connector.log - Connector logs. service.log - Main gateway service logs. storage.log - Storage logs. tb_connection.log - Logs for connection to the ThingsBoard instance.
主配置问及那用于连接到ThingsBoard平台实例和启用/禁用连接器。这配置文件只想ThingsBoard实例并使用配置为存储最多100000条记录的内存文件存储。有4个不同的连接器处于活动状态。如果您只想使用其中之一,只需移除所有其他连接器。
主配置文件样例:
thingsboard:
host: thingsboard.cloud
port: 1883
security:
accessToken: PUT_YOUR_ACCESS_TOKEN_HERE
storage:
type: memory
read_records_count: 100
max_records_count: 100000
connectors:
-
name: MQTT Broker Connector
type: mqtt
configuration: mqtt.json
-
name: Modbus Connector
type: modbus
configuration: modbus.json
-
name: Modbus Connector
type: modbus
configuration: modbus_serial.json
-
name: OPC-UA Connector
type: opcua
configuration: opcua.json
-
name: BLE Connector
type: ble
configuration: ble.json
-
name: CAN Connector
type: can
configuration: can.json
-
name: Custom Serial Connector
type: serial
configuration: custom_serial.json
class: CustomSerialConnector
安全子模块“security”
登录您的ThingsBoard平台来获取访问令牌。首先进入到设备选项卡(设备为网关的)
参数 | 默认值 | 描述 |
accessToken | PUT_YOUR_GW_ACCESS_TOKEN_HEAR | 来自ThingsBoard服务器的网关的访问令牌 |
安全子模块的配置如下所示:
...
security:
accessToken: PUT_YOUR_GW_ACCESS_TOKEN_HERE
...
参数 | 默认值 | 描述 |
accessToken | PUT_YOUR_GW_ACCESS_TOKEN_HEAR | 来自 ThingsBoard服务器的网关访问令牌 |
caCert | /etc/thingsboard-gateway/mqttserver.pub.pem | CA证书文件 |
安全子模块的配置如下所示:
security:
accessToken: PUT_YOUR_GW_ACCESS_TOKEN_HERE
caCert: /etc/thingsboard-gateway/mqttserver.pub.pem
参数 | 默认值 | 描述 |
caCert | /etc/thingsboard-gateway/ca.pem | CA证书文件 |
privateKey | /etc/thingsboard-gateway/privateKey.pem | 私钥文件 |
cert | /etc/thingsboard-gateway/certificate.pem | 证书文件 |
安全子模块的配置如下所示:
security:
privateKey: /etc/thingsboard-gateway/privateKey.pem
caCert: /etc/thingsboard-gateway/ca.pem
cert: /etc/thingsboard-gateway/certificate.pem
存储模块配置提供了在将传入数据发送到ThingsBoard平台之前保存传入数据的相关配置。其中有两种存储方式:内存和文件
1. 内存存储 - 接收到的数据存储到内存中
2. 文件存储 - 接收到的数据存储到硬盘中
参数 | 默认值 | 描述 |
type | memory | 存储类型(存储到内存) |
read_records_count | 10 | 从存储中获取并发送到ThingsBoard的消息数量 |
max_records_count* | 100 | 发送到ThingsBoard之前存储的最大数据量 |
备注:如果接收到的数据超过最大存储最大值,新的数据将会丢失
存储模块配置如下所示:
storage:
type: memory
read_records_count: 10
max_records_count: 1000
参数 | 默认值 | 描述 |
type | file | 存储类型(存储到硬盘) |
data_folder_path | ./data/ | 文件路径 |
max_file_count | 5 | 将会保存的最大文件数 |
max_read_records_count* | 6 | 从存储中获取并发送到ThingsBoard的消息数量 |
max_records_per_file | 14 | 每个文件存储的最大记录数 |
备注:如果接收到的数据超过最大存储最大值,新的数据将会丢失
存储模块的配置如下所示:
storage
type: file
data_folder_path: ./data/
max_file_count: 5
max_read_records_count: 6
max_records_per_file: 14
连接器配置
通过实现不同协议连接到设备的配置,每种连接器的配置参数如下表所示:
参数 | 默认值 | 描述 |
name | MQTT Broker Connector | 连接到broker的连接器名称 |
type | mqtt | 连接器类型 |
configuration | mqtt.json | 配置文件的名字 |
connectors:
-
name: MQTT Broker Connector
type: mqtt
configuration: mqtt.json
-
name: Modbus Connector
type: modbus
configuration: modbus.json
-
name: Modbus Connector
type: modbus
configuration: modbus_serial.json
-
name: OPC-UA Connector
type: opcua
configuration: opcua.json
-
name: BLE Connector
type: ble
configuration: ble.json
-
name: CAN Connector
type: can
configuration: can.json
-
name: Custom Serial Connector
type: serial
configuration: custom_serial.json
class: CustomSerialConnector