-
Notifications
You must be signed in to change notification settings - Fork 676
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
[Bug]: MQTT JSON Bug #1763
Comments
the MQTT stuff is quite verbose in debug logging. Can you attach a serial debug log of the device (meshtastic --noproto if you got CLI installed) so we can have a look what is actually transmitted? There should be lines like 'publish json message to...' in there |
Sure. While doing this I noticed another issue. When NOT connected via CLI the payload of the packets on topic msh/1/json/LongFast/!7efec08c look like: When connected via CLI or via the web client there are either no MQTT JSON packets or the packet forwarded by the broker looks like: The enclosed file is the debug output of the MQQT-connected heltec 2.1 from reset until three messages are received and displayed on the OLED. The messages were sent from an android app connected to second Heltec. (A T-beam is also on the mesh.) The debug file seems to be somewhat unhelpful as the MQQT doesn't seem to work properly when the device is connecting to something via the usb. |
Further observations. Duplicated the behavior on a t-beam connected to the network. Findings are: the JSON topic will not publish to MQTT if the device has been connected to the Web client or the CLI even after disconnect. An unencrypted protobuf packet will publish after disconnect under the topic - msh/1/c/LongFast/!deviceName. |
Looks like some buffer is too small. Also please don't mix several issues in one bug report, it gets harder and harder to actually solve one issues... Lets focus on this buffer/garbling issue and retest the other observations after we get rid of this. |
Sounds good. |
In case anyone comes here trying to figure out a way to get plain text messages while JSON is not working, I've put an interim solution on the discourse site: |
Updated firmware test 1.3.44.4fa8d02 (there was a note that mqtt was worked on). Similar errors, Serial debug file attached Incidental observations:
|
I have no experience with coding this language but I think at least one of the problems may be in the MQTT.cpp module, line 282: |
Really great catch. That explains why we can easily blow out the buffer and why the text message payloads are coming through as json |
Closing, based on the fix in that latest PR. If any further issues occur, please open a new ticket with those. |
sorry, but that still doesn't cut it based on debug logging ...
|
and (which irks me more) that it doesn't seem to be able to deserialize the buffer it just sent and received back from MQTT.
|
Thank you very much for looking into this. I am new to this environment but got it loaded and am working through the mqtt code by adding debug statements. I know there are other problems in this situation but in the section that converts a downstream packet to json (line 253). // if it isn't, then we need to create a json object It seems to not be agreeable with this statement that follows all the "cases" --> |
that deserialization error was a red herrig which came from trying to feed the json payload to nanopb. i cleaned up a bit of debug printing there and changed the order of tests. What caused the garbled output was the new fixed 160 char buffer in our debug print. I fixed that to truncate properly instead of just printing random areas of memory to the console. JSON and MQTT should work fine now. |
Almost there. Remaining issue is that JSON text payload does not sent the latest message, it only repeatedly sends the first message received since reboot over and over. The enclosed log is what happens when sending "Test message number one.", then "Test message number two.", then "Test message number three." msh/2/c/channelID/nodeID sends correctly to mqtt Here is a JPEG from the broker side with two messages. First one was: "Test package." Second one was: "Message one." |
I have a possible fix building for that on https://github.com/meshtastic/Meshtastic-device/pull/1822/checks - can you verify once the PR build is done? |
Awesome! |
Category
Other
Hardware
T-Beam, Heltec v2.1
Firmware Version
1.3.42.9bd9252
Description
Environments and settings:
1.3.42.9bd9252 firmware, heltec and t-beam devices, android 1.3.41, windows chrome web, node-red mqtt broker, using default channel for this example. One device is connected to wifi with Settings for default channel uplink and downlink ENABLED. Settings module, MQTT config, encryption off, JSON output enabled ON.
Issue:
When a sequence of LORA message packets is sent to a lora module connected to a mqtt broker, the broker responds by repeatedly sending out only the first message received from that particular client. The correct text messages in the sequence correctly display on the receiving OLED.
Example:
Device one which is connected by bluetooth via android sends three messages: “Let’s stay another message”, “I meant try”,
“It doesn’t increment”.
Device two is connected via wifi network to a mqtt broker. The broker responds to each message but the payloads sent all only contain the first message's text. The three messages are published by the broker on topic:
“msh/1/json/LongFast/!7efec08c”
and all look like:
{“channel”: 0, “from”: 2130621128, “id”: -1175740138, “payload”: {“text”: “Let’s stay another message”}, “sender”: “!7efec08c”, “timestamp”: 0, “to”: -1, “type”: “text”}
Reset via button on the receiving lora device doesn't fix it. Pulling power on that device to reset allows a fresh message to be sent via mqtt. Two different sending devices will send two different packets to the receiving device connected via mqtt. Those two different messages will then continue to repeat depending on the sending machine.
Relevant log output
No response
The text was updated successfully, but these errors were encountered: