Skip to content

Commit 2e351ad

Browse files
committed
Update to latest version of mcci-catena/arduino-lmic library
1 parent 4baa7a9 commit 2e351ad

15 files changed

+257
-104
lines changed

src/aes/other.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,4 @@ u4_t os_aes (u1_t mode, xref2u1_t buf, u2_t len) {
142142
return 0;
143143
}
144144

145-
#endif // !defined(USE_ORIGINAL_AES)
145+
#endif // !defined(USE_ORIGINAL_AES)

src/hal/hal_esp32.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ static bool hal_wait(wait_open_e wait_option)
347347
if (wait_option != WAIT_FOR_TIMER)
348348
hal_disarm_timer();
349349
hal_enterCriticalSection();
350-
radio_irq_handler(item.ev, item.time);
350+
radio_irq_handler_v2(item.ev, item.time);
351351
hal_leaveCriticalSection();
352352
if (wait_option != WAIT_FOR_TIMER)
353353
return true;

src/lmic/lmic.c

100755100644
Lines changed: 67 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@ static void startScan (void);
4747
#endif
4848

4949
static inline void initTxrxFlags(const char *func, u1_t mask) {
50+
LMIC_DEBUG2_PARAMETER(func);
51+
5052
#if LMIC_DEBUG_LEVEL > 1
51-
// ttn-esp32 change: fix printf for for ostime_t
52-
LMIC_DEBUG_PRINTF("%u: %s txrxFlags %#02x --> %02x\n", (unsigned)os_getTime(), func, LMIC.txrxFlags, mask);
53+
LMIC_DEBUG_PRINTF("%"LMIC_PRId_ostime_t": %s txrxFlags %#02x --> %02x\n", os_getTime(), func, LMIC.txrxFlags, mask);
5354
#endif
5455
LMIC.txrxFlags = mask;
5556
}
@@ -273,30 +274,6 @@ ostime_t calcAirTime (rps_t rps, u1_t plen) {
273274
return (((ostime_t)tmp << sfx) * OSTICKS_PER_SEC + div/2) / div;
274275
}
275276

276-
extern inline rps_t updr2rps (dr_t dr);
277-
extern inline rps_t dndr2rps (dr_t dr);
278-
extern inline int isFasterDR (dr_t dr1, dr_t dr2);
279-
extern inline int isSlowerDR (dr_t dr1, dr_t dr2);
280-
extern inline dr_t incDR (dr_t dr);
281-
extern inline dr_t decDR (dr_t dr);
282-
// ttn-esp32 change: remove unused function creating warning
283-
//extern inline dr_t assertDR (dr_t dr);
284-
extern inline dr_t validDR (dr_t dr);
285-
extern inline dr_t lowerDR (dr_t dr, u1_t n);
286-
287-
extern inline sf_t getSf (rps_t params);
288-
extern inline rps_t setSf (rps_t params, sf_t sf);
289-
extern inline bw_t getBw (rps_t params);
290-
extern inline rps_t setBw (rps_t params, bw_t cr);
291-
extern inline cr_t getCr (rps_t params);
292-
extern inline rps_t setCr (rps_t params, cr_t cr);
293-
extern inline int getNocrc (rps_t params);
294-
extern inline rps_t setNocrc (rps_t params, int nocrc);
295-
extern inline int getIh (rps_t params);
296-
extern inline rps_t setIh (rps_t params, int ih);
297-
extern inline rps_t makeRps (sf_t sf, bw_t bw, cr_t cr, int ih, int nocrc);
298-
extern inline int sameSfBw (rps_t r1, rps_t r2);
299-
300277
// END LORA
301278
// ================================================================================
302279

@@ -416,6 +393,8 @@ static void txDelay (ostime_t reftime, u1_t secSpan) {
416393

417394

418395
void LMICcore_setDrJoin (u1_t reason, u1_t dr) {
396+
LMIC_EV_PARAMETER(reason);
397+
419398
EV(drChange, INFO, (e_.reason = reason,
420399
e_.deveui = MAIN::CDEV->getEui(),
421400
e_.dr = dr|DR_PAGE,
@@ -428,6 +407,8 @@ void LMICcore_setDrJoin (u1_t reason, u1_t dr) {
428407

429408

430409
static void setDrTxpow (u1_t reason, u1_t dr, s1_t pow) {
410+
LMIC_EV_PARAMETER(reason);
411+
431412
EV(drChange, INFO, (e_.reason = reason,
432413
e_.deveui = MAIN::CDEV->getEui(),
433414
e_.dr = dr|DR_PAGE,
@@ -464,6 +445,8 @@ void LMIC_setPingable (u1_t intvExp) {
464445
#endif // !DISABLE_PING
465446

466447
static void runEngineUpdate (xref2osjob_t osjob) {
448+
LMIC_API_PARAMETER(osjob);
449+
467450
engineUpdate();
468451
}
469452

@@ -478,6 +461,8 @@ static void reportEvent (ev_t ev) {
478461

479462

480463
static void runReset (xref2osjob_t osjob) {
464+
LMIC_API_PARAMETER(osjob);
465+
481466
// Disable session
482467
LMIC_reset();
483468
#if !defined(DISABLE_JOIN)
@@ -596,9 +581,8 @@ scan_mac_cmds(
596581
// of contiguous commands (whatever that means), and ignore the
597582
// data rate, NbTrans (uprpt) and txPow until the last one.
598583
#if LMIC_DEBUG_LEVEL > 0
599-
// ttn-esp32 change: fix printf for for ostime_t
600-
LMIC_DEBUG_PRINTF("%u: LinkAdrReq: p1:%02x chmap:%04x chpage:%02x uprt:%02x ans:%02x\n",
601-
(unsigned)os_getTime(), p1, chmap, chpage, uprpt, LMIC.ladrAns
584+
LMIC_DEBUG_PRINTF("%"LMIC_PRId_ostime_t": LinkAdrReq: p1:%02x chmap:%04x chpage:%02x uprt:%02x ans:%02x\n",
585+
os_getTime(), p1, chmap, chpage, uprpt, LMIC.ladrAns
602586
);
603587
#endif /* LMIC_DEBUG_LEVEL */
604588

@@ -760,8 +744,7 @@ static bit_t decodeFrame (void) {
760744
e_.info2 = hdr + (dlen<<8)));
761745
norx:
762746
#if LMIC_DEBUG_LEVEL > 0
763-
// ttn-esp32 change: fix printf for for ostime_t
764-
LMIC_DEBUG_PRINTF("%u: Invalid downlink, window=%s\n", (unsigned)os_getTime(), window);
747+
LMIC_DEBUG_PRINTF("%"LMIC_PRId_ostime_t": Invalid downlink, window=%s\n", os_getTime(), window);
765748
#endif
766749
LMIC.dataLen = 0;
767750
return 0;
@@ -853,8 +836,7 @@ static bit_t decodeFrame (void) {
853836

854837
#if LMIC_DEBUG_LEVEL > 0
855838
// Process OPTS
856-
// ttn-esp32 change: fix printf for for ostime_t
857-
LMIC_DEBUG_PRINTF("%u: process options (olen=%#x)\n", (unsigned)os_getTime(), olen);
839+
LMIC_DEBUG_PRINTF("%"LMIC_PRId_ostime_t": process options (olen=%#x)\n", os_getTime(), olen);
858840
#endif
859841

860842
xref2u1_t opts = &d[OFF_DAT_OPTS];
@@ -873,17 +855,15 @@ static bit_t decodeFrame (void) {
873855
if (port == 0) {
874856
// this is a mac command. scan the options.
875857
#if LMIC_DEBUG_LEVEL > 0
876-
// ttn-esp32 change: fix printf for for ostime_t
877-
LMIC_DEBUG_PRINTF("%u: process mac commands for port 0 (olen=%#x)\n", (unsigned)os_getTime(), pend-poff);
858+
LMIC_DEBUG_PRINTF("%"LMIC_PRId_ostime_t": process mac commands for port 0 (olen=%#x)\n", os_getTime(), pend-poff);
878859
#endif
879860
int optendindex = scan_mac_cmds(d+poff, pend-poff);
880861
if (optendindex != pend-poff) {
881862
#if LMIC_DEBUG_LEVEL > 0
882-
// ttn-esp32 change: fix printf for for ostime_t
883863
LMIC_DEBUG_PRINTF(
884-
"%u: error processing mac commands for port 0 "
864+
"%"LMIC_PRId_ostime_t": error processing mac commands for port 0 "
885865
"(len=%#x, optendindex=%#x)\n",
886-
(unsigned)os_getTime(), pend-poff, optendindex
866+
os_getTime(), pend-poff, optendindex
887867
);
888868
#endif
889869
}
@@ -918,8 +898,7 @@ static bit_t decodeFrame (void) {
918898
e_.info = seqno,
919899
e_.info2 = ackup));
920900
#if LMIC_DEBUG_LEVEL > 1
921-
// ttn-esp32 change: fix printf for for ostime_t
922-
LMIC_DEBUG_PRINTF("%u: ??ack error ack=%d txCnt=%d\n", (unsigned)os_getTime(), ackup, LMIC.txCnt);
901+
LMIC_DEBUG_PRINTF("%"LMIC_PRId_ostime_t": ??ack error ack=%d txCnt=%d\n", os_getTime(), ackup, LMIC.txCnt);
923902
#endif
924903
}
925904

@@ -936,8 +915,7 @@ static bit_t decodeFrame (void) {
936915
LMIC.dataLen = pend-poff;
937916
}
938917
#if LMIC_DEBUG_LEVEL > 0
939-
// ttn-esp32 change: fix printf for for ostime_t
940-
LMIC_DEBUG_PRINTF("%u: Received downlink, window=%s, port=%d, ack=%d, txrxFlags=%#x\n", (unsigned)os_getTime(), window, port, ackup, LMIC.txrxFlags);
918+
LMIC_DEBUG_PRINTF("%"LMIC_PRId_ostime_t": Received downlink, window=%s, port=%d, ack=%d, txrxFlags=%#x\n", os_getTime(), window, port, ackup, LMIC.txrxFlags);
941919
#endif
942920
return 1;
943921
}
@@ -986,7 +964,7 @@ static void schedRx12 (ostime_t delay, osjobcb_t func, u1_t dr) {
986964
// (again note that hsym is half a sumbol time, so no /2 needed)
987965
LMIC.rxtime = LMIC.txend + delay + PAMBL_SYMS * hsym - LMIC.rxsyms * hsym;
988966

989-
LMIC_X_DEBUG_PRINTF("%lu: sched Rx12 %lu\n", os_getTime(), LMIC.rxtime - RX_RAMPUP);
967+
LMIC_X_DEBUG_PRINTF("%"LMIC_PRId_ostime_t": sched Rx12 %"LMIC_PRId_ostime_t"\n", os_getTime(), LMIC.rxtime - RX_RAMPUP);
990968
os_setTimedCallback(&LMIC.osjob, LMIC.rxtime - RX_RAMPUP, func);
991969
}
992970

@@ -1029,6 +1007,8 @@ static void txDone (ostime_t delay, osjobcb_t func) {
10291007

10301008
#if !defined(DISABLE_JOIN)
10311009
static void onJoinFailed (xref2osjob_t osjob) {
1010+
LMIC_API_PARAMETER(osjob);
1011+
10321012
// Notify app - must call LMIC_reset() to stop joining
10331013
// otherwise join procedure continues.
10341014
reportEvent(EV_JOIN_FAILED);
@@ -1081,8 +1061,9 @@ static bit_t processJoinAccept (void) {
10811061
}
10821062
u1_t hdr = LMIC.frame[0];
10831063
u1_t dlen = LMIC.dataLen;
1084-
// ttn-esp32 change: suppress warning
1085-
u4_t __attribute__((unused)) mic = os_rlsbf4(&LMIC.frame[dlen-4]); // safe before modified by encrypt!
1064+
u4_t mic = os_rlsbf4(&LMIC.frame[dlen-4]); // safe before modified by encrypt!
1065+
LMIC_EV_VARIABLE(mic); // only used by EV().
1066+
10861067
if( (dlen != LEN_JA && dlen != LEN_JAEXT)
10871068
|| (hdr & (HDR_FTYPE|HDR_MAJOR)) != (HDR_FTYPE_JACC|HDR_MAJOR_V1) ) {
10881069
EV(specCond, ERR, (e_.reason = EV::specCond_t::UNEXPECTED_FRAME,
@@ -1119,8 +1100,7 @@ static bit_t processJoinAccept (void) {
11191100
if( freq ) {
11201101
LMIC_setupChannel(chidx, freq, 0, -1);
11211102
#if LMIC_DEBUG_LEVEL > 1
1122-
// ttn-esp32 change: fix printf for for ostime_t
1123-
LMIC_DEBUG_PRINTF("%u: Setup channel, idx=%d, freq=%lu\n", (unsigned)os_getTime(), chidx, (unsigned long)freq);
1103+
LMIC_DEBUG_PRINTF("%"LMIC_PRId_ostime_t": Setup channel, idx=%d, freq=%"PRIu32"\n", os_getTime(), chidx, freq);
11241104
#endif
11251105
}
11261106
}
@@ -1172,6 +1152,8 @@ static bit_t processJoinAccept (void) {
11721152

11731153

11741154
static void processRx2Jacc (xref2osjob_t osjob) {
1155+
LMIC_API_PARAMETER(osjob);
1156+
11751157
if( LMIC.dataLen == 0 ) {
11761158
initTxrxFlags(__func__, 0); // nothing in 1st/2nd DN slot
11771159
}
@@ -1180,23 +1162,31 @@ static void processRx2Jacc (xref2osjob_t osjob) {
11801162

11811163

11821164
static void setupRx2Jacc (xref2osjob_t osjob) {
1165+
LMIC_API_PARAMETER(osjob);
1166+
11831167
LMIC.osjob.func = FUNC_ADDR(processRx2Jacc);
11841168
setupRx2();
11851169
}
11861170

11871171

11881172
static void processRx1Jacc (xref2osjob_t osjob) {
1173+
LMIC_API_PARAMETER(osjob);
1174+
11891175
if( LMIC.dataLen == 0 || !processJoinAccept() )
11901176
schedRx12(DELAY_JACC2_osticks, FUNC_ADDR(setupRx2Jacc), LMIC.dn2Dr);
11911177
}
11921178

11931179

11941180
static void setupRx1Jacc (xref2osjob_t osjob) {
1181+
LMIC_API_PARAMETER(osjob);
1182+
11951183
setupRx1(FUNC_ADDR(processRx1Jacc));
11961184
}
11971185

11981186

11991187
static void jreqDone (xref2osjob_t osjob) {
1188+
LMIC_API_PARAMETER(osjob);
1189+
12001190
txDone(DELAY_JACC1_osticks, FUNC_ADDR(setupRx1Jacc));
12011191
}
12021192

@@ -1208,10 +1198,14 @@ static void jreqDone (xref2osjob_t osjob) {
12081198
static bit_t processDnData(void);
12091199

12101200
static void processRx2DnDataDelay (xref2osjob_t osjob) {
1201+
LMIC_API_PARAMETER(osjob);
1202+
12111203
processDnData();
12121204
}
12131205

12141206
static void processRx2DnData (xref2osjob_t osjob) {
1207+
LMIC_API_PARAMETER(osjob);
1208+
12151209
if( LMIC.dataLen == 0 ) {
12161210
initTxrxFlags(__func__, 0); // nothing in 1st/2nd DN slot
12171211
// Delay callback processing to avoid up TX while gateway is txing our missed frame!
@@ -1226,23 +1220,31 @@ static void processRx2DnData (xref2osjob_t osjob) {
12261220

12271221

12281222
static void setupRx2DnData (xref2osjob_t osjob) {
1223+
LMIC_API_PARAMETER(osjob);
1224+
12291225
LMIC.osjob.func = FUNC_ADDR(processRx2DnData);
12301226
setupRx2();
12311227
}
12321228

12331229

12341230
static void processRx1DnData (xref2osjob_t osjob) {
1231+
LMIC_API_PARAMETER(osjob);
1232+
12351233
if( LMIC.dataLen == 0 || !processDnData() )
12361234
schedRx12(sec2osticks(LMIC.rxDelay +(int)DELAY_EXTDNW2), FUNC_ADDR(setupRx2DnData), LMIC.dn2Dr);
12371235
}
12381236

12391237

12401238
static void setupRx1DnData (xref2osjob_t osjob) {
1239+
LMIC_API_PARAMETER(osjob);
1240+
12411241
setupRx1(FUNC_ADDR(processRx1DnData));
12421242
}
12431243

12441244

12451245
static void updataDone (xref2osjob_t osjob) {
1246+
LMIC_API_PARAMETER(osjob);
1247+
12461248
txDone(sec2osticks(LMIC.rxDelay), FUNC_ADDR(setupRx1DnData));
12471249
}
12481250

@@ -1387,7 +1389,9 @@ static void buildDataFrame (void) {
13871389

13881390
#if !defined(DISABLE_BEACONS)
13891391
// Callback from HAL during scan mode or when job timer expires.
1390-
static void onBcnRx (xref2osjob_t job) {
1392+
static void onBcnRx (xref2osjob_t osjob) {
1393+
LMIC_API_PARAMETER(osjob);
1394+
13911395
// If we arrive via job timer make sure to put radio to rest.
13921396
os_radio(RADIO_RST);
13931397
os_clearCallback(&LMIC.osjob);
@@ -1508,6 +1512,8 @@ static void buildJoinRequest (u1_t ftype) {
15081512
}
15091513

15101514
static void startJoining (xref2osjob_t osjob) {
1515+
LMIC_API_PARAMETER(osjob);
1516+
15111517
reportEvent(EV_JOINING);
15121518
}
15131519

@@ -1541,6 +1547,8 @@ bit_t LMIC_startJoining (void) {
15411547

15421548
#if !defined(DISABLE_PING)
15431549
static void processPingRx (xref2osjob_t osjob) {
1550+
LMIC_API_PARAMETER(osjob);
1551+
15441552
if( LMIC.dataLen != 0 ) {
15451553
initTxrxFlags(__func__, TXRX_PING);
15461554
if( decodeFrame() ) {
@@ -1622,6 +1630,8 @@ static bit_t processDnData (void) {
16221630

16231631
#if !defined(DISABLE_BEACONS)
16241632
static void processBeacon (xref2osjob_t osjob) {
1633+
LMIC_API_PARAMETER(osjob);
1634+
16251635
ostime_t lasttx = LMIC.bcninfo.txtime; // save here - decodeBeacon might overwrite
16261636
u1_t flags = LMIC.bcninfo.flags;
16271637
ev_t ev;
@@ -1683,6 +1693,8 @@ static void processBeacon (xref2osjob_t osjob) {
16831693

16841694

16851695
static void startRxBcn (xref2osjob_t osjob) {
1696+
LMIC_API_PARAMETER(osjob);
1697+
16861698
LMIC.osjob.func = FUNC_ADDR(processBeacon);
16871699
os_radio(RADIO_RX);
16881700
}
@@ -1691,6 +1703,8 @@ static void startRxBcn (xref2osjob_t osjob) {
16911703

16921704
#if !defined(DISABLE_PING)
16931705
static void startRxPing (xref2osjob_t osjob) {
1706+
LMIC_API_PARAMETER(osjob);
1707+
16941708
LMIC.osjob.func = FUNC_ADDR(processPingRx);
16951709
os_radio(RADIO_RX);
16961710
}
@@ -1700,8 +1714,7 @@ static void startRxPing (xref2osjob_t osjob) {
17001714
// Decide what to do next for the MAC layer of a device
17011715
static void engineUpdate (void) {
17021716
#if LMIC_DEBUG_LEVEL > 0
1703-
// ttn-esp32 change: fix printf for for ostime_t
1704-
LMIC_DEBUG_PRINTF("%u: engineUpdate, opmode=0x%x\n", (unsigned)os_getTime(), LMIC.opmode);
1717+
LMIC_DEBUG_PRINTF("%"LMIC_PRId_ostime_t": engineUpdate, opmode=0x%x\n", os_getTime(), LMIC.opmode);
17051718
#endif
17061719
// Check for ongoing state: scan or TX/RX transaction
17071720
if( (LMIC.opmode & (OP_SCAN|OP_TXRXPEND|OP_SHUTDOWN)) != 0 )
@@ -1715,9 +1728,10 @@ static void engineUpdate (void) {
17151728
#endif // !DISABLE_JOIN
17161729

17171730
ostime_t now = os_getTime();
1718-
// ttn-esp32 change: suppress unused variable warning
1719-
ostime_t __attribute__((unused)) rxtime = 0;
1731+
ostime_t rxtime = 0;
17201732
ostime_t txbeg = 0;
1733+
// ttn-esp32: suppress unused variable
1734+
LMIC_UNREFERENCED_VARIABLE(rxtime);
17211735

17221736
#if !defined(DISABLE_BEACONS)
17231737
if( (LMIC.opmode & OP_TRACK) != 0 ) {
@@ -1861,7 +1875,7 @@ static void engineUpdate (void) {
18611875
e_.eui = MAIN::CDEV->getEui(),
18621876
e_.info = osticks2ms(txbeg-now),
18631877
e_.info2 = LMIC.seqnoUp-1));
1864-
LMIC_X_DEBUG_PRINTF("%lu: next engine update in %lu\n", now, txbeg-TX_RAMPUP);
1878+
LMIC_X_DEBUG_PRINTF("%"LMIC_PRId_ostime_t": next engine update in %"LMIC_PRId_ostime_t"\n", now, txbeg-TX_RAMPUP);
18651879
os_setTimedCallback(&LMIC.osjob, txbeg-TX_RAMPUP, FUNC_ADDR(runEngineUpdate));
18661880
}
18671881

0 commit comments

Comments
 (0)