[LoRaWAN] Collection of fixes (also fixes #1254)
This commit is contained in:
parent
dc77e6e662
commit
9db98f2ab4
2 changed files with 10 additions and 6 deletions
|
@ -183,11 +183,12 @@ int16_t LoRaWANNode::sendReceive(uint8_t* dataUp, size_t lenUp, uint8_t fPort, u
|
||||||
eventUp->nbTrans = trans;
|
eventUp->nbTrans = trans;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if a hardware error occurred, return
|
|
||||||
if(state < RADIOLIB_ERR_NONE) {
|
|
||||||
#if !RADIOLIB_STATIC_ONLY
|
#if !RADIOLIB_STATIC_ONLY
|
||||||
delete[] uplinkMsg;
|
delete[] uplinkMsg;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// if a hardware error occurred, return
|
||||||
|
if(state < RADIOLIB_ERR_NONE) {
|
||||||
return(state);
|
return(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -938,6 +939,9 @@ int16_t LoRaWANNode::activateOTAA(uint8_t joinDr, LoRaWANJoinEvent_t *joinEvent)
|
||||||
this->devNonce += 1;
|
this->devNonce += 1;
|
||||||
LoRaWANNode::hton<uint16_t>(&this->bufferNonces[RADIOLIB_LORAWAN_NONCES_DEV_NONCE], this->devNonce);
|
LoRaWANNode::hton<uint16_t>(&this->bufferNonces[RADIOLIB_LORAWAN_NONCES_DEV_NONCE], this->devNonce);
|
||||||
|
|
||||||
|
// set the Time on Air of the JoinRequest
|
||||||
|
this->lastToA = this->phyLayer->getTimeOnAir(RADIOLIB_LORAWAN_JOIN_REQUEST_LEN) / 1000;
|
||||||
|
|
||||||
// configure Rx1 and Rx2 delay for JoinAccept message - these are re-configured once a valid JoinAccept is received
|
// configure Rx1 and Rx2 delay for JoinAccept message - these are re-configured once a valid JoinAccept is received
|
||||||
this->rxDelays[1] = RADIOLIB_LORAWAN_JOIN_ACCEPT_DELAY_1_MS;
|
this->rxDelays[1] = RADIOLIB_LORAWAN_JOIN_ACCEPT_DELAY_1_MS;
|
||||||
this->rxDelays[2] = RADIOLIB_LORAWAN_JOIN_ACCEPT_DELAY_2_MS;
|
this->rxDelays[2] = RADIOLIB_LORAWAN_JOIN_ACCEPT_DELAY_2_MS;
|
||||||
|
@ -1481,7 +1485,7 @@ int16_t LoRaWANNode::parseDownlink(uint8_t* data, size_t* len, LoRaWANEvent_t* e
|
||||||
// check the address
|
// check the address
|
||||||
uint32_t addr = LoRaWANNode::ntoh<uint32_t>(&downlinkMsg[RADIOLIB_LORAWAN_FHDR_DEV_ADDR_POS]);
|
uint32_t addr = LoRaWANNode::ntoh<uint32_t>(&downlinkMsg[RADIOLIB_LORAWAN_FHDR_DEV_ADDR_POS]);
|
||||||
if(addr != this->devAddr) {
|
if(addr != this->devAddr) {
|
||||||
RADIOLIB_DEBUG_PROTOCOL_PRINTLN("Device address mismatch, expected 0x%08X, got 0x%08X", this->devAddr, addr);
|
RADIOLIB_DEBUG_PROTOCOL_PRINTLN("Device address mismatch, expected 0x%08lX, got 0x%08lX", this->devAddr, addr);
|
||||||
#if !RADIOLIB_STATIC_ONLY
|
#if !RADIOLIB_STATIC_ONLY
|
||||||
delete[] downlinkMsg;
|
delete[] downlinkMsg;
|
||||||
#endif
|
#endif
|
||||||
|
@ -3197,7 +3201,7 @@ bool LoRaWANNode::verifyMIC(uint8_t* msg, size_t len, uint8_t* key) {
|
||||||
// calculate the expected value and compare
|
// calculate the expected value and compare
|
||||||
uint32_t micCalculated = generateMIC(msg, len - sizeof(uint32_t), key);
|
uint32_t micCalculated = generateMIC(msg, len - sizeof(uint32_t), key);
|
||||||
if(micCalculated != micReceived) {
|
if(micCalculated != micReceived) {
|
||||||
RADIOLIB_DEBUG_PROTOCOL_PRINTLN("MIC mismatch, expected %08x, got %08x", micCalculated, micReceived);
|
RADIOLIB_DEBUG_PROTOCOL_PRINTLN("MIC mismatch, expected %08lx, got %08lx", micCalculated, micReceived);
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -605,7 +605,7 @@ class LoRaWANNode {
|
||||||
\param initialDr The datarate at which to send the first uplink and any subsequent uplinks (unless ADR is enabled).
|
\param initialDr The datarate at which to send the first uplink and any subsequent uplinks (unless ADR is enabled).
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t activateABP(uint8_t initialDr = RADIOLIB_LORAWAN_DATA_RATE_UNUSED);
|
virtual int16_t activateABP(uint8_t initialDr = RADIOLIB_LORAWAN_DATA_RATE_UNUSED);
|
||||||
|
|
||||||
/*! \brief Whether there is an ongoing session active */
|
/*! \brief Whether there is an ongoing session active */
|
||||||
bool isActivated();
|
bool isActivated();
|
||||||
|
|
Loading…
Add table
Reference in a new issue