mcci-catena / arduino-lmic

LoraWAN-MAC-in-C library, adapted to run under the Arduino environment
https://forum.mcci.io/c/device-software/arduino-lmic/
MIT License
638 stars 208 forks source link

How to replace HardwareSerial #789

Closed olicooper closed 2 years ago

olicooper commented 3 years ago

I have a wrapper around Arduino's HardwareSerial class to add functionality to it. I use extern SerialWrapper Serial to give it global scope (the same as Arduino does) and I define NO_GLOBAL_SERIAL so Arduino.h doesn't include the default implementation. I noticed you have LMIC_FAILURE_TO which I tried to use, but this doesn't actually need to be overridden anyway in my case as the name is the same.

The problem I have is that it wont compile because:

MCCI LoRaWAN LMIC library\src\hal\../lmic/config.h:106:25: error: 'Serial' was not declared in this scope

I assume this is due to my code not being in scope of the lmic header files, so how can I get this to work? What file should I edit? I am using PlatformIO which automatically downloads the latest external library code so editing your library isn't an ideal solution.

P.S. Thank you for all your hard work! You have a great library :)

terrillmoore commented 2 years ago

You have to inject a header file that has your definition. If you look around you'll see that there's a way to do it by defining LMIC_DEBUG_INCLUDE as the name of your extra header file. The macros in lmic.h add the required double-quote, so you write something like -D LMIC_DEBUG_INCLUDE=myfile.h.

The other way to do this is with the GCC flag that causes a forced include of a specified file before doing a compile. Check your compiler docs.

Best regards, --Terry

olicooper commented 2 years ago

Thank you, I will give this a try 👍