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.

Parents
  • 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().
Comment
  • 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().
Children
No Data