tryfix - no mqtt if no mqtt wanted...

This commit is contained in:
Thomas Göttgens 2022-12-30 14:51:00 +01:00
parent 115cb05d3b
commit 65aad62702

View File

@ -222,28 +222,30 @@ ErrorCode Router::send(MeshPacket *p)
ChannelIndex chIndex = p->channel; // keep as a local because we are about to change it ChannelIndex chIndex = p->channel; // keep as a local because we are about to change it
#if HAS_WIFI || HAS_ETHERNET #if HAS_WIFI || HAS_ETHERNET
// check if we should send decrypted packets to mqtt if(moduleConfig.mqtt.enabled) {
// check if we should send decrypted packets to mqtt
// truth table: // truth table:
/* mqtt_server mqtt_encryption_enabled should_encrypt /* mqtt_server mqtt_encryption_enabled should_encrypt
* not set 0 1 * not set 0 1
* not set 1 1 * not set 1 1
* set 0 0 * set 0 0
* set 1 1 * set 1 1
* *
* => so we only decrypt mqtt if they have a custom mqtt server AND mqtt_encryption_enabled is FALSE * => so we only decrypt mqtt if they have a custom mqtt server AND mqtt_encryption_enabled is FALSE
*/ */
bool shouldActuallyEncrypt = true; bool shouldActuallyEncrypt = true;
if (*moduleConfig.mqtt.address && !moduleConfig.mqtt.encryption_enabled) { if (*moduleConfig.mqtt.address && !moduleConfig.mqtt.encryption_enabled) {
shouldActuallyEncrypt = false; shouldActuallyEncrypt = false;
}
DEBUG_MSG("Should encrypt MQTT?: %d\n", shouldActuallyEncrypt);
// the packet is currently in a decrypted state. send it now if they want decrypted packets
if (mqtt && !shouldActuallyEncrypt)
mqtt->onSend(*p, chIndex);
} }
DEBUG_MSG("Should encrypt MQTT?: %d\n", shouldActuallyEncrypt);
// the packet is currently in a decrypted state. send it now if they want decrypted packets
if (mqtt && !shouldActuallyEncrypt)
mqtt->onSend(*p, chIndex);
#endif #endif
auto encodeResult = perhapsEncode(p); auto encodeResult = perhapsEncode(p);
@ -253,10 +255,12 @@ ErrorCode Router::send(MeshPacket *p)
} }
#if HAS_WIFI || HAS_ETHERNET #if HAS_WIFI || HAS_ETHERNET
// the packet is now encrypted. if(moduleConfig.mqtt.enabled) {
// check if we should send encrypted packets to mqtt // the packet is now encrypted.
if (mqtt && shouldActuallyEncrypt) // check if we should send encrypted packets to mqtt
mqtt->onSend(*p, chIndex); if (mqtt && shouldActuallyEncrypt)
mqtt->onSend(*p, chIndex);
}
#endif #endif
} }