From e683d8f5525b1b3efd445c296b2cce2b37f7deb5 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 27 Apr 2024 08:55:04 -0500 Subject: [PATCH] Rebrand "send network ping" to more honest "try send position" with better output (#3737) --- src/ButtonThread.cpp | 7 +++++-- src/mesh/MeshService.cpp | 4 +++- src/mesh/MeshService.h | 5 +++-- src/modules/CannedMessageModule.cpp | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/ButtonThread.cpp b/src/ButtonThread.cpp index 206bb7239..e9717521a 100644 --- a/src/ButtonThread.cpp +++ b/src/ButtonThread.cpp @@ -136,9 +136,12 @@ int32_t ButtonThread::runOnce() case BUTTON_EVENT_DOUBLE_PRESSED: { LOG_BUTTON("Double press!\n"); service.refreshLocalMeshNode(); - service.sendNetworkPing(NODENUM_BROADCAST, true); + auto sentPosition = service.trySendPosition(NODENUM_BROADCAST, true); if (screen) { - screen->print("Sent ad-hoc ping\n"); + if (sentPosition) + screen->print("Sent ad-hoc position\n"); + else + screen->print("Sent ad-hoc nodeinfo\n"); screen->forceDisplay(true); // Force a new UI frame, then force an EInk update } break; diff --git a/src/mesh/MeshService.cpp b/src/mesh/MeshService.cpp index 2c1969e30..6b8d37975 100644 --- a/src/mesh/MeshService.cpp +++ b/src/mesh/MeshService.cpp @@ -267,7 +267,7 @@ void MeshService::sendToMesh(meshtastic_MeshPacket *p, RxSource src, bool ccToPh } } -void MeshService::sendNetworkPing(NodeNum dest, bool wantReplies) +bool MeshService::trySendPosition(NodeNum dest, bool wantReplies) { meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(nodeDB->getNodeNum()); @@ -278,6 +278,7 @@ void MeshService::sendNetworkPing(NodeNum dest, bool wantReplies) if (positionModule) { LOG_INFO("Sending position ping to 0x%x, wantReplies=%d, channel=%d\n", dest, wantReplies, node->channel); positionModule->sendOurPosition(dest, wantReplies, node->channel); + return true; } } else { #endif @@ -286,6 +287,7 @@ void MeshService::sendNetworkPing(NodeNum dest, bool wantReplies) nodeInfoModule->sendOurNodeInfo(dest, wantReplies, node->channel); } } + return false; } void MeshService::sendToPhone(meshtastic_MeshPacket *p) diff --git a/src/mesh/MeshService.h b/src/mesh/MeshService.h index 8d1434030..d777b7a01 100644 --- a/src/mesh/MeshService.h +++ b/src/mesh/MeshService.h @@ -108,8 +108,9 @@ class MeshService void reloadOwner(bool shouldSave = true); /// Called when the user wakes up our GUI, normally sends our latest location to the mesh (if we have it), otherwise at least - /// sends our owner - void sendNetworkPing(NodeNum dest, bool wantReplies = false); + /// sends our nodeinfo + /// returns true if we sent a position + bool trySendPosition(NodeNum dest, bool wantReplies = false); /// Send a packet into the mesh - note p must have been allocated from packetPool. We will return it to that pool after /// sending. This is the ONLY function you should use for sending messages into the mesh, because it also updates the nodedb diff --git a/src/modules/CannedMessageModule.cpp b/src/modules/CannedMessageModule.cpp index 24e5d28d1..ea7d5029a 100644 --- a/src/modules/CannedMessageModule.cpp +++ b/src/modules/CannedMessageModule.cpp @@ -452,7 +452,7 @@ int32_t CannedMessageModule::runOnce() break; case 0xaf: // fn+space send network ping like double press does service.refreshLocalMeshNode(); - service.sendNetworkPing(NODENUM_BROADCAST, true); + service.trySendPosition(NODENUM_BROADCAST, true); runState = CANNED_MESSAGE_RUN_STATE_INACTIVE; break; default: