Understanding, c++ & MySensors lib



  • In my attempts to become a better C++ (Arduino) developer, so I can make those advanced nodes I'm thinking on, I often dismantle and see inside of big avr projects.
    In case of MyS, I can't understand how, in an archiectural point of view, can work.

    Let me explain: I created a new project in Platformio for ESP8266. Then I took the bare minimum from MyS lib, to be able to debug send a message, and stripped all other content. Even removing the ability for hook setup and loop, removing MyHwHAL and replacing with normal functions.
    So it has a main.ino with setup and loop that calls mysensorscore setup and loop.
    Other files, with content stripped that still remain are main mysensors.h, myconfig.h and hal for 8266. Nothing more. In hal I only leave debug related content, initilizing serial in hwInit() (called in core without conditional inclusion).

    As is, it never compiles. It throws error for two reasons. Core.cpp doesn't see content in hwHal (hwInit, DEBUG macros), and files in hwHal doesn't see the serial macros defined in config.
    I tried 4 and 5 times, with fresh projects and I can't make it work. I even thought it was something with the linux/platformio compiler, so switched to VS+vsmicro and then arduinoIDE without any success.

    Yesterday I took all the content and incorporated "as is" in order of call in the Mysensors.h file, and it compiled. Then I took out all the files one by one to reveal those two avobe problems in cpps.
    Then I took another copy of the bare project and eliminated the mysensors-mysensorscore level. I moved the coding from core to mys.h and it worked well and solved 1 problem. But Still have to reference myconfig in myhwesp8266 for it to see the debug macros.

    I'm sure it's my ignorance, so perhaps someone more expert in avr-c++ can explain me how mys library ignores those problems?


 

236
Online

8.9k
Users

9.6k
Topics

101.0k
Posts