mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-19 17:22:59 +00:00
InkHUD: don't try to access meshNodes directly
This commit is contained in:
@@ -62,22 +62,12 @@ void InkHUD::HeardApplet::populateFromNodeDB()
|
|||||||
{
|
{
|
||||||
// Fill a collection with pointers to each node in db
|
// Fill a collection with pointers to each node in db
|
||||||
std::vector<meshtastic_NodeInfoLite *> ordered;
|
std::vector<meshtastic_NodeInfoLite *> ordered;
|
||||||
for (auto mn = nodeDB->meshNodes->begin(); mn != nodeDB->meshNodes->end(); ++mn) {
|
for (int i = 1; i < maxCards(); i++) {
|
||||||
// Only copy if valid, and not our own node
|
auto mn = nodeDB->getMeshNodeByIndex(i);
|
||||||
if (mn->num != 0 && mn->num != nodeDB->getNodeNum())
|
if (mn->num != 0 && mn->num != nodeDB->getNodeNum())
|
||||||
ordered.push_back(&*mn);
|
ordered.push_back(&*mn);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort the collection by age
|
|
||||||
std::sort(ordered.begin(), ordered.end(), [](meshtastic_NodeInfoLite *top, meshtastic_NodeInfoLite *bottom) -> bool {
|
|
||||||
return (top->last_heard > bottom->last_heard);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Keep the most recent entries only
|
|
||||||
// Just enough to fill the screen
|
|
||||||
if (ordered.size() > maxCards())
|
|
||||||
ordered.resize(maxCards());
|
|
||||||
|
|
||||||
// Create card info for these (stale) node observations
|
// Create card info for these (stale) node observations
|
||||||
meshtastic_NodeInfoLite *ourNode = nodeDB->getMeshNode(nodeDB->getNodeNum());
|
meshtastic_NodeInfoLite *ourNode = nodeDB->getMeshNode(nodeDB->getNodeNum());
|
||||||
for (meshtastic_NodeInfoLite *node : ordered) {
|
for (meshtastic_NodeInfoLite *node : ordered) {
|
||||||
|
|||||||
Reference in New Issue
Block a user