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

MQTT Will message is invalid #171

Closed
xoseperez opened this issue Jul 21, 2017 · 6 comments
Closed

MQTT Will message is invalid #171

xoseperez opened this issue Jul 21, 2017 · 6 comments

Comments

@xoseperez
Copy link
Owner

Originally reported by: Abílio Costa (Bitbucket: amfcosta, GitHub: Unknown)


The MQTT will message is not correct. It seems to be reading another memory part.

After looking at the code, I think the issue is here (haven't tested yet): https://bitbucket.org/xoseperez/espurna/src/e327a219a81af889d81701e94f41eb78ec5db426/code/espurna/mqtt.ino?at=master&fileviewer=file-view-default#mqtt.ino-251

On line 251, the will char* is being freed, but it is probably stored by the mqtt lib when mqtt.setWill(...) is called.

@xoseperez
Copy link
Owner Author

For me it is working fine, I get the will topic ~40 seconds after disconnecting the board...

@xoseperez
Copy link
Owner Author

Original comment by Abílio Costa (Bitbucket: amfcosta, GitHub: Unknown):


Weird. The device on which you tested was being used? Try to toggle its state sometimes before disconnecting, just to try and get that memory zone rewritten. Could it be that when you tested, despite being freed, the memory still had the valid contents?

This is what I'm getting from mosquitto_sub:

#!arduino

Client mosqsub/2342-rpi3 received PUBLISH (d0, q0, r0, m0, 'yGetter', ... (1 bytes))
0

The topics vary a bit ("yGetter", "1Getter", "Getter"), that's why it looks like invalid memory reads.

Tested on a Sonoff S20 and a Sonoff TH10.

@xoseperez
Copy link
Owner Author

Caught it! Moved the variable to global scope. Right now in the dev branch, will be released soon.

@xoseperez
Copy link
Owner Author

Original comment by Abílio Costa (Bitbucket: amfcosta, GitHub: Unknown):


Great! :D

@xoseperez
Copy link
Owner Author

Pushed with 1.8.3.

@xoseperez
Copy link
Owner Author

Removing milestone: 1.8.3 (automated comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant