Last modified by Alec Chen on 2025/04/02 18:03

From version 4.1
edited by Alec Chen
on 2025/04/02 16:30
Change comment: There is no comment for this version
To version 6.1
edited by Alec Chen
on 2025/04/02 16:35
Change comment: There is no comment for this version

Summary

Details

Page properties
Title
... ... @@ -1,1 +1,1 @@
1 -How to communice Dragino -NB and -CB series devices data by MQTT with Thingseye
1 +How to connect -NB and -CB series devices data by MQTT with Thingseye
Content
... ... @@ -56,81 +56,6 @@
56 56  [[image:1743578461281-635.png]]
57 57  
58 58  
59 -
60 -
61 -The **Add data converter** window will appear.
62 -
63 -Let's create an uplink data converter for the device named '**Device A**'. Name it ‘**MQTT Uplink Converter - Device A**’ and select the Type as **Uplink**.
64 -
65 -Click on the **TBEL** button if it has not been selected by default.
66 -
67 -Modify the default TBEL function to match with your device as described below:
68 -
69 -* Uncomment** line 11**:
70 -
71 -//var data = decodeToJson(payload)//
72 -
73 -* **Line 13**: Assign your device name to the **deviceName** field. - We used **Device A** as it is to match with our device, **Device A **in the Devices section.
74 -* From **line 38**: Modify the telemetry section to allow parsed data to be assigned to the fields.
75 -
76 -//telemetry: {
77 - temperature: data.temperature,
78 - humidity: data.humidity,
79 - rawData: payloadStr
80 - }//
81 -
82 -The modified uplink decoder function to match with **Device A** is shown below.
83 -
84 -{{code language="nono"}}
85 -// Decode an uplink message from a buffer
86 -// payload - array of bytes
87 -// metadata - key/value object
88 -
89 -/** Decoder **/
90 -
91 -// decode payload to string
92 -var payloadStr = decodeToString(payload);
93 -
94 -// decode payload to JSON
95 -var data = decodeToJson(payload);
96 -
97 -var deviceName = 'Device A';
98 -var deviceType = 'thermostat';
99 -var customerName = 'Customer C';
100 -var groupName = 'thermostat devices';
101 -var manufacturer = 'Example corporation';
102 -// use assetName and assetType instead of deviceName and deviceType
103 -// to automatically create assets instead of devices.
104 -// var assetName = 'Asset A';
105 -// var assetType = 'building';
106 -
107 -// Result object with device/asset attributes/telemetry data
108 -var result = {
109 -// Use deviceName and deviceType or assetName and assetType, but not both.
110 -  deviceName: deviceName,
111 -   deviceType: deviceType,
112 -// assetName: assetName,
113 -// assetType: assetType,
114 -// customerName: customerName,
115 -  groupName: groupName,
116 -   attributes: {
117 -       model: 'Model A',
118 -       serialNumber: 'SN111',
119 -       integrationName: metadata['integrationName'],
120 -       manufacturer: manufacturer
121 -   },
122 -   telemetry: {
123 -       temperature: data.temperature,
124 -       humidity: data.humidity,
125 -       rawData: payloadStr
126 -   }
127 -};
128 -
129 -/** Helper functions 'decodeToString' and 'decodeToJson' are already built-in **/
130 -
131 -return result;
132 -{{/code}}
133 -
134 134  Once you modify the decoder function, click on the **Add** button.
135 135  
136 136  [[image:https://wiki.dragino.com/xwiki/bin/download/Main/ThingsBoard/ul-data-converter-device-a.png?width=500&height=524&rev=1.1||alt="ul-data-converter-device-a.png"]]