Skip to content

Commit 95f88d4

Browse files
committedNov 20, 2019
Added more debug information to ABP Activation
1 parent ba30466 commit 95f88d4

File tree

1 file changed

+62
-12
lines changed

1 file changed

+62
-12
lines changed
 

‎TTN_TTGOLora32/src/main.cpp

+62-12
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// https://github.com/gonzalocasas/arduino-uno-dragino-lorawan/blob/master/LICENSE
33
// Based on examples from https://github.com/matthijskooijman/arduino-lmic
44
// Copyright (c) 2015 Thomas Telkamp and Matthijs Kooijman
5+
// Modified by github FGCDAM user https://github.com/fcgdam
56

67
#include <Arduino.h>
78
#include "lmic.h"
@@ -92,6 +93,7 @@ void onEvent (ev_t ev) {
9293
display.drawString (0, 20, "Received DATA.");
9394
for ( i = 0 ; i < LMIC.dataLen ; i++ )
9495
TTN_response[i] = LMIC.frame[LMIC.dataBeg+i];
96+
9597
TTN_response[i] = 0;
9698
display.drawString (0, 32, String(TTN_response));
9799
}
@@ -140,26 +142,58 @@ void setup() {
140142
pinMode(LEDPIN,OUTPUT);
141143

142144
// reset the OLED
143-
pinMode(OLED_RESET,OUTPUT);
144-
digitalWrite(OLED_RESET, LOW);
145-
delay(50);
146-
digitalWrite(OLED_RESET, HIGH);
147-
148-
display.init ();
149-
display.flipScreenVertically ();
150-
display.setFont (ArialMT_Plain_10);
151-
152-
display.setTextAlignment (TEXT_ALIGN_LEFT);
145+
pinMode(OLED_RESET,OUTPUT);
146+
digitalWrite(OLED_RESET, LOW);
147+
delay(50);
148+
digitalWrite(OLED_RESET, HIGH);
149+
150+
display.init ();
151+
display.flipScreenVertically ();
152+
display.setFont (ArialMT_Plain_10);
153+
154+
display.setTextAlignment (TEXT_ALIGN_LEFT);
155+
156+
display.drawString (0, 0, "Init!");
157+
display.display ();
158+
159+
if ( DEVADDR == 0x00 ) { // Device is misconfigured with an invalid or not defined device id.
160+
int i = 0;
161+
162+
while ( true ) {
163+
display.clear();
164+
display.drawString (0, 0, "INIT FAILED! ");
165+
display.drawString (0, 9, "Device ID is not SET!");
166+
167+
display.drawString (0, 18, "Invalid TTN settings!");
168+
display.drawString (0, 27, "Set NWSKEY and APPSKEY!");
169+
170+
display.drawString( 0, 36, "Correct and reset.");
171+
172+
display.drawString( 0, 45, "Waiting for user action...");
173+
if ( i == 0 )
174+
display.drawString( 0, 54, "." );
175+
else
176+
display.drawString( 0, 54, "*" );
177+
i++;
178+
i = i % 2;
179+
display.display ();
180+
delay( 1000 );
181+
}
153182

154-
display.drawString (0, 0, "Init!");
155-
display.display ();
183+
}
156184

157185
// LMIC init
158186
os_init();
159187

188+
display.drawString (0, 8, "LMIC was initiated!");
189+
display.display ();
190+
160191
// Reset the MAC state. Session and pending data transfers will be discarded.
161192
LMIC_reset();
162193

194+
display.drawString (0, 16, "LMIC reset -> OK!");
195+
display.display ();
196+
163197
// Set up the channels used by the Things Network, which corresponds
164198
// to the defaults of most gateways. Without this, only three base
165199
// channels from the LoRaWAN specification are used, which certainly
@@ -181,6 +215,9 @@ void setup() {
181215
// devices' ping slots. LMIC does not have an easy way to define set this
182216
// frequency and support for class B is spotty and untested, so this
183217
// frequency is not configured here.
218+
display.drawString (0, 24, "LMIC setChannels -> OK!");
219+
display.display ();
220+
184221

185222
// Set static session parameters.
186223
LMIC_setSession (0x1, DEVADDR, NWKSKEY, APPSKEY);
@@ -195,6 +232,19 @@ void setup() {
195232
//LMIC_setDrTxpow(DR_SF11,14);
196233
LMIC_setDrTxpow(DR_SF9,14);
197234

235+
display.drawString (0, 32, "LMIC setup -> OK!");
236+
display.display ();
237+
238+
for ( int i = 0 ; i < 5 ; i++ ) {
239+
delay ( 1000 );
240+
241+
display.drawString (0+i*8, 50, ".");
242+
display.display ();
243+
}
244+
245+
Serial.println("LMIC setup done.");
246+
Serial.println("Starting transmit job.");
247+
198248
// Start job
199249
do_send(&sendjob);
200250
}

0 commit comments

Comments
 (0)
Please sign in to comment.