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. Troubleshooting
  3. How to use MyMessage .setDestination ??

How to use MyMessage .setDestination ??

Scheduled Pinned Locked Moved Troubleshooting
4 Posts 2 Posters 2.6k Views 1 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.
  • S Offline
    S Offline
    shasha
    wrote on last edited by
    #1

    Hello,

    I would like to use the MyMessage set on the fly functions.
    Here is a dummy sketch that cannot compile.

    #include <MyMessage.h>
    
    MyMessage msgOut();
    
    void setup() {
    msgOut.setDestination(10);
    }
    
    void loop() {
    }
    

    here is the error I got :

    error: request for member 'setDestination' in 'msgOut', which is of non-class type 'MyMessage()'

    What it is wrong in the way I use this function ?
    Thanks

    1 Reply Last reply
    0
    • S Offline
      S Offline
      shasha
      wrote on last edited by shasha
      #2

      Hum some news :

      There are two constructors for MyMessage

      one is MyMessage::MyMessage()
      the other one is MyMessage::MyMessage(uint8_t _sensor, uint8_t _type)

      if I modify my dummy sketch like this :

      #include <MyMessage.h>
      
      MyMessage msgOut();
      MyMessage msgIn(1, V_TRIPPED);
      
      void setup() {
      msgIn.isAck();
      msgOut.isAck();
      msgOut.setDestination(10);
      msgIn.setDestination(10);
      }
      
      void loop() {
      }
      

      I get the following errors :

      In function 'void setup()':
      error: request for member 'isAck' in 'msgOut', which is of non-class type 'MyMessage()'
      error: request for member 'setDestination' in 'msgOut', which is of non-class type 'MyMessage()'

      The errors are only for msgOut that uses the first constructor.
      msgIn uses the second constructor and it works.

      Looks wierd to me. Can you explain why the simplest constructor gives errors ?

      Thanks again

      1 Reply Last reply
      0
      • hekH Offline
        hekH Offline
        hek
        Admin
        wrote on last edited by
        #3

        @shasha said:

        MyMessage msgOut();

        I think you should write like this to use the no-arg constructor:

        MyMessage msgOut;
        
        1 Reply Last reply
        0
        • S Offline
          S Offline
          shasha
          wrote on last edited by
          #4

          hum you are right !!

          thank you !

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          36

          Online

          11.7k

          Users

          11.2k

          Topics

          113.1k

          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