Compare commits

...

2 Commits

Author SHA1 Message Date
Ben Meadors
b9fcd9da23
Add some no-nonsense coercion for self-reporting node values (#6793)
Some checks failed
CI / build-rpi2040 (push) Has been cancelled
CI / build-stm32 (push) Has been cancelled
CI / gather-artifacts (esp32) (push) Has been cancelled
CI / gather-artifacts (esp32c3) (push) Has been cancelled
CI / gather-artifacts (esp32c6) (push) Has been cancelled
CI / gather-artifacts (esp32s3) (push) Has been cancelled
CI / gather-artifacts (nrf52840) (push) Has been cancelled
CI / gather-artifacts (rp2040) (push) Has been cancelled
CI / gather-artifacts (stm32) (push) Has been cancelled
CI / release-artifacts (push) Has been cancelled
CI / release-firmware (esp32) (push) Has been cancelled
CI / release-firmware (esp32c3) (push) Has been cancelled
CI / release-firmware (esp32c6) (push) Has been cancelled
CI / release-firmware (esp32s3) (push) Has been cancelled
CI / release-firmware (nrf52840) (push) Has been cancelled
CI / release-firmware (rp2040) (push) Has been cancelled
CI / release-firmware (stm32) (push) Has been cancelled
CI / publish-firmware (push) Has been cancelled
process stale Issues and PR's / Close Stale Issues (push) Has been cancelled
Nightly / Trunk Check and Upload (push) Has been cancelled
Nightly / Trunk Upgrade (PR) (push) Has been cancelled
Daily Packaging / docker-multiarch (push) Has been cancelled
Daily Packaging / package-ppa (jammy) (push) Has been cancelled
Daily Packaging / package-ppa (noble) (push) Has been cancelled
Daily Packaging / package-ppa (oracular) (push) Has been cancelled
Daily Packaging / package-ppa (plucky) (push) Has been cancelled
Daily Packaging / package-obs (push) Has been cancelled
Daily Packaging / hook-copr (push) Has been cancelled
End to end tests / native-tests (push) Has been cancelled
End to end tests / hardware-tests (push) Has been cancelled
* Add some no-nonsense coercion for self-reporting node values

* Update src/mesh/PhoneAPI.cpp

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-05-11 18:08:29 -05:00
Ben Meadors
2a06b058fd
Only send nodes on want_config of 69421 (#6792) 2025-05-11 15:18:53 -05:00
2 changed files with 31 additions and 9 deletions

View File

@ -54,7 +54,13 @@ void PhoneAPI::handleStartConfig()
} }
// even if we were already connected - restart our state machine // even if we were already connected - restart our state machine
state = STATE_SEND_MY_INFO; if (config_nonce == SPECIAL_NONCE_ONLY_NODES) {
// If client only wants node info, jump directly to sending nodes
state = STATE_SEND_OWN_NODEINFO;
LOG_INFO("Client only wants node info, skipping other config");
} else {
state = STATE_SEND_MY_INFO;
}
pauseBluetoothLogging = true; pauseBluetoothLogging = true;
spiLock->lock(); spiLock->lock();
filesManifest = getFiles("/", 10); filesManifest = getFiles("/", 10);
@ -224,7 +230,12 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
// Should allow us to resume sending NodeInfo in STATE_SEND_OTHER_NODEINFOS // Should allow us to resume sending NodeInfo in STATE_SEND_OTHER_NODEINFOS
nodeInfoForPhone.num = 0; nodeInfoForPhone.num = 0;
} }
state = STATE_SEND_METADATA; if (config_nonce == SPECIAL_NONCE_ONLY_NODES) {
// If client only wants node info, jump directly to sending nodes
state = STATE_SEND_OTHER_NODEINFOS;
} else {
state = STATE_SEND_METADATA;
}
break; break;
} }
@ -388,8 +399,14 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
config_state++; config_state++;
// Advance when we have sent all of our ModuleConfig objects // Advance when we have sent all of our ModuleConfig objects
if (config_state > (_meshtastic_AdminMessage_ModuleConfigType_MAX + 1)) { if (config_state > (_meshtastic_AdminMessage_ModuleConfigType_MAX + 1)) {
// Clients sending special nonce don't want to see other nodeinfos // Handle special nonce behaviors:
state = config_nonce == SPECIAL_NONCE ? STATE_SEND_FILEMANIFEST : STATE_SEND_OTHER_NODEINFOS; // - SPECIAL_NONCE_ONLY_CONFIG: Skip node info, go directly to file manifest
// - SPECIAL_NONCE_ONLY_NODES: After sending nodes, skip to complete
if (config_nonce == SPECIAL_NONCE_ONLY_CONFIG) {
state = STATE_SEND_FILEMANIFEST;
} else {
state = STATE_SEND_OTHER_NODEINFOS;
}
config_state = 0; config_state = 0;
} }
break; break;
@ -415,7 +432,8 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
case STATE_SEND_FILEMANIFEST: { case STATE_SEND_FILEMANIFEST: {
LOG_DEBUG("FromRadio=STATE_SEND_FILEMANIFEST"); LOG_DEBUG("FromRadio=STATE_SEND_FILEMANIFEST");
// last element // last element
if (config_state == filesManifest.size()) { // also handles an empty filesManifest if (config_state == filesManifest.size() ||
config_nonce == SPECIAL_NONCE_ONLY_NODES) { // also handles an empty filesManifest
config_state = 0; config_state = 0;
filesManifest.clear(); filesManifest.clear();
// Skip to complete packet // Skip to complete packet
@ -547,9 +565,12 @@ bool PhoneAPI::available()
auto nextNode = nodeDB->readNextMeshNode(readIndex); auto nextNode = nodeDB->readNextMeshNode(readIndex);
if (nextNode) { if (nextNode) {
nodeInfoForPhone = TypeConversions::ConvertToNodeInfo(nextNode); nodeInfoForPhone = TypeConversions::ConvertToNodeInfo(nextNode);
nodeInfoForPhone.hops_away = nodeInfoForPhone.num == nodeDB->getNodeNum() ? 0 : nodeInfoForPhone.hops_away; bool isUs = nodeInfoForPhone.num == nodeDB->getNodeNum();
nodeInfoForPhone.is_favorite = nodeInfoForPhone.hops_away = isUs ? 0 : nodeInfoForPhone.hops_away;
nodeInfoForPhone.is_favorite || nodeInfoForPhone.num == nodeDB->getNodeNum(); // Our node is always a favorite nodeInfoForPhone.last_heard = isUs ? getValidTime(RTCQualityFromNet) : nodeInfoForPhone.last_heard;
nodeInfoForPhone.snr = isUs ? 0 : nodeInfoForPhone.snr;
nodeInfoForPhone.via_mqtt = isUs ? false : nodeInfoForPhone.via_mqtt;
nodeInfoForPhone.is_favorite = nodeInfoForPhone.is_favorite || isUs; // Our node is always a favorite
} }
} }
return true; // Always say we have something, because we might need to advance our state machine return true; // Always say we have something, because we might need to advance our state machine

View File

@ -18,7 +18,8 @@
#error "meshtastic_ToRadio_size is too large for our BLE packets" #error "meshtastic_ToRadio_size is too large for our BLE packets"
#endif #endif
#define SPECIAL_NONCE 69420 #define SPECIAL_NONCE_ONLY_CONFIG 69420
#define SPECIAL_NONCE_ONLY_NODES 69421 // ( ͡° ͜ʖ ͡°)
/** /**
* Provides our protobuf based API which phone/PC clients can use to talk to our device * Provides our protobuf based API which phone/PC clients can use to talk to our device