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 Relay Issue #31

Closed
xoseperez opened this issue Jan 8, 2017 · 3 comments
Closed

MQTT Relay Issue #31

xoseperez opened this issue Jan 8, 2017 · 3 comments

Comments

@xoseperez
Copy link
Owner

Originally reported by: RAJEEV TANDON (Bitbucket: rajtan, GitHub: rajtan)


There seems to be an issue in relay module.

When there is an incoming request (mqtt message for setting up a relay) - the code which is used to get the relayID seems to be erroneous (at least in my case). The code used to fetch the index of character having relayId is IMHO wrong. I have used the following code fragment to get the correct relayID.

#!arduino

relayID = topic[strlen(topic)-strlen(MQTT_USE_SETTER)-1] - '0'

This would manifest only when an MQTT message for setting up a relay status is received wherein an incorrect relay being triggered (usually relay 0 due to the following code) when some other one was intending the other relay.

I could also not understand the code to reset the relay to 0 if extracted Id was higher?

Anyone having this problem? Though I have fixed both of above for now.

@xoseperez
Copy link
Owner Author

Thank you!
You are right, there is a huge bug there. But it should be like this:

#!cpp
unsigned int relayID = topic[strlen(topic) - mqttSetter.length() - 1] - '0';

Because you might have a custom setter in the future. Besides, the default 0 was a poor man's solution. It should discard invalid messages.

@xoseperez
Copy link
Owner Author

Fixed with commit 9ce457f.

@xoseperez
Copy link
Owner Author

Fixed in 1.4.2

xoseperez added a commit that referenced this issue Jan 24, 2018
Conflicts:
	code/espurna/data/index.html.gz
	code/espurna/static/index.html.gz.h
	code/platformio.ini
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