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?
Suggested Topics
-
Arduino Celebrates 10 years (Malmö/Sweden)
Announcements • 29 Mar 2014, 17:08 • hek 29 Mar 2014, 17:08 -
MQTT-Help me understand about the MQTT Gateway.
Development • 2 Mar 2025, 01:44 • dpcons 12 Mar 2025, 23:39 -
Saving last known good state, but not in EEPROM
Development • 30 Jan 2024, 18:46 • OldSurferDude 15 Jan 2025, 08:51 -
Home Assistant/MySensors quirks
Development • 27 days ago • OldSurferDude 27 days ago -
PJON and Minicore not working
Development • 23 days ago • Trand 23 days ago -
Adding Listen only device to my system.
Development • 26 Feb 2025, 00:39 • dpcons 26 Feb 2025, 06:26