mirror of
https://github.com/meshtastic/firmware.git
synced 2025-08-03 12:20:43 +00:00
Heartbeat response (#7506)
* Heartbeat response * Move it * Add debug log for visibility
This commit is contained in:
parent
1b793d1f23
commit
7d926da98c
@ -31,6 +31,9 @@
|
|||||||
#include "Throttle.h"
|
#include "Throttle.h"
|
||||||
#include <RTC.h>
|
#include <RTC.h>
|
||||||
|
|
||||||
|
// Flag to indicate a heartbeat was received and we should send queue status
|
||||||
|
bool heartbeatReceived = false;
|
||||||
|
|
||||||
PhoneAPI::PhoneAPI()
|
PhoneAPI::PhoneAPI()
|
||||||
{
|
{
|
||||||
lastContactMsec = millis();
|
lastContactMsec = millis();
|
||||||
@ -155,6 +158,7 @@ bool PhoneAPI::handleToRadio(const uint8_t *buf, size_t bufLength)
|
|||||||
#endif
|
#endif
|
||||||
case meshtastic_ToRadio_heartbeat_tag:
|
case meshtastic_ToRadio_heartbeat_tag:
|
||||||
LOG_DEBUG("Got client heartbeat");
|
LOG_DEBUG("Got client heartbeat");
|
||||||
|
heartbeatReceived = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// Ignore nop messages
|
// Ignore nop messages
|
||||||
@ -194,6 +198,17 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
|
|||||||
// In case we send a FromRadio packet
|
// In case we send a FromRadio packet
|
||||||
memset(&fromRadioScratch, 0, sizeof(fromRadioScratch));
|
memset(&fromRadioScratch, 0, sizeof(fromRadioScratch));
|
||||||
|
|
||||||
|
// Respond to heartbeat by sending queue status
|
||||||
|
if (heartbeatReceived) {
|
||||||
|
memset(&fromRadioScratch, 0, sizeof(fromRadioScratch));
|
||||||
|
fromRadioScratch.which_payload_variant = meshtastic_FromRadio_queueStatus_tag;
|
||||||
|
fromRadioScratch.queueStatus = router->getQueueStatus();
|
||||||
|
heartbeatReceived = false;
|
||||||
|
size_t numbytes = pb_encode_to_bytes(buf, meshtastic_FromRadio_size, &meshtastic_FromRadio_msg, &fromRadioScratch);
|
||||||
|
LOG_DEBUG("FromRadio=STATE_SEND_QUEUE_STATUS, numbytes=%u", numbytes);
|
||||||
|
return numbytes;
|
||||||
|
}
|
||||||
|
|
||||||
// Advance states as needed
|
// Advance states as needed
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case STATE_SEND_NOTHING:
|
case STATE_SEND_NOTHING:
|
||||||
|
Loading…
Reference in New Issue
Block a user