Compare commits

..

No commits in common. "b9fcd9da233ad5b7438f2b836b612eba15b149ef" and "62e1974d092453d481dfa2546bcb34180707a029" have entirely different histories.

2 changed files with 9 additions and 31 deletions

View File

@ -54,13 +54,7 @@ void PhoneAPI::handleStartConfig()
} }
// even if we were already connected - restart our state machine // even if we were already connected - restart our state machine
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; state = STATE_SEND_MY_INFO;
}
pauseBluetoothLogging = true; pauseBluetoothLogging = true;
spiLock->lock(); spiLock->lock();
filesManifest = getFiles("/", 10); filesManifest = getFiles("/", 10);
@ -230,12 +224,7 @@ 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;
} }
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; state = STATE_SEND_METADATA;
}
break; break;
} }
@ -399,14 +388,8 @@ 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)) {
// Handle special nonce behaviors: // Clients sending special nonce don't want to see other nodeinfos
// - SPECIAL_NONCE_ONLY_CONFIG: Skip node info, go directly to file manifest state = config_nonce == SPECIAL_NONCE ? STATE_SEND_FILEMANIFEST : STATE_SEND_OTHER_NODEINFOS;
// - 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;
@ -432,8 +415,7 @@ 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() || if (config_state == filesManifest.size()) { // also handles an empty filesManifest
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
@ -565,12 +547,9 @@ 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);
bool isUs = nodeInfoForPhone.num == nodeDB->getNodeNum(); nodeInfoForPhone.hops_away = nodeInfoForPhone.num == nodeDB->getNodeNum() ? 0 : nodeInfoForPhone.hops_away;
nodeInfoForPhone.hops_away = isUs ? 0 : nodeInfoForPhone.hops_away; nodeInfoForPhone.is_favorite =
nodeInfoForPhone.last_heard = isUs ? getValidTime(RTCQualityFromNet) : nodeInfoForPhone.last_heard; nodeInfoForPhone.is_favorite || nodeInfoForPhone.num == nodeDB->getNodeNum(); // Our node is always a favorite
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,8 +18,7 @@
#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_ONLY_CONFIG 69420 #define SPECIAL_NONCE 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