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. Migrating to MySensors 2.0

Migrating to MySensors 2.0

Scheduled Pinned Locked Moved Troubleshooting
3 Posts 2 Posters 849 Views 2 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.
  • M Offline
    M Offline
    Marcell Kovacs
    wrote on last edited by Marcell Kovacs
    #1

    Dear MySensors Devs,

    I already have a basic home automation setup with MySensors 1.5-6. Now I decided to give a try and update my nodes to run MySensors 2.0, but Im facing challenges i cant overcome at the moment.
    More or less its related to my low experience with C++ and Arduino build. I hope this will be easy for you.

    The main problem is, i implemented some classes to separate responsibilities. Few of them are depending on MyMessage and one depends on MyGateway. Since 2.0 these classes seems to be not available for inclusion from the .ino and other .h/.cpp files.

    Is there any workaround for this? (basically i have no reference to MySensor's gateway object, none of them can be included)
    Another way will be to hide all MySensors functionality behind an interface, implemented in the main .ino file, passing calls to mySensors. I'm about to make this change to make the MySensors dependency somewhat weaker, but would be nice to refactor this after i have a working state.

    One of my classes in the example: RadioMirror's constructor:
    RadioMirror(MySensor *gw, OutputState state, byte outputCount, const byte radioIds);
    , where i cant pass a gw object anymore, because its hidden somewhere (or include MyMessage.h anymore).

    Thank you in advance, You created an awesome library anyway :)
    BR,
    marcell

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

      I don't think you need to pass gw object any more. Methods like send/request is available in the global scope.

      You might need to declare them extern so the compiler won't complain.

      M 1 Reply Last reply
      1
      • hekH hek

        I don't think you need to pass gw object any more. Methods like send/request is available in the global scope.

        You might need to declare them extern so the compiler won't complain.

        M Offline
        M Offline
        Marcell Kovacs
        wrote on last edited by
        #3

        @hek said:

        You might need to declare them extern so the compiler won't complain.

        This IS the solution. Thank you for this. To be honest i never used (or knew) extern keyword exists. As a Java-dev, i see this against I believe in : )

        Thank you! You made me see the light in the tunnel. (I'm still in the hope its not the train : )

        To share the actual solution:
        In the class, where I was using MyGateway *gw before, now I have this (in the .cpp file):
        extern bool send(MyMessage &message, bool enableAck)
        ...and i replaced gw->send(..) with send(..)

        The imports for the MyMessage class had to be changed to core/MyMessage.h.
        I'm using visual micro + visual studio for this development.

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


        25

        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