When requesting with request() function what reply should I expect?
-
Hello all,
I am requesting the status of a switch with child ID 1 from another sensor node ID 2.
I used request(uint8_t childSensorId, uint8_t variableType, uint8_t destination);
In my case variable type is V_LIGHT so its request(1, 2, 2).I can see the sensor node 1 sending message and sensor node 2 receiving message in the debug log but sensor node doesn't send anything back to the requesting node.
Now what kind of message should I expect from the node? OR I should write some code in the receiving node to create a response?
Thank You
-
@palande.vaibhav - without any major knowledge in this, i use request() against the controller and receive() to get the message back. Maybe you need to use recieve() in node 2 and code some reply in that function?
-
@sundberg84
I have void receive() in node 2. But to code something I need to know what I am listening to.Is that just a bool message with the state of the switch saying its ON or OFF??
What do you have in the void receive() function you are using?
-
This is from my rainsensor and its < 2.0.
Its expecting V_VAR1 (pulsecounter) from controller database.//Read if we have a incoming message. void receive(const MyMessage &msg) { if (msg.type==V_VAR1) { hwPulseCounter = msg.getULong(); hwRainVolume = hwPulseCounter; pcReceived = true; Serial.print("Received last pulse count from gw: "); Serial.println(hwPulseCounter); } }```
-
@palande.vaibhav https://github.com/mysensors/MySensorsArduinoExamples/blob/master/examples/RainGauge/RainGauge.ino#L546
Is another example - i think this is 2.0 code
-
@sundberg84
OK. And does your request() function looks just like mine?
So, are you requesting V_VAR1 from the node?
-
@palande.vaibhav - Nope, im requestion v_var from the controller. Thats what im unsure about...
-
@sundberg84
Can you share your snippet of code where you have request() function?
-
-
@sundberg84 As far as I understand by looking at the code you have sensor on the same node which is requesting the pulse count from the GW??
OR you have reed switch on this node and sensor is on some other node? In the debug prints do you see a READ message in the serial monitor for your node which has reed switch?
With me, I am sending the request() from node 1 to node 2. I can see SEND message in serial monitor of node 1 and READ message in the serial monitor of GW and also a SEND message in GW serial monitor and READ message in node 2. So the message is reaching node 2 successfully but my node 2 is not sending any reply to that message.
So, node 1 is sending to GW, GW is receiving it and sending it to node 2, node 2 is receiving the message but node 2 is not replying. Is this what is supposed to happen? OR node 2 is actually supposed to send a reply back to node 1?