Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. My Project
  3. about ACK ...

about ACK ...

Scheduled Pinned Locked Moved My Project
2 Posts 1 Posters 1.4k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • zzz-teoZ Offline
    zzz-teoZ Offline
    zzz-teo
    wrote on last edited by
    #1

    Hi, all
    I am trying to build a simple project of two nodes.One node with a push button(TOGGLE) and one switch, both with feedback LEDs.The other node with two relays and local control buttons.
    Its mandatory to have a reliable feedback to first node LEDs so, trying to figure out how ACK work in mysensors and how to resend the message if not ACK, I used
    this...

     //function to handle the ACK .
    #define ATTEMPTS 5
    
    void SendData(byte sensor, byte destination, bool value, bool ack) {
             msg.setSensor(sensor);
             msg.setDestination(destination);
             
      for(byte i=0; i<=ATTEMPTS; i++){
          if(send(msg.set((bool)value),ack)){
             Serial.println("ACK");
             break;
            }else{
            Serial.println("NACK");
            }
        
            }
    }
    

    ... which works great but only until the message reaches the gateway, not the target node! although I can see the ACK back from the target node it remains unparsed!
    Can anyone give me an example of how to do it?

    1 Reply Last reply
    0
    • zzz-teoZ Offline
      zzz-teoZ Offline
      zzz-teo
      wrote on last edited by zzz-teo
      #2

      ... this approach seems that work !

      #define ACKDELAY 40 //seems 40 millis is a good value
      bool nodeACK = false;  
      void SendData(byte sensor, byte destination, bool value, bool ack) {
               msg.setSensor(sensor);
               msg.setDestination(destination);
               
        for(byte i=0; i<=ATTEMPTS; i++){
            if(send(msg.set(value),ack)){
               Serial.println("Gateway ACK");
      //         wait(ACKDELAY);
               if(nodeACK == true){
               Serial.println("Node ACK");
               nodeACK = false;
               break;}else{
               Serial.println("Node NACK");
               }
              }else{
              Serial.println("Gateway NACK");
              }
              wait(ACKDELAY);
              }
      }
      
      

      ... in combination with this

      void receive(const MyMessage &message) {
      if (message.isAck()){
              nodeACK=true;
              digitalWrite(LED_PINS[message.sensor], message.getBool()? LED_ON:LED_OFF);
              Serial.println(F("ACK recieved LED Status Changed")); 
      }
      

      ... but probably is not the most elegand way!
      ... because if during the send/ack back message duty cycle, an ack from an other sensor received, a conflict may occure! i do not feel safe!
      (i also have a feeling that i did that post in the wrong topic! :confused: )

      1 Reply Last reply
      0

      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

      With your input, this post could be even better 💗

      Register Login
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      25

      Online

      12.1k

      Users

      11.2k

      Topics

      113.4k

      Posts


      Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • MySensors
      • OpenHardware.io
      • Categories
      • Recent
      • Tags
      • Popular