interperating messages from controller
-
Hi all,
I was hoping somebody could help me out here or call me out on not looking properly. I'm currently trying to check messages coming from the controller to the sensor in hope of extracting the Node ID, Child ID in order to toggle the state of the target relay.
I'm currently confused on the proper way to do it, and have only managed to determine what state the controller is wanting to set on which ever relay it's meant to be targeting.
I should also note I'm using MySensor Library v2
Thanks
Mango
-
Welcome to the MySensors community @mango !
Could https://www.mysensors.org/download/serial_api_20 be what you are looking for?
-
Thanks very much for the welcome as well as the quick response! That does somewhat, but what I'm not so sure about is how one actually extracts it, for example:
int incoming_command = atoi(message.data);
would allows me to see the state the controller is trying to set my relay to, should I be extracting the node and child ID's in the same way?
-
@mango the receive function in the dimmer example shows one way to access the contents of the message.
https://www.mysensors.org/download/sensor_api_20#message-manipulation shows which set and get functions are available on the message object.
The sensor can get its own node ID by calling getNodeID(). Info here: https://www.mysensors.org/download/sensor_api_20#received-node-id
The child id is available through message.sensor Note: sensor is not a function, so no () after. The relay example shows how to use message.sensor.
-
@mango I also do that in this project. Probably look at my last post for the best example
-
I would just like to say a huge thank you to the both of you! Absolute legends! I am now sorted.
Thanks again lads.