Move function after include

This commit is contained in:
Jonathan Bennett 2025-06-25 20:42:47 -05:00
parent c090a7f6d5
commit 11d307c609

View File

@ -1345,30 +1345,6 @@ bool NodeDB::saveNodeDatabaseToDisk()
return saveProto(nodeDatabaseFileName, nodeDatabaseSize, &meshtastic_NodeDatabase_msg, &nodeDatabase, false);
}
void NodeDB::sortMeshDB()
{
if (!Throttle::isWithinTimespanMs(lastSort, 1000 * 5)) {
lastSort = millis();
std::sort(meshNodes->begin(), meshNodes->end(), [](const meshtastic_NodeInfoLite &a, const meshtastic_NodeInfoLite &b) {
if (a.num == myNodeInfo.my_node_num) {
return true;
}
if (b.num == myNodeInfo.my_node_num) {
return false;
}
bool aFav = a.is_favorite;
bool bFav = b.is_favorite;
if (aFav != bFav)
return aFav;
if (a.last_heard == 0 || a.last_heard == UINT32_MAX)
return false;
if (b.last_heard == 0 || b.last_heard == UINT32_MAX)
return true;
return a.last_heard > b.last_heard;
});
}
}
bool NodeDB::saveToDiskNoRetry(int saveWhat)
{
bool success = true;
@ -1698,6 +1674,30 @@ void NodeDB::updateFrom(const meshtastic_MeshPacket &mp)
}
}
void NodeDB::sortMeshDB()
{
if (!Throttle::isWithinTimespanMs(lastSort, 1000 * 5)) {
lastSort = millis();
std::sort(meshNodes->begin(), meshNodes->end(), [](const meshtastic_NodeInfoLite &a, const meshtastic_NodeInfoLite &b) {
if (a.num == myNodeInfo.my_node_num) {
return true;
}
if (b.num == myNodeInfo.my_node_num) {
return false;
}
bool aFav = a.is_favorite;
bool bFav = b.is_favorite;
if (aFav != bFav)
return aFav;
if (a.last_heard == 0 || a.last_heard == UINT32_MAX)
return false;
if (b.last_heard == 0 || b.last_heard == UINT32_MAX)
return true;
return a.last_heard > b.last_heard;
});
}
}
uint8_t NodeDB::getMeshNodeChannel(NodeNum n)
{
const meshtastic_NodeInfoLite *info = getMeshNode(n);