Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions Firmware/LoRaSerial/States.ino
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@ void updateRadioState()
//----------
//Always check for link timeout
//----------
if ((millis() - linkDownTimer) >= (LINK_BREAK_MULTIPLIER * settings.heartbeatTimeout))
if ((millis() - linkDownTimer) >= (LINK_BREAK_MULTIPLIER * (uint32_t)settings.heartbeatTimeout))
//Break the link
breakLink();
break;
Expand Down Expand Up @@ -1256,6 +1256,7 @@ void updateRadioState()
switch (packetType)
{
default:
stopChannelTimer();
triggerEvent(TRIGGER_UNKNOWN_PACKET);
if (settings.debugDatagrams)
{
Expand All @@ -1268,14 +1269,17 @@ void updateRadioState()
break;

case DATAGRAM_BAD:
stopChannelTimer();
triggerEvent(TRIGGER_BAD_PACKET);
break;

case DATAGRAM_CRC_ERROR:
stopChannelTimer();
triggerEvent(TRIGGER_CRC_ERROR);
break;

case DATAGRAM_NETID_MISMATCH:
stopChannelTimer();
triggerEvent(TRIGGER_NETID_MISMATCH);
break;

Expand All @@ -1286,10 +1290,12 @@ void updateRadioState()
case DATAGRAM_REMOTE_COMMAND:
case DATAGRAM_REMOTE_COMMAND_RESPONSE:
//We should not be receiving these datagrams, but if we do, just ignore
stopChannelTimer();
triggerEvent(TRIGGER_BAD_PACKET);
break;

case DATAGRAM_FIND_PARTNER:
stopChannelTimer();
triggerEvent(TRIGGER_RX_FIND_PARTNER);
break;

Expand Down Expand Up @@ -1334,6 +1340,7 @@ void updateRadioState()

case DATAGRAM_DATA:
//Don't deal with data until we are sync'd with server
stopChannelTimer();
triggerEvent(TRIGGER_RX_DATA);
break;
}
Expand Down Expand Up @@ -1411,10 +1418,6 @@ void updateRadioState()
changeState(RADIO_MP_WAIT_TX_DONE);
}
}
else
{
changeState(RADIO_MP_STANDBY);
}
break;

case DATAGRAM_HEARTBEAT:
Expand All @@ -1432,7 +1435,6 @@ void updateRadioState()
lastPacketReceived = millis(); //Update timestamp for Link LED

blinkHeartbeatLed(true);
changeState(RADIO_MP_STANDBY);
}
break;

Expand All @@ -1446,8 +1448,6 @@ void updateRadioState()
frequencyCorrection += radio.getFrequencyError() / 1000000.0;

lastPacketReceived = millis(); //Update timestamp for Link LED

changeState(RADIO_MP_STANDBY);
break;
}
}
Expand Down Expand Up @@ -1482,7 +1482,7 @@ void updateRadioState()
//If the client hasn't received a packet in too long, return to scanning
else if (settings.server == false)
{
if ((millis() - lastPacketReceived) > (settings.heartbeatTimeout * 3))
if ((millis() - lastPacketReceived) > ((uint32_t)settings.heartbeatTimeout * LINK_BREAK_MULTIPLIER))
{
if (settings.debugSync)
{
Expand Down Expand Up @@ -1926,7 +1926,7 @@ void updateRadioState()
vcReceiveHeartbeat(millis() - currentMillis);

//Delay for a while before sending the HEARTBEAT
heartbeatRandomTime = random((settings.heartbeatTimeout * 2) / 10, settings.heartbeatTimeout);
heartbeatRandomTime = random(((uint32_t)settings.heartbeatTimeout * 2) / 10, settings.heartbeatTimeout);
changeState(RADIO_VC_WAIT_RECEIVE);
}
else
Expand Down Expand Up @@ -2510,7 +2510,7 @@ void updateRadioState()
//Determine if the link has timed out
vc = &virtualCircuitList[index];
if ((vc->vcState != VC_STATE_LINK_DOWN) && (serverLinkBroken
|| ((currentMillis - vc->lastTrafficMillis) > (LINK_BREAK_MULTIPLIER * settings.heartbeatTimeout))))
|| ((currentMillis - vc->lastTrafficMillis) > (LINK_BREAK_MULTIPLIER * (uint32_t)settings.heartbeatTimeout))))
{
if (index == VC_SERVER)
{
Expand Down