Message acknowledgements hoot



  • Hi guys.

    I’m trying to get acknowledgements to work and need some guidance.

    First of all, are there any code examples or information on this that I’ve missed? I can’t seem to find any real information apart from what’s in the API doc.

    Secondly to my specific problem, I’ve enabled message ack as the in code fragments below but still getting messages at the gateway end with ack flag set to 0.

    Code:
    gw.send(msg.set(value==HIGH ? 1 : 0),true);
    or
    gw.sendBatteryLevel(batteryPcnt,true);

    but still only getting the following messages without ack enabled (4;3;1;0;16;1
    and 4;255;3;0;6;0)

    Below is the documented serial protocol
    node-id;child-sensor-id;message-type;ack;sub-type;payload

    Am I missing something?

    It will be great if someone can point me in the right direction

    Thanks



  • Hi.. I also try this and have same result .. I don't know why ..
    I'm waiting for answer ..


  • Admin

    Not sure I understand .. But the ack:ing of the message is handled by the gateway and is never visible the serial monitor (unless debugging is enabled).

    Scenario:

    1. A sensor enables ack for a Battery Lever message and sends it.
    2. Message reaches gateway. The MySensors library sends an ack message back to sensor and outputs the Battery Level message to serial.


  • hi hek.
    pls make any sketch example or write where we can download it ..
    and what we must see in debugging if we use it ..
    you write that not possible to see only if debugging is enable ...
    I enable debugging but still see 4 argument is 0 in gateway .. and don't see received packet in node .. I try it ..

    regards..


  • Admin

    With debugging you can see that gateway is replying back to sensor. Don't mix up serial protocol with debug messages, they are not the same.

    You can pick up the ack message in the normal callback. See for example RelayActuator on how to handle incoming messages.


  • Admin

    @lodewyk said:

    4;3;1;0;16;1

    When you receive a message through serial protocol the zero above means that this not is an ack message.

    You will only get 1 here if you have sent a message through serial protocol out to an sensor and it has REPLIED with an ack message back to controller.'

    All this is described in the first section here:
    http://www.mysensors.org/build/serial_api



  • hek .. hi ..
    right now I testing this :
    to node load relay actuator and try controll relay (digitla output ) on node by serial gateway ..

    I see debugging message in gateway and in node ..
    if send packet from serial gateway : 40;1;1;1;2;0
    node = 40 , sensor = 1 , message type = set , ACK = true , sub-command =V_LIGHT , payload = 0
    then in node see that received packet and send ACK to gateway ..
    and in serial gateway I see that received it ..

    OK this working .. huraaaa... ACK request serial gateway from node

    But now qestion is how to do it : ACK request node from srial gateway ...
    if push buton then I want to know that packet delivery to serial gateway ..
    or not .. if yes .. OK .. if not then want inform user .. some problem..

    regards.



  • @hek Thank you, this is useful. This was my first assumption but I don't receive any ack callback at the sensor end and thought I had to handle ack explicitly at the gateway side. I’ve implemented my own node.js gateway using the serial gateway sketch .

    After more debugging I can actually see the ack arriving at the sensor but my callback still don’t get fired. I am calling gw.process() in the program loop and my callback look as follow.

    void incomingMessage(const MyMessage &message) {
    Serial.println("Got message");
    if (message.isAck()) {
    Serial.println("This is an ack from gateway");
    }
    }

    mysensor gateway begin code:

    gw.begin(incomingMessage, 4, false, 0, RF24_PA_LEVEL, RF24_CHANNEL, RF24_DATARATE);

    Debug after firing a battery update:
    send: 4-4-0-0 s=255,c=3,t=0,pt=1,l=1,st=ok:102
    read: 0-0-4 s=255,c=3,t=0,pt=1,l=1:102 <----- I assume this is the ack

    Any suggestions?

    Thanks


  • Admin

    @lodewyk

    Strange..
    Can you post the part where you send the message to controller also?



  • @hek gw.sendBatteryLevel(batteryPcnt,true);


  • Admin

    Ok, I see now that there is a bug for callback on receiving acks for internal commands.

    You might try removing this line:
    https://github.com/mysensors/Arduino/blob/master/libraries/MySensors/MySensor.cpp#L370



  • @hek It unfortunately did not work 😞

    Thanks for the help so far. I'll have to leave this for another day.


Log in to reply
 

Suggested Topics

  • 3
  • 2
  • 3
  • 1
  • 4
  • 2

1
Online

11.2k
Users

11.1k
Topics

112.5k
Posts