Acknowledged

AntPlus speed / speed+Cadence sensor conflict

My app needs to be able to read data from ANT plus speed or speed/cadence sensors.

To handle this I create an AntPlus.BikeSpeed and AntPlus.BikeSpeedCadence objects, both with appropriate listeners.

It mostly works, BUT if I do the following the BikeSpeedCadence sensor returns null values for speed.

  1. Connect to Speed sensor
  2. Open app - speed reads correctly.
  3. Close App
  4. close speed sensor and connect to Speed+Cadence sensor.
  5. Open app.  SPEED READS NULL.

Below is my full speed/cadence code:

using Toybox.AntPlus;
using Toybox.System as Sys;
using Toybox.Attention as Attention;

class aero_bsc_listener extends AntPlus.BikeSpeedCadenceListener
{
	hidden var m_spd;
	hidden var ctr;
	hidden var warned;
	hidden var device;

	function initialize(_device)
	{
		BikeSpeedCadenceListener.initialize();
		m_spd = null;
		warned = false;
		ctr = 0;
		device = _device;
	}

	function onBikeSpeedCadenceUpdate(info)
	{
		if (info != null)
		{
			m_spd = info.speed;
			if (as_fit_file.isLogging())
			{
				as_fit_file.fields[ROAD_SPEED_FIELD].setData(m_spd);
			}
			else if (info.speed > 2)
			{
				if (!warned)
				{
					Attention.playTone(Attention.TONE_LOUD_BEEP);
					ctr++;
					if (ctr == 10)
					{
						warned = true;
					}
				}
			}
			else
			{
				if (warned)
				{
					warned = false;
					ctr = 0;
				}
			}
		}
	}

	function getSpeed()
	{
		return m_spd;
	}
}

class antplus_bsc
{
	hidden var m_bsc;
	hidden var m_listener;
	
	function initialize()
	{
		// Initialise BSC device:
		m_listener = new aero_bsc_listener(self);
		m_bsc = new AntPlus.BikeSpeedCadence(m_listener);
	}
	
	function isTracking()
	{
		return m_bsc.getDeviceState().state == AntPlus.DEVICE_STATE_TRACKING;
	}

	function getSpeed()
	{
		var spd = m_listener.getSpeed();
		if (spd == null) {spd = 0;}
		else if (spd < 0) {spd = 0;}
		return spd;
	}
	
	
	function getDeviceNumber()
	{
		return m_bsc.getDeviceState().deviceNumber;
	}

	// Returns device state.
	function getDeviceStateText()
	{
		var text = "";
		if (isTracking())
		{
			text = "Tracking";
		}
		else
		{
			text = "Closed";
		}
		return text;
	}
	
}

Parents
  • I am pretty sure it is CIQ related bug.  It does NOT happen on 830, or 540 simulator, only on the edge 540 device (it is the only x40 device I have).  In the condition where the Antplus.BikeSpeedCadence library returns null, if i go out of the app into a ride page (built in speed field), the Garmin displays the correct speed.

    By speed+cadence sensor, I mean a single sensor (i.e. AntPlus.BikeSpeedCadence).


    In smaller steps:

    1. Connect edge to speed sensor.
    2. Open app.  Speed reads correctly.
    3. Close app.
    4. Disconnect speed sensor (Menu->sensors->speed sensor->status, set to closed).
    5. Connect speed+cadence sensor (Menu->sensors->add sensor-> connect to speed/cadence sensor).
    6. Open app - now speed reads null.
    7. Turn off Garmin.
    8. Switch Garmin back on.
    9. Enter app - now it receives speed from speed+cadence sensor fine.
Comment
  • I am pretty sure it is CIQ related bug.  It does NOT happen on 830, or 540 simulator, only on the edge 540 device (it is the only x40 device I have).  In the condition where the Antplus.BikeSpeedCadence library returns null, if i go out of the app into a ride page (built in speed field), the Garmin displays the correct speed.

    By speed+cadence sensor, I mean a single sensor (i.e. AntPlus.BikeSpeedCadence).


    In smaller steps:

    1. Connect edge to speed sensor.
    2. Open app.  Speed reads correctly.
    3. Close app.
    4. Disconnect speed sensor (Menu->sensors->speed sensor->status, set to closed).
    5. Connect speed+cadence sensor (Menu->sensors->add sensor-> connect to speed/cadence sensor).
    6. Open app - now speed reads null.
    7. Turn off Garmin.
    8. Switch Garmin back on.
    9. Enter app - now it receives speed from speed+cadence sensor fine.
Children
No Data