Hi - I am having some problems !
I am trying to implement the MQTT library to have a bit of a play with some automation here at home. I have messages being sent around the network and I'm using the MQTT library on an EtherTen.
The MQTT library uses a callback function that is fired whenever an MQTT message hits the topic that the Arduino is subscribed to. Anyway you wont to know about that to help me solve this !
The callback function takes this form:
void callback(char* topic, byte* payload,int length) {
//stuff in here
}
I am having problems with the payload parameter. It is (I think) an array of bytes. Now I'm not sure how I need these presented to the part of my code hat make decisions. Let's go back a step...
I want to pass a message along the lines of:
PUMP:ON
Now if I pass that message via MQ I guess I will end up with an array of byte values.
Should I put all these bytes back together into a String and then use an if/else statement to loop over the possible values in the message, ie. PUMP:OFF or VALVE:1:OPEN
If so, how do I do this ? If not what would you suggest I do to be able to perform conditional logic based on the values in the messages I pass.
Any help would be appreciated.