Android

The Aidlab SDK for Android provides a simple way to communicate with your Aidlab Chest Strap using an Android app. This guide will cover the functionality of the Android API and how to set up your project to use the API.

Building for Android Studio

  • Create a new Android Studio project using API level 25 (Android 7.1+) as the minimum SDK.
  • Copy aidlabnativesdk.aar and aidlabsdk.aar to your_project_dir/your_module_name/libs
  • Set the libs directory as a dependency repository by adding the following before the dependencies block in your module's build.gradle:
allprojects {
    repositories {
        jcenter()
        flatDir {
            dirs 'libs'
        }
    }
}
  • Add the following dependencies to your module's build.gradle:
compile(name:'aidlabnativesdk', ext:'aar')
compile(name:'aidlabsdk', ext:'aar')

// Dependencies used by AidlabSDK
implementation 'com.polidea.rxandroidble2:rxandroidble:1.11.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1'
  • Sync the project.

  • Add the following lines to your AndroidManifest.xml:

<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/>

Example

Most recent example is available on our GitHub.

Documentation

To start your connection with Aidlab, you need to create an AidlabSDK object, constructor of which expects two parameters:

  • context
  • aidlabSDKDelegate
aidlabSDK = AidlabSDK(this, this)

After Bluetooth connectivity is enabled, it can start scanning for nearby Aidlabs:

override fun onBluetoothStarted() {

    println("MainActivity.onBluetoothStarted()")

    /// Bluetooth check process completed - start scanning for devices
    aidlabSDK.scanForDevices()
}

After an Aidlab is detected, the onAidlabDetected function is called. In order to connect Aidlab to your device, choose the desired signals by adding them to the signals array:

val signals = EnumSet.of(Signal.ecg,  Signal.respiration)

The signals array is one of the parameters of the connect function:

connectedDevice?.connect(signals, true, dataReceiver)

The other two are:

  • reconnect
  • delegate

Saving data

While developing an app in Kotlin, you can take control over synchronization. After acquiring data and connecting Aidlab to your device, Aidlab will start sending unsynchronized data immediately. To change that, you can use the following functions on your IAidlab object:

fun startSynchronization()
fun stopSynchronization()

results matching ""

    No results matching ""