Wiki source code of Add GPS Support in LG308N / LPS8v2
Last modified by Edwin Chen on 2023/12/22 21:40
Hide last authors
author | version | line-number | content |
---|---|---|---|
9.1 | 1 | **Table of Contents:** | |
2 | |||
3 | {{toc/}} | ||
4 | |||
5 | |||
1.8 | 6 | ((( | |
9.1 | 7 | = 1. Introduction = | |
5.2 | 8 | ||
9 | ---- | ||
10 | |||
8.1 | 11 | It is possible to GPS supports in LG308N-EC25 version and LPS8v2-EC25 version so device will add location info to uplink packet to LoRaWAN server. | |
1.8 | 12 | ))) | |
1.1 | 13 | ||
5.2 | 14 | ||
23.1 | 15 | = 2. Connect GPS Antenna to Cellular modules = | |
8.1 | 16 | ||
22.1 | 17 | Connect GNSS port to GPS antenna. The connector type is i-pex connector, please make sure the GPS antenna can be extended outdoor for GPS signal. | |
18.1 | 18 | ||
22.1 | 19 | **For LPS8v2:** | |
20 | |||
21 | [[image:image-20231208153214-1.png||height="426" width="590"]] | ||
22 | |||
23 | |||
24 | **For LG308N:** | ||
25 | |||
26 | [[image:image-20220527160148-2.png]] | ||
27 | |||
28 | |||
29 | = 3. Use Cellular Module GPS feature for LoRaWAN Timing. = | ||
30 | |||
31 | == 3.1 Configure on LG308N / LPS8N == | ||
32 | |||
1.8 | 33 | ((( | |
5.2 | 34 | (% style="color:blue" %)**Below are the steps:** | |
1.8 | 35 | ))) | |
1.1 | 36 | ||
1.8 | 37 | ((( | |
5.2 | 38 | **~1. Open the box and connect GPS antenna to GNSS port of EC25** | |
1.8 | 39 | ))) | |
1.1 | 40 | ||
5.2 | 41 | **2. modify the two files:** | |
1.1 | 42 | ||
1.9 | 43 | ((( | |
1.2 | 44 | /etc/chatscripts/3g.chat | |
1.9 | 45 | ))) | |
1.1 | 46 | ||
1.3 | 47 | (% class="box" %) | |
48 | ((( | ||
49 | ABORT BUSY | ||
50 | ABORT 'NO CARRIER' | ||
51 | ABORT ERROR | ||
52 | REPORT CONNECT | ||
1.2 | 53 | TIMEOUT 10 | |
1.3 | 54 | "" "AT&F" | |
55 | OK "ATE1" | ||
4.1 | 56 | (% style="color:red" %)**OK "AT+QGPS=1" ~-~-> Add this line, so EC25 module GPS will be enable when dial up**(%%) | |
1.3 | 57 | (% style="color:black" %)OK 'AT+CGDCONT=1,"IP","$USE_APN"' | |
58 | SAY "Calling UMTS/GPRS" | ||
1.2 | 59 | TIMEOUT 30 | |
1.3 | 60 | OK "ATD$DIALNUMBER" | |
1.2 | 61 | CONNECT ' ' | |
1.3 | 62 | ))) | |
1.1 | 63 | ||
7.2 | 64 | ||
1.8 | 65 | ((( | |
6.2 | 66 | (% style="color:red" %)**Note: **(%%)**After above settings, the GPS will be enable when dial up, if user doesn't use Cellular for Internet access, above script won't execute, in this case, user can (% style="color:red" %)run "echo AT+QGPS=1 > /dev/ttyUSB2" (%%)to (% style="color:blue" %)enable GPS /usr/bin/generate-config.sh,(%%) after configure this, in the web page, select any frequency band and save to make this take affect.** | |
1.8 | 67 | ))) | |
1.1 | 68 | ||
7.2 | 69 | ||
1.3 | 70 | (% class="box" %) | |
71 | ((( | ||
1.9 | 72 | ((( | |
4.2 | 73 | ((( | |
1.3 | 74 | gen_gw_cfg() { | |
1.2 | 75 | json_init | |
76 | json_add_object gateway_conf | ||
77 | json_add_string "gateway_ID" "$gwid" | ||
78 | json_add_string "server_address" "$server" | ||
79 | json_add_int "serv_port_up" "$upp" | ||
80 | json_add_int "serv_port_down" "$dpp" | ||
81 | json_add_int "stat_interval" "$stat" | ||
82 | json_add_boolean "forward_crc_valid" 1 | ||
83 | json_add_boolean "forward_crc_error" 0 | ||
4.2 | 84 | ))) | |
85 | |||
86 | ((( | ||
87 | (% style="color:red" %)**json_add_string "gps_tty_path" "/dev/ttyUSB1" ~-~-~-~--> Add this line so lora program knows to get the gps info from EC25** | ||
88 | ))) | ||
89 | |||
90 | ((( | ||
1.8 | 91 | (% style="color:black" %) json_close_object | |
4.2 | 92 | json_dump > /etc/lora/local_conf.json(%%) | |
93 | (% style="color:black" %)**}** | ||
1.3 | 94 | ))) | |
1.9 | 95 | ))) | |
4.2 | 96 | ))) | |
1.1 | 97 | ||
7.2 | 98 | ||
1.8 | 99 | ((( | |
5.2 | 100 | **3. Reboot the device and run logread -f to verify if GPS already works.** | |
1.8 | 101 | ))) | |
1.1 | 102 | ||
1.3 | 103 | (% class="box" %) | |
104 | ((( | ||
4.3 | 105 | Fri Mar 6 04:08:59 2020 daemon.info lora_pkt_fwd[3016]: (% style="color:red" %)**INFO~~ GPS serial port path is configured to "/dev/ttyUSB1"**(%%) | |
1.3 | 106 | Fri Mar 6 04:08:59 2020 daemon.info lora_pkt_fwd[3016]: INFO~~ [main] TTY port /dev/ttyUSB1 open for GPS synchronization | |
107 | Fri Mar 6 04:09:00 2020 cron.err crond[1689]: time disparity of 4301528 minutes detected | ||
108 | Fri Mar 6 04:09:00 2020 daemon.info lora_pkt_fwd[3016]: INFO~~ sockfd=4 | ||
109 | Fri Mar 6 04:09:00 2020 daemon.info lora_pkt_fwd[3016]: INFO~~ sockfd=5 | ||
110 | Fri Mar 6 04:09:00 2020 daemon.info lora_pkt_fwd[3016]: INFO~~ FPort Filter: 0 | ||
111 | Fri Mar 6 04:09:00 2020 daemon.info lora_pkt_fwd[3016]: INFO~~ DevAddrMask: 0x0 | ||
112 | Fri Mar 6 04:09:34 2020 daemon.info lora_pkt_fwd[3016]: INFO: [jit] queue is empty | ||
4.3 | 113 | Fri Mar 6 04:09:34 2020 daemon.info lora_pkt_fwd[3016]: STAT~~ {"stat":{"time":"2020-03-06 04:09:34 UTC"**,(% style="color:red" %)"lati":22.70627,"long":114.24277,"alti":58,(%%)** | |
1.3 | 114 | (% style="color:black" %)"rxnb":0,"rxok":0,"rxfw":0,"ackr":0.0,"dwnb":0,"txnb":0}} | |
115 | Fri Mar 6 04:09:35 2020 daemon.info lora_pkt_fwd[3016]: INFO~~ [up] PUSH_ACK received in 293 ms | ||
116 | Fri Mar 6 04:09:35 2020 daemon.info lora_pkt_fwd[3016]: INFO~~ [down] PULL_ACK received in 596 ms | ||
117 | ))) | ||
8.1 | 118 | ||
119 | |||
22.1 | 120 | == 3.2. Configure on LPS8v2 == | |
8.1 | 121 | ||
16.1 | 122 | ((( | |
123 | (% style="color:blue" %)**Below are the steps:** | ||
124 | ))) | ||
125 | |||
126 | ((( | ||
127 | **~1. Open the box and connect GPS antenna to GNSS port of EC25** | ||
128 | ))) | ||
129 | |||
130 | **2. modify the two files:** | ||
131 | |||
132 | /etc/rc.local | ||
133 | |||
134 | (% class="box" %) | ||
135 | ((( | ||
136 | #!/bin/sh -e | ||
137 | # | ||
138 | # rc.local | ||
139 | # | ||
140 | # This script is executed at the end of each multiuser runlevel. | ||
141 | # Make sure that the script will "exit 0" on success or any other | ||
142 | # value on error. | ||
143 | # | ||
144 | # In order to enable or disable this script just change the execution | ||
145 | # bits. | ||
146 | # | ||
147 | # By default this script does nothing. | ||
148 | |||
149 | echo 0 > /sys/class/leds/dragino\:blue\:opt/brightness | ||
150 | echo 0 > /sys/class/leds/dragino\:green\:stat/brightness | ||
151 | echo 0 > /sys/class/leds/dragino\:red\:sys/brightness | ||
152 | (% style="color:red" %)**echo AT+QGPS=1 > /dev/ttyUSB2** | ||
153 | |||
154 | |||
155 | exit 0 | ||
156 | ))) | ||
157 | |||
17.1 | 158 | (% style="color:red" %)**Note: **(%%) **After above settings, LPS8v2 will (% style="color:blue" %)enable GPS(%%) automatically on boot.** | |
16.1 | 159 | ||
160 | |||
17.1 | 161 | **The user can run (% style="color:red" %)"echo AT+QGPS=1 > /dev/ttyUSB2" (%%)to manually (% style="color:blue" %)enable GPS.(%%)** | |
16.1 | 162 | ||
17.1 | 163 | **/usr/local/dragino/generate-config.sh, after configuring this, on the web page, select any frequency band and save to make this take effect.** | |
16.1 | 164 | ||
165 | (% class="box" %) | ||
166 | ((( | ||
167 | gen_gw_cfg() { | ||
168 | json_init | ||
169 | json_add_object gateway_conf | ||
170 | json_add_string "platform" "SX1$chip" | ||
171 | json_add_string "description" "Dragino LoRaWAN Gateway" | ||
172 | json_add_string "gateway_ID" "$gwid" | ||
173 | json_add_boolean "radiostream_enable" 1 | ||
174 | json_add_string "ghost_host" "localhost" | ||
175 | json_add_string "ghost_port" "1760" | ||
176 | json_add_boolean "manage_enable" 0 | ||
177 | json_add_boolean "custom_downlink" 0 | ||
178 | json_add_int "stat_interval" "30" | ||
179 | json_add_boolean "wd_enable" 1 | ||
180 | json_add_boolean "mac_decode" 0 | ||
181 | json_add_boolean "mac2file" 0 | ||
182 | json_add_boolean "mac2db" 0 | ||
183 | json_add_string "log_mask" "1111" | ||
23.1 | 184 | (% style="color:red" %)**json_add_string "gps_tty_path" "/dev/ttyUSB1" ~-~-~-~--> Add this line so lora program knows to get the gps info from EC25**(%%) | |
16.1 | 185 | json_add_double "ref_latitude" "$latitude" | |
186 | json_add_double "ref_longitude" "$longitude" | ||
187 | json_add_double "ref_altitude" "$altitude" | ||
188 | json_add_int "beacon_period" "0" | ||
189 | json_add_int "beacon_freq_hz" "869525000" | ||
190 | ))) | ||
191 | |||
192 | **3. Reboot the device and run journalctl -u draginofwd -f to verify if GPS already works.** | ||
193 | |||
194 | [[image:image-20231208160114-2.png||height="288" width="907"]] | ||
195 | |||
196 | |||
197 | [[image:image-20231208161058-5.png||height="548" width="965"]] | ||
198 | |||
199 | |||
18.1 | 200 | ||
22.1 | 201 | = 4. Use Cellular Module GPS feature for System Timing. = | |
18.1 | 202 | ||
22.1 | 203 | == 4.1 Configure on LPS8v2 == | |
18.1 | 204 | ||
20.1 | 205 | This introduction shows how to use the Cellular Module GPS feature for System Timing. | |
206 | |||
207 | |||
208 | 1. Download script from dragino site and move it to properly directory | ||
209 | |||
21.1 | 210 | (% class="box" %) | |
20.1 | 211 | ((( | |
212 | root@dragino-e4e891:# wget http://repo.dragino.com/release/tool/gpstime/gpstodate.sh | ||
213 | 2023-12-21 07:25:25 http://repo.dragino.com/release/tool/gpstime/gpstodate.sh | ||
214 | Resolving repo.dragino.com (repo.dragino.com)... 47.89.8.92 | ||
215 | Connecting to repo.dragino.com (repo.dragino.com)|47.89.8.92|:80... connected. | ||
216 | HTTP request sent, awaiting response... 200 OK | ||
217 | Length: 1114 (1.1K) [application/octet-stream] | ||
218 | Saving to: ‘gpstodate.sh’ | ||
219 | |||
220 | gpstodate.sh 100%[===========================================================================================================>] 1.09K .-KB/s in 0s | ||
221 | |||
222 | 2023-12-21 07:25:25 (16.5 MB/s) - ‘gpstodate.sh’ saved [1114/1114] | ||
223 | |||
224 | root@dragino-e4e891:# chmod +x gpstodate.sh;mv gpstodate.sh /usr/bin/ | ||
225 | root@dragino-e4e891:# | ||
226 | ))) | ||
227 | |||
228 | 2. Run **cat /dev/ttyUSB1** to check if the GPS location is successful. | ||
229 | |||
230 | [[image:image-20231221153129-1.png||height="440" width="632"]] | ||
231 | |||
232 | |||
233 | 3. Run the **date** and **/usr/bin/gpstodate.sh** **&** to check if the system time is correct | ||
234 | |||
235 | |||
21.1 | 236 | 4. Add **gpstodate.sh** to cron work **/etc/rc.local** , LPS8v2 will Use Cellular Module GPS feature for System Timing automatically on boot | |
237 | |||
238 | (% class="box" %) | ||
239 | ((( | ||
240 | #!/bin/sh -e | ||
241 | # | ||
242 | # rc.local | ||
243 | # | ||
244 | # This script is executed at the end of each multiuser runlevel. | ||
245 | # Make sure that the script will "exit 0" on success or any other | ||
246 | # value on error. | ||
247 | # | ||
248 | # In order to enable or disable this script just change the execution | ||
249 | # bits. | ||
250 | # | ||
251 | # By default this script does nothing. | ||
252 | |||
253 | echo 0 > /sys/class/leds/dragino\:blue\:opt/brightness | ||
254 | echo 0 > /sys/class/leds/dragino\:green\:stat/brightness | ||
255 | echo 0 > /sys/class/leds/dragino\:red\:sys/brightness | ||
22.1 | 256 | (% style="color:red" %)**echo AT+QGPS=1 > /dev/ttyUSB2**(%%) | |
21.1 | 257 | (% style="color:red" %)**/usr/bin/gpstodate.sh** | |
258 | |||
259 | exit 0 | ||
260 | ))) |