Getting Started
This article will describe the main structure of SDK, how to include and use it in your project. For more information and usage examples please refer to sample app source code.
Structure of Android SDK
Corsano SDK currently consists of 3 main modules:
ble
– module for connecting to Corsano bracelet over Bluetooth Low Energy (BLE) and performing remote commands. It can be used for getting raw data.data
- module for retrieving, storing data and processing health data obtained from the Corsano braceletdfu
- module for performing device firmware upgrades
There could be other modules in the future. Stay tuned for the updates.
Note: If you'd like to work with lower level commands, then
ble
module will be enough, but you may also want to usedata
, which will provide summaries and persistent storage.
See SDK Reference section for more details.
Installing SDK to your project
SDK requires at least Java 7+ and Android API 21+.
To include a release version to you project just add whatever modules you need in builde.gradle
's dependencies
section:
dependencies {
def corsanoSdkVersion = "0.8.3"
// this is a minimum requirement
implementation "com.corsano.sdk:ble:$corsanoSdkVersion"
// data storage and processing
implementation "com.corsano.sdk:data:$corsanoSdkVersion"
// device firmware update module
implementation "com.corsano.sdk:dfu:$corsanoSdkVersion"
}
For build.gradle.kts
use the following snippet:
dependencies {
val corsanoSdkVersion = "0.8.3"
// this is a minimum requirement
implementation("com.corsano.sdk:ble:$corsanoSdkVersion")
// data storage and processing
implementation("com.corsano.sdk:data:$corsanoSdkVersion")
// device firmware update module
implementation("com.corsano.sdk:dfu:$corsanoSdkVersion")
}
Snapshots of the development version are available in Sonatype's snapshots repository.
Note: You can add any of the modules or all of them to your project.
Initializing SDK
Initialization of all SDK modules is performed through one call. Put this to you Application onCreate()
method:
CorsanoSdk.initialize(context)
For most cases that will be enough to start working with Corsano bracelet, but you may want to pass some extra configuration parameters to the SDK.
Custom configuration
You can set schedulers and logger instance to be used in all SDK modules by supplying your own config:
val config = CorsanoSdkConfig.Builder()
.commandScheduler(Scheduler.newThread("ble-handler"))
.callbackScheduler(Scheduler.MAIN)
.logger(SdkLogger.LogCat(level = Log.INFO))
.build()
CorsanoSdk.initialize(context, config)
You can also provide specific parameters for any particular module. In the example below, we are setting notificationTarget
for the DFU module.
val dfuConfig = CorsanoDfu.Config(
notificationTarget = MainActivity::class.java
)
val config = CorsanoSdkConfig.Builder()
.addModuleConfig(dfuConfig)
.build()
CorsanoSdk.initialize(context, config)