Ticket Created
over 4 years ago

WERETECH-10039

ANT+ Battery Status

The latest in the saga for Battery Status. I used an ANT+ dongle on my Windows Laptop, and paired it with the Eclipse Simulator. I tried both an older Garmin Cadence Sensor, and a brand new one (the one that does both ANT and BT). Same outcome. In both cases, the CIQ data field immediately gets Device State info. After maybe 30-40 seconds, the ProductInfo.serial number comes thru. Just like in real life when paired to a real Garmin Edge computer. But in both cases, even after several minutes, the Battery Status remains null.

When I pair the new cadence sensor to my actual Garmin Edge computer, the Battery Status does come up as OK within 15 seconds or so and then maybe 30 seconds later the Serial # info comes through.

Any clue why the polling code isn't seeing the Battery Status?

Oh, also, the State Update Listener is triggering, but the BatteryStatusListener is not.

  • Thanks Kurev,  Yeah I registered the listener too, just without passing in "self".  Output now (from simulator): Listener: deviceState: 1 Ant: [RX] [65, 21, 0, 0, 0, 0, 0, 0] [null][65] Ant: [RX] [66, 0, 0, 0, 0, 0, 0, 0] [null][66] Ant: [RX] [81, 0, 0, 0, 0, 0, 0, 0] [null][81] Ant: [RX] [69, 0, 0, 0, 0, 0, 0, 0] [null][69] Ant: [RX] [67, 0, 0, 0, 0, 0, 0, 0] [null][67] Ant: [RX] [99, 0, 0, 0, 0, 0, 0, 0] [null][99] Ant: [RX] [68, 0, 0, 0, 0, 0, 0, 0] [null][68] Ant: [RX] [113, 0, 0, 0, 0, 0, 0, 0] [null][113] Ant: [RX] [75, 0, 0, 0, 0, 0, 0, 0] [null][75] Ant: [RX] [5, 1, 255, 255, 205, 242, 8, 254] [130641][5] Ant: [RX] [5, 1, 255, 255, 205, 242, 8, 254] [130641][5] Ant: [RX] [1, 5, 0, 0, 0, 0, 0, 0] [null][1] Listener: deviceState: 3 Ant: [RX] [2, 1, 129, 0, 205, 242, 8, 254] [130641][2] Ant: [RX] [1, 5, 0, 0, 0, 0, 0, 0] [null][1] Ant: [RX] [3, 187, 23, 9, 205, 242, 8, 254] [130641][3] Ant: [RX] [1, 5, 0, 0, 0, 0, 0, 0] [null][1] Ant: [RX] [4, 255, 235, 50, 205, 242, 8, 254] [130641][4] Ant: Battery Status 0x04: state: 3, voltage: 2.917969 Ant: [RX] [1, 5, 0, 0, 0, 0, 0, 0] [null][1] Ant: [RX] [5, 1, 255, 255, 205, 242, 8, 254] [130641][5] Ant: [RX] [5, 1, 255, 255, 205, 242, 8, 254] [130641][5] Ant: [RX] [4, 255, 233, 50, 205, 242, 8, 254] [130641][4] Ant: Battery Status 0x04: state: 3, voltage: 2.910156 Ant: [RX] [4, 255, 233, 50, 205, 242, 8, 254] [130641][4] Ant: Battery Status 0x04: state: 3, voltage: 2.910156 Ant: [RX] [4, 255, 233, 50, 205, 242, 8, 254] [130641][4] Ant: Battery Status 0x04: state: 3, voltage: 2.910156 Ant: [RX] [4, 255, 233, 50, 205, 242, 8, 254] [130641][4] Ant: Battery Status 0x04: state: 3, voltage: 2.910156 Ant: [RX] [5, 1, 255, 255, 205, 242, 8, 254] [130641][5] Ant: [RX] [5, 1, 255, 255, 205, 242, 8, 254] [130641][5] Ant: [RX] [2, 1, 129, 0, 205, 242, 8, 254] [130641][2] Ant: [RX] [5, 1, 255, 255, 205, 242, 8, 254] [130641][5]
  • And you did register the listener too, doing something like this:    var mySpeedListener = new MyBikeSpeedListener(self);    var mySpeedDevice = new AntPlus.BikeSpeed(mySpeedListener); Here is slightly improved version, handling both common page and page 4. It also prints out all pages it receives, so you should definitely see something coming out. It is ok to use on simulator, but on real device the 1k + 1k file buffers will overflow quickly. Just disable the first print if it's too much:
        function onMessage(msg) {
            var payload = msg.getPayload();
            var page = payload[0] & 0x7F;
            Sys.println("Ant: [RX] " + payload + " [" + msg.deviceNumber + "][" + page + "]");
            
            if (page == 0x52) {
                var state = (payload[7] >> 4) & 0x7;
    
                var voltage = (payload[7] & 0xF);
                if (voltage != 0xF) {
                    voltage = voltage + (payload[6] / 256.0);
                } else {
                    voltage = 0.00;
                }
    
                Sys.println("Ant: Battery Status 0x52: state: " + state + ", voltage: " + voltage);
            }
            if (page == 0x04) {
                var state = (payload[3] >> 4) & 0x7;
    
                var voltage = (payload[3] & 0xF);
                if (voltage != 0xF) {
                    voltage = voltage + (payload[2] / 256.0);
                } else {
                    voltage = 0.00;
                }
    
                Sys.println("Ant: Battery Status 0x04: state: " + state + ", voltage: " + voltage);
            }
        }
    This will give me on simulator with Garmin Speed 2 following print on page 4 (and battery state is available ok):
    Ant: [RX] [4, 255, 2, 51, 210, 22, 3, 0] [287300][4]
    Ant: Battery Status 0x04: state: 3, voltage: 3.007812
    Speed sensor is not broadcasting page 82, I'll try later if I can get it with sendPageRequest().
  • Sorry (haven't used that before).  Yep, so it's paired now - went from grey to yellow to green and so far, one message output (still running): Listener: deviceState: 3 Code was this:
    class MyBikeSpeedListener extends AntPlus.BikeSpeedListener {
    
        function initialize() {
            BikeSpeedListener.initialize();
    		Sys.println("Starting BikeSpeed.Listener");
        }
    
        function onDeviceStateUpdate(data){
            Sys.println("Listener: deviceState: "+ data.state);
        }
    
        function onBatteryStatusUpdate(data){
            Sys.println("Listener: batteryStatus: " + data.batteryStatus);
        }
    
    	function onMessage(msg) {
    		var payload = msg.getPayload();
    		if ((payload[0] & 0x7F) == 0x52) {
    			Sys.println("Ant: [RX] " + payload + " [" + msg.deviceNumber + "], PAGE_BATTERY_STATUS");
    
    			var state = (payload[7] >> 4) & 0x7;
    
    			var voltage = (payload[7] & 0xF);
    			if (voltage != 0xF) {
    				voltage = voltage + (payload[6] / 256.0);
    			} else {
    				voltage = 0.00;
    			}
    
    			Sys.println("Ant: Battery Status: state: " + state + ", voltage: " + voltage);
    		}
    	}
    }
    
  • Grey means not paired... Try right-clicking on the item and hit pair. Should turn green.
  • Hey Kurev, just reporting back.  I added a bikeSpeed Listener class (including your onMessage function and appropriate initialisation at the start) into my app to test.  I can see my Speed Sensor in the "ANT+ Sensors" view under the simulator, though it does show a status with a grey circle (not sure what that means); I can see my sensor on my Fenix5+ and it reports Battery:  OK.  Running my app (and it's been running for 20 mins), I'm not seeing any messages at all coming out of the listener (except for one I added into initialize()).  Is that what you expected?  My Garmin sensor is definitely ANT+ (It's imprinted on the back).