#error No forward link or gateway feature activated - when including MySensors



  • Hello everyone,

    I know this topic exists more than once in this forum, but I couldnt find a solution until now. Im not a c++ expert, so the solution might be obvious.
    Im always getting the mentioned error when splitting files and including <MySensors.h>

    here is the error then compiling:

    In file included from src/Example.h:5:0,
                     from src\Example.cpp:1:
    C:\Users\timo\.platformio\lib\MySensors_ID548/MySensors.h:426:2: error: #error No forward link or gateway feature activated. This means nowhere to send messages! Pretty pointless.
     #error No forward link or gateway feature activated. This means nowhere to send messages! Pretty pointless.
    

    And here is my simplified code... Im trying to write external files for recurring code over serveral projects.

    src/main.cpp:

    #define MY_RADIO_RF24
    
    #include <MySensors.h>
    
    #include <Example.h>
    
    void setup()
    {
    }
    
    void presentation()
    {
    }
    
    void loop()
    {
    }
    

    src/Example.h:

    #ifndef _example_
    #define _example_
    
    #include <Arduino.h>
    #include <MySensors.h>
    
    void someFunction(int test);
    
    #endif
    

    src/Example.cpp

    #include <Example.h>
    
    void someFunction(int test) {
        Serial.println(test);
    }
    

    Environment:

    • VS Code with PlatformIO
    • MySensor lib 2.3.1

    It seems that the <MySensors.h> - include in the example file has no access to my defined constants and somehow gets executed first?
    Im not able to get rid of this problem.

    It compiles successfully if I leave out the include of MySensors in the Example.h
    Any help is appreciated 🙂


  • Mod

    Welcome to the MySensors community @timo458!
    The message tries to say that you haven't selected any transport method (which is required for a MySensors node to work), nor have you configured that you want a gateway (which can be used without a transport). So if you were allowed to upload this code, MySensors would not work, which would be pretty pointless.

    The getting started guide will probably be the quickest way to get up to speed. Perhaps https://www.mysensors.org/about/overview can be useful as well.



  • Yes. But the first line of my Code is selecting the nrf24 as radio. So it should work. And indeed it works if I comment out the include of my example :

    #define MY_RADIO_RF24
    
    #include <MySensors.h>
    
    // #include <Example.h>
    
    void setup() {}
    
    void loop() {}
    

    This works and compiles without error. It has to be something with the include of MySensors in the Example.h file. But I dont know why.

    edit:
    This is a corresponding github issue I found:
    https://github.com/mysensors/MySensors/issues/485 - But it has no solution 🙂


  • Mod

    @timo4583 I see. Thanks for explaining.

    I have no experience with Platformio but the Arduino IDE has some very strange behavior when using multiple files. Could be a side-effect of that.


  • Mod

    Maybe the trick mentioned in https://forum.mysensors.org/post/51634 can be useful


  • Mod



  • Thank you very much for your help. I found a solution which is a little ugly, but it works. Splitting to header(.h) and code(.cpp) files does somehow not work with MySensors, or Im not able to find the right solution.

    For now Im no creating a seperate code(.cpp) file and put evertything to the header(.h). This works:
    /src/main.cpp:

    #define MY_RADIO_RF24
    
    #include <MySensors.h>
    
    #include <Example.h>
    
    void setup() {}
    
    void presentation() {}
    
    void loop() {}
    

    src/Example.h:

    // HEADER PART
    #ifndef _example_
    #define _example_
    
    #include <Arduino.h>
    #include <MySensors.h>
    
    void someFunction(int test);
    
    // IMPLEMENTATION PART
    
    void someFunction(int test) {
        Serial.println(test);
    }
    
    #endif
    

    This way, it will be easy to split the files again, as soon as I find out how 🙂



  • What happens if you first include the example and then the Mysensors library?
    I also use platformio and it works perfectly.



  • @electrik Okayy.. that makes me curious. Did you try the exact same files and code like in my first post and it compiles? Changing the order does not work for me.



  • No I didn't try that, just out of experience.
    But now I see you include Mysensors.h again in the example. If you want to use mysensors functions in the header file you should just include
    #include <core/MySensorsCore.h>
    See also https://forum.mysensors.org/topic/6646/solved-multiple-source-files-including-mysensors-h-problem/2



  • @electrik Oh yes, that did the trick. Thank you so much


 

204
Online

8.9k
Users

9.6k
Topics

100.8k
Posts