LMiC adapted to work with SX1272MB2xAS LoRa shield.
Fork of LMiC by
Diff: lmic.cpp
- Revision:
- 8:5879e83f632a
- Parent:
- 7:29058a7ccf23
--- a/lmic.cpp Thu Feb 25 21:28:23 2016 +0000 +++ b/lmic.cpp Mon Apr 02 12:04:59 2018 +0000 @@ -7,7 +7,20 @@ * * Contributors: * IBM Zurich Research Lab - initial API, implementation and documentation - *******************************************************************************/ + * + * ///////////////////////////////////////////////////////////////////////////// + * + * Used by Giorgos Tsapparellas for Internet of Things (IoT) smart monitoring + * device for agriculture using LoRaWAN technology. + * + * Date of issued copy: 25 January 2018 + * + * Modifications: + * - No external modifications of the existing "AS IT IS" software. + * - Comment out debug messages of each function for more clear + * debugging procedure. + * + ******************************************************************************/ //! \file #include "lmic.h" @@ -60,7 +73,7 @@ #if !defined(os_rlsbf2) u2_t os_rlsbf2 (xref2cu1_t buf) { - debug("LMIC os_rlsbf2 enter\r\n"); + //debug("LMIC os_rlsbf2 enter\r\n"); return (u2_t)(buf[0] | (buf[1]<<8)); } #endif @@ -68,7 +81,7 @@ #if !defined(os_rlsbf4) u4_t os_rlsbf4 (xref2cu1_t buf) { - debug("LMIC os_rlsbf4 enter\r\n"); + //debug("LMIC os_rlsbf4 enter\r\n"); return (u4_t)(buf[0] | (buf[1]<<8) | ((u4_t)buf[2]<<16) | ((u4_t)buf[3]<<24)); } #endif @@ -77,7 +90,7 @@ #if !defined(os_rmsbf4) u4_t os_rmsbf4 (xref2cu1_t buf) { - debug("LMIC os_rmsbf4 enter\r\n"); + //debug("LMIC os_rmsbf4 enter\r\n"); return (u4_t)(buf[3] | (buf[2]<<8) | ((u4_t)buf[1]<<16) | ((u4_t)buf[0]<<24)); } #endif @@ -86,7 +99,7 @@ #if !defined(os_wlsbf2) void os_wlsbf2 (xref2u1_t buf, u2_t v) { - debug("LMIC os_wlsbf2 enter\r\n"); + //debug("LMIC os_wlsbf2 enter\r\n"); buf[0] = v; buf[1] = v>>8; } @@ -95,7 +108,7 @@ #if !defined(os_wlsbf4) void os_wlsbf4 (xref2u1_t buf, u4_t v) { - debug("LMIC os_wlsbf4 enter\r\n"); + //debug("LMIC os_wlsbf4 enter\r\n"); buf[0] = v; buf[1] = v>>8; buf[2] = v>>16; @@ -106,7 +119,7 @@ #if !defined(os_wmsbf4) void os_wmsbf4 (xref2u1_t buf, u4_t v) { - debug("LMIC os_wmsbf4 enter\r\n"); + //debug("LMIC os_wmsbf4 enter\r\n"); buf[3] = v; buf[2] = v>>8; buf[1] = v>>16; @@ -117,7 +130,7 @@ #if !defined(os_getBattLevel) u1_t os_getBattLevel (void) { - debug("LMIC os_getBattLevel enter\r\n"); + //debug("LMIC os_getBattLevel enter\r\n"); return MCMD_DEVS_BATT_NOINFO; } #endif @@ -126,7 +139,7 @@ // New CRC-16 CCITT(XMODEM) checksum for beacons: u2_t os_crc16 (xref2u1_t data, uint len) { - debug("LMIC os_crc16 enter\r\n"); + //debug("LMIC os_crc16 enter\r\n"); u2_t remainder = 0; u2_t polynomial = 0x1021; for( uint i = 0; i < len; i++ ) @@ -154,7 +167,7 @@ static void micB0 (u4_t devaddr, u4_t seqno, int dndir, int len) { - debug("LMIC micB0 enter\r\n"); + //debug("LMIC micB0 enter\r\n"); os_clearMem(AESaux,16); AESaux[0] = 0x49; AESaux[5] = dndir?1:0; @@ -166,7 +179,7 @@ static int aes_verifyMic (xref2cu1_t key, u4_t devaddr, u4_t seqno, int dndir, xref2u1_t pdu, int len) { - debug("LMIC aes_verifyMic enter\r\n"); + //debug("LMIC aes_verifyMic enter\r\n"); micB0(devaddr, seqno, dndir, len); os_copyMem(AESkey,key,16); return os_aes(AES_MIC, pdu, len) == os_rmsbf4(pdu+len); @@ -175,7 +188,7 @@ static void aes_appendMic (xref2cu1_t key, u4_t devaddr, u4_t seqno, int dndir, xref2u1_t pdu, int len) { - debug("LMIC aes_appendMic enter\r\n"); + //debug("LMIC aes_appendMic enter\r\n"); micB0(devaddr, seqno, dndir, len); os_copyMem(AESkey,key,16); // MSB because of internal structure of AES @@ -185,15 +198,15 @@ static void aes_appendMic0 (xref2u1_t pdu, int len) { - debug("LMIC aes_appendMic0 enter\r\n"); + //debug("LMIC aes_appendMic0 enter\r\n"); os_getDevKey(AESkey); - os_wmsbf4(pdu+len, os_aes(AES_MIC|AES_MICNOAUX, pdu, len)); // MSB because of internal structure of AES + os_wmsbf4(pdu+len, os_aes(AES_MIC|AES_MICNOAUX, pdu, len)); // MSB because of internal structure of AES } static int aes_verifyMic0 (xref2u1_t pdu, int len) { - debug("LMIC aes_verifyMic0 enter\r\n"); + //debug("LMIC aes_verifyMic0 enter\r\n"); os_getDevKey(AESkey); return os_aes(AES_MIC|AES_MICNOAUX, pdu, len) == os_rmsbf4(pdu+len); } @@ -201,7 +214,7 @@ static void aes_encrypt (xref2u1_t pdu, int len) { - debug("LMIC aes_encrypt enter\r\n"); + //debug("LMIC aes_encrypt enter\r\n"); os_getDevKey(AESkey); os_aes(AES_ENC, pdu, len); } @@ -209,7 +222,7 @@ static void aes_cipher (xref2cu1_t key, u4_t devaddr, u4_t seqno, int dndir, xref2u1_t payload, int len) { - debug("LMIC aes_cipher enter\r\n"); + //debug("LMIC aes_cipher enter\r\n"); if( len <= 0 ) return; os_clearMem(AESaux, 16); @@ -224,7 +237,7 @@ static void aes_sessKeys (u2_t devnonce, xref2cu1_t artnonce, xref2u1_t nwkkey, xref2u1_t artkey) { - debug("LMIC aes_sessKeys enter\r\n"); + //debug("LMIC aes_sessKeys enter\r\n"); os_clearMem(nwkkey, 16); nwkkey[0] = 0x01; os_copyMem(nwkkey+1, artnonce, LEN_ARTNONCE+LEN_NETID); @@ -310,13 +323,13 @@ int getSensitivity (rps_t rps) { - debug("LMIC getSensitivity enter\r\n"); + //debug("LMIC getSensitivity enter\r\n"); return -141 + SENSITIVITY[getSf(rps)][getBw(rps)]; } ostime_t calcAirTime (rps_t rps, u1_t plen) { - debug("LMIC calcAirTime enter\r\n"); + //debug("LMIC calcAirTime enter\r\n"); u1_t bw = getBw(rps); // 0,1,2 = 125,250,500kHz u1_t sf = getSf(rps); // 0=FSK, 1..6 = SF7..12 if( sf == FSK ) { @@ -433,7 +446,7 @@ static ostime_t calcRxWindow (u1_t secs, dr_t dr) { - debug("LMIC calcRxWindow enter\r\n"); + //debug("LMIC calcRxWindow enter\r\n"); ostime_t rxoff, err; if( secs==0 ) { // aka 128 secs (next becaon) @@ -455,7 +468,7 @@ // Setup beacon RX parameters assuming we have an error of ms (aka +/-(ms/2)) static void calcBcnRxWindowFromMillis (u1_t ms, bit_t ini) { - debug("LMIC calcBcnRxWindowFromMillis enter\r\n"); + //debug("LMIC calcBcnRxWindowFromMillis enter\r\n"); if( ini ) { LMIC.drift = 0; LMIC.maxDriftDiff = 0; @@ -471,7 +484,7 @@ // Setup scheduled RX window (ping/multicast slot) static void rxschedInit (xref2rxsched_t rxsched) { - debug("LMIC rxschedInit enter\r\n"); + //debug("LMIC rxschedInit enter\r\n"); os_clearMem(AESkey,16); os_clearMem(LMIC.frame+8,8); os_wlsbf4(LMIC.frame, LMIC.bcninfo.time); @@ -490,7 +503,7 @@ static bit_t rxschedNext (xref2rxsched_t rxsched, ostime_t cando) { - debug("LMIC rxschedNext enter\r\n"); + //debug("LMIC rxschedNext enter\r\n"); again: if( rxsched->rxtime - cando >= 0 ) return 1; @@ -510,7 +523,7 @@ static ostime_t rndDelay (u1_t secSpan) { - debug("LMIC rndDelay enter\r\n"); + //debug("LMIC rndDelay enter\r\n"); u2_t r = os_getRndU2(); ostime_t delay = r; if( delay > OSTICKS_PER_SEC ) @@ -523,7 +536,7 @@ static void txDelay (ostime_t reftime, u1_t secSpan) { - debug("LMIC txDelay enter\r\n"); + //debug("LMIC txDelay enter\r\n"); reftime += rndDelay(secSpan); if( LMIC.globalDutyRate == 0 || (reftime - LMIC.globalDutyAvail) > 0 ) { LMIC.globalDutyAvail = reftime; @@ -534,7 +547,7 @@ static void setDrJoin (u1_t reason, u1_t dr) { - debug("LMIC setDrJoin enter\r\n"); + //debug("LMIC setDrJoin enter\r\n"); EV(drChange, INFO, (e_.reason = reason, e_.deveui = MAIN::CDEV->getEui(), e_.dr = dr|DR_PAGE, @@ -548,7 +561,7 @@ static void setDrTxpow (u1_t reason, u1_t dr, s1_t pow) { - debug("LMIC setDrTxpow enter\r\n"); + //debug("LMIC setDrTxpow enter\r\n"); EV(drChange, INFO, (e_.reason = reason, e_.deveui = MAIN::CDEV->getEui(), e_.dr = dr|DR_PAGE, @@ -571,14 +584,14 @@ void LMIC_stopPingable (void) { - debug("LMIC LMIC_stopPingable enter\r\n"); + //debug("LMIC LMIC_stopPingable enter\r\n"); LMIC.opmode &= ~(OP_PINGABLE|OP_PINGINI); } void LMIC_setPingable (u1_t intvExp) { - debug("LMIC LMIC_setPingable enter\r\n"); + //debug("LMIC LMIC_setPingable enter\r\n"); // Change setting LMIC.ping.intvExp = (intvExp & 0x7); LMIC.opmode |= OP_PINGABLE; @@ -691,7 +704,6 @@ return 1; } - static void updateTx (ostime_t txbeg) { u4_t freq = LMIC.channelFreq[LMIC.txChnl]; // Update global/band specific duty cycle stats @@ -1066,14 +1078,14 @@ static void runEngineUpdate (xref2osjob_t osjob) { - debug("LMIC runEngineUpdate enter\r\n"); + //debug("LMIC runEngineUpdate enter\r\n"); engineUpdate(); } static void reportEvent (ev_t ev) { - debug("LMIC reportEvent enter %d\r\n",ev); + //debug("LMIC reportEvent enter %d\r\n",ev); EV(devCond, INFO, (e_.reason = EV::devCond_t::LMIC_EV, e_.eui = MAIN::CDEV->getEui(), e_.info = ev)); @@ -1084,7 +1096,7 @@ static void runReset (xref2osjob_t osjob) { -debug("LMIC runReset enterr\n"); + //debug("LMIC runReset enterr\n"); // Disable session LMIC_reset(); LMIC_startJoining(); @@ -1093,7 +1105,7 @@ static void stateJustJoined (void) { -debug("LMIC stateJustJoined enter\r\n"); + //debug("LMIC stateJustJoined enter\r\n"); LMIC.seqnoDn = LMIC.seqnoUp = 0; LMIC.rejoinCnt = 0; LMIC.dnConf = LMIC.adrChanged = LMIC.ladrAns = LMIC.devsAns = 0; @@ -1116,7 +1128,7 @@ // Decode beacon - do not overwrite bcninfo unless we have a match! static int decodeBeacon (void) { -debug("LMIC decodeBeacon enter\r\n"); +//debug("LMIC decodeBeacon enter\r\n"); ASSERT(LMIC.dataLen == LEN_BCN); // implicit header RX guarantees this xref2u1_t d = LMIC.frame; if( @@ -1154,7 +1166,7 @@ static bit_t decodeFrame (void) { -debug("LMIC decodeFrame enter\r\n"); + //debug("LMIC decodeFrame enter\r\n"); xref2u1_t d = LMIC.frame; u1_t hdr = d[0]; u1_t ftype = hdr & HDR_FTYPE; @@ -1448,7 +1460,7 @@ static void setupRx2 (void) { -debug("LMIC setupRx2 enter\r\n"); +//debug("LMIC setupRx2 enter\r\n"); LMIC.txrxFlags = TXRX_DNW2; LMIC.rps = dndr2rps(LMIC.dn2Dr); LMIC.freq = LMIC.dn2Freq; @@ -1459,16 +1471,16 @@ static void schedRx2 (ostime_t delay, osjobcb_t func) { -debug("LMIC schedRx2 enter\r\n"); + //debug("LMIC schedRx2 enter\r\n"); // Add 1.5 symbols we need 5 out of 8. Try to sync 1.5 symbols into the preamble. LMIC.rxtime = LMIC.txend + delay + (PAMBL_SYMS-MINRX_SYMS)*dr2hsym(LMIC.dn2Dr); -// LMIC.rxtime = LMIC.txend + delay; + //LMIC.rxtime = LMIC.txend + delay; os_setTimedCallback(&LMIC.osjob, LMIC.rxtime - RX_RAMPUP, func); } static void setupRx1 (osjobcb_t func) { -debug("LMIC setupRx1 enter\r\n"); + //debug("LMIC setupRx1 enter\r\n"); LMIC.txrxFlags = TXRX_DNW1; // Turn LMIC.rps from TX over to RX LMIC.rps = setNocrc(LMIC.rps,1); @@ -1481,7 +1493,7 @@ // Called by HAL once TX complete and delivers exact end of TX time stamp in LMIC.rxtime static void txDone (ostime_t delay, osjobcb_t func) { -debug("LMIC txDone enter\r\n"); + //debug("LMIC txDone enter\r\n"); if( (LMIC.opmode & (OP_TRACK|OP_PINGABLE|OP_PINGINI)) == (OP_TRACK|OP_PINGABLE) ) { rxschedInit(&LMIC.ping); // note: reuses LMIC.frame buffer! @@ -1502,7 +1514,7 @@ #endif { LMIC.rxtime = LMIC.txend + delay + (PAMBL_SYMS-MINRX_SYMS)*dr2hsym(LMIC.dndr); -// LMIC.rxtime = LMIC.txend + delay; +// LMIC.rxtime = LMIC.txend + delay; LMIC.rxsyms = MINRX_SYMS; } os_setTimedCallback(&LMIC.osjob, LMIC.rxtime - RX_RAMPUP, func); @@ -1514,7 +1526,7 @@ static void onJoinFailed (xref2osjob_t osjob) { -debug("LMIC onJoinFailed enter\r\n"); + //debug("LMIC onJoinFailed enter\r\n"); // Notify app - must call LMIC_reset() to stop joining // otherwise join procedure continues. reportEvent(EV_JOIN_FAILED); @@ -1523,7 +1535,7 @@ static bit_t processJoinAccept (void) { -debug("LMIC processJoinAccept enter\r\n"); + //debug("LMIC processJoinAccept enter\r\n"); ASSERT(LMIC.txrxFlags != TXRX_DNW1 || LMIC.dataLen != 0); ASSERT((LMIC.opmode & OP_TXRXPEND)!=0); @@ -1624,7 +1636,7 @@ static void processRx2Jacc (xref2osjob_t osjob) { -debug("LMIC processRx2Jacc enter\r\n"); + //debug("LMIC processRx2Jacc enter\r\n"); if( LMIC.dataLen == 0 ) LMIC.txrxFlags = 0; // nothing in 1st/2nd DN slot processJoinAccept(); @@ -1633,7 +1645,7 @@ static void setupRx2Jacc (xref2osjob_t osjob) { -debug("LMIC setupRx2Jacc enter\r\n"); + //debug("LMIC setupRx2Jacc enter\r\n"); LMIC.osjob.func = FUNC_ADDR(processRx2Jacc); setupRx2(); } @@ -1641,7 +1653,7 @@ static void processRx1Jacc (xref2osjob_t osjob) { -debug("LMIC processRx1Jacc enter\r\n"); + //debug("LMIC processRx1Jacc enter\r\n"); if( LMIC.dataLen == 0 || !processJoinAccept() ) schedRx2(DELAY_JACC2_osticks, FUNC_ADDR(setupRx2Jacc)); } @@ -1649,14 +1661,14 @@ static void setupRx1Jacc (xref2osjob_t osjob) { -debug("LMIC setupRx1Jacc enter\r\n"); + //debug("LMIC setupRx1Jacc enter\r\n"); setupRx1(FUNC_ADDR(processRx1Jacc)); } static void jreqDone (xref2osjob_t osjob) { -debug("LMIC jreqDone enter\r\n"); + //debug("LMIC jreqDone enter\r\n"); txDone(DELAY_JACC1_osticks, FUNC_ADDR(setupRx1Jacc)); } @@ -1667,13 +1679,13 @@ static void processRx2DnDataDelay (xref2osjob_t osjob) { -debug("LMIC processRx2DnDataDelay enter\r\n"); + //debug("LMIC processRx2DnDataDelay enter\r\n"); processDnData(); } static void processRx2DnData (xref2osjob_t osjob) { -debug("LMIC processRx2DnData enter\r\n"); + //debug("LMIC processRx2DnData enter\r\n"); if( LMIC.dataLen == 0 ) { LMIC.txrxFlags = 0; // nothing in 1st/2nd DN slot // Delay callback processing to avoid up TX while gateway is txing our missed frame! @@ -1689,7 +1701,7 @@ static void setupRx2DnData (xref2osjob_t osjob) { -debug("LMIC setupRx2DnData enter\r\n"); + //debug("LMIC setupRx2DnData enter\r\n"); LMIC.osjob.func = FUNC_ADDR(processRx2DnData); setupRx2(); } @@ -1697,7 +1709,7 @@ static void processRx1DnData (xref2osjob_t osjob) { -debug("LMIC processRx1DnData enter\r\n"); + //debug("LMIC processRx1DnData enter\r\n"); if( LMIC.dataLen == 0 || !processDnData() ) schedRx2(DELAY_DNW2_osticks, FUNC_ADDR(setupRx2DnData)); } @@ -1705,14 +1717,14 @@ static void setupRx1DnData (xref2osjob_t osjob) { -debug("LMIC setupRx1DnData enter\r\n"); + //debug("LMIC setupRx1DnData enter\r\n"); setupRx1(FUNC_ADDR(processRx1DnData)); } static void updataDone (xref2osjob_t osjob) { -debug("LMIC updataDone enter\r\n"); + //debug("LMIC updataDone enter\r\n"); txDone(DELAY_DNW1_osticks, FUNC_ADDR(setupRx1DnData)); } @@ -1721,7 +1733,7 @@ static void buildDataFrame (void) { -debug("LMIC buildDataFrame enter\r\n"); + //debug("LMIC buildDataFrame enter\r\n"); bit_t txdata = ((LMIC.opmode & (OP_TXDATA|OP_POLL)) != OP_POLL); u1_t dlen = txdata ? LMIC.pendTxLen : 0; @@ -1841,7 +1853,7 @@ // Callback from HAL during scan mode or when job timer expires. static void onBcnRx (xref2osjob_t job) { -debug("LMIC onBcnRx enter\r\n"); + //debug("LMIC onBcnRx enter\r\n"); // If we arrive via job timer make sure to put radio to rest. os_radio(RADIO_RST); os_clearCallback(&LMIC.osjob); @@ -1875,7 +1887,7 @@ // Also cancels an onpoing joining procedure. static void startScan (void) { -debug("LMIC startScan enter\r\n"); + //debug("LMIC startScan enter\r\n"); ASSERT(LMIC.devaddr!=0 && (LMIC.opmode & OP_JOINING)==0); if( (LMIC.opmode & OP_SHUTDOWN) != 0 ) return; @@ -1891,7 +1903,7 @@ bit_t LMIC_enableTracking (u1_t tryBcnInfo) { -debug("LMIC LMIC_enableTracking enter\r\n"); + //debug("LMIC LMIC_enableTracking enter\r\n"); if( (LMIC.opmode & (OP_SCAN|OP_TRACK|OP_SHUTDOWN)) != 0 ) return 0; // already in progress or failed to enable // If BCN info requested from NWK then app has to take are @@ -1904,7 +1916,7 @@ void LMIC_disableTracking (void) { -debug("LMIC LMIC_disableTracking enter\r\n"); + //debug("LMIC LMIC_disableTracking enter\r\n"); LMIC.opmode &= ~(OP_SCAN|OP_TRACK); LMIC.bcninfoTries = 0; engineUpdate(); @@ -1919,7 +1931,7 @@ static void buildJoinRequest (u1_t ftype) { -debug("LMIC buildJoinRequest enter\r\n"); + //debug("LMIC buildJoinRequest enter\r\n"); // Do not use pendTxData since we might have a pending // user level frame in there. Use RX holding area instead. xref2u1_t d = LMIC.frame; @@ -1944,14 +1956,14 @@ static void startJoining (xref2osjob_t osjob) { -debug("LMIC startJoining enter\r\n"); + //debug("LMIC startJoining enter\r\n"); reportEvent(EV_JOINING); } // Start join procedure if not already joined. bit_t LMIC_startJoining (void) { -debug("LMIC LMIC_startJoining enter\r\n"); + //debug("LMIC LMIC_startJoining enter\r\n"); if( LMIC.devaddr == 0 ) { // There should be no TX/RX going on @@ -1980,7 +1992,7 @@ static void processPingRx (xref2osjob_t osjob) { -debug("LMIC processPingRx enter\r\n"); + //debug("LMIC processPingRx enter\r\n"); if( LMIC.dataLen != 0 ) { LMIC.txrxFlags = TXRX_PING; if( decodeFrame() ) { @@ -1995,7 +2007,7 @@ static bit_t processDnData (void) { -debug("LMIC processDnData enter\r\n"); + //debug("LMIC processDnData enter\r\n"); ASSERT((LMIC.opmode & OP_TXRXPEND)!=0); if( LMIC.dataLen == 0 ) { @@ -2061,7 +2073,7 @@ static void processBeacon (xref2osjob_t osjob) { -debug("LMIC processBeacon enter\r\n"); + //debug("LMIC processBeacon enter\r\n"); ostime_t lasttx = LMIC.bcninfo.txtime; // save here - decodeBeacon might overwrite u1_t flags = LMIC.bcninfo.flags; ev_t ev; @@ -2124,7 +2136,7 @@ static void startRxBcn (xref2osjob_t osjob) { -debug("LMIC startRxBcn enter\r\n"); + //debug("LMIC startRxBcn enter\r\n"); LMIC.osjob.func = FUNC_ADDR(processBeacon); os_radio(RADIO_RX); } @@ -2132,7 +2144,7 @@ static void startRxPing (xref2osjob_t osjob) { -debug("LMIC startRxPing enter\r\n"); + //debug("LMIC startRxPing enter\r\n"); LMIC.osjob.func = FUNC_ADDR(processPingRx); os_radio(RADIO_RX); } @@ -2141,7 +2153,7 @@ // Decide what to do next for the MAC layer of a device static void engineUpdate (void) { -debug("LMIC engineUpdate enter\r\n"); + //debug("LMIC engineUpdate enter\r\n"); // Check for ongoing state: scan or TX/RX transaction if( (LMIC.opmode & (OP_SCAN|OP_TXRXPEND|OP_SHUTDOWN)) != 0 ) return; @@ -2289,7 +2301,7 @@ void LMIC_setAdrMode (bit_t enabled) { -debug("LMIC LMIC_setAdrMode enter\r\n"); + //debug("LMIC LMIC_setAdrMode enter\r\n"); LMIC.adrEnabled = enabled ? FCT_ADREN : 0; } @@ -2297,14 +2309,14 @@ // Should we have/need an ext. API like this? void LMIC_setDrTxpow (dr_t dr, s1_t txpow) { -debug("LMIC LMIC_setDrTxpow enter\r\n"); + //debug("LMIC LMIC_setDrTxpow enter\r\n"); setDrTxpow(DRCHG_SET, dr, txpow); } void LMIC_shutdown (void) { -debug("LMIC LMIC_shutdown enter\r\n"); + //debug("LMIC LMIC_shutdown enter\r\n"); os_clearCallback(&LMIC.osjob); os_radio(RADIO_RST); LMIC.opmode |= OP_SHUTDOWN; @@ -2313,7 +2325,7 @@ void LMIC_reset (void) { -debug("LMIC LMIC_reset enter\r\n"); + //debug("LMIC LMIC_reset enter\r\n"); EV(devCond, INFO, (e_.reason = EV::devCond_t::LMIC_EV, e_.eui = MAIN::CDEV->getEui(), e_.info = EV_RESET)); @@ -2345,14 +2357,14 @@ void LMIC_init (void) { - debug("LMIC_init enter\r\n"); + // debug("LMIC_init enter\r\n"); LMIC.opmode = OP_SHUTDOWN; } void LMIC_clrTxData (void) { -debug("LMIC LMIC_clrTxData enter\r\n"); + //debug("LMIC LMIC_clrTxData enter\r\n"); LMIC.opmode &= ~(OP_TXDATA|OP_TXRXPEND|OP_POLL); LMIC.pendTxLen = 0; if( (LMIC.opmode & (OP_JOINING|OP_SCAN)) != 0 ) // do not interfere with JOINING @@ -2365,7 +2377,7 @@ void LMIC_setTxData (void) { -debug("LMIC LMIC_setTxData enter\r\n"); + //debug("LMIC LMIC_setTxData enter\r\n"); LMIC.opmode |= OP_TXDATA; if( (LMIC.opmode & OP_JOINING) == 0 ) LMIC.txCnt = 0; // cancel any ongoing TX/RX retries @@ -2376,7 +2388,7 @@ // int LMIC_setTxData2 (u1_t port, xref2u1_t data, u1_t dlen, u1_t confirmed) { -debug("LMIC LMIC_setTxData2 enter\r\n"); + //debug("LMIC LMIC_setTxData2 enter\r\n"); if( dlen > SIZEOFEXPR(LMIC.pendTxData) ) return -2; if( data != (xref2u1_t)0 ) @@ -2392,7 +2404,7 @@ // Send a payload-less message to signal device is alive void LMIC_sendAlive (void) { -debug("LMIC LMIC_sendAlive enter\r\n"); + //debug("LMIC LMIC_sendAlive enter\r\n"); LMIC.opmode |= OP_POLL; engineUpdate(); } @@ -2401,7 +2413,7 @@ // Check if other networks are around. void LMIC_tryRejoin (void) { -debug("LMIC LMIC_tryRejoin enter\r\n"); + //debug("LMIC LMIC_tryRejoin enter\r\n"); LMIC.opmode |= OP_REJOIN; engineUpdate(); } @@ -2422,7 +2434,7 @@ //! If NULL the caller has copied the key into `LMIC.artKey` before. void LMIC_setSession (u4_t netid, devaddr_t devaddr, xref2u1_t nwkKey, xref2u1_t artKey) { -debug("LMIC LMIC_setSession enter\r\n"); + //debug("LMIC LMIC_setSession enter\r\n"); LMIC.netid = netid; LMIC.devaddr = devaddr; if( nwkKey != (xref2u1_t)0 ) @@ -2449,7 +2461,7 @@ // This must be called only if a session is established (e.g. after EV_JOINED) void LMIC_setLinkCheckMode (bit_t enabled) { -debug("LMIC LMIC_setLinkCheckMode enter\r\n"); + //debug("LMIC LMIC_setLinkCheckMode enter\r\n"); LMIC.adrChanged = 0; LMIC.adrAckReq = enabled ? LINK_CHECK_INIT : LINK_CHECK_OFF; }