mcci-catena/arduino-lmic

Add means for application to influence battery response to device status request

terrillmoore opened this issue · 0 comments

Per @altishchenko in #560, we need a way to provide proper data for battery level in the DeviceStatusAns message.

The proposed approach (from here):

  • add LMIC_setBatteryLevel() (and LMIC_getBatteryLevel()) in header file (note slightly different name to os_getBattLevel()
  • add a private LMIC field to hold the recorded value
  • change LMIC initializations to initialize the default value of the private field to 0xFF (the value that indicates that the battery level is not known). Client is required to call LMIC_setBatteryLevel() after a re-initialization. I'm avoiding the question of "what happens at LMIC_reset()", because it's used internally as well as externally -- sorting that out requires some analysis.
  • change os_getBattLevel() so that it returns the private field. (The change to LMIC initialization ensures that behavior is unchanged for existing applications.)
  • update the documentation

Footprint impact of this would be minimal -- a byte of RAM and a few bytes of code for init and the change to os_getBattLevel().