Skip to main content

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 bracelet
  • dfu - 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 use data, 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 build.gradle's dependencies section:

dependencies {
def corsanoSdkVersion = "1.1.5"

// 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 = "1.1.5"

// 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 this sample code. Put this to you Application onCreate() method:

val dfuConfig = CorsanoDfu.Config(notificationTarget = MainActivity::class.java)

val dataConfig = DataSdk.Config(
slotsIntervalSecs = 10 * 60,
ppg2ThresholdFileSize = 500 * 1024,
bioZThresholdFileSize = 30 * 1024,
accThresholdFileSize = 30 * 1024,
licenceKey = "my_key" // update your licence key here, if you need a key, please contact mbortot@corsano.com
) // Add data config here if needed

val config = CorsanoSdkConfig.Builder()
.logger(SdkLogger.LogCat(Log.DEBUG))
.addModuleConfig(dfuConfig)
.addModuleConfig(dataConfig)
.build()

CorsanoSdk.initialize(this, config)

Licence Key

The licence key is mandatory to use the Corsano SDK, please contact your Corsano account Manager or mbortot@corsano.com if you do not have one. The licence key will be valid for the duration of the subscribtion

Other parameters

More on Data configuration here

DFU configuration

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)

Logger 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)