Skip to content

Commit b49496d

Browse files
committed
Merge branch 'master' into develop
2 parents 52527e2 + 34c2191 commit b49496d

File tree

4 files changed

+36
-19
lines changed

4 files changed

+36
-19
lines changed

src/gps/GPS.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,7 @@ bool GPS::setup()
516516
}
517517
}
518518
// Rare Serial Speeds
519+
#ifndef CONFIG_IDF_TARGET_ESP32C6
519520
if (probeTries == GPS_PROBETRIES) {
520521
LOG_DEBUG("Probe for GPS at %d", rareSerialSpeeds[speedSelect]);
521522
gnssModel = probe(rareSerialSpeeds[speedSelect]);
@@ -526,6 +527,7 @@ bool GPS::setup()
526527
}
527528
}
528529
}
530+
#endif
529531
}
530532

531533
if (gnssModel != GNSS_MODEL_UNKNOWN) {

src/mesh/ReliableRouter.cpp

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -97,27 +97,34 @@ bool ReliableRouter::shouldFilterReceived(const meshtastic_MeshPacket *p)
9797
void ReliableRouter::sniffReceived(const meshtastic_MeshPacket *p, const meshtastic_Routing *c)
9898
{
9999
if (isToUs(p)) { // ignore ack/nak/want_ack packets that are not address to us (we only handle 0 hop reliability)
100-
if (p->want_ack) {
101-
if (MeshModule::currentReply) {
102-
LOG_DEBUG("Another module replied to this message, no need for 2nd ack");
103-
} else if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag) {
104-
// A response may be set to want_ack for retransmissions, but we don't need to ACK a response if it received an
105-
// implicit ACK already. If we received it directly, only ACK with a hop limit of 0
106-
if (!p->decoded.request_id)
107-
sendAckNak(meshtastic_Routing_Error_NONE, getFrom(p), p->id, p->channel,
100+
if (!MeshModule::currentReply) {
101+
if (p->want_ack) {
102+
if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag) {
103+
/* A response may be set to want_ack for retransmissions, but we don't need to ACK a response if it received
104+
an implicit ACK already. If we received it directly or via NextHopRouter, only ACK with a hop limit of 0 to
105+
make sure the other side stops retransmitting. */
106+
if (!p->decoded.request_id && !p->decoded.reply_id) {
107+
sendAckNak(meshtastic_Routing_Error_NONE, getFrom(p), p->id, p->channel,
108+
routingModule->getHopLimitForResponse(p->hop_start, p->hop_limit));
109+
} else if ((p->hop_start > 0 && p->hop_start == p->hop_limit) || p->next_hop != NO_NEXT_HOP_PREFERENCE) {
110+
sendAckNak(meshtastic_Routing_Error_NONE, getFrom(p), p->id, p->channel, 0);
111+
}
112+
} else if (p->which_payload_variant == meshtastic_MeshPacket_encrypted_tag && p->channel == 0 &&
113+
(nodeDB->getMeshNode(p->from) == nullptr || nodeDB->getMeshNode(p->from)->user.public_key.size == 0)) {
114+
LOG_INFO("PKI packet from unknown node, send PKI_UNKNOWN_PUBKEY");
115+
sendAckNak(meshtastic_Routing_Error_PKI_UNKNOWN_PUBKEY, getFrom(p), p->id, channels.getPrimaryIndex(),
108116
routingModule->getHopLimitForResponse(p->hop_start, p->hop_limit));
109-
else if (p->hop_start > 0 && p->hop_start == p->hop_limit)
110-
sendAckNak(meshtastic_Routing_Error_NONE, getFrom(p), p->id, p->channel, 0);
111-
} else if (p->which_payload_variant == meshtastic_MeshPacket_encrypted_tag && p->channel == 0 &&
112-
(nodeDB->getMeshNode(p->from) == nullptr || nodeDB->getMeshNode(p->from)->user.public_key.size == 0)) {
113-
LOG_INFO("PKI packet from unknown node, send PKI_UNKNOWN_PUBKEY");
114-
sendAckNak(meshtastic_Routing_Error_PKI_UNKNOWN_PUBKEY, getFrom(p), p->id, channels.getPrimaryIndex(),
115-
routingModule->getHopLimitForResponse(p->hop_start, p->hop_limit));
116-
} else {
117-
// Send a 'NO_CHANNEL' error on the primary channel if want_ack packet destined for us cannot be decoded
118-
sendAckNak(meshtastic_Routing_Error_NO_CHANNEL, getFrom(p), p->id, channels.getPrimaryIndex(),
119-
routingModule->getHopLimitForResponse(p->hop_start, p->hop_limit));
117+
} else {
118+
// Send a 'NO_CHANNEL' error on the primary channel if want_ack packet destined for us cannot be decoded
119+
sendAckNak(meshtastic_Routing_Error_NO_CHANNEL, getFrom(p), p->id, channels.getPrimaryIndex(),
120+
routingModule->getHopLimitForResponse(p->hop_start, p->hop_limit));
121+
}
122+
} else if (p->next_hop == nodeDB->getLastByteOfNodeNum(getNodeNum()) && p->hop_limit > 0) {
123+
// No wantAck, but we need to ACK with hop limit of 0 if we were the next hop to stop their retransmissions
124+
sendAckNak(meshtastic_Routing_Error_NONE, getFrom(p), p->id, p->channel, 0);
120125
}
126+
} else {
127+
LOG_DEBUG("Another module replied to this message, no need for 2nd ack");
121128
}
122129
if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag && c &&
123130
c->error_reason == meshtastic_Routing_Error_PKI_UNKNOWN_PUBKEY) {

src/nimble/NimbleBluetooth.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,10 @@ class NimbleBluetoothServerCallback : public NimBLEServerCallbacks
231231
{
232232
LOG_INFO("BLE disconnect");
233233
#endif
234+
#ifdef NIMBLE_TWO
235+
if (ble->isDeInit)
236+
return;
237+
#endif
234238

235239
meshtastic::BluetoothStatus newStatus(meshtastic::BluetoothStatus::ConnectionState::DISCONNECTED);
236240
bluetoothStatus->updateStatus(&newStatus);
@@ -270,6 +274,7 @@ void NimbleBluetooth::deinit()
270274
{
271275
#ifdef ARCH_ESP32
272276
LOG_INFO("Disable bluetooth until reboot");
277+
isDeInit = true;
273278

274279
#ifdef BLE_LED
275280
#ifdef BLE_LED_INVERTED
@@ -278,8 +283,10 @@ void NimbleBluetooth::deinit()
278283
digitalWrite(BLE_LED, LOW);
279284
#endif
280285
#endif
286+
#ifndef NIMBLE_TWO
281287
NimBLEDevice::deinit();
282288
#endif
289+
#endif
283290
}
284291

285292
// Has initial setup been completed

src/nimble/NimbleBluetooth.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class NimbleBluetooth : BluetoothApi
1515
#if defined(NIMBLE_TWO)
1616
void startAdvertising();
1717
#endif
18+
bool isDeInit = false;
1819

1920
private:
2021
void setupService();

0 commit comments

Comments
 (0)