Skip to content

Commit

Permalink
Check for oktomqtt flag presence before uplinking to MQTT
Browse files Browse the repository at this point in the history
  • Loading branch information
thebentern committed Nov 21, 2024
1 parent ccfc9e5 commit 27dfccf
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/mesh/Router.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,12 +618,13 @@ void Router::handleReceived(meshtastic_MeshPacket *p, RxSource src)
MeshModule::callModules(*p, src);

#if !MESHTASTIC_EXCLUDE_MQTT
bool shouldUplinkDecoded = decoded && p->decoded.has_bitfield && (p->decoded.bitfield & BITFIELD_OK_TO_MQTT_MASK) != 0;
// Mark as pki_encrypted if it is not yet decoded and MQTT encryption is also enabled, hash matches and it's a DM not to
// us (because we would be able to decrypt it)
if (!decoded && moduleConfig.mqtt.encryption_enabled && p->channel == 0x00 && !isBroadcast(p->to) && !isToUs(p))
p_encrypted->pki_encrypted = true;
// After potentially altering it, publish received message to MQTT if we're not the original transmitter of the packet
if ((decoded || p_encrypted->pki_encrypted) && moduleConfig.mqtt.enabled && !isFromUs(p) && mqtt)
if ((shouldUplinkDecoded || p_encrypted->pki_encrypted) && moduleConfig.mqtt.enabled && !isFromUs(p) && mqtt)
mqtt->onSend(*p_encrypted, *p, p->channel);
#endif
}
Expand Down

0 comments on commit 27dfccf

Please sign in to comment.