SRAM AXS Battery Status

Is it possible to get battery status for a SRAM AXS system using shiftinglistener? I am using the following, but the answer is always '7' And, if it is possible, does it give the battery status of the front or rear derailleur. In my groupset the rear derailleur is the master component so I assume it would give the battery status of this??

ShifterListener = new AntPlus.ShiftingListener();
BikeShifter = new AntPlus.Shifting(ShifterListener);

if(BikeShifter has :batteryStatus) {
if(BikeShifter.batteryStatus != null) {
ShifterBattery = BikeShifter.batteryStatus;
} else {
ShifterBattery = 7;
}
}

  • I guess shifterArray is an empty array

  • I guess shifterArray is an empty array

    Can that be...?
    How to check an empty array other than "IF != null"

            shifterArray = bikeShifter.getComponentIdentifiers();
            if ( shifterArray != null ) {
                var batStatus = bikeShifter.getBatteryStatus(shifterArray[0]);  // This line throws an "Array out of bound" error!
                if ( batStatus != 0 ) {
                    batStat1 = batStatus.batteryStatus;
                    batVolt1 = batStatus.batteryVoltage;
                }
                batStatus = bikeShifter.getBatteryStatus(shifterArray[1]);
                if ( batStatus != 0 ) {
                    batStat2 = batStatus.batteryStatus;
                    batVolt2 = batStatus.batteryVoltage;
                }
            }

    EDIT:
    just see that there are typos in checking batStatus (should be null instead of 0 ) - but that‘s not the problem here…

  • Like this?

    if ( shifterArray != null  && shifterArray.size()>0) {

  • Ok, thanks, that‘s reasonable.

    But: if shifterArray is not null but its size() is 0 - how can I get the batStatus of the rear derailleur?