arduino-lmic
arduino-lmic copied to clipboard
Function os_getBattLevel
Hello, I've used arduino-lmic library for my sensor node. I would like to implement function os_getBattLevel correct without edit the library files.
There is pieces of code in file /src/lmic/oslmic.h
#ifndef os_getBattLevel
u1_t os_getBattLevel (void);
#endif
and in file /src/lmic/lmic.h
#if !defined(os_getBattLevel)
u1_t os_getBattLevel (void) {
return MCMD_DEVS_BATT_NOINFO;
}
#endif
When I wrote own function os_getBattLevel and commented code in file arduino-lmic/src/lmic/lmic.h, that was working.
But when I wrote macro
#define os_getBattLevel() getBattLevel()
and new own function getBattLevel(), that wasn‘t working.
What is correct implementation?
This question has more to do with understanding of compiler and C programming than it has to do with this library. I suggest you create a repository, upload you code there, and describe how you compile the code (Arduino compiler vs PlatformIO, etc) as there are many ways you could get this problem and each environment had is own quirks.
Perhaps you should consider getting help from one of the many forums online; there are many active communities out there that are likely to help. Issues in GitHub should be strictly related to the project itself. For example feature requests, actual bugs that are fully documented, etc.
I ran in exactly the same problem. Tried several option (forward declaration, etc.) but did not manage to declare own function os_getBattLevel without modify the source code of the library. Is there any straight forward solution for this?
Issue is within the "hacked" symbol resolving process to allow lazy code writing without creating prototypes etc. In PlatformIO you can resolve it by adding the define to platfomio.ini;
build_flags =
-D os_getBattLevel=getBattLevel
I don't know if there is any chance to do something like that with the Arduino IDE