• Categories
    • Recent
    • Tags
    • Popular
    • Register
    • Login

    Getting V_FORECAST on a node from controller?

    Scheduled Pinned Locked Moved Troubleshooting
    8 Posts 2 Posters 917 Views 1 Watching
    Loading More Posts
    • 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.
    • skywatchS Offline
      skywatch
      last edited by

      HI all!

      I have been trying to get the V_FORECAST to another node (not the originating node). I have set up the payload forward in MyController, but I am having a problem getting it to work on the receiving node.

      I have tried various variations on....

      void receive(const MyMessage &message) {
          if (message.sensor == CHILD_ID_GETFORECAST && message.type == V_FORECAST){
          FORECAST = (message.getInt());   
          }
      

      including getByte and getString. But still I can't seem to get it to work.

      So what is the correct way to get relayed V_FORECAST on a node?

      jkandasaJ 1 Reply Last reply Reply Quote 0
      • jkandasaJ Offline
        jkandasa @skywatch
        last edited by

        @skywatch can you paste the screenshot of forward payload configuration?

        skywatchS 1 Reply Last reply Reply Quote 0
        • skywatchS Offline
          skywatch @jkandasa
          last edited by skywatch

          @jkandasa Sure I can! 🙂

          0_1534957288554_Forward.jpg

          I think I have the wrong variable type to get V_FORECAST - Although I only need a byte or int with the index pointer of the current forecast (0-5).

          When testing it with byte received I could send a raw message and it worked, so I guess it is not a byte or int that is sent to the controller and then on to the node?

          jkandasaJ 1 Reply Last reply Reply Quote 0
          • jkandasaJ Offline
            jkandasa @skywatch
            last edited by

            @skywatch MyController sends payload as is.
            Can you double check that, you have configured right sensor?
            You may debug by adding a serial print line right after void receive(const MyMessage &message) { before if loop?

            skywatchS 1 Reply Last reply Reply Quote 0
            • skywatchS Offline
              skywatch @jkandasa
              last edited by skywatch

              @skywatch MyController sends payload as is.

              I do not know what that is - is it an int? byte?string?

              Can you double check that, you have configured right sensor?

              Yes I have, I can send the receiving node a byte and the screen displays the correct value. I did this to test with action>send raw message and it was good.

              You may debug by adding a serial print line right after void receive(const MyMessage &message) { before if loop?

              That's a thought for tomorrow.....thanks!

              jkandasaJ 1 Reply Last reply Reply Quote 0
              • jkandasaJ Offline
                jkandasa @skywatch
                last edited by jkandasa

                @skywatch

                I do not know what that is - is it an int? byte?string?

                MyController receives all the payload in String format and sends all the payload in String format.
                From the gateway, MyController receives payload as String, https://www.mysensors.org/download/serial_api_20
                However, We have multiple functions in MySensors, based on your payload you can call a particular function,
                https://www.mysensors.org/download/sensor_api_20#message-constructor

                 // Getters for picking up payload on incoming messages
                    char* getStream(char *buffer) const;
                    char* getString(char *buffer) const;
                    const char* getString() const;
                    void* getCustom() const;
                    uint8_t getByte() const;
                    bool getBool() const;
                    float getFloat() const;
                    long getLong() const;
                    unsigned long getULong() const;
                    int getInt() const;
                    unsigned int getUInt() const;
                

                Can you check it in the resources page, do you receive data from the source node? You can enable Notice and check activities in resources log page.

                skywatchS 1 Reply Last reply Reply Quote 0
                • skywatchS Offline
                  skywatch @jkandasa
                  last edited by

                  @jkandasa

                  Thanks I got it to work!

                  The below is what I used as I cannot display the full message on a small oled and so I use abbreviations held in an array. Therefore I needed to get a value to act as a pointer to the message to display and the below did the trick! - Node finished! 🙂

                  void receive(const MyMessage &message) {
                     if (message.sensor == CHILD_ID_GETFORECAST && message.type == V_FORECAST) {
                      forecast = (message.getString());
                      if (forecast == "stable"){
                      Index = 0;}
                      else if (forecast == "sunny"){
                      Index = 1;}
                      else if (forecast == "cloudy"){
                      Index = 2;}
                      else if (forecast == "unstable"){
                      Index = 3;}
                      else if (forecast == "thunderstorm"){
                      Index = 4;}
                      else if (forecast == "unknown"){
                      Index = 5;}
                   
                    }
                  
                  skywatchS 1 Reply Last reply Reply Quote 1
                  • skywatchS Offline
                    skywatch @skywatch
                    last edited by skywatch

                    @skywatch Just a quick update - ......

                    Keep the receive section clean - I took all the 'if' and 'elseif' out of receive and into the main loop - This is good practice. So now it looks like this......

                    // process incoming message
                    void receive(const MyMessage &message) {
                      if (message.sensor == CHILD_ID_GETFORECAST && message.type == V_FORECAST) {
                        forecast = (message.getString());
                        NewForecast = 1;
                      }
                    }
                    

                    The NewForecast is there to alert the main loop to a new incomming value to be tested and updated.

                    1 Reply Last reply Reply Quote 1
                    • First post
                      Last post

                    0

                    Online

                    586

                    Users

                    529

                    Topics

                    3.4k

                    Posts
                    Copyright © 2015-2025 MyController.org | Contributors | Localization