Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only publish MQTT on LoRa Tx if packet is from us and on Rx if not #3245

Merged
merged 5 commits into from
Feb 21, 2024

Conversation

GUVWAF
Copy link
Member

@GUVWAF GUVWAF commented Feb 18, 2024

Currently we're only publishing to MQTT when we're transmitting a packet via LoRa. Nevertheless, we still see received packets on MQTT as well, but this is only because we forced a node to always rebroadcast when MQTT is enabled:

if (!moduleConfig.mqtt.enabled && config.device.role != meshtastic_Config_DeviceConfig_Role_ROUTER &&

However, as observed in #3138, direct messages towards the MQTT node will not be published, because we don't rebroadcast if we're the destination.

With this, we're publishing when transmitting via LoRa only when we're the original transmitter, and we publish when receiving when we're not the original transmitter. This way we can get rid of the "hack" where we're always rebroadcasting via LoRa when MQTT is enabled, and we'll see direct messages to the MQTT node as well.

Since we already don't publish packets to MQTT if they came via MQTT, this will not create any extra traffic when bridging networks.

Also fixed a possible issue where env->packet contains the encrypted version of the packet and we're trying to print decoded.portnum.

… if not

Such that direct message to MQTT node gets published and we get rid of always rebroadcasting when MQTT is enabled
thebentern added a commit to meshtastic/artifacts that referenced this pull request Feb 18, 2024
@GUVWAF GUVWAF marked this pull request as draft February 18, 2024 20:17
@GUVWAF
Copy link
Member Author

GUVWAF commented Feb 18, 2024

Converting to draft for now. I just realized we should filter received packets with wasSeenRecently() to avoid getting duplicates. Need to find a clean way to do this.

@GUVWAF
Copy link
Member Author

GUVWAF commented Feb 21, 2024

I just realized we should filter received packets with wasSeenRecently() to avoid getting duplicates.

After further testing I found that this is not needed because it is already done in shouldFilterReceived() which is called in Router::perhapsHandleReceived() before handleReceived(), where we send to MQTT.

This should be good to go then :)

@GUVWAF GUVWAF marked this pull request as ready for review February 21, 2024 18:55
@thebentern thebentern merged commit eb8a12e into meshtastic:master Feb 21, 2024
63 checks passed
jimwhitelaw pushed a commit to jimwhitelaw/aotromesh that referenced this pull request Feb 22, 2024
… if not (meshtastic#3245)

Such that direct message to MQTT node gets published and we get rid of always rebroadcasting when MQTT is enabled

Co-authored-by: Ben Meadors <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants