Guarding PhoneAPI node-info staging with mutex to prevent BLE future foot-gun (#8354)

* Eliminating foot-gun and placing Phone NodeInfo into a mutex

* Swapping over to concurrency::Lock from mutex
This commit is contained in:
Clive Blackledge
2025-10-15 04:08:06 -07:00
committed by GitHub
parent 034d2dd025
commit a6df18e60a
3 changed files with 72 additions and 36 deletions

View File

@@ -1,6 +1,7 @@
#pragma once
#include "Observer.h"
#include "concurrency/Lock.h"
#include "mesh-pb-constants.h"
#include "meshtastic/portnums.pb.h"
#include <deque>
@@ -84,6 +85,8 @@ class PhoneAPI
std::deque<meshtastic_NodeInfo> nodeInfoQueue;
// Tunable size of the node info cache so we can keep BLE reads non-blocking.
static constexpr size_t kNodePrefetchDepth = 4;
// Protect nodeInfoForPhone + nodeInfoQueue because NimBLE callbacks run in a separate FreeRTOS task.
concurrency::Lock nodeInfoMutex;
meshtastic_ToRadio toRadioScratch = {
0}; // this is a static scratch object, any data must be copied elsewhere before returning