Android SDK Guide
The Impilo Mobile SDK enables faster and unified integration of remote patient monitoring (RPM) devices for mobile applications. Our native SDK, written in Kotlin, handles connecting and communicating with RPM devices while providing you with standardized interactions and data.
These Native Android SDK docs are written in Kotlin. It is interoperable with Java.
Installation
Add our Mobile SDK package to your project and import it:
import health.impilo.impilomobilesdk.SDK
import health.impilo.impilomobilesdk.Config
import health.impilo.impilomobilesdk.DeviceType
import health.impilo.impilomobilesdk.DeviceReading
import quicktype.BloodPressure
SDK Initialization
Create a configuration for the SDK and initialize it:
var sdk = SDK.initialize()
sdk.setupBluetooth(activity)
Implementing the Delegate
These docs focus on using the TranstekBBZ32BB01 BPM. To receive events, you provide a delegate which should implement TranstekBBZ32BB01Delegate:
class Delegate: TranstekBBZ32BB01Delegate {
override fun didDiscover(device: Unpaired<TranstekBBZ32BB01>) {
}
override fun didPair(device: TranstekBBZ32BB01) {
}
override fun didReceiveReading(reading: DeviceReading<BloodPressure>) {
}
}
Discovering Devices
Call discover on the desired type of device. When a device is discovered, the didDiscover delegate method will be called:
TranstekBBZ32BB01.discover(sdk, delegate)
Pairing Devices
A discovered device is a device that can be paired with. To pair with the discovered device, simply call pair on the discovered device. If the pairing succeeds, the didPair delegate method will be invoked:
override fun didDiscover(device: Unpaired<TranstekBBZ32BB01>) {
device.pair()
}
To remember a device for later, you can request an identifier for said device:
device.bluetoothIdentifier()
If the device is one you've already paired with before, you can skip the pairing process:
device.skipPairing()
Getting Readings
If the connected device can receive readings without programmatically initiating them, you can call monitorForReading() which will invoke the didReceiveReading delegate method with the associated reading data when a reading is received:
override fun didPair(device: TranstekBBZ32BB01) {
device.monitorForReading()
}
Complete Example
Here's a complete example of how the SDK can be used:
import health.impilo.impilomobilesdk.SDK
import health.impilo.impilomobilesdk.TranstekBBZ32BB01
import health.impilo.impilomobilesdk.TranstekBBZ32BB01Delegate
import health.impilo.impilomobilesdk.Unpaired
import health.impilo.impilomobilesdk.DeviceReading
import quicktype.BloodPressure
var sdk = SDK.initialize()
class Delegate: TranstekBBZ32BB01Delegate {
override fun didDiscover(device: Unpaired<TranstekBBZ32BB01>) {
device.pair()
}
override fun didPair(device: TranstekBBZ32BB01) {
device.startReading()
}
override fun didReceiveReading(reading: DeviceReading<BloodPressure>) {
// Access reading data via .data
val systolic = reading.data.systolicInMmHg
val diastolic = reading.data.diastolicInMmHg
}
}
var delegate = Delegate()
TranstekBBZ32BB01.discover(sdk, delegate)
Reading Models
The readings the SDK provides match our Impilo API. View our API documentation to see what the readings look like.
How Data is Managed
The SDK does not store any data—it only forwards received data to you. You are responsible for handling and storing readings as needed in your application.
Working with Health Connect
With an instance of the SDK, you can request access to Android's Health Connect from the user, asking for the reading types you'd like to access.
val sdk = try {
SDK.initialize()
} catch (e: Exception) {
throw RuntimeException("Failed to initialize SDK", e)
}
// Request Android Health Connect access (read/write)
sdk.androidHealthConnect.requestAccess(
read = setOf(
ReadingType.stepCount,
ReadingType.heartRate
),
write = emptySet() // add write types if you need them
)
Then you can query for readings from Health Connect:
// 1-day interval
val interval: Period = Period.ofDays(1)
// Date range: yesterday to now
val end = ZonedDateTime.now()
val start = end.minusDays(1)
// Steps
val steps: List<StepCountReading> = sdk.androidHealthConnect.steps.query(
startDate = start,
endDate = end,
interval = interval,
limit = null // optional record limit
)
// Heart rate
val heartRates: List<HeartRateReading> = sdk.androidHealthConnect.heartRate.query(
startDate = start,
endDate = end,
interval = interval,
limit = null // optional record limit
)
Supported Reading Types
We currently support these reading types from Health Connect:
- Step Count
- Heart Rate
- Blood Glucose
- Blood Pressure
- Blood Oxygen
- Body Weight
- Body Temperature
- Peak Expiratory Flow
More coming soon!
Looking for More Device Integrations?
For additional device integration requests, please reach out to sales@impilo.health.