mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-22 18:52:30 +00:00
cleanup
This commit is contained in:
@@ -1015,6 +1015,23 @@ void CannedMessageModule::sendText(NodeNum dest, ChannelIndex channel, const cha
|
|||||||
this->lastSentNode = dest;
|
this->lastSentNode = dest;
|
||||||
this->incoming = dest;
|
this->incoming = dest;
|
||||||
|
|
||||||
|
// Manually find the node by number to check PKI capability
|
||||||
|
meshtastic_NodeInfoLite *node = nullptr;
|
||||||
|
size_t numMeshNodes = nodeDB->getNumMeshNodes();
|
||||||
|
for (size_t i = 0; i < numMeshNodes; ++i) {
|
||||||
|
meshtastic_NodeInfoLite *n = nodeDB->getMeshNodeByIndex(i);
|
||||||
|
if (n && n->num == dest) {
|
||||||
|
node = n;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NodeNum myNodeNum = nodeDB->getNodeNum();
|
||||||
|
if (node && node->num != myNodeNum && node->has_user && node->user.public_key.size == 32) {
|
||||||
|
p->pki_encrypted = true;
|
||||||
|
p->channel = 0; // force PKI
|
||||||
|
}
|
||||||
|
|
||||||
// Track this packet’s request ID for matching ACKs
|
// Track this packet’s request ID for matching ACKs
|
||||||
this->lastRequestId = p->id;
|
this->lastRequestId = p->id;
|
||||||
|
|
||||||
@@ -1029,7 +1046,7 @@ void CannedMessageModule::sendText(NodeNum dest, ChannelIndex channel, const cha
|
|||||||
|
|
||||||
this->waitingForAck = true;
|
this->waitingForAck = true;
|
||||||
|
|
||||||
// Send to mesh
|
// Send to mesh (PKI-encrypted if conditions above matched)
|
||||||
service->sendToMesh(p, RX_SRC_LOCAL, true);
|
service->sendToMesh(p, RX_SRC_LOCAL, true);
|
||||||
|
|
||||||
// Show banner immediately
|
// Show banner immediately
|
||||||
@@ -1045,13 +1062,8 @@ void CannedMessageModule::sendText(NodeNum dest, ChannelIndex channel, const cha
|
|||||||
|
|
||||||
// Always use our local time, consistent with other paths
|
// Always use our local time, consistent with other paths
|
||||||
uint32_t nowSecs = getValidTime(RTCQuality::RTCQualityDevice, true);
|
uint32_t nowSecs = getValidTime(RTCQuality::RTCQualityDevice, true);
|
||||||
if (nowSecs > 0) {
|
sm.timestamp = (nowSecs > 0) ? nowSecs : millis() / 1000;
|
||||||
sm.timestamp = nowSecs;
|
sm.isBootRelative = (nowSecs == 0);
|
||||||
sm.isBootRelative = false;
|
|
||||||
} else {
|
|
||||||
sm.timestamp = millis() / 1000;
|
|
||||||
sm.isBootRelative = true; // mark for later upgrade
|
|
||||||
}
|
|
||||||
|
|
||||||
sm.sender = nodeDB->getNodeNum(); // us
|
sm.sender = nodeDB->getNodeNum(); // us
|
||||||
sm.channelIndex = channel;
|
sm.channelIndex = channel;
|
||||||
@@ -1080,8 +1092,6 @@ void CannedMessageModule::sendText(NodeNum dest, ChannelIndex channel, const cha
|
|||||||
|
|
||||||
playComboTune();
|
playComboTune();
|
||||||
|
|
||||||
// Important
|
|
||||||
// Instead of INACTIVE here, use SENDING_ACTIVE so runOnce() does the cleanup.
|
|
||||||
this->runState = CANNED_MESSAGE_RUN_STATE_SENDING_ACTIVE;
|
this->runState = CANNED_MESSAGE_RUN_STATE_SENDING_ACTIVE;
|
||||||
this->payload = wantReplies ? 1 : 0;
|
this->payload = wantReplies ? 1 : 0;
|
||||||
requestFocus();
|
requestFocus();
|
||||||
@@ -1090,11 +1100,6 @@ void CannedMessageModule::sendText(NodeNum dest, ChannelIndex channel, const cha
|
|||||||
UIFrameEvent e;
|
UIFrameEvent e;
|
||||||
e.action = UIFrameEvent::Action::SWITCH_TO_TEXTMESSAGE;
|
e.action = UIFrameEvent::Action::SWITCH_TO_TEXTMESSAGE;
|
||||||
notifyObservers(&e);
|
notifyObservers(&e);
|
||||||
|
|
||||||
// Now mark ourselves as sending
|
|
||||||
this->runState = CANNED_MESSAGE_RUN_STATE_SENDING_ACTIVE;
|
|
||||||
this->payload = wantReplies ? 1 : 0;
|
|
||||||
requestFocus(); // focus only after event is dispatched
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CannedMessageModule::runOnce()
|
int32_t CannedMessageModule::runOnce()
|
||||||
|
|||||||
Reference in New Issue
Block a user