Last modified by Hera Guo on 2025/09/25 09:23

From version 9.1
edited by Chxy
on 2024/10/10 21:20
Change comment: There is no comment for this version
To version 23.1
edited by Hera Guo
on 2025/09/25 09:18
Change comment: There is no comment for this version

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.EdwinChen
1 +XWiki.hera
Content
... ... @@ -7,6 +7,7 @@
7 7  
8 8  = 1. Overview =
9 9  
10 +This instructions will show you how to connect a device that has been registered to the server to the Thingseye platform.
10 10  
11 11  
12 12  = 2. UDP Procotol  ~-~- Directly Connection =
... ... @@ -14,34 +14,21 @@
14 14  == 2.1 UDP Interface ==
15 15  
16 16  * Server Address: server1.thingseye.io
17 -* Port: 11562
18 +* Port: 11560
18 18  
19 19  The data sent to above UDP interface will not go directly to client's database.
20 20  
21 21  Please contact ThingsEye team for detail how to forward data to client.
22 22  
24 +**Note:Currently udp connections require port forwarding, please contact the ThingsEye team to inform them of your device's IMEI before connecting.**
23 23  
24 -== 2.2 Test UDP Interface via Socket Tool ==
25 25  
26 -Download the UDP Test Tool from:  [[https:~~/~~/sourceforge.net/projects/sockettest/ >>https://sourceforge.net/projects/sockettest/]]. Run this tool, and input the server address and UDP port  as below and click send.
27 +----
27 27  
28 -[[image:1728566363151-470.png]]
29 +== 2.2 Test with Dragino NB device ==
29 29  
30 -In server side, Tenant Administrator can check this in Tenant UDP Server location.
31 +=== 2.2.1 Configure NB-IoT End Node ===
31 31  
32 -[[image:1728362834430-749.png||height="510" width="1667"]]
33 -
34 -Click and see the debug info as below:
35 -
36 -[[image:1728363020699-203.png]]
37 -
38 -We can see the message arrives, but it shows ERROR because the message doesn't follow with the UDP Server format.
39 -
40 -
41 -== 2.3 Test with Dragino NB device ==
42 -
43 -=== 2.3.1 Configure NB-IoT End Node ===
44 -
45 45  Device here is **[[S31-NB>>https://www.dragino.com/products/temperature-humidity-sensor/item/288-s31-nb-s31b-nb.html]]** : and have been configure below
46 46  
47 47  * Set to use ThingsEye UDP server: **AT+SERVADDR=server1.thingseye.io,11560**
... ... @@ -50,156 +50,75 @@
50 50  
51 51  The S31-NB's cellular module has the IMEI: **863663062789483**
52 52  
41 +=== 2.2.2 Check Uplink Data ===
53 53  
54 -=== 2.3.2 Check Uplink Data ===
43 +Turn on debug mod
55 55  
45 +[[image:1758762334133-608.png||height="494" width="1003"]]
46 +
47 +----
48 +
56 56  Re-activate the S31-NB, and we can see it in the debug window:
57 57  
58 -[[image:1728378218744-800.png||height="431" width="1003"]]
51 +[[image:1758762371290-726.png||height="528" width="1005"]]
59 59  
53 +[[image:1728378218744-800.png||_mstalt="295269" height="431" width="1003"]]
60 60  
61 -=== 2.3.3 Auto-Create Device ===
55 +----
62 62  
57 +=== 2.2.4 Auto-Create Device ===
58 +
63 63  The default **Tenant UDP Server** has already been configured to decode the Dragino -NB / -CB NB-IoT node. So once each end node sends a data to server. Tenant will auto create the device in the server.
64 64  
65 -[[image:1728378968101-683.png||height="273" width="1307"]]
61 +[[image:1728378968101-683.png||_mstalt="297154" height="210" width="1005"]]
66 66  
67 -[[image:1728379050044-764.png||height="424" width="1312"]]
63 +[[image:1728379050044-764.png||_mstalt="295282" height="326" width="1009"]]
68 68  
69 69  
70 -**So we have this device in the Tenant Device List. The next step will be how to use these value to make a nice dashboard for user's application.**
66 +----
71 71  
68 += 3.  Connect to The Things Stack =
72 72  
70 +== 3.1 Network Structure ==
73 73  
74 -= 2.  Connect to The Things Stack =
72 +The network diagram below illustrates the connection between the devices and The Things Stack, as well as how the data can be integrated with the ThingsEye IoT platform.
75 75  
76 -== 2.1 Network Structure ==
74 +[[image:1732679444539-853.jpg||_mstalt="296933" height="388" width="1452"]]
77 77  
76 +== 3.2 Creat Integration for The Things Stack. ==
78 78  
79 -== 2.2 Creat Integration for The Things Stack. ==
80 -
81 81  (% class="lead" %)
82 82  Add Integration
83 83  
84 -[[image:1728535775119-971.png||height="456" width="1087"]]
81 +[[image:1728535775119-971.png||_mstalt="297661" height="423" width="1007"]]
85 85  
86 86  
87 87  (% class="lead" %)
88 88  Choose Connection Type
89 89  
90 -[[image:1728535857345-950.png]]
87 +[[image:1728535857345-950.png||_mstalt="297154" height="257" width="403"]]
91 91  
92 92  
93 93  (% class="lead" %)
94 94  Input Uplink Data Converter Code
95 95  
96 -[[image:1728535941851-388.png||height="466" width="398"]]
93 +[[image:1728535941851-388.png||_mstalt="297856" height="466" width="398"]]
97 97  
98 -Demo Code as below:
95 +Demo JavaScript Code: [[https:~~/~~/raw.githubusercontent.com/ThingsEye-io/te-platform/refs/heads/main/Data%20Converters/The_Things_Network_MQTT_Uplink_Converter.js >>https://raw.githubusercontent.com/ThingsEye-io/te-platform/refs/heads/main/Data%20Converters/The_Things_Network_MQTT_Uplink_Converter.js]]
99 99  
100 ->var data = decodeToJson(payload);
101 ->var deviceName = data.end_device_ids.device_id;
102 ->var deviceType = data.end_device_ids.application_ids.application_id;
103 ->var model = {};
104 ->var data2 = data.uplink_message.decoded_payload;
105 ->var flg = data.uplink_message.f_port
106 ->for (var key in data2) {
107 -> model[key] = data2[key];
108 ->}
109 ->var obj =  {"devid":deviceName}
110 ->var result = {
111 -> deviceName: deviceName,
112 -> deviceType: deviceType,
113 -> telemetry: model,
114 -> groupName: "Case Study",
115 -> attributes:{"devid":deviceName,
116 -> "timevalue":"test",
117 -> "inactivityTimeout":1260000
118 -> }
119 ->};
120 ->function decodeToString(payload) {
121 -> return String.fromCharCode.apply(String, payload);
122 ->}function decodeToJson(payload) {
123 -> var str = decodeToString(payload);
124 -> var data = JSON.parse(str);
125 -> return data;
126 ->}
127 ->if (flg===2){
128 ->return result;
129 ->}
130 130  
131 -
132 132  (% class="lead" %)
133 133  Input Downlink Converter
134 134  
135 -[[image:1728536142721-488.png||height="470" width="407"]]
101 +[[image:1728536142721-488.png||_mstalt="296127" height="470" width="407"]]
136 136  
137 -Example Code as below:
103 +Example Javascript Code as below: [[https:~~/~~/raw.githubusercontent.com/ThingsEye-io/te-platform/refs/heads/main/Data%20Converters/The_Things_Network_MQTT_Downlink_Converter.js>>https://raw.githubusercontent.com/ThingsEye-io/te-platform/refs/heads/main/Data%20Converters/The_Things_Network_MQTT_Downlink_Converter.js]]
138 138  
139 ->function hexToBase64(hexString) {
140 -> var bytes = hexString.match(/.{2}/g);
141 -> var binaryString = bytes.map(function(byte) {
142 -> return String.fromCharCode(parseInt(byte, 16));
143 -> }).join('');
144 ->
145 -> return btoa(binaryString);
146 ->}
147 ->var flg = "shared_value" in metadata
148 ->var value2 = parseInt(metadata.ss_timevalue).toString(16)if (value2.length==1){
149 -> value2 = "00000"+parseInt(metadata.ss_timevalue).toString(16)
150 ->}
151 ->else if (value2.length==2){
152 -> value2 = "0000"+parseInt(metadata.ss_timevalue).toString(16)
153 ->}
154 ->else if (value2.length==3){
155 -> value2 = "000"+parseInt(metadata.ss_timevalue).toString(16)
156 ->}
157 ->else if (value2.length==4){
158 -> value2 = "00"+parseInt(metadata.ss_timevalue).toString(16)
159 ->}
160 ->else if (value2.length==5){
161 -> value2 = "0"+parseInt(metadata.ss_timevalue).toString(16)
162 ->}
163 ->else {
164 -> value2 = value2
165 ->}
166 ->var data = "01"+value2
167 ->if (flg === true){
168 ->data = {
169 -> downlinks: [{
170 -> f_port: 1,
171 -> confirmed: false,
172 -> frm_payload: hexToBase64(metadata.shared_value),
173 -> priority: "NORMAL"
174 -> }]
175 -> };
176 ->}
177 ->else{
178 -> data = {
179 -> downlinks: [{
180 -> f_port: 1,
181 -> confirmed: false,
182 -> frm_payload: hexToBase64(data),
183 -> priority: "NORMAL"
184 -> }]
185 -> };
186 ->}
187 ->var result = {
188 -> contentType: "JSON",
189 -> data: JSON.stringify(data),
190 -> metadata: {
191 -> devId: metadata.ss_devid
192 -> }
193 ->};
194 ->if (metadata.shared_timevalue!=="test" || metadata.ss_timevalue!=="test"){
195 ->return result;
196 ->}
197 197  
198 -
199 199  (% class="lead" %)
200 200  Set up Connection to The Things Network application
201 201  
202 -[[image:1728536305503-380.png||height="510" width="1206"]]
109 +[[image:1728536305503-380.png||_mstalt="293254" height="431" width="1019"]]
203 203  
204 204  
205 205  
... ... @@ -206,18 +206,230 @@
206 206  (% class="lead" %)
207 207  Test Connection & Add iIntegration
208 208  
209 -[[image:1728536374214-962.png]]
116 +[[image:1728536374214-962.png||_mstalt="295893" height="380" width="1024"]]
210 210  
211 211  After add , we can see the integration here:
212 212  
213 -[[image:1728536420275-153.png||height="208" width="1404"]]
120 +[[image:1728536420275-153.png||_mstalt="293748" height="152" width="1026"]]
214 214  
215 215  
216 -== 2.3 Test Uplink ==
123 +== 3.3 Test Uplink ==
217 217  
218 218  We can use Simulate Uplink to simulate an uplink in the things stack. Then we should be able to see the message in ThingsEye
219 219  
220 -[[image:1728536524638-768.png||height="493" width="1071"]]
127 +[[image:1728536524638-768.png||_mstalt="298870" height="473" width="1028"]]
221 221  
222 222  
223 -[[image:1728536541040-814.png]]
130 +[[image:1728536541040-814.png||_mstalt="293215" height="424" width="1026"]]
131 +
132 +
133 +
134 += 4.Connect chirpstack to Thingseye by way of MQTT =
135 +
136 +* **How to connect chirpstack to Thingseye by way of MQTT? The following tutorial will show you**
137 +
138 +== 4.1 Network Structure ==
139 +
140 +The network diagram below illustrates the connection between the devices andchirpstack, as well as how the data can be integrated with the ThingsEye IoT platform.
141 +
142 +[[image:1732679647697-982.jpg||_mstalt="299884" height="399" width="1492"]]
143 +
144 +== 4.2 Thingseye adds MQTT integration ==
145 +
146 +Go to the Integrations page in the Integrations center section. Click the plus button to start adding a new integration. Select the type "MQTT" integration and click "Next";
147 +
148 +[[image:1758762634175-353.png||height="783" width="1020"]]
149 +
150 +== 4.3 Add an uplink and downlink data converter ==
151 +
152 +In the function decoder field, specify the uplink script to parse and transform the data.
153 +
154 +[[image:1758763061703-634.png||height="783" width="1020"]]
155 +
156 +* **Uplink——JavaScript:**
157 +
158 +var data = decodeToJson(payload);
159 +
160 +var deviceName = data.deviceInfo.deviceName;
161 +
162 +var deviceType = data.applicationName;
163 +
164 +var devEui = data.deviceInfo.devEui
165 +
166 +var label = data.deviceInfo.devEui
167 +
168 +var model = {};
169 +
170 +var data2 = data.object;
171 +
172 +var flg = data.fPort
173 +
174 +for (var key in data2) {
175 +
176 + ~/~/ 将属性名存入新对象中
177 +
178 + model[key] = data2[key];
179 +
180 +}
181 +
182 +~/~/var obj = {"devid":deviceName}
183 +
184 +var result = {
185 +
186 + deviceName: deviceName,
187 +
188 + deviceType: deviceType,
189 +
190 + telemetry: model,
191 +
192 + groupName: "Case Study",
193 +
194 + ~/~/label:label,
195 +
196 + attributes:{"devEui":devEui,
197 +
198 + ~/~/"timevalue":"test",
199 +
200 + "inactivityTimeout":1260000
201 +
202 + ~/~/ "High_humidity_alarm":"not set",
203 +
204 + ~/~/ "High_temperature_alarm":"not set",
205 +
206 + ~/~/ "Low_humidity_alarm":"not set",
207 +
208 + ~/~/ "Low_temperature_alarm":"not set",
209 +
210 + ~/~/ "Low_voltage_alarm":"not set"
211 +
212 + ~/~/"customerName": "Civionic Engineering & Consulting (2014) Inc."
213 +
214 + }
215 +
216 +};
217 +
218 +function decodeToString(payload) {
219 +
220 + return String.fromCharCode.apply(String, payload);
221 +
222 +}
223 +
224 +function decodeToJson(payload) {
225 +
226 + var str = decodeToString(payload);
227 +
228 + var data = JSON.parse(str);
229 +
230 + return data;
231 +
232 +}
233 +
234 +return result;
235 +
236 +----
237 +
238 +In the function decoder field, specify the downlink script to parse and transform the data.
239 +
240 +[[image:1758763019466-819.png||height="787" width="1022"]]
241 +
242 +* **Dowblink——JavaScript:**
243 +
244 +~/~/ Encode downlink data from incoming Rule Engine message
245 +
246 +~/~/ msg - JSON message payload downlink message json
247 +
248 +~/~/ msgType - type of message, for ex. 'ATTRIBUTES_UPDATED', 'POST_TELEMETRY_REQUEST', etc.
249 +
250 +~/~/ metadata - list of key-value pairs with additional data about the message
251 +
252 +~/~/ integrationMetadata - list of key-value pairs with additional data defined in Integration executing this converter
253 +
254 +~/~/ /~*~* Encoder ~*~*/
255 +
256 +~/~/var data = {"value":99};
257 +
258 +~/~/ ~/~/ Process data from incoming message and metadata
259 +
260 +~/~/ data.tempFreq = msg.temperatureUploadFrequency;
261 +
262 +~/~/ data.humFreq = msg.humidityUploadFrequency;
263 +
264 +~/~/ data.devSerialNumber = metadata['ss_serialNumber'];
265 +
266 +~/~/ ~/~/ Result object with encoded downlink payload
267 +
268 +var result = {
269 +
270 + ~/~/ downlink data content type: JSON, TEXT or BINARY (base64 format)
271 +
272 + contentType: "TEXT",
273 +
274 + ~/~/ downlink data
275 +
276 + data: msg.shared_value ,~/~/JSON.stringify(data),
277 +
278 + ~/~/ Optional metadata object presented in key/value format
279 +
280 + metadata: {
281 +
282 + topic: '/test/down/'+metadata.deviceName
283 +
284 + }
285 +
286 +};
287 +
288 +return result;
289 +
290 +----
291 +
292 +== 4.4 Configure the connection ==
293 +
294 +Generate MQTT certificate integrated on chirpstack
295 +
296 +Chirpstack generates CA certificate, TLS certificate, and TLS key respectively
297 +
298 +They correspond to the CA certificate file, Certificate file, and Private key file on thingseye
299 +
300 +[[image:图片4.png||_mstalt="5131737" height="504" width="1016"]]
301 +
302 +[[image:图片5.png||_mstalt="5131854" height="505" width="1017"]]
303 +
304 +* Copy the contents of the certificates and paste them into the linked file below, a total of three certificates are required
305 +
306 +**Integrated Certificate File demo Download Address:**
307 +
308 +[[https:~~/~~/github.com/ThingsEye-io/te-platform/tree/main/chirpstack>>https://github.com/ThingsEye-io/te-platform/tree/main/chirpstack]]
309 +
310 +Enter the server address Host: lns1.thingseye.io on the Connection configuration
311 +
312 +Port: 8883
313 +
314 +Credentials type: PEM
315 +
316 +Upload the certificate and key file
317 +
318 +[[image:图片6.png||_mstalt="5131971"]]
319 +
320 +[[image:图片7.png||_mstalt="5132088"]]
321 +
322 +The default for Topic is:
323 +
324 +application/**chirpstack application id**/device/+/event/up
325 +
326 +[[image:图片8.png||_mstalt="5132205"]]
327 +
328 +
329 +(% class="wikigeneratedid" %)
330 +[[image:屏幕截图 2024-11-25 095805.png||_mstalt="10831028" height="374" width="1272"]]
331 +
332 +== 4.5 Check the connection ==
333 +
334 +[[image:图片9.png||_mstalt="5132322"]]
335 +
336 +[[image:图片10.png||_mstalt="5142449"]]
337 +
338 += 5. Check Data Uplink Log =
339 +
340 +User can check the devices log in Intergration.
341 +
342 +[[image:1729562069134-315.png||_mstalt="294190" height="587" width="723"]]
1729562069134-315.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.EdwinChen
Size
... ... @@ -1,0 +1,1 @@
1 +67.5 KB
Content
1732678750938-753.jpg
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.hera
Size
... ... @@ -1,0 +1,1 @@
1 +173.5 KB
Content
1732679080974-799.jpg
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.hera
Size
... ... @@ -1,0 +1,1 @@
1 +176.4 KB
Content
1732679444539-853.jpg
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.hera
Size
... ... @@ -1,0 +1,1 @@
1 +180.5 KB
Content
1732679647697-982.jpg
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.hera
Size
... ... @@ -1,0 +1,1 @@
1 +179.2 KB
Content
1758762334133-608.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.hera
Size
... ... @@ -1,0 +1,1 @@
1 +161.4 KB
Content
1758762371290-726.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.hera
Size
... ... @@ -1,0 +1,1 @@
1 +215.2 KB
Content
1758762634175-353.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.hera
Size
... ... @@ -1,0 +1,1 @@
1 +213.8 KB
Content
1758762919291-489.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.hera
Size
... ... @@ -1,0 +1,1 @@
1 +209.4 KB
Content
1758763019466-819.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.hera
Size
... ... @@ -1,0 +1,1 @@
1 +227.9 KB
Content
1758763061703-634.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.hera
Size
... ... @@ -1,0 +1,1 @@
1 +222.0 KB
Content
图片1.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.hera
Size
... ... @@ -1,0 +1,1 @@
1 +123.1 KB
Content
图片10.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.hera
Size
... ... @@ -1,0 +1,1 @@
1 +173.4 KB
Content
图片2.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.hera
Size
... ... @@ -1,0 +1,1 @@
1 +163.3 KB
Content
图片3.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.hera
Size
... ... @@ -1,0 +1,1 @@
1 +124.8 KB
Content
图片4.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.hera
Size
... ... @@ -1,0 +1,1 @@
1 +68.8 KB
Content
图片5.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.hera
Size
... ... @@ -1,0 +1,1 @@
1 +98.5 KB
Content
图片6.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.hera
Size
... ... @@ -1,0 +1,1 @@
1 +136.5 KB
Content
图片7.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.hera
Size
... ... @@ -1,0 +1,1 @@
1 +143.5 KB
Content
图片8.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.hera
Size
... ... @@ -1,0 +1,1 @@
1 +151.0 KB
Content
图片9.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.hera
Size
... ... @@ -1,0 +1,1 @@
1 +134.6 KB
Content
屏幕截图 2024-11-25 095805.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.hera
Size
... ... @@ -1,0 +1,1 @@
1 +45.7 KB
Content
屏幕截图 2024-11-27 113616.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.hera
Size
... ... @@ -1,0 +1,1 @@
1 +117.5 KB
Content