Skip to content

Commit b30d0ba

Browse files
committed
Add logging of frame counts in compliance app
1 parent d2ed33f commit b30d0ba

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

examples/compliance-otaa-halconfig/compliance-otaa-halconfig.ino

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Author:
2020
#include <arduino_lmic_lorawan_compliance.h>
2121

2222
#include <SPI.h>
23+
class cEventQueue;
2324

2425
//
2526
// For compliance tests with the RWC5020A, we use the default addresses
@@ -93,8 +94,10 @@ public:
9394
ostime_t time;
9495
ostime_t txend;
9596
u4_t freq;
96-
rps_t rps;
9797
u2_t opmode;
98+
u2_t fcntDn;
99+
u2_t fcntUp;
100+
rps_t rps;
98101
u1_t txChnl;
99102
u1_t datarate;
100103
u1_t txrxFlags;
@@ -125,10 +128,12 @@ public:
125128
pn->pMessage = pMessage;
126129
pn->datum = datum;
127130
pn->freq = LMIC.freq;
128-
pn->txChnl = LMIC.txChnl;
131+
pn->opmode = LMIC.opmode;
132+
pn->fcntDn = (u2_t) LMIC.seqnoDn;
133+
pn->fcntUp = (u2_t) LMIC.seqnoUp;
129134
pn->rps = LMIC.rps;
135+
pn->txChnl = LMIC.txChnl;
130136
pn->datarate = LMIC.datarate;
131-
pn->opmode = LMIC.opmode;
132137
pn->txrxFlags = LMIC.txrxFlags;
133138
pn->saveIrqFlags = LMIC.saveIrqFlags;
134139
m_tail = i;
@@ -187,6 +192,8 @@ void myEventCb(void *pUserData, ev_t ev) {
187192
}
188193

189194
void eventPrint(cEventQueue::eventnode_t &e);
195+
void printFcnts(cEventQueue::eventnode_t &e);
196+
190197

191198
void eventPrintAll(void) {
192199
while (eventPrintOne())
@@ -233,6 +240,11 @@ void printHex2(unsigned v) {
233240
Serial.print(v, HEX);
234241
}
235242

243+
void printHex4(unsigned v) {
244+
printHex2(v >> 8u);
245+
printHex2(v);
246+
}
247+
236248
void printFreq(u4_t freq) {
237249
Serial.print(F(": freq="));
238250
Serial.print(freq / 1000000);
@@ -280,6 +292,13 @@ void printSaveIrqFlags(u1_t saveIrqFlags) {
280292
printHex2(saveIrqFlags);
281293
}
282294

295+
void printFcnts(cEventQueue::eventnode_t &e) {
296+
Serial.print(F(", FcntUp="));
297+
printHex4(e.fcntUp);
298+
Serial.print(F(", FcntDn="));
299+
printHex4(e.fcntDn);
300+
}
301+
283302
// dump all the registers. Must have printf setup.
284303
void printAllRegisters(void) {
285304
uint8_t regbuf[0x80];
@@ -409,6 +428,7 @@ void eventPrint(cEventQueue::eventnode_t &e) {
409428
printTxChnl(e.txChnl);
410429
printRps(e.rps);
411430
printTxrxflags(e.txrxFlags);
431+
printFcnts(e);
412432
break;
413433
case EV_LOST_TSYNC:
414434
break;
@@ -610,7 +630,7 @@ void setup() {
610630
// Reset the MAC state. Session and pending data transfers will be discarded.
611631
LMIC_reset();
612632

613-
LMIC_setClockError(5 * MAX_CLOCK_ERROR / 100);
633+
LMIC_setClockError(1 * MAX_CLOCK_ERROR / 100);
614634

615635
// do the network-specific setup prior to join.
616636
setupForNetwork(false);
@@ -680,10 +700,10 @@ void setupForNetwork(bool preJoin) {
680700

681701
void loop() {
682702
os_runloop_once();
683-
while ((LMIC.opmode & OP_TXRXPEND) == 0 &&
684-
! os_queryTimeCriticalJobs(ms2osticks(1000)) &&
685-
eventPrintOne())
686-
;
703+
if ((LMIC.opmode & OP_TXRXPEND) == 0 &&
704+
!os_queryTimeCriticalJobs(ms2osticks(1000))) {
705+
eventPrintOne();
706+
}
687707
}
688708

689709
// there's a problem with running 2.5 of the MCCI STM32 BSPs;

0 commit comments

Comments
 (0)