Wiki source code of TCP Connection Instruction

Version 25.2 by Xiaoling on 2023/01/06 17:21

Hide last authors
Xiaoling 16.9 1 **Table of Contents:**
Xiaoling 1.1 2
Xiaoling 16.12 3 (% aria-label="macro:toc widget" contenteditable="false" role="region" tabindex="-1" %)
4 (((
5 (% style="background-image:url(http://wiki.dragino.com/xwiki/webjars/wiki%3Axwiki/application-ckeditor-webjar/1.61/plugins/widget/images/handle.png); background:rgba(220,220,220,0.5); display:none" %)[[image:data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==||height="15" role="presentation" title="Click and drag to move" width="15"]]
6 )))
Xiaoling 16.2 7
Xiaoling 16.13 8 {{toc/}}
Xiaoling 16.2 9
Xiaoling 16.12 10
11
Xiaoling 1.2 12 = 1. Introduction =
Xiaoling 1.1 13
Xiaoling 16.16 14
Xiaoling 1.2 15 In the TCP IP Client mode, LoRa Gateway can accept LoRa or LoRaWAN packets and send it to the TCP/IP server.
Xiaoling 1.1 16
17
Xiaoling 16.11 18
Xiaoling 1.2 19 = 2. LoRaWAN Mode TCP Connection =
Xiaoling 1.1 20
Xiaoling 1.2 21 == 2.1 Support Hardware ==
Xiaoling 1.1 22
Xiaoling 16.16 23
Xiaoling 1.2 24 * [[LPS8>>url:http://www.dragino.com/products/lora-lorawan-gateway/item/148-lps8.html]]
25 * [[LG308>>url:http://www.dragino.com/products/lora-lorawan-gateway/item/140-lg308.html]], [[DLOS8>>url:http://www.dragino.com/products/lora-lorawan-gateway/item/160-dlos8.html]]
Xiaoling 1.1 26
Xiaoling 16.7 27
Xiaoling 25.2 28
Xiaoling 1.2 29 == 2.2 Typology & Instruction ==
Xiaoling 1.1 30
Xiaoling 16.16 31
Xiaoling 16.12 32 (% aria-label="image-20220527144058-1.png image widget" contenteditable="false" role="region" tabindex="-1" %)[[image:image-20220527144058-1.png||data-widget="image"]](% style="background-image:url(http://wiki.dragino.com/xwiki/webjars/wiki%3Axwiki/application-ckeditor-webjar/1.61/plugins/widget/images/handle.png); background:rgba(220,220,220,0.5); display:none" %)[[image:data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==||draggable="true" height="15" role="presentation" title="Click and drag to move" width="15"]](% title="Click and drag to resize" %)​
Xiaoling 1.1 33
Xiaoling 1.2 34 Network Structure
Xiaoling 1.1 35
36
Xiaoling 16.16 37 **[[Intrudctions>>Communicate with ABP End Node without LoRaWAN Network Server --- LG308||anchor="H4.Example2:CommunicatetoTCPServer"]]**
Xiaoling 1.1 38
Xiaoling 16.10 39
Xiaoling 16.16 40
Xiaoling 1.2 41 = 3. Raw LoRa Mode TCP Connection =
Xiaoling 1.1 42
Xiaoling 1.3 43 == 3.1 Support Hardware ==
Xiaoling 1.2 44
Xiaoling 16.16 45
Xiaoling 1.10 46 * [[LG01-N>>url:http://www.dragino.com/products/lora-lorawan-gateway/item/143-lg01n.html]], [[OLG01-N>>url:http://www.dragino.com/products/lora-lorawan-gateway/item/144-olg01n.html]]
47 * [[LG02>>url:http://www.dragino.com/products/lora-lorawan-gateway/item/135-lg02.html]], [[OLG02>>url:http://www.dragino.com/products/lora-lorawan-gateway/item/136-olg02.html]]
Xiaoling 1.2 48
Xiaoling 16.3 49
Xiaoling 25.2 50
Xiaoling 16.11 51 == 3.2 Typology ==
Xiaoling 16.10 52
53
Xiaoling 1.2 54 The working topology is as below. In this mode, The Uplink LoRa packets should use a customized format.
55
56
Xiaoling 16.16 57 (% aria-label="image-20220527144300-2.png image widget" contenteditable="false" role="region" tabindex="-1" %)[[image:image-20220527144300-2.png||data-widget="image"]](% title="Click and drag to resize" %)​
58
Xiaoling 1.2 59 TCP/IP Forward working topology
60
61
Xiaoling 1.3 62 == 3.3 Instruction Before Firmware lgw~-~-build-v5.4.1606631585-20201129-1434 ==
Xiaoling 1.2 63
Xiaoling 1.3 64 === 3.3.1 Select TCP-IP Client mode ===
Xiaoling 1.2 65
66
Xiaoling 16.16 67 (% aria-label="image-20220527144723-3.png image widget" contenteditable="false" role="region" tabindex="-1" %)[[image:image-20220527144723-3.png||data-widget="image"]](% title="Click and drag to resize" %)​
68
Xiaoling 1.2 69 Select TCP-IP Client mode
70
71
Xiaoling 1.3 72 === 3.3.2 Configure the Radio channel ===
Xiaoling 1.2 73
74
Xiaoling 16.16 75 (% aria-label="image-20220527144755-4.png image widget" contenteditable="false" role="region" tabindex="-1" %)[[image:image-20220527144755-4.png||data-widget="image"]](% title="Click and drag to resize" %)​
76
Xiaoling 1.2 77 Configure the Radio channel with the match radio settings frequency as the LoRa End Node
78
79
Xiaoling 1.3 80 === 3.3.3 Configure TCP Server Info ===
Xiaoling 1.2 81
82
Xiaoling 16.16 83 (% style="color:red" %)**Note: Gateway may receive many LoRa packets, it will only transfer the packet with the same ID as specify in the channel.**
Xiaoling 16.11 84
Xiaoling 16.16 85 (% aria-label="image-20220527144837-5.png image widget" contenteditable="false" role="region" tabindex="-1" %)[[image:image-20220527144837-5.png||data-widget="image"]](% title="Click and drag to resize" %)​
Xiaoling 1.2 86
87 Configure TCP Server Info
88
89
Xiaoling 1.6 90 === 3.3.4 About uplink data format from End Node ===
Xiaoling 1.2 91
Xiaoling 16.11 92
Xiaoling 1.2 93 The LoRa end node should upload the data with below format:
94
Xiaoling 1.5 95 (% class="box" %)
96 (((
Xiaoling 6.3 97 Uplink Format:** (% style="color:#4f81bd" %)<Channel_ID>data(%%)**
Xiaoling 1.5 98 For example, if we have configured 2 channels 12345 and 34567.
Xiaoling 1.2 99 And there is are three LoRa End nodes sending: 12345,34567,78
100 The LG02 will accept the data from 12345 and 34567, it will ignore the data from Node 78
Xiaoling 16.11 101 (% style="color:blue" %)**Case 1**:(%%)
Xiaoling 1.2 102 Node 12345 send <12345>field1=0.0&field2=1102.0
103 Node 34567 doesn’t send anyting
Xiaoling 1.5 104 The TCP/IP server will get {"12345":"field1=0.0&field2=1102.0"}
Xiaoling 16.11 105 (% style="color:blue" %)**Case 2**:(%%)
Xiaoling 1.2 106 Node 12345 send <12345>field1=0.0&field2=1102.0
107 Node 34567 send <34567>temp=34
Xiaoling 1.5 108 The TCP/IP server will get {"34567":"temp=34","12345":"field1=0.0&field2=1102.0"}
109 )))
Xiaoling 1.2 110
Xiaoling 16.16 111 (% aria-label="image-20220527144959-6.png image widget" contenteditable="false" role="region" tabindex="-1" %)[[image:image-20220527144959-6.png||data-widget="image"]](% title="Click and drag to resize" %)​
Xiaoling 1.2 112
113 Configure TCP Server Info
114
Xiaoling 16.12 115
Xiaoling 1.7 116 LoRa End Device reference source code: [[check this link>>url:https://github.com/dragino/Arduino-Profile-Examples/blob/master/libraries/Dragino/examples/IoTServer/ThingSpeak/MQTT_Client/MQTT_DHT11_Client_updata_to_ThingSpeak_/MQTT_DHT11_Client_updata_to_ThingSpeak_.ino]].
Xiaoling 1.2 117
118
Xiaoling 1.3 119 == 3.4 Instruction After Firmware lgw~-~-build~-~-v5.4.1612428704~-~-20210204-1653 ==
Xiaoling 1.2 120
Xiaoling 1.3 121 === 3.4.1 Configure the Radio channel ===
Xiaoling 1.2 122
Xiaoling 16.16 123
Xiaoling 16.12 124 (% aria-label="image-20220527145111-7.png image widget" contenteditable="false" role="region" tabindex="-1" %)[[image:image-20220527145111-7.png||data-widget="image"]](% style="background:url(~"http://wiki.dragino.com/xwiki/webjars/wiki%3Axwiki/application-ckeditor-webjar/1.61/plugins/widget/images/handle.png~") rgba(220, 220, 220, 0.5); left:0px; top:-15px" %)[[image:data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==||draggable="true" height="15" role="presentation" title="Click and drag to move" width="15"]](% title="Click and drag to resize" %)​
Xiaoling 1.2 125
126 Configure the Radio channel with the match radio settings frequency as the LoRa End Node
127
128
Xiaoling 1.4 129 === 3.4.2 Configure TCP Server Info ===
Xiaoling 1.2 130
Xiaoling 16.12 131
Xiaoling 16.16 132 (% style="color:red" %)**Note: Gateway will transfer the packet if they arrive in the right format .**
Xiaoling 1.2 133
Xiaoling 16.12 134 (% aria-label="image-20220527145151-8.png image widget" contenteditable="false" role="region" tabindex="-1" %)[[image:image-20220527145151-8.png||data-widget="image"]](% style="background:url(~"http://wiki.dragino.com/xwiki/webjars/wiki%3Axwiki/application-ckeditor-webjar/1.61/plugins/widget/images/handle.png~") rgba(220, 220, 220, 0.5); left:0px; top:-15px" %)[[image:data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==||draggable="true" height="15" role="presentation" title="Click and drag to move" width="15"]](% title="Click and drag to resize" %)​
Xiaoling 1.2 135
136 Configure TCP Server Info
137
138
Xiaoling 1.4 139 === 3.4.3 About uplink data format from End Node ===
Xiaoling 1.2 140
Xiaoling 16.16 141
Xiaoling 1.2 142 The LoRa end node should upload the data with below format:
143
Xiaoling 1.8 144 (% class="box" %)
145 (((
Xiaoling 9.3 146 Uplink Format: (% style="color:#4f81bd" %)**<Channel_ID>data**(%%)
Xiaoling 1.2 147 And there is a LoRa End node sending below packets:
148 *<12345>Hello From Sensor1
Xiaoling 1.8 149 )))
Xiaoling 1.2 150
151
Xiaoling 1.8 152 (% class="box" %)
153 (((
154 LG01/LG02 will uplink 12345:Hello From Sensor1 and usr can use logread -f to check the log.
155 Thu Feb  4 08:21:49 2021 user.notice iot_keep_alive: use WAN or WiFi for internet access now
156 Thu Feb  4 08:21:53 2021 daemon.info tcp_process.sh[18564]: /var/iot/channels/ CREATE 12345
157 Thu Feb  4 08:21:53 2021 user.notice root: [IoT.TCP]: Check for sensor update
158 Thu Feb  4 08:21:53 2021 user.notice root: [IoT.TCP]: Found Data at Local Channels: 12345
159 Thu Feb  4 08:21:53 2021 user.notice root: [IoT.TCP]:
160 Thu Feb  4 08:21:53 2021 user.notice root: [IoT.TCP]:~-~-~-~--
161 Thu Feb  4 08:21:53 2021 user.notice root: [IoT.TCP]:server: 10.130.2.149
162 Thu Feb  4 08:21:53 2021 user.notice root: [IoT.TCP]:port: 60000
163 Thu Feb  4 08:21:53 2021 user.notice root: [IoT.TCP]:decoder: LG01/LG02 Raw Data
164 Thu Feb  4 08:21:53 2021 user.notice root: [IoT.TCP]:tcp_data: 12345:Hello From Sensor1;
165 Thu Feb  4 08:21:53 2021 user.notice root: [IoT.TCP]:~-~-~-~-~-~-
166 )))
Xiaoling 1.2 167
168
169 and TCP server get:
170
Xiaoling 16.12 171 (% aria-label="image-20220527145304-9.png image widget" contenteditable="false" role="region" tabindex="-1" %)[[image:image-20220527145304-9.png||data-widget="image"]](% style="background-image:url(http://wiki.dragino.com/xwiki/webjars/wiki%3Axwiki/application-ckeditor-webjar/1.61/plugins/widget/images/handle.png); background:rgba(220,220,220,0.5); display:none" %)[[image:data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==||draggable="true" height="15" role="presentation" title="Click and drag to move" width="15"]](% title="Click and drag to resize" %)​
Xiaoling 1.2 172
173 TCP Server
174
Xiaoling 16.15 175
Xiaoling 1.8 176 LoRa End Device reference source code: [[check this link>>url:https://github.com/dragino/Arduino-Profile-Examples/blob/master/libraries/Dragino/examples/IoTServer/ThingSpeak/MQTT_Client/MQTT_DHT11_Client_updata_to_ThingSpeak_/MQTT_DHT11_Client_updata_to_ThingSpeak_.ino]].
Xiaoling 1.2 177
Xiaoling 1.8 178
Kilight Cao 22.1 179 == 3.5 Instruction After Firmware lgw~-~-build-v5.4.1668567157-20221116-1054 ==
Xiaoling 16.14 180
Kilight Cao 22.1 181 === 3.5.1 Configure the Frequency Plan ===
182
Xiaoling 25.2 183
Kilight Cao 22.1 184 [[image:image-20230105114141-1.png||height="539" width="1128"]]
185
186 Configure the Frequency Plan with the match radio settings frequency as the LoRa End Node
187
188
189 === 3.5.2 Configure TCP Server Info ===
190
191
192 (% style="color:red" %)**Note: Gateway will transfer the packet if they arrive in the right format.**
193
194 (% aria-label="image-20220527145151-8.png image widget" contenteditable="false" role="region" tabindex="-1" %)[[image:image-20220527145151-8.png||data-widget="image"]]
195
196
197 === 3.5.3 Configure ABP Decryption ===
198
199
200 (% style="color:red" %)**Note: The End Node devices must use ABP join network mode.**
201
202 [[image:image-20230105170545-2.png||height="577" width="1087"]]
203
204
205 === 3.5.3 About uplink data format from End Node ===
206
207
Kilight Cao 25.1 208 [[image:image-20230105171605-5.png||height="513" width="1084"]]
Kilight Cao 22.1 209
Xiaoling 25.2 210
Kilight Cao 25.1 211 [[image:image-20230105171235-4.png||height="480" width="523"]]
Kilight Cao 22.1 212
Xiaoling 25.2 213
Xiaoling 1.4 214 = 4. Reference =
Xiaoling 1.2 215
Xiaoling 16.16 216
Xiaoling 1.2 217 Set up a TCP/IP server use node.js: [[Reference Link>>url:http://www.dragino.com/downloads/index.php?dir=LoRa_Gateway/LG02-OLG02/Firmware/customized_script/&file=node_tcp_server.txt]]
Xiaoling 25.2 218
219
220
221