[LoRaWAN] Fix warnings

This commit is contained in:
StevenCellist 2024-01-05 11:36:01 +01:00
parent 574555ca09
commit 853c1731ca

View file

@ -307,7 +307,7 @@ int16_t LoRaWANNode::restoreChannels() {
#endif #endif
void LoRaWANNode::beginCommon() { void LoRaWANNode::beginCommon() {
LoRaWANMacCommand_t cmd; LoRaWANMacCommand_t cmd = { 0, 0, 0, 0 };
cmd.cid = RADIOLIB_LORAWAN_MAC_LINK_ADR; cmd.cid = RADIOLIB_LORAWAN_MAC_LINK_ADR;
cmd.len = MacTable[RADIOLIB_LORAWAN_MAC_LINK_ADR].lenDn; cmd.len = MacTable[RADIOLIB_LORAWAN_MAC_LINK_ADR].lenDn;
cmd.payload[0] = (this->dataRates[RADIOLIB_LORAWAN_CHANNEL_DIR_UPLINK] << 4); cmd.payload[0] = (this->dataRates[RADIOLIB_LORAWAN_CHANNEL_DIR_UPLINK] << 4);
@ -1449,11 +1449,9 @@ int16_t LoRaWANNode::downlink(uint8_t* data, size_t* len, LoRaWANEvent_t* event)
} }
RADIOLIB_DEBUG_PRINTLN("MAC response:"); RADIOLIB_DEBUG_PRINTLN("MAC response:");
for (int x; x < this->commandsUp.numCommands; x++) { for (int i = 0; i < this->commandsUp.numCommands; i++) {
LoRaWANMacCommand_t cmd = this->commandsUp.commands[x]; RADIOLIB_DEBUG_HEXDUMP(&this->commandsUp[i].cid, sizeof(LoRaWANMacCommand_t));
RADIOLIB_DEBUG_PRINTLN("[%02x] %02x %02x %02x %02x %02x (%02x)", cmd.cid, }
cmd.payload[0], cmd.payload[1], cmd.payload[2], cmd.payload[3], cmd.payload[4], cmd.len);
}
// if FOptsLen for the next uplink is larger than can be piggybacked onto an uplink, send separate uplink // if FOptsLen for the next uplink is larger than can be piggybacked onto an uplink, send separate uplink
if(this->commandsUp.len > 15) { if(this->commandsUp.len > 15) {
@ -1972,8 +1970,10 @@ uint32_t LoRaWANNode::dutyCycleInterval(uint32_t msPerHour, uint32_t airtime) {
uint32_t LoRaWANNode::timeUntilUplink() { uint32_t LoRaWANNode::timeUntilUplink() {
Module* mod = this->phyLayer->getMod(); Module* mod = this->phyLayer->getMod();
uint32_t nextUplink = this->rxDelayStart + dutyCycleInterval(this->dutyCycle, this->lastToA); uint32_t nextUplink = this->rxDelayStart + dutyCycleInterval(this->dutyCycle, this->lastToA);
uint32_t timeRemaining = RADIOLIB_MAX(0, nextUplink - mod->hal->millis() + 1); if(mod->hal->millis() > nextUplink){
return(timeRemaining); return(0);
}
return(nextUplink - mod->hal->millis() + 1);
} }
void LoRaWANNode::setDwellTime(bool enable, uint32_t msPerUplink) { void LoRaWANNode::setDwellTime(bool enable, uint32_t msPerUplink) {