Class: Toybox::AntPlus::LightNetworkListener

Inherits:
DeviceListener show all

Overview

Listener class for use with LightNetwork.

Examples:

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:

  • 2.2.0

Light Type collapse

Methods inherited from DeviceListener

onBatteryStatusUpdate, onDeviceStateUpdate, onManufacturerInfoUpdate, onProductInfoUpdate

Methods inherited from Lang::Object

equals, hashCode, method, toString, weak

Constructor Details

initializeLightNetworkListener

Constructor

Since:

  • 2.2.0


15409
15410
# File 'Monkeybrains.rb', line 15409

def initialize()
end

Instance Method Details

onBikeLightUpdate(data) ⇒ Object

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

Parameters:

Since:

  • 2.2.0


15421
15422
# File 'Monkeybrains.rb', line 15421

def onBikeLightUpdate(data)
end

onLightNetworkStateUpdate(data) ⇒ Object

Callback when the light network state changes

Parameters:

Since:

  • 2.2.0


15415
15416
# File 'Monkeybrains.rb', line 15415

def onLightNetworkStateUpdate(data)
end