ANT+ battery status

Hi

I am having problems getting the batteryStatus from different ANT+ devices.

In my datatfield I have implemented all possible ANT+ devices including listeners.

Except for one power device I do not get any battery status on all other ant+ devices. As far as I know all other values work correctly.

Code looks like this:

if(lstBikeSpeed == null) {
    lstBikeSpeed = new MyBikeSpeedListener();
	devBikeSpeed = new AntPlus.BikeSpeed(lstBikeSpeed);
}
...
status = lstBikeSpeed.GetBattery();

...

class MyBikeSpeedListener extends AntPlus.BikeSpeedListener {
	function initialize() {
		BikeSpeedListener.initialize();
	}
	var mBat  = null;
	function onBatteryStatusUpdate(data) {
		mBat = data;
	}
	function GetBattery() {
		if(mBat != null && mBat.batteryVoltage != null) { 
			return mBat.batteryVoltage; 
		} else { 
			return 0; 
		}
	}
...

I also tried this line before the GetBattery, to update the mBat directly:

lstBikeSpeed.mBat = devBikeSpeed.getBatteryStatus(null);

It works only on one power device. Is there anything I should change or do I just dont get the values from the SDK??

thanks

regards

Erich

  • example for bikespeed device, comparable to other ant+ devices ...
    var antSpeed = new AntPlus.BikeSpeed(null);
    var battObj = antSpeed.getBatteryStatus(null);
    System.println(battObj.batteryStatus);
  • I'm not 100% sure... But I believe "getBatteryStatus" does not provide new data... meaning it does not send a page request to the sensor and wait for a page back with new data. If/when you call "getBatteryStatus() it simply returns the stored value from the most recent page that you also observed in the last onMessage handling. Does this make sense? For example, I know that Power and Shifting profiles do not even allow for sendPageRequest(). So that supports the idea that CIQ can't ask the sensor to send a page, which getBatteryStatus() would have to do.

  • A bike speed ANT sensor usually sends 4 main data pages per second. Following spec it is required to send background data package (which incl. battery status) every 65th message automatically. So every 16 sec battery status is updated automatically and can be get by getBatteryStatus(). I think this is sufficient and is working on most devices (except e.g. many HR sensors, because on HR devices it's not mandatory to send, but in these usually sensor is not able to send battery status anyhow).

  • Yep either parse the onMessage or use getBatteryStatus. I have two issues. First, for my quad component Shifters (front/rear derailleurs and left/right shift levers) and my dual component Power Meter Pedals (left/right), the onMessage battery pages seem to work for the primary component but only sporadically for the others. So I was hoping "getBatteryStatus(componentID)" would work. But no. Second, HR doesn't have an ANT+ Profile, so you can't use ANT+ to listen for pages. You could use the Generic ANT library, but when you do that to connect to the HR Strap, it prevents the Garmin Device from also having access to HR data. Garmin REALLY needs to create an ANT+ profile for Heart Rate!

  • If there are more than one components available check this:

    https://forums.garmin.com/developer/connect-iq/f/discussion/239382/sram-axs-battery-status

    So you should get an array of components and get battery status of the components. Using 'null' in this case will lead to random results.

    Pairing allways leads to Garmin blocking any other ANT communication with the devices .. would not be necessary mandatorily, but that's the way Germin is thinking.

    You're right, related to HR, I was thinking about HRM straps of Garmin incl. RD. I found by now no way to get battery status of, but might be because of the complex communication (different ANT channels are used for HR and RD). Bud did not spend much time, because needed to re-implement ANT communication to HRM RD because my watch is not supporting RD :|