@@ -47,9 +47,10 @@ static void startScan (void);
47
47
#endif
48
48
49
49
static inline void initTxrxFlags (const char * func , u1_t mask ) {
50
+ LMIC_DEBUG2_PARAMETER (func );
51
+
50
52
#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 );
53
54
#endif
54
55
LMIC .txrxFlags = mask ;
55
56
}
@@ -273,30 +274,6 @@ ostime_t calcAirTime (rps_t rps, u1_t plen) {
273
274
return (((ostime_t )tmp << sfx ) * OSTICKS_PER_SEC + div /2 ) / div ;
274
275
}
275
276
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
-
300
277
// END LORA
301
278
// ================================================================================
302
279
@@ -416,6 +393,8 @@ static void txDelay (ostime_t reftime, u1_t secSpan) {
416
393
417
394
418
395
void LMICcore_setDrJoin (u1_t reason , u1_t dr ) {
396
+ LMIC_EV_PARAMETER (reason );
397
+
419
398
EV (drChange , INFO , (e_ .reason = reason ,
420
399
e_ .deveui = MAIN ::CDEV -> getEui (),
421
400
e_ .dr = dr |DR_PAGE ,
@@ -428,6 +407,8 @@ void LMICcore_setDrJoin (u1_t reason, u1_t dr) {
428
407
429
408
430
409
static void setDrTxpow (u1_t reason , u1_t dr , s1_t pow ) {
410
+ LMIC_EV_PARAMETER (reason );
411
+
431
412
EV (drChange , INFO , (e_ .reason = reason ,
432
413
e_ .deveui = MAIN ::CDEV -> getEui (),
433
414
e_ .dr = dr |DR_PAGE ,
@@ -464,6 +445,8 @@ void LMIC_setPingable (u1_t intvExp) {
464
445
#endif // !DISABLE_PING
465
446
466
447
static void runEngineUpdate (xref2osjob_t osjob ) {
448
+ LMIC_API_PARAMETER (osjob );
449
+
467
450
engineUpdate ();
468
451
}
469
452
@@ -478,6 +461,8 @@ static void reportEvent (ev_t ev) {
478
461
479
462
480
463
static void runReset (xref2osjob_t osjob ) {
464
+ LMIC_API_PARAMETER (osjob );
465
+
481
466
// Disable session
482
467
LMIC_reset ();
483
468
#if !defined(DISABLE_JOIN )
@@ -596,9 +581,8 @@ scan_mac_cmds(
596
581
// of contiguous commands (whatever that means), and ignore the
597
582
// data rate, NbTrans (uprpt) and txPow until the last one.
598
583
#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
602
586
);
603
587
#endif /* LMIC_DEBUG_LEVEL */
604
588
@@ -760,8 +744,7 @@ static bit_t decodeFrame (void) {
760
744
e_ .info2 = hdr + (dlen <<8 )));
761
745
norx :
762
746
#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 );
765
748
#endif
766
749
LMIC .dataLen = 0 ;
767
750
return 0 ;
@@ -853,8 +836,7 @@ static bit_t decodeFrame (void) {
853
836
854
837
#if LMIC_DEBUG_LEVEL > 0
855
838
// 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 );
858
840
#endif
859
841
860
842
xref2u1_t opts = & d [OFF_DAT_OPTS ];
@@ -873,17 +855,15 @@ static bit_t decodeFrame (void) {
873
855
if (port == 0 ) {
874
856
// this is a mac command. scan the options.
875
857
#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 );
878
859
#endif
879
860
int optendindex = scan_mac_cmds (d + poff , pend - poff );
880
861
if (optendindex != pend - poff ) {
881
862
#if LMIC_DEBUG_LEVEL > 0
882
- // ttn-esp32 change: fix printf for for ostime_t
883
863
LMIC_DEBUG_PRINTF (
884
- "%u : error processing mac commands for port 0 "
864
+ "%" LMIC_PRId_ostime_t " : error processing mac commands for port 0 "
885
865
"(len=%#x, optendindex=%#x)\n" ,
886
- ( unsigned ) os_getTime (), pend - poff , optendindex
866
+ os_getTime (), pend - poff , optendindex
887
867
);
888
868
#endif
889
869
}
@@ -918,8 +898,7 @@ static bit_t decodeFrame (void) {
918
898
e_ .info = seqno ,
919
899
e_ .info2 = ackup ));
920
900
#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 );
923
902
#endif
924
903
}
925
904
@@ -936,8 +915,7 @@ static bit_t decodeFrame (void) {
936
915
LMIC .dataLen = pend - poff ;
937
916
}
938
917
#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 );
941
919
#endif
942
920
return 1 ;
943
921
}
@@ -986,7 +964,7 @@ static void schedRx12 (ostime_t delay, osjobcb_t func, u1_t dr) {
986
964
// (again note that hsym is half a sumbol time, so no /2 needed)
987
965
LMIC .rxtime = LMIC .txend + delay + PAMBL_SYMS * hsym - LMIC .rxsyms * hsym ;
988
966
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 );
990
968
os_setTimedCallback (& LMIC .osjob , LMIC .rxtime - RX_RAMPUP , func );
991
969
}
992
970
@@ -1029,6 +1007,8 @@ static void txDone (ostime_t delay, osjobcb_t func) {
1029
1007
1030
1008
#if !defined(DISABLE_JOIN )
1031
1009
static void onJoinFailed (xref2osjob_t osjob ) {
1010
+ LMIC_API_PARAMETER (osjob );
1011
+
1032
1012
// Notify app - must call LMIC_reset() to stop joining
1033
1013
// otherwise join procedure continues.
1034
1014
reportEvent (EV_JOIN_FAILED );
@@ -1081,8 +1061,9 @@ static bit_t processJoinAccept (void) {
1081
1061
}
1082
1062
u1_t hdr = LMIC .frame [0 ];
1083
1063
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
+
1086
1067
if ( (dlen != LEN_JA && dlen != LEN_JAEXT )
1087
1068
|| (hdr & (HDR_FTYPE |HDR_MAJOR )) != (HDR_FTYPE_JACC |HDR_MAJOR_V1 ) ) {
1088
1069
EV (specCond , ERR , (e_ .reason = EV ::specCond_t ::UNEXPECTED_FRAME ,
@@ -1119,8 +1100,7 @@ static bit_t processJoinAccept (void) {
1119
1100
if ( freq ) {
1120
1101
LMIC_setupChannel (chidx , freq , 0 , -1 );
1121
1102
#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 );
1124
1104
#endif
1125
1105
}
1126
1106
}
@@ -1172,6 +1152,8 @@ static bit_t processJoinAccept (void) {
1172
1152
1173
1153
1174
1154
static void processRx2Jacc (xref2osjob_t osjob ) {
1155
+ LMIC_API_PARAMETER (osjob );
1156
+
1175
1157
if ( LMIC .dataLen == 0 ) {
1176
1158
initTxrxFlags (__func__ , 0 ); // nothing in 1st/2nd DN slot
1177
1159
}
@@ -1180,23 +1162,31 @@ static void processRx2Jacc (xref2osjob_t osjob) {
1180
1162
1181
1163
1182
1164
static void setupRx2Jacc (xref2osjob_t osjob ) {
1165
+ LMIC_API_PARAMETER (osjob );
1166
+
1183
1167
LMIC .osjob .func = FUNC_ADDR (processRx2Jacc );
1184
1168
setupRx2 ();
1185
1169
}
1186
1170
1187
1171
1188
1172
static void processRx1Jacc (xref2osjob_t osjob ) {
1173
+ LMIC_API_PARAMETER (osjob );
1174
+
1189
1175
if ( LMIC .dataLen == 0 || !processJoinAccept () )
1190
1176
schedRx12 (DELAY_JACC2_osticks , FUNC_ADDR (setupRx2Jacc ), LMIC .dn2Dr );
1191
1177
}
1192
1178
1193
1179
1194
1180
static void setupRx1Jacc (xref2osjob_t osjob ) {
1181
+ LMIC_API_PARAMETER (osjob );
1182
+
1195
1183
setupRx1 (FUNC_ADDR (processRx1Jacc ));
1196
1184
}
1197
1185
1198
1186
1199
1187
static void jreqDone (xref2osjob_t osjob ) {
1188
+ LMIC_API_PARAMETER (osjob );
1189
+
1200
1190
txDone (DELAY_JACC1_osticks , FUNC_ADDR (setupRx1Jacc ));
1201
1191
}
1202
1192
@@ -1208,10 +1198,14 @@ static void jreqDone (xref2osjob_t osjob) {
1208
1198
static bit_t processDnData (void );
1209
1199
1210
1200
static void processRx2DnDataDelay (xref2osjob_t osjob ) {
1201
+ LMIC_API_PARAMETER (osjob );
1202
+
1211
1203
processDnData ();
1212
1204
}
1213
1205
1214
1206
static void processRx2DnData (xref2osjob_t osjob ) {
1207
+ LMIC_API_PARAMETER (osjob );
1208
+
1215
1209
if ( LMIC .dataLen == 0 ) {
1216
1210
initTxrxFlags (__func__ , 0 ); // nothing in 1st/2nd DN slot
1217
1211
// Delay callback processing to avoid up TX while gateway is txing our missed frame!
@@ -1226,23 +1220,31 @@ static void processRx2DnData (xref2osjob_t osjob) {
1226
1220
1227
1221
1228
1222
static void setupRx2DnData (xref2osjob_t osjob ) {
1223
+ LMIC_API_PARAMETER (osjob );
1224
+
1229
1225
LMIC .osjob .func = FUNC_ADDR (processRx2DnData );
1230
1226
setupRx2 ();
1231
1227
}
1232
1228
1233
1229
1234
1230
static void processRx1DnData (xref2osjob_t osjob ) {
1231
+ LMIC_API_PARAMETER (osjob );
1232
+
1235
1233
if ( LMIC .dataLen == 0 || !processDnData () )
1236
1234
schedRx12 (sec2osticks (LMIC .rxDelay + (int )DELAY_EXTDNW2 ), FUNC_ADDR (setupRx2DnData ), LMIC .dn2Dr );
1237
1235
}
1238
1236
1239
1237
1240
1238
static void setupRx1DnData (xref2osjob_t osjob ) {
1239
+ LMIC_API_PARAMETER (osjob );
1240
+
1241
1241
setupRx1 (FUNC_ADDR (processRx1DnData ));
1242
1242
}
1243
1243
1244
1244
1245
1245
static void updataDone (xref2osjob_t osjob ) {
1246
+ LMIC_API_PARAMETER (osjob );
1247
+
1246
1248
txDone (sec2osticks (LMIC .rxDelay ), FUNC_ADDR (setupRx1DnData ));
1247
1249
}
1248
1250
@@ -1387,7 +1389,9 @@ static void buildDataFrame (void) {
1387
1389
1388
1390
#if !defined(DISABLE_BEACONS )
1389
1391
// 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
+
1391
1395
// If we arrive via job timer make sure to put radio to rest.
1392
1396
os_radio (RADIO_RST );
1393
1397
os_clearCallback (& LMIC .osjob );
@@ -1508,6 +1512,8 @@ static void buildJoinRequest (u1_t ftype) {
1508
1512
}
1509
1513
1510
1514
static void startJoining (xref2osjob_t osjob ) {
1515
+ LMIC_API_PARAMETER (osjob );
1516
+
1511
1517
reportEvent (EV_JOINING );
1512
1518
}
1513
1519
@@ -1541,6 +1547,8 @@ bit_t LMIC_startJoining (void) {
1541
1547
1542
1548
#if !defined(DISABLE_PING )
1543
1549
static void processPingRx (xref2osjob_t osjob ) {
1550
+ LMIC_API_PARAMETER (osjob );
1551
+
1544
1552
if ( LMIC .dataLen != 0 ) {
1545
1553
initTxrxFlags (__func__ , TXRX_PING );
1546
1554
if ( decodeFrame () ) {
@@ -1622,6 +1630,8 @@ static bit_t processDnData (void) {
1622
1630
1623
1631
#if !defined(DISABLE_BEACONS )
1624
1632
static void processBeacon (xref2osjob_t osjob ) {
1633
+ LMIC_API_PARAMETER (osjob );
1634
+
1625
1635
ostime_t lasttx = LMIC .bcninfo .txtime ; // save here - decodeBeacon might overwrite
1626
1636
u1_t flags = LMIC .bcninfo .flags ;
1627
1637
ev_t ev ;
@@ -1683,6 +1693,8 @@ static void processBeacon (xref2osjob_t osjob) {
1683
1693
1684
1694
1685
1695
static void startRxBcn (xref2osjob_t osjob ) {
1696
+ LMIC_API_PARAMETER (osjob );
1697
+
1686
1698
LMIC .osjob .func = FUNC_ADDR (processBeacon );
1687
1699
os_radio (RADIO_RX );
1688
1700
}
@@ -1691,6 +1703,8 @@ static void startRxBcn (xref2osjob_t osjob) {
1691
1703
1692
1704
#if !defined(DISABLE_PING )
1693
1705
static void startRxPing (xref2osjob_t osjob ) {
1706
+ LMIC_API_PARAMETER (osjob );
1707
+
1694
1708
LMIC .osjob .func = FUNC_ADDR (processPingRx );
1695
1709
os_radio (RADIO_RX );
1696
1710
}
@@ -1700,8 +1714,7 @@ static void startRxPing (xref2osjob_t osjob) {
1700
1714
// Decide what to do next for the MAC layer of a device
1701
1715
static void engineUpdate (void ) {
1702
1716
#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 );
1705
1718
#endif
1706
1719
// Check for ongoing state: scan or TX/RX transaction
1707
1720
if ( (LMIC .opmode & (OP_SCAN |OP_TXRXPEND |OP_SHUTDOWN )) != 0 )
@@ -1715,9 +1728,10 @@ static void engineUpdate (void) {
1715
1728
#endif // !DISABLE_JOIN
1716
1729
1717
1730
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 ;
1720
1732
ostime_t txbeg = 0 ;
1733
+ // ttn-esp32: suppress unused variable
1734
+ LMIC_UNREFERENCED_VARIABLE (rxtime );
1721
1735
1722
1736
#if !defined(DISABLE_BEACONS )
1723
1737
if ( (LMIC .opmode & OP_TRACK ) != 0 ) {
@@ -1861,7 +1875,7 @@ static void engineUpdate (void) {
1861
1875
e_ .eui = MAIN ::CDEV -> getEui (),
1862
1876
e_ .info = osticks2ms (txbeg - now ),
1863
1877
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 );
1865
1879
os_setTimedCallback (& LMIC .osjob , txbeg - TX_RAMPUP , FUNC_ADDR (runEngineUpdate ));
1866
1880
}
1867
1881
0 commit comments