Class: Toybox.AntPlus.LightNetworkListener

Overview

Listener class for use with LightNetwork.

Example:

using Toybox.WatchUi;
using Toybox.AntPlus;

var isNetworkNewlyFormed;
var networkState;

// Initializes class variables
function initialize() {
    LightNetworkListener.initialize();
    isNetworkNewlyFormed = false;
}

// Checks if the new state of the network is LIGHT_NETWORK_STATE_FORMED
// If true: Sets isNetworkNewlyFormed to true and requests a Ui Update
// Updates the networkState
// The data parameter is the network state as a number
function onLightNetworkStateUpdate(data) {
    networkState = data;
    if (AntPlus.LIGHT_NETWORK_STATE_FORMED == data) {
        isNetworkNewlyFormed = true;
        WatchUi.requestUpdate();
    }
}
function onBikeLightUpdate(data) {
    WatchUi.requestUpdate();
}

Since:

API Level 2.2.0

Supported Devices:

Instance Method Summary collapse

Instance Method Details

initialize()

Constructor

Since:

API Level 2.2.0

onBikeLightUpdate(data as AntPlus.BikeLight) as Void

Callback when a bike light's data is updated (max freq. 1Hz)

Parameters:

Since:

API Level 2.2.0

onLightNetworkStateUpdate(data as AntPlus.LightNetworkState) as Void

Callback when the light network state changes

Parameters:

Since:

API Level 2.2.0


Generated Sep 23, 2024, 3:32:48 PM