...
It can easy to communicate with ASUS VivoWatch BPthe supported devices, such as create a connection channel, connect device, upload device vital signs data to OmniCare and retrieve the vital signs data back from OmniCare.
...
The OmniCare SDK is distributed as aar file. To add it to your project, copy OmniCareSDK.aar to the libs folder and add the following to your build.gradle.
程式碼區塊 |
---|
repositories |
...
{ flatDir { dirs 'libs' } } dependencies { implementation(name: 'OmniCareSDK', ext: 'aar') |
...
} |
Permissions & Service
Add the properties in manifest file. For Android 6.0+, users grant permissions to apps while the app is running, not when they install the app. Please refer official document to add necessary code: https://developer.android.com/training/permissions/requesting.html.
程式碼區塊 |
---|
<uses-permission android:name="android.permission.BLUETOOTH" /> |
...
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" / |
...
> <!-- Coarse Location for API <29 (Android 9 and lower) --> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" |
...
/> <!-- Fine Location for API >=29 (Android 10 and higher) --> <uses-permission android:name="android.permission. |
...
ACCESS_FINE_LOCATION" /> |
...
<uses-permission android:name="android.permission. |
...
ACCESS_ |
...
BACKGROUND_ |
...
LOCATION" /> <uses-permission android:name="android.permission. |
...
INTERNET" /> |
...
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> |
...
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" |
...
/> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WAKE_LOCK"/> <uses-permission android:name="android.permission.READ_CONTACTS"/> |
...
<uses-permission android:name="android.permission.READ_PHONE_STATE" / |
...
> <!-- Permission needed for Android Pie to distinguish who is calling --> <uses-permission android:name="android.permission.READ_CALL_LOG"/> <!-- Permission needed for Android Oreo call handling --> <uses-permission android:name="android.permission.ANSWER_PHONE_CALLS"/> <!-- Permission needed to reject incoming phone calls --> <uses-permission android:name="android.permission.CALL_PHONE"/ |
...
> <!-- Media Control Permission for Advanced Music Controls --> <uses-permission android:name="android.Manifest.permission.MEDIA_CONTENT_CONTROL"/> <!-- Foreground Permission required for newer Android SDKs --> <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/> |
Add the <service> tag below, contained in <application> tag in manifest file.
程式碼區塊 |
---|
...
<!-- For VivoWatchBP BLE communication service--> <service android:name="com.asuslife.omnicaresdk.BluetoothLeServiceVivoWatchBP" |
...
android:enabled="true" |
...
android:exported="false" /> <!-- You can customize NotificationListenerService label name on your own --> <service android:name="com.asuslife.omnicaresdk.NotificationListenerService" android:label="Custom" tools:replace="label"/> <service android:name="com.garmin.android.gncs.GNCSListenerService" android:label="Custom" tools:replace="label"/> <!-- You can change the foreground notification icon on your own → <meta-data tools:replace="resource" android:name="com.garmin.health.foreground_notification_icon" android:resource="@mipmap/ic_launcher"/> |
Dependencies
The OmniCare SDK has dependencies on the following third-party library that will need to be included in you project.
build.gradle file
...
程式碼區塊 |
---|
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0' implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.61' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.0' implementation 'com.google.code.gson:gson:2.8.5' implementation 'com.google.protobuf:protobuf-lite:3.0.1' implementation 'com.google.guava:guava:28.0-android' implementation 'net.danlew:android.joda:2.9.9.2' implementation "androidx.room:room-runtime:2.2.3" implementation "androidx.room:room-guava:2.2.3" implementation 'org.slf4j:slf4j-api:1.7.25' implementation 'com.github.tony19:logback-android:1.1.1-12' implementation 'net.zetetic:android-database-sqlcipher:4.3.0' |
How to use the OmniCare SDK
Before using the OmniCare SDK, you need to initialize it first. Add a call to AsusLifeOmniCare.initialize()must be added to all entry point Activities.in the onCreate() method of your Application class. (If you gona build with Garmin devices, please be sure to pass the license key to the init method)
程式碼區塊 |
---|
AsusLifeOmniCare.initialize(context, account, password, new AsusLifeOmniCareInitializationCallback() |
...
{ @Override public void onSuccess() |
...
{ // Called when the initializing process completes successfully. |
...
} @Override public void onFailed(AsusLifeOmniCareInitializationException e) |
...
{ // Called if initializing fails. |
...
}
} }); |
Device Communication
Finding OmniCare Devices
...
After you hold the Location permission, you have also to verify that Location services are enabled before starting the scan.
程式碼區塊 |
---|
private void verifyLocationServices() |
...
{ final LocationManager manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); |
...
if (!manager.isProviderEnabled(LocationManager.GPS_PROVIDER) && !manager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) |
...
{ buildAlertMessageNoGps(); |
...
} } |
With the prerequisites taken care of, we can start the scan. BluetoothLeScanner requires a ScanCallback to return results of the scan. AsusLifeDeviceScanCallback is provided to filter the scan results to only include OmniCare devices that are supported by the SDK. You must extend this class to get the results of the scan.
程式碼區塊 |
---|
private AsusLifeDeviceScanCallback asusLifeDeviceScanCallback = new AsusLifeDeviceScanCallback() |
...
{ @Override public void onScannedDevice(ScannedDevice device) |
...
{ // Called when a OmniCare Device advertisement has been found. |
...
} @Override public void onScanStarted() |
...
{ // Called when Bluetooth Low Energy start to scan. |
...
} @Override public void onScanFinished() |
...
{ // Called when Bluetooth Low Energy scan finished. |
...
} @Override public void onScanFailed() |
...
{ // Called when Bluetooth Low Energy scan failed. |
...
} }; |
...
… |
...
DeviceManager deviceManager = AsusLifeOmniCare.getDeviceManager(); |
...
deviceManager.startScan(asusLifeDeviceScanCallback, millis); |
...
... |
Pairing a Device
Attempt to pair a scanned device returned from BLE scanning in the SDK.
程式碼區塊 |
---|
private PairingCallback pairingCallback = new PairingCallback() |
...
{ @Override public void pairingFailed(PairingFailedException cause) |
...
{ // Called if pairing fails. |
...
} @Override public void pairingSucceeded(Device device) |
...
{ // Called when the pairing process completes successfully. |
...
} }; |
...
… |
...
DeviceManager deviceManager = AsusLifeOmniCare.getDeviceManager(); |
...
deviceManager.requestDevicePair(scannedDevice, pairingCallback); |
...
... |
Syncing & Uploading Data
As the device has been paired, using the method below to sync the vital signs data from device and upload the data to OmniCare.
程式碼區塊 |
---|
private SyncingCallback syncingCallback = new SyncingCallback() |
...
{ @Override public void onSyncComplete(Device device) |
...
{ // Called when the syncing process completes successfully. |
...
} @Override public void onSyncFailed(Device device, SyncingFailedException e) { |
...
// Called if syncing fails. |
...
} @Override public void onSyncStarted(Device device) |
...
{ // Called if syncing starts. |
...
…
...
} } … DeviceManager deviceManager = AsusLifeOmniCare.getDeviceManager(); |
...
deviceManager.requestDeviceSync(device, syncingCallback); |
...
... |
Vital Signs Data Integration
...
After the device syncing is successful, using method below to request vital signs data from OmniCare.
程式碼區塊 |
---|
OmniCareAPI.getDataByDevcie(device, startTime, endTime, new OmniCareAPI.DataRequestCallback() |
...
{ @Override public void onSuccess(SyncResultData syncResultData) { |
...
// Called when the data requesting process completes successfully. |
...
} @Override public void onError(DataRequestException dre) { |
...
// Called if data requesting fails. |
...
} }); |
Additional Information
Proguard Configuration
A number of the libraries required as dependencies for the SDK also have proguard configuration requirements. The complete recommended configuration is located in the SDK Sample App.
Release Notes
V1.6.1(September 2020)
1.Security update.
V1.6.0(August 2020)
1.In order to ensure the stability of data retrieval, we have established a local database. When the server is abnormal, the data will be returned from the local database.
V1.5.0(July 2020)
1.Added support for VivoSmart 4.
V1.4.3(June 2020)
1.Fine tuned SSL Pinning logic.
2.Fine tuned IOException(no internet or server connection timed out).
3.Fine tuned device pairing logic.
V1.4.2(May 2020)
1.Updated SSL Pinning.
V1.4.0(March 2020)
1.Modified GetTokenResponse model(removed sguri).
...