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 $localip gets truncated #309

Closed
pwrsoft opened this issue Feb 28, 2017 · 5 comments
Closed

MQTT $localip gets truncated #309

pwrsoft opened this issue Feb 28, 2017 · 5 comments
Labels

Comments

@pwrsoft
Copy link

pwrsoft commented Feb 28, 2017

Having an issue with Homie v2.0.0 MQTT $localip
it gets truncated in the last symbol when published in MQTT:
e.g. instead of "192.168.1.128" it gets "192.168.1.12", tested this on two nodes but with the same results.

@bertmelis
Copy link
Contributor

bertmelis commented Feb 28, 2017

try changing the file BootNormal.cpp on line 193:

snprintf(localIpStr, MAX_IP_STRING_LENGTH - 1, "%d.%d.%d.%d", localIp[0], localIp[1], localIp[2], localIp[3]);

to

snprintf(localIpStr, MAX_IP_STRING_LENGTH + 1, "%d.%d.%d.%d", localIp[0], localIp[1], localIp[2], localIp[3]);

If it works, you should also changed it BootConfig.cpp. But if this fix works, I would think the bug is that the IP gets truncated by 2 characters.

@pwrsoft
Copy link
Author

pwrsoft commented Feb 28, 2017

Thank you for your reply and suggestion!
Checked the solution you provide - the IP is now OK!

One thing that changed too is the device id – is gets extended by 1 symbol (for some reason):
e.g. XXXXXXXXXf9 changed to XXXXXXXXXf93

@bertmelis
Copy link
Contributor

The default device ID is actually the MAC address and hence is 12 characters long. It was a bug: see #296
The underlying cause was the same for this issue. You could propose a pull request for this solution (otherwise I will).

@pwrsoft
Copy link
Author

pwrsoft commented Feb 28, 2017

Feel free to make a pull request 👍

@marvinroger
Copy link
Member

Fixed with the above PR, thanks!

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

No branches or pull requests

3 participants