System 8 sensor pairing for ANT

I started to get reports from users who participate in beta program and have already upgraded their device to system8 that my datafield stopped working. My datafield uses ANT with GenericChannel (see code below).

I wonder if anyone managed to do whatever changes we need to do in our apps? If yes, can you share the insights?

The only information I found regarding this is from the announcement: https://forums.garmin.com/developer/connect-iq/b/news-announcements/posts/system-8-beta-now-available :

Sensor Pairing

If your device application or data field communicates wirelessly with a sensor or peripheral using ANT, ANT plus, or Bluetooth Low Energy (BLE), then you will need to implement a pairing process. Connect IQ allows you to implement a Sensors.SensorDelegate that allows you to have your device pair as part of the device’s sensor paring UI flow. See the SensorDelegate 

In my datafield I specifically ask the users not to pair or at least disconnect their ANT HR band from the device's Sensors menu, and I connect to it from the datafield using Ant.GenericChannel:

Ant.GenericChannel.initialize(method(:onMessage), new Ant.ChannelAssignment(
    Ant.CHANNEL_TYPE_RX_NOT_TX, // Bidirectional Receive (Slave)
    Ant.NETWORK_PLUS)
);

var devCfg = new Ant.DeviceConfig( {
    :deviceNumber => 0,                    // Set to 0 to use wildcard search
    :deviceType => 0x78,                   // Heart Rate Sensors: 0x78 = 120
    :transmissionType => 0,                // Set to 0 to use wildcard search
    :messagePeriod => 32280,               // 4Hz: 8070, 2Hz: 16140, 1Hz: 32280
    :radioFrequency => 57,                 // ANT+ Frequency 2.457GHz
    :searchTimeoutLowPriority => 10,       // Timeout in 25s
    :searchThreshold => 0} );              // Pair to all transmitting sensors
GenericChannel.setDeviceConfig(devCfg);

GenericChannel.open();
  • Ah cool. So it runs the code in a context that is (strangely) not able to log. I guess I'll try to debug it by creating a special logger that reads a property or storage, appends to it, writes it back...

  • This whole thing is a big mess...

    I'm still only playing with the simulator, but, even though it seemingly works, I still get occasionally a pop up out of blue, asking me if I want to connect the non secure device.

    The 2nd strange thing is not related to the pairing, but just noticed something strange in the "old code": When the ANT device is paired (not in the new sense, but that it gets am Ant.Message.messageId that is MSG_ID_BROADCAST_DATA | MSG_ID_ACKNOWLEDGED_DATA | MSG_ID_CHANNEL_ID, then GenericChannel.getDeviceConfig().deviceNumber != message.deviceNumber. In my case 287 vs 917791.

    What's even more interesting, is that if here I generate a SensorInfo and send a notification:

    public function onMessage(msg as Message) as Void {
        var deviceCfg = GenericChannel.getDeviceConfig();
        var sensorInfo = new Sensor.SensorInfo();
        sensorInfo.enabled = true;
        sensorInfo.name = "ANT: " + deviceCfg.deviceNumber + " | " + msg.deviceNumber;
        sensorInfo.technology = Sensor.SENSOR_TECHNOLOGY_ANT;
        sensorInfo.type = Sensor.SENSOR_HEARTRATE;
        sensorInfo.data = {
            :antSerialNumber => antId,
            :antMessage => msg
        };
        sensorLog("notifyNewSensor: " + sensorInfoToDictionary(sensorInfo));
        Sensor.notifyNewSensor(sensorInfo, false);
    }
    
    public function onPair(sensor as SensorInfo) as Boolean {
        sensorLog("onPair: " + sensorInfoToDictionary(sensor));
        return true;
    }

    then the :antMessage has deviceNumber: 917791 when I create the SensorInfo in onMessage, but it is 287 when I receive it in onPair.