DevStatusReq and libxDot-mbed5

Home Forums mDot/xDot DevStatusReq and libxDot-mbed5

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #31018
    Camilo Rojas
    Participant

    Hi,

    We are trying to override the MeasureBattery() function on mDotEvent.h file, but we are not able to add any custom code, as the function always returns 255 to our server:

    virtual uint8_t MeasureBattery(void) {
      uint8_t batteryLevel = myXdotbat.getBatteryLevel();
      return batteryLevel;
    }

    In the other hand, if we modify the function like this, we are able to receive 128 on our server.

    virtual uint8_t MeasureBattery(void) {
      return 128;
    }

    Our custom function is working when it’s included in main() function.
    Link margin value is always working as expected.

    Could you please provide guidance on how to modify the function properly?

    Kind regards,

    #31020
    Jason Reiss
    Keymaster

    What does myXdotbat.getBatteryLevel() do?
    What value is it returning?
    Does it change if you fix the value returned by getBatteryLevel() to 128?

    #31026
    Camilo Rojas
    Participant

    Hi Jason,

    myXdotbat.getBatteryLevel() reads an ADC pin, makes calculations and returns a value from 0 to 255.

    We resolved the issue by calling the class member function with no object (static):

    virtual uint8_t MeasureBattery(void) {
      return Xdotbat::getBatteryLevel();
    }

    Thank you.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.