arduino-lmic icon indicating copy to clipboard operation
arduino-lmic copied to clipboard

Function os_getBattLevel

Open kamarat opened this issue 5 years ago • 3 comments

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?

kamarat avatar Jan 08 '19 14:01 kamarat

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.

sle118 avatar Apr 03 '19 12:04 sle118

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?

cyberman54 avatar Sep 07 '19 20:09 cyberman54

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

geeks-r-us avatar Sep 07 '20 07:09 geeks-r-us