OpenMovement AxLE

This is the sync client for the OpenMovement AxLE Band. This client will handle communication with the AxLE bands and sync all data to the OpenMovement repository for retrieval by one of our partner services.

Functionality:

  • Syncing and Viewing of Epoch data from AxLE band.

  • Goal settings and configuration.

  • General band configuration.

  • Data syncing service.

  • Firmware Updater.

This application is available on the iOS and Android app stores.

Getting Started

The OpenMovement AxLE Band API is a set of C# libraries with pre-built support for Xamarin (iOS, Android & UWP) and Windows 10 APIs.

Xamarin

To get started for Xamarin projects you simply need to add a reference to the following package:

  • OpenMovement.AxLE.Comms

  • OpenMovement.AxLE.Comms.Bluetooth.Mobile.Android (Android only shims)

This will provide you with all the utilities required to communicate with your AxLE device. You use the Plugin.BLE NuGet package to interact with the Bluetooth hardware cross platform.

Windows

To get started with a Xamarin or Windows application create a new project in Visual Studio. Run the following command to add the OpenMovement AxLE respository as a sub-module.

git submodule add https://github.com/digitalinteraction/OpenMovement-AxLE-Comms OpenMovement.AxLE.Comms
cd OpenMovement.AxLE.Comms
git submodule update --init

When using a non-Universal Windows application you must manually add the Windows.Devices namespace as outlined here. Ensure the Build flags WIN_CONSOLE or WINDOWS_UWP are set appropriately.

Once added as a submodule include the following projects as existing projects to your solution:

  • OpenMovement.AxLE.Service

  • OpenMovement.AxLE.Comms

  • OpenMovement.AxLE.Comms.Bluetooth.Windows

Other Platforms

If you would like to use another platform to communicate with the OpenMovement AxLE devices we have simplified this process for you.

You just need to implement the following interfaces for the nativave Bluetooth interfaces you are using:

  • OpenMovement.AxLE.Comms.Bluetooth.Interfaces.IBluetoothManager

  • OpenMovement.AxLE.Comms.Bluetooth.Interfaces.IDevice

  • OpenMovement.AxLE.Comms.Bluetooth.Interfaces.IService

  • OpenMovement.AxLE.Comms.Bluetooth.Interfaces.ICharacteristic

This interfaces are available in the OpenMovement.AxLE.Comms NuGet package. You can use the existing Mobile and Windows implementations as guides both in the Bluetooth namespace in the comms library.

Scanning for AxLE Bands

All interactions with the AxLE devices start with the AxLEManager. This manager is responsible for scanning and monitoring, connecting, disconnecting and firmware updating devices.

To begin we need to create an instance of the manager:

IAxLEManager manager = new AxLEManager(nativeBluetoothManager, [nearbyTimeout = 30000]);

Now we need to set our relevant callbacks for when a new device is found:

manager.DeviceFound += (sender, serial) =>
{
    // Do something amazing...
};

Finally we call manager.StartScan(); to begin scanning for AxLE devices and trigger our DeviceFound callback when we have found devices nearby. To stop scanning call manager.StopScan();.

Connecting to an AxLE device

We again use the manager to connect to an AxLE device. The AxLEManager returns a serial number string for devices it has found. We shall use this as follows:

try
{
    manager.ConnectDevice(serial);
}
catch (DeviceNotInRangeException ex)
{
    // Called if the device has not yet been discovered
    // by the manager or is no longer nearby
}
catch (Exception ex)
{
    // Depending on platform other Bluetooth Comms
    // exceptions may be thrown by the stack.
    // Android Gatt errors for example which can
    // usually be ignored and tried again.
}

On some platforms you should call manager.StopScan(); before connecting to a device. Android is particularly sensitive to this and will result in a higher likely hood of Gatt errors if the manager is still scanning.

Disconnecting from an AxLE device

Disconnecting from an AxLE once you are finished with the device is very important, reconnecting to an already connected device may cause serial port issues and commands may fail. Disconnect from devices like this:

await manager.DisconnectDevice(device);

Using the Devices Nearby monitor

The AxLE manager can monitor for devices nearby and keep you up to date as devices appear and disappear from nearby your device.

There are two properties for you to configure in this instance, the nearbyTimeout parameter on the constructor and the RssiFilter (lower is closer) property on the manager.

On Windows the Nearby monitor may not work as expected. The Windows Bluetooth APIs are incomplete and lack the functionality required to implement a complete nearby monitor.

Once the nearby monitor is configured you can start using the relevant callbacks to monitor devices:

manager.DeviceFound += (sender, serial) =>
{
    // Called each time a device that was once lost is found.
    // Like the ring of power...
};

manager.DeviceLost += (sender, serial) =>
{
    // Called each time a device is considered lost.
};

Last updated