NDU Gateway

Integrate legacy and third-party systems with NDU platform using IoT Gateway.

IoT Gateway Configuration

Directory structure

Please see default directory structure below for daemon installation.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/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 NDU instance.

General configuration file

The main configuration file that is used for connection to NDU platform instance and enable/disable connectors. This configuration points to NDU instance smartapp.netcad.com and uses memory file storage configured to store maximum of 100,000 records. There are 4 different connectors active. If you like to use only one of them - just remove all other connectors.


Example of main configuration file. Press to show.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
thingsboard:
  host: smartapp.netcad.com
  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
Spaces identity are important.

Sections in config file

Connection to NDU

Parameter Default value Description
thingsboard   Configuration for connection to server.
host 127.0.0.1 Hostname or ip address of NDU server.
port 1883 Port of mqtt service on NDU server.
Subsection “security”

There are 3 variants of security subsection:

One type of security configuration is accessToken, to get it you should login into your NDU platform instance, go to DEVICE tab, press the plus icon, fill the values and check the “Is gateway” option, open this device and press the “COPY ACCESS TOKEN” button and replace default with your value

Parameter Default value Description
accessToken PUT_YOUR_GW_ACCESS_TOKEN_HERE Access token for the gateway from NDU server.

Security subsection in configuration file will look like this:

1
2
3
4
...
  security:
    accessToken: PUT_YOUR_GW_ACCESS_TOKEN_HERE
...

In table below described parameters to configure authorization of IoT gateway on NDU platform.

Parameter Default value Description
accessToken PUT_YOUR_GW_ACCESS_TOKEN_HERE Access token for the gateway from NDU server.
caCert /etc/thingsboard-gateway/mqttserver.pub.pem Path to CA certificate file.

Security subsection in configuration file will look like this:

1
2
3
  security:
    accessToken: PUT_YOUR_GW_ACCESS_TOKEN_HERE
    caCert: /etc/thingsboard-gateway/mqttserver.pub.pem

In table below described parameters to configure authorization of IoT gateway on NDU platform.

Parameter Default value Description
caCert /etc/thingsboard-gateway/ca.pem Path to CA file.
privateKey /etc/thingsboard-gateway/privateKey.pem Path to private key file.
cert /etc/thingsboard-gateway/certificate.pem Path to certificate file.

Security subsection in configuration file will look like this:

1
2
3
4
  security:
    privateKey: /etc/thingsboard-gateway/privateKey.pem
    caCert: /etc/thingsboard-gateway/ca.pem
    cert: /etc/thingsboard-gateway/certificate.pem

Storage configuration

Configs in storage subsection provides configuration for saving incoming data before it will be send to NDU platform.

There are 2 variants for this section: memory or file.

  1. Memory storage - Received data saving to the RAM memory.
  2. File storage - Received data saving to the hard drive.
Parameter Default value Description
type memory Storage type (Saving data to RAM, no save to hard drive).
read_records_count 10 Count of messages to get from storage and send to NDU.
max_records_count * 100 Maximum count of data in storage before send to NDU.

* – If receive data when storage has already counted, described in this parameter, new data will lose.

Storage section of configuration file will look like:

1
2
3
4
storage:
  type: memory
  read_records_count: 10
  max_records_count: 1000
Parameter Default value Description
type file Storage type (Saving data to hard drive)
data_folder_path ./data/ Path to folder, that will contains data (Relative or Absolute).
max_file_count 5 Maximum count of file that will be saved.
max_read_records_count * 6 Count of messages to get from storage and send to NDU.
max_records_per_file 14 Maximum count of records that will be stored in one file.

* – If receive data when storage has already counted, described in this parameter, new data will lose.

Storage section of configuration file will look like:

1
2
3
4
5
6
storage
  type: file
  data_folder_path: ./data/
  max_file_count: 5
  max_read_records_count: 6
  max_records_per_file: 14

Connectors configuration

Configs in connectors section configuration for connecting to devices by implemented protocols. Config for every connector in this section must have parameters as in table below:

Parameter Default value Description
name MQTT Broker Connector Name of connector to broker.
type mqtt Type of connector, must be like a name of folder, contained configuration file.
configuration mqtt.json Name of the file with configuration in config folder.*

* – Folder with this configuration file.

Section connectors in your configuration file may differ from shown below, but they should have structure like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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

Note: You can use several similar connectors at same time, but you should provide different names and configuration files to them.

If you need different type of connector, you can implement it using customization guide or email us: info@thingsboard.io.