mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-23 03:00:56 +00:00
Look into tophone queue for the received packet.
- only works if we don't have a phone connected, but that is probably dsired - this will send a copy of device-originating text messgaes to a connected phone. Breaking change. - this will iterate the tophone queue by deconstructing and reconstructing it every time we look for an ID. Probably also mangles the queue oder since it aborts when a ID is found. - Can we navigate the packet pool instead? If so, how? - Let's keep this in draft state for now
This commit is contained in:
@@ -140,6 +140,22 @@ void MeshService::reloadOwner(bool shouldSave)
|
||||
}
|
||||
}
|
||||
|
||||
// search the queue for a request id and return the matching nodenum
|
||||
NodeNum MeshService::getNodenumFromRequestId(uint32_t request_id)
|
||||
{
|
||||
NodeNum nodenum = 0;
|
||||
for (int i = 0; i < toPhoneQueue.numUsed(); i++) {
|
||||
meshtastic_MeshPacket *p = toPhoneQueue.dequeuePtr(0);
|
||||
// put it right back on the queue
|
||||
toPhoneQueue.enqueue(p, 0);
|
||||
if (p->id == request_id) {
|
||||
nodenum = p->to;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return nodenum;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a ToRadio buffer parse it and properly handle it (setup radio, owner or send packet into the mesh)
|
||||
* Called by PhoneAPI.handleToRadio. Note: p is a scratch buffer, this function is allowed to write to it but it can not keep a
|
||||
|
||||
@@ -82,6 +82,9 @@ class MeshService
|
||||
/// Return the next MqttClientProxyMessage packet destined to the phone.
|
||||
meshtastic_MqttClientProxyMessage *getMqttClientProxyMessageForPhone() { return toPhoneMqttProxyQueue.dequeuePtr(0); }
|
||||
|
||||
// search the queue for a request id and return the matching nodenum
|
||||
NodeNum getNodenumFromRequestId(uint32_t request_id);
|
||||
|
||||
// Release QueueStatus packet to pool
|
||||
void releaseQueueStatusToPool(meshtastic_QueueStatus *p) { queueStatusPool.release(p); }
|
||||
|
||||
|
||||
@@ -27,6 +27,8 @@ template <class T> class TypedQueue
|
||||
|
||||
bool isEmpty() { return uxQueueMessagesWaiting(h) == 0; }
|
||||
|
||||
int numUsed() { return uxQueueMessagesWaiting(h); }
|
||||
|
||||
/** euqueue a packet. Also, maxWait used to default to portMAX_DELAY, but we now want to callers to THINK about what blocking
|
||||
* they want */
|
||||
bool enqueue(T x, TickType_t maxWait)
|
||||
@@ -80,6 +82,8 @@ template <class T> class TypedQueue
|
||||
|
||||
bool isEmpty() { return q.empty(); }
|
||||
|
||||
int numUsed() { return q.size(); }
|
||||
|
||||
bool enqueue(T x, TickType_t maxWait = portMAX_DELAY)
|
||||
{
|
||||
if (reader) {
|
||||
|
||||
Reference in New Issue
Block a user