• header.categories
    • header.recent
    • header.tags
    • header.popular
    • register
    • login

    Getting V_FORECAST on a node from controller?

    scheduled pinned locked moved Troubleshooting
    8 posts 2 posters 1.6k views 1 watching
    loading-more-posts
    • oldest-to-newest
    • newest-to-oldest
    • most-votes
    reply
    • reply-as-topic
    guest-login-reply
    deleted-message
    • skywatchS offline
      skywatch
      global: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 one-reply-to-this-post last-reply-time reply quote 0
      • jkandasaJ offline
        jkandasa @skywatch
        global:last-edited-by,

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

        skywatchS one-reply-to-this-post last-reply-time reply quote 0
        • skywatchS offline
          skywatch @jkandasa
          global: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 one-reply-to-this-post last-reply-time reply quote 0
          • jkandasaJ offline
            jkandasa @skywatch
            global: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 one-reply-to-this-post last-reply-time reply quote 0
            • skywatchS offline
              skywatch @jkandasa
              global: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 one-reply-to-this-post last-reply-time reply quote 0
              • jkandasaJ offline
                jkandasa @skywatch
                global: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 one-reply-to-this-post last-reply-time reply quote 0
                • skywatchS offline
                  skywatch @jkandasa
                  global: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 one-reply-to-this-post last-reply-time reply quote 1
                  • skywatchS offline
                    skywatch @skywatch
                    global: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.

                    one-reply-to-this-post last-reply-time reply quote 1
                    • first-post
                      last-post

                    0

                    online

                    644

                    users

                    532

                    topics

                    3.4k

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