Add QueueStatus sending to the firmware (#1820)

* Yank mqtt service envelope queue

* trybuildfix mqtt system

* removed too much

* no excessive heap debugging on release builds

* send QueueStatus messages

The QueueStatus message is sent as a response to the attempt to queue
an outgoing MeshPacket and contains statuses of the last queue
attempt, TX Queue space and capacity and MeshPacket.id that was
queued.

When TX Queue changes status from completely full to at least
a single slot free a QueueStatus message is also sent to notify
that user can queue more messages.

Signed-off-by: Pavel Boldin <pavel.b@techspark.engineering>

* WIP: update protobufs

Signed-off-by: Pavel Boldin <pavel.b@techspark.engineering>

* update protobufs

* regen protos

Signed-off-by: Pavel Boldin <pavel.b@techspark.engineering>
Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
Co-authored-by: Thomas Göttgens <tgoettgens@gmail.com>
Co-authored-by: Sacha Weatherstone <sachaw100@hotmail.com>
This commit is contained in:
pavelb-techspark
2023-01-04 14:56:52 +02:00
committed by GitHub
parent d077be1496
commit 30ae4c2a38
21 changed files with 184 additions and 66 deletions

View File

@@ -50,6 +50,7 @@ void PhoneAPI::close()
unobserve(&service.fromNumChanged);
releasePhonePacket(); // Don't leak phone packets on shutdown
releaseQueueStatusPhonePacket();
onConnectionChanged(false);
}
@@ -282,14 +283,19 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
case STATE_SEND_PACKETS:
// Do we have a message from the mesh?
LOG_INFO("getFromRadio=STATE_SEND_PACKETS\n");
if (packetForPhone) {
if (queueStatusPacketForPhone) {
fromRadioScratch.which_payload_variant = FromRadio_queueStatus_tag;
fromRadioScratch.queueStatus = *queueStatusPacketForPhone;
releaseQueueStatusPhonePacket();
} else if (packetForPhone) {
printPacket("phone downloaded packet", packetForPhone);
// Encapsulate as a FromRadio packet
fromRadioScratch.which_payload_variant = FromRadio_packet_tag;
fromRadioScratch.packet = *packetForPhone;
releasePhonePacket();
}
releasePhonePacket();
break;
default:
@@ -322,6 +328,14 @@ void PhoneAPI::releasePhonePacket()
}
}
void PhoneAPI::releaseQueueStatusPhonePacket()
{
if (queueStatusPacketForPhone) {
service.releaseQueueStatusToPool(queueStatusPacketForPhone);
queueStatusPacketForPhone = NULL;
}
}
/**
* Return true if we have data available to send to the phone
*/
@@ -342,9 +356,15 @@ bool PhoneAPI::available()
return true; // Always say we have something, because we might need to advance our state machine
case STATE_SEND_PACKETS: {
if (!queueStatusPacketForPhone)
queueStatusPacketForPhone = service.getQueueStatusForPhone();
bool hasPacket = !!queueStatusPacketForPhone;
if (hasPacket)
return true;
if (!packetForPhone)
packetForPhone = service.getForPhone();
bool hasPacket = !!packetForPhone;
hasPacket = !!packetForPhone;
// LOG_DEBUG("available hasPacket=%d\n", hasPacket);
return hasPacket;
}