diff --git a/.gitignore b/.gitignore
index 49c42a75..4a239692 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,11 +2,5 @@
*.iml
build
demos/**/libs/
-.gradle
-gradle
-gradlew
-gradlew.bat
-.idea
-local.properties
project.xcworkspace
xcuserdata
diff --git a/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/build.gradle b/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/build.gradle
index d78027e3..d873a8bb 100644
--- a/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/build.gradle
+++ b/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/build.gradle
@@ -1,14 +1,14 @@
apply plugin: 'com.android.application'
android {
- compileSdkVersion 28
+ compileSdkVersion 29
defaultConfig {
applicationId "com.polar.polarsdkdemo"
minSdkVersion 21
- targetSdkVersion 28
+ targetSdkVersion 29
versionCode 1
versionName "1.0"
- testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+ testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
buildTypes {
release {
@@ -31,16 +31,15 @@ task copySdk {
}
preBuild.dependsOn copySdk
+
dependencies {
- implementation "com.androidplot:androidplot-core:1.5.6"
implementation files('libs/polar-ble-sdk.aar')
+ implementation 'com.androidplot:androidplot-core:1.5.6'
implementation 'io.reactivex.rxjava3:rxjava:3.0.0'
- implementation group: 'commons-io', name: 'commons-io', version: '2.4'
implementation 'io.reactivex.rxjava3:rxandroid:3.0.0'
- implementation fileTree(dir: 'libs', include: ['*.jar'])
- implementation 'com.android.support:appcompat-v7:28.0.0'
- implementation 'com.android.support.constraint:constraint-layout:1.1.3'
- testImplementation 'junit:junit:4.12'
- androidTestImplementation 'com.android.support.test:runner:1.0.2'
- androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
+ implementation 'androidx.appcompat:appcompat:1.2.0'
+ implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
+ testImplementation 'junit:junit:4.13.1'
+ androidTestImplementation 'androidx.test.ext:junit:1.1.2'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
diff --git a/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/androidTest/java/com/polar/polarsdkecghrdemo/ExampleInstrumentedTest.java b/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/androidTest/java/com/polar/polarsdkecghrdemo/ExampleInstrumentedTest.java
index 95dfe313..aa32ca33 100644
--- a/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/androidTest/java/com/polar/polarsdkecghrdemo/ExampleInstrumentedTest.java
+++ b/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/androidTest/java/com/polar/polarsdkecghrdemo/ExampleInstrumentedTest.java
@@ -1,8 +1,8 @@
package com.polar.polarsdkecghrdemo;
import android.content.Context;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.runner.AndroidJUnit4;
+import androidx.test.platform.app.InstrumentationRegistry;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/main/AndroidManifest.xml b/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/main/AndroidManifest.xml
index 1439498e..aac1f0ca 100755
--- a/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/main/AndroidManifest.xml
+++ b/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/main/AndroidManifest.xml
@@ -2,9 +2,9 @@
-
-
-
+
+
+
+ android:label="@string/app_name"
+ android:screenOrientation="portrait">
@@ -24,12 +25,12 @@
-
+ android:label="@string/ecg_name"
+ android:screenOrientation="portrait"/>
-
+ android:label="@string/hr_name"
+ android:screenOrientation="portrait"/>
diff --git a/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/main/java/com/polar/polarsdkecghrdemo/ECGActivity.java b/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/main/java/com/polar/polarsdkecghrdemo/ECGActivity.java
index 06480db2..39953d55 100755
--- a/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/main/java/com/polar/polarsdkecghrdemo/ECGActivity.java
+++ b/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/main/java/com/polar/polarsdkecghrdemo/ECGActivity.java
@@ -2,52 +2,52 @@
import android.content.Context;
import android.os.Bundle;
-import android.support.annotation.Nullable;
-import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.TextView;
import android.widget.Toast;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AppCompatActivity;
+
import com.androidplot.xy.BoundaryMode;
import com.androidplot.xy.StepMode;
import com.androidplot.xy.XYPlot;
import org.reactivestreams.Publisher;
-import java.util.List;
import java.util.UUID;
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
import io.reactivex.rxjava3.disposables.Disposable;
-import io.reactivex.rxjava3.functions.Action;
-import io.reactivex.rxjava3.functions.Consumer;
import io.reactivex.rxjava3.functions.Function;
import polar.com.sdk.api.PolarBleApi;
import polar.com.sdk.api.PolarBleApiCallback;
import polar.com.sdk.api.PolarBleApiDefaultImpl;
+import polar.com.sdk.api.errors.PolarInvalidArgument;
import polar.com.sdk.api.model.PolarDeviceInfo;
import polar.com.sdk.api.model.PolarEcgData;
import polar.com.sdk.api.model.PolarHrData;
import polar.com.sdk.api.model.PolarSensorSetting;
-import polar.com.sdk.api.errors.PolarInvalidArgument;
public class ECGActivity extends AppCompatActivity implements PlotterListener {
+ private static final String TAG = "ECGActivity";
+ private PolarBleApi api;
+ private TextView textViewHR;
+ private TextView textViewFW;
private XYPlot plot;
private Plotter plotter;
- TextView textViewHR, textViewFW;
- private String TAG = "Polar_ECGActivity";
- public PolarBleApi api;
private Disposable ecgDisposable = null;
- private Context classContext = this;
- private String DEVICE_ID;
+ private final Context classContext = this;
+ private String deviceId;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ecg);
- DEVICE_ID = getIntent().getStringExtra("id");
+ deviceId = getIntent().getStringExtra("id");
textViewHR = findViewById(R.id.info);
textViewFW = findViewById(R.id.fw);
@@ -65,57 +65,55 @@ public void blePowerStateChanged(boolean b) {
}
@Override
- public void deviceConnected(PolarDeviceInfo s) {
+ public void deviceConnected(@NonNull PolarDeviceInfo s) {
Log.d(TAG, "Device connected " + s.deviceId);
- Toast.makeText(classContext, R.string.connected,
- Toast.LENGTH_SHORT).show();
+ Toast.makeText(classContext, R.string.connected, Toast.LENGTH_SHORT).show();
}
@Override
- public void deviceConnecting(PolarDeviceInfo polarDeviceInfo) {
+ public void deviceConnecting(@NonNull PolarDeviceInfo polarDeviceInfo) {
}
@Override
- public void deviceDisconnected(PolarDeviceInfo s) {
+ public void deviceDisconnected(@NonNull PolarDeviceInfo s) {
Log.d(TAG, "Device disconnected " + s);
-
}
@Override
- public void ecgFeatureReady(String s) {
+ public void ecgFeatureReady(@NonNull String s) {
Log.d(TAG, "ECG Feature ready " + s);
streamECG();
}
@Override
- public void accelerometerFeatureReady(String s) {
+ public void accelerometerFeatureReady(@NonNull String s) {
Log.d(TAG, "ACC Feature ready " + s);
}
@Override
- public void ppgFeatureReady(String s) {
+ public void ppgFeatureReady(@NonNull String s) {
Log.d(TAG, "PPG Feature ready " + s);
}
@Override
- public void ppiFeatureReady(String s) {
+ public void ppiFeatureReady(@NonNull String s) {
Log.d(TAG, "PPI Feature ready " + s);
}
@Override
- public void biozFeatureReady(String s) {
+ public void biozFeatureReady(@NonNull String s) {
}
@Override
- public void hrFeatureReady(String s) {
+ public void hrFeatureReady(@NonNull String s) {
Log.d(TAG, "HR Feature ready " + s);
}
@Override
- public void disInformationReceived(String s, UUID u, String s1) {
- if( u.equals(UUID.fromString("00002a28-0000-1000-8000-00805f9b34fb"))) {
+ public void disInformationReceived(@NonNull String s, @NonNull UUID u, @NonNull String s1) {
+ if (u.equals(UUID.fromString("00002a28-0000-1000-8000-00805f9b34fb"))) {
String msg = "Firmware: " + s1.trim();
Log.d(TAG, "Firmware: " + s + " " + s1.trim());
textViewFW.append(msg + "\n");
@@ -123,7 +121,7 @@ public void disInformationReceived(String s, UUID u, String s1) {
}
@Override
- public void batteryLevelReceived(String s, int i) {
+ public void batteryLevelReceived(@NonNull String s, int i) {
String msg = "ID: " + s + "\nBattery level: " + i;
Log.d(TAG, "Battery level " + s + " " + i);
// Toast.makeText(classContext, msg, Toast.LENGTH_LONG).show();
@@ -131,24 +129,23 @@ public void batteryLevelReceived(String s, int i) {
}
@Override
- public void hrNotificationReceived(String s,
- PolarHrData polarHrData) {
+ public void hrNotificationReceived(@NonNull String s, @NonNull PolarHrData polarHrData) {
Log.d(TAG, "HR " + polarHrData.hr);
textViewHR.setText(String.valueOf(polarHrData.hr));
}
@Override
- public void polarFtpFeatureReady(String s) {
+ public void polarFtpFeatureReady(@NonNull String s) {
Log.d(TAG, "Polar FTP ready " + s);
}
});
try {
- api.connectToDevice(DEVICE_ID);
- } catch (PolarInvalidArgument a){
+ api.connectToDevice(deviceId);
+ } catch (PolarInvalidArgument a) {
a.printStackTrace();
}
- plotter = new Plotter(this, "ECG");
+ plotter = new Plotter("ECG");
plotter.setListener(this);
plot.addSeries(plotter.getSeries(), plotter.getFormatter());
@@ -167,37 +164,24 @@ public void onDestroy() {
public void streamECG() {
if (ecgDisposable == null) {
ecgDisposable =
- api.requestEcgSettings(DEVICE_ID).toFlowable().flatMap(new Function>() {
- @Override
- public Publisher apply(PolarSensorSetting sensorSetting) throws Exception {
- return api.startEcgStreaming(DEVICE_ID,
- sensorSetting.maxSettings());
- }
- }).observeOn(AndroidSchedulers.mainThread()).subscribe(
- new Consumer() {
- @Override
- public void accept(PolarEcgData polarEcgData) throws Exception {
- Log.d(TAG, "ecg update");
- for (Integer data : polarEcgData.samples) {
- plotter.sendSingleSample((float) ((float) data / 1000.0));
- }
- }
- },
- new Consumer() {
- @Override
- public void accept(Throwable throwable) throws Exception {
- Log.e(TAG,
- "" + throwable.getLocalizedMessage());
- ecgDisposable = null;
- }
- },
- new Action() {
- @Override
- public void run() throws Exception {
- Log.d(TAG, "complete");
- }
- }
- );
+ api.requestEcgSettings(deviceId)
+ .toFlowable()
+ .flatMap((Function>) sensorSetting -> api.startEcgStreaming(deviceId, sensorSetting.maxSettings()))
+ .observeOn(AndroidSchedulers.mainThread())
+ .subscribe(
+ polarEcgData -> {
+ Log.d(TAG, "ecg update");
+ for (Integer data : polarEcgData.samples) {
+ plotter.sendSingleSample((float) ((float) data / 1000.0));
+ }
+ },
+ throwable -> {
+ Log.e(TAG,
+ "" + throwable.getLocalizedMessage());
+ ecgDisposable = null;
+ },
+ () -> Log.d(TAG, "complete")
+ );
} else {
// NOTE stops streaming if it is "running"
ecgDisposable.dispose();
@@ -207,11 +191,6 @@ public void run() throws Exception {
@Override
public void update() {
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- plot.redraw();
- }
- });
+ runOnUiThread(() -> plot.redraw());
}
}
diff --git a/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/main/java/com/polar/polarsdkecghrdemo/HRActivity.java b/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/main/java/com/polar/polarsdkecghrdemo/HRActivity.java
index cf32d5a8..3f2268a5 100755
--- a/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/main/java/com/polar/polarsdkecghrdemo/HRActivity.java
+++ b/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/main/java/com/polar/polarsdkecghrdemo/HRActivity.java
@@ -2,12 +2,14 @@
import android.content.Context;
import android.os.Bundle;
-import android.support.annotation.Nullable;
-import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.TextView;
import android.widget.Toast;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AppCompatActivity;
+
import com.androidplot.xy.BoundaryMode;
import com.androidplot.xy.StepMode;
import com.androidplot.xy.XYGraphWidget;
@@ -17,31 +19,27 @@
import java.util.List;
import java.util.UUID;
-import io.reactivex.rxjava3.disposables.Disposable;
import polar.com.sdk.api.PolarBleApi;
import polar.com.sdk.api.PolarBleApiCallback;
import polar.com.sdk.api.PolarBleApiDefaultImpl;
+import polar.com.sdk.api.errors.PolarInvalidArgument;
import polar.com.sdk.api.model.PolarDeviceInfo;
import polar.com.sdk.api.model.PolarHrData;
-import polar.com.sdk.api.errors.PolarInvalidArgument;
public class HRActivity extends AppCompatActivity implements PlotterListener {
-
+ private static final String TAG = "HRActivity";
private XYPlot plot;
private TimePlotter plotter;
-
- TextView textViewHR, textViewFW;
- private String TAG = "Polar_HRActivity";
- public PolarBleApi api;
- private Disposable ecgDisposable = null;
- private Context classContext = this;
- private String DEVICE_ID;
+ private TextView textViewHR;
+ private TextView textViewFW;
+ private PolarBleApi api;
+ private final Context classContext = this;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_hr);
- DEVICE_ID = getIntent().getStringExtra("id");
+ String deviceId = getIntent().getStringExtra("id");
textViewHR = findViewById(R.id.info2);
textViewFW = findViewById(R.id.fw2);
@@ -58,56 +56,56 @@ public void blePowerStateChanged(boolean b) {
}
@Override
- public void deviceConnected(PolarDeviceInfo s) {
+ public void deviceConnected(@NonNull PolarDeviceInfo s) {
Log.d(TAG, "Device connected " + s.deviceId);
Toast.makeText(classContext, R.string.connected,
Toast.LENGTH_SHORT).show();
}
@Override
- public void deviceConnecting(PolarDeviceInfo polarDeviceInfo) {
+ public void deviceConnecting(@NonNull PolarDeviceInfo polarDeviceInfo) {
}
@Override
- public void deviceDisconnected(PolarDeviceInfo s) {
+ public void deviceDisconnected(@NonNull PolarDeviceInfo s) {
Log.d(TAG, "Device disconnected " + s);
}
@Override
- public void ecgFeatureReady(String s) {
+ public void ecgFeatureReady(@NonNull String s) {
Log.d(TAG, "ECG Feature ready " + s);
}
@Override
- public void accelerometerFeatureReady(String s) {
+ public void accelerometerFeatureReady(@NonNull String s) {
Log.d(TAG, "ACC Feature ready " + s);
}
@Override
- public void ppgFeatureReady(String s) {
+ public void ppgFeatureReady(@NonNull String s) {
Log.d(TAG, "PPG Feature ready " + s);
}
@Override
- public void ppiFeatureReady(String s) {
+ public void ppiFeatureReady(@NonNull String s) {
Log.d(TAG, "PPI Feature ready " + s);
}
@Override
- public void biozFeatureReady(String s) {
+ public void biozFeatureReady(@NonNull String s) {
}
@Override
- public void hrFeatureReady(String s) {
+ public void hrFeatureReady(@NonNull String s) {
Log.d(TAG, "HR Feature ready " + s);
}
@Override
- public void disInformationReceived(String s, UUID u, String s1) {
- if( u.equals(UUID.fromString("00002a28-0000-1000-8000-00805f9b34fb"))) {
+ public void disInformationReceived(@NonNull String s, @NonNull UUID u, @NonNull String s1) {
+ if (u.equals(UUID.fromString("00002a28-0000-1000-8000-00805f9b34fb"))) {
String msg = "Firmware: " + s1.trim();
Log.d(TAG, "Firmware: " + s + " " + s1.trim());
textViewFW.append(msg + "\n");
@@ -115,7 +113,7 @@ public void disInformationReceived(String s, UUID u, String s1) {
}
@Override
- public void batteryLevelReceived(String s, int i) {
+ public void batteryLevelReceived(@NonNull String s, int i) {
String msg = "ID: " + s + "\nBattery level: " + i;
Log.d(TAG, "Battery level " + s + " " + i);
// Toast.makeText(classContext, msg, Toast.LENGTH_LONG).show();
@@ -123,11 +121,11 @@ public void batteryLevelReceived(String s, int i) {
}
@Override
- public void hrNotificationReceived(String s,
- PolarHrData polarHrData) {
+ public void hrNotificationReceived(@NonNull String s,
+ @NonNull PolarHrData polarHrData) {
Log.d(TAG, "HR " + polarHrData.hr);
List rrsMs = polarHrData.rrsMs;
- String msg = String.valueOf(polarHrData.hr) + "\n";
+ String msg = polarHrData.hr + "\n";
for (int i : rrsMs) {
msg += i + ",";
}
@@ -139,25 +137,23 @@ public void hrNotificationReceived(String s,
}
@Override
- public void polarFtpFeatureReady(String s) {
+ public void polarFtpFeatureReady(@NonNull String s) {
Log.d(TAG, "Polar FTP ready " + s);
}
});
try {
- api.connectToDevice(DEVICE_ID);
- } catch (PolarInvalidArgument a){
+ api.connectToDevice(deviceId);
+ } catch (PolarInvalidArgument a) {
a.printStackTrace();
}
- plotter = new TimePlotter(this, "HR/RR");
+ plotter = new TimePlotter();
plotter.setListener(this);
plot.addSeries(plotter.getHrSeries(), plotter.getHrFormatter());
plot.addSeries(plotter.getRrSeries(), plotter.getRrFormatter());
- plot.setRangeBoundaries(50, 100,
- BoundaryMode.AUTO);
- plot.setDomainBoundaries(0, 360000,
- BoundaryMode.AUTO);
+ plot.setRangeBoundaries(50, 100, BoundaryMode.AUTO);
+ plot.setDomainBoundaries(0, 360000, BoundaryMode.AUTO);
// Left labels will increment by 10
plot.setRangeStep(StepMode.INCREMENT_BY_VAL, 10);
plot.setDomainStep(StepMode.INCREMENT_BY_VAL, 60000);
@@ -175,11 +171,6 @@ public void onDestroy() {
}
public void update() {
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- plot.redraw();
- }
- });
+ runOnUiThread(() -> plot.redraw());
}
}
diff --git a/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/main/java/com/polar/polarsdkecghrdemo/MainActivity.java b/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/main/java/com/polar/polarsdkecghrdemo/MainActivity.java
index ecce2ed1..5ae0d293 100755
--- a/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/main/java/com/polar/polarsdkecghrdemo/MainActivity.java
+++ b/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/main/java/com/polar/polarsdkecghrdemo/MainActivity.java
@@ -1,15 +1,11 @@
package com.polar.polarsdkecghrdemo;
import android.Manifest;
-import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.content.Context;
-import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
-import android.support.v7.app.AlertDialog;
-import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.InputType;
import android.util.Log;
@@ -19,12 +15,13 @@
import android.widget.EditText;
import android.widget.Toast;
+import androidx.appcompat.app.AlertDialog;
+import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
-
- private String TAG = "Polar_MainActivity";
- private String sharedPrefsKey = "polar_device_id";
- private String DEVICE_ID;
+ private static final String TAG = "Polar_MainActivity";
+ private static final String SHARED_PREFS_KEY = "polar_device_id";
+ private String deviceId;
SharedPreferences sharedPreferences;
@Override
@@ -37,28 +34,28 @@ protected void onCreate(Bundle savedInstanceState) {
public void onClickConnect(View view) {
checkBT();
- DEVICE_ID = sharedPreferences.getString(sharedPrefsKey,"");
- Log.d(TAG,DEVICE_ID);
- if(DEVICE_ID.equals("")){
+ deviceId = sharedPreferences.getString(SHARED_PREFS_KEY, "");
+ Log.d(TAG, deviceId);
+ if (deviceId.equals("")) {
showDialog(view);
} else {
- Toast.makeText(this,getString(R.string.connecting) + " " + DEVICE_ID,Toast.LENGTH_SHORT).show();
+ Toast.makeText(this, getString(R.string.connecting) + " " + deviceId, Toast.LENGTH_SHORT).show();
Intent intent = new Intent(this, ECGActivity.class);
- intent.putExtra("id", DEVICE_ID);
+ intent.putExtra("id", deviceId);
startActivity(intent);
}
}
public void onClickConnect2(View view) {
checkBT();
- DEVICE_ID = sharedPreferences.getString(sharedPrefsKey,"");
- Log.d(TAG,DEVICE_ID);
- if(DEVICE_ID.equals("")){
+ deviceId = sharedPreferences.getString(SHARED_PREFS_KEY, "");
+ Log.d(TAG, deviceId);
+ if (deviceId.equals("")) {
showDialog(view);
} else {
- Toast.makeText(this,getString(R.string.connecting) + " " + DEVICE_ID,Toast.LENGTH_SHORT).show();
+ Toast.makeText(this, getString(R.string.connecting) + " " + deviceId, Toast.LENGTH_SHORT).show();
Intent intent = new Intent(this, HRActivity.class);
- intent.putExtra("id", DEVICE_ID);
+ intent.putExtra("id", deviceId);
startActivity(intent);
}
}
@@ -67,35 +64,27 @@ public void onClickChangeID(View view) {
showDialog(view);
}
- public void showDialog(View view){
+ public void showDialog(View view) {
AlertDialog.Builder dialog = new AlertDialog.Builder(this, R.style.PolarTheme);
dialog.setTitle("Enter your Polar device's ID");
- View viewInflated = LayoutInflater.from(getApplicationContext()).inflate(R.layout.device_id_dialog_layout,(ViewGroup) view.getRootView() , false);
+ View viewInflated = LayoutInflater.from(getApplicationContext()).inflate(R.layout.device_id_dialog_layout, (ViewGroup) view.getRootView(), false);
final EditText input = viewInflated.findViewById(R.id.input);
input.setInputType(InputType.TYPE_CLASS_TEXT);
dialog.setView(viewInflated);
- dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- DEVICE_ID = input.getText().toString();
- SharedPreferences.Editor editor = sharedPreferences.edit();
- editor.putString(sharedPrefsKey, DEVICE_ID);
- editor.apply();
- }
- });
- dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- dialog.cancel();
- }
+ dialog.setPositiveButton("OK", (dialog1, which) -> {
+ deviceId = input.getText().toString();
+ SharedPreferences.Editor editor = sharedPreferences.edit();
+ editor.putString(SHARED_PREFS_KEY, deviceId);
+ editor.apply();
});
+ dialog.setNegativeButton("Cancel", (dialog12, which) -> dialog12.cancel());
dialog.show();
}
- public void checkBT(){
+ public void checkBT() {
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter != null && !mBluetoothAdapter.isEnabled()) {
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
@@ -103,8 +92,8 @@ public void checkBT(){
}
//requestPermissions() method needs to be called when the build SDK version is 23 or above
- if(Build.VERSION.SDK_INT >= 23){
- this.requestPermissions(new String[]{Manifest.permission.ACCESS_COARSE_LOCATION,Manifest.permission.ACCESS_FINE_LOCATION},1);
+ if (Build.VERSION.SDK_INT >= 23) {
+ this.requestPermissions(new String[]{Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION}, 1);
}
}
}
diff --git a/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/main/java/com/polar/polarsdkecghrdemo/Plotter.java b/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/main/java/com/polar/polarsdkecghrdemo/Plotter.java
index af5a300c..a1c4728e 100755
--- a/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/main/java/com/polar/polarsdkecghrdemo/Plotter.java
+++ b/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/main/java/com/polar/polarsdkecghrdemo/Plotter.java
@@ -1,53 +1,45 @@
package com.polar.polarsdkecghrdemo;
-import android.content.Context;
import android.graphics.Paint;
import com.androidplot.xy.AdvancedLineAndPointRenderer;
import com.androidplot.xy.SimpleXYSeries;
import com.androidplot.xy.XYSeries;
+
import java.util.Arrays;
public class Plotter {
-
- String title;
- private String TAG = "Polar_Plotter";
+ private static final String TAG = "Plotter";
private PlotterListener listener;
- private Context context;
- private Number[] plotNumbers = new Number[500];
- private FadeFormatter formatter;
- private XYSeries series;
+ private final Number[] plotNumbers = new Number[500];
+ private final FadeFormatter formatter;
+ private final XYSeries series;
private int dataIndex;
-
- public Plotter(Context context, String title){
- this.context = context;
- this.title = title;
-
- for(int i = 0; i < plotNumbers.length - 1; i++){
+ public Plotter(String title) {
+ for (int i = 0; i < plotNumbers.length - 1; i++) {
plotNumbers[i] = 60;
}
formatter = new FadeFormatter(800);
formatter.setLegendIconEnabled(false);
-
series = new SimpleXYSeries(Arrays.asList(plotNumbers), SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, title);
}
- public SimpleXYSeries getSeries(){
+ public SimpleXYSeries getSeries() {
return (SimpleXYSeries) series;
}
- public FadeFormatter getFormatter(){
+ public FadeFormatter getFormatter() {
return formatter;
}
- public void sendSingleSample(float mV){
+ public void sendSingleSample(float mV) {
plotNumbers[dataIndex] = mV;
- if(dataIndex >= plotNumbers.length - 1){
+ if (dataIndex >= plotNumbers.length - 1) {
dataIndex = 0;
}
- if(dataIndex < plotNumbers.length - 1){
+ if (dataIndex < plotNumbers.length - 1) {
plotNumbers[dataIndex + 1] = null;
}
@@ -56,13 +48,13 @@ public void sendSingleSample(float mV){
listener.update();
}
- public void setListener(PlotterListener listener){
+ public void setListener(PlotterListener listener) {
this.listener = listener;
}
//Custom paint stroke to generate a "fade" effect
public static class FadeFormatter extends AdvancedLineAndPointRenderer.Formatter {
- private int trailSize;
+ private final int trailSize;
public FadeFormatter(int trailSize) {
this.trailSize = trailSize;
@@ -72,14 +64,14 @@ public FadeFormatter(int trailSize) {
public Paint getLinePaint(int thisIndex, int latestIndex, int seriesSize) {
// offset from the latest index:
int offset;
- if(thisIndex > latestIndex) {
+ if (thisIndex > latestIndex) {
offset = latestIndex + (seriesSize - thisIndex);
} else {
- offset = latestIndex - thisIndex;
+ offset = latestIndex - thisIndex;
}
float scale = 255f / trailSize;
int alpha = (int) (255 - (offset * scale));
- getLinePaint().setAlpha(alpha > 0 ? alpha : 0);
+ getLinePaint().setAlpha(Math.max(alpha, 0));
return getLinePaint();
}
}
diff --git a/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/main/java/com/polar/polarsdkecghrdemo/PlotterListener.java b/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/main/java/com/polar/polarsdkecghrdemo/PlotterListener.java
index a7be0d2d..dc090556 100755
--- a/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/main/java/com/polar/polarsdkecghrdemo/PlotterListener.java
+++ b/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/main/java/com/polar/polarsdkecghrdemo/PlotterListener.java
@@ -1,5 +1,5 @@
package com.polar.polarsdkecghrdemo;
-public interface PlotterListener{
+public interface PlotterListener {
void update();
}
diff --git a/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/main/java/com/polar/polarsdkecghrdemo/TimePlotter.java b/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/main/java/com/polar/polarsdkecghrdemo/TimePlotter.java
index f4c48011..e684ef1b 100755
--- a/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/main/java/com/polar/polarsdkecghrdemo/TimePlotter.java
+++ b/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/main/java/com/polar/polarsdkecghrdemo/TimePlotter.java
@@ -1,6 +1,5 @@
package com.polar.polarsdkecghrdemo;
-import android.content.Context;
import android.graphics.Color;
import com.androidplot.xy.LineAndPointFormatter;
@@ -17,13 +16,11 @@
* Implements two series for HR and RR using time for the x values.
*/
public class TimePlotter {
+ private static final String TAG = "TimePlotter";
private static final int NVALS = 300; // 5 min
-
- String title;
- private String TAG = "Polar_Plotter";
- private double RR_SCALE = .1;
+ private static final double RR_SCALE = .1;
private PlotterListener listener;
- private Context context;
+
private XYSeriesFormatter hrFormatter;
private XYSeriesFormatter rrFormatter;
private SimpleXYSeries hrSeries;
@@ -33,9 +30,7 @@ public class TimePlotter {
private Double[] xRrVals = new Double[NVALS];
private Double[] yRrVals = new Double[NVALS];
- public TimePlotter(Context context, String title) {
- this.context = context;
- this.title = title; // Not used
+ public TimePlotter() {
Date now = new Date();
double endTime = now.getTime();
double startTime = endTime - NVALS * 1000;
@@ -43,33 +38,26 @@ public TimePlotter(Context context, String title) {
// Specify initial values to keep it from auto sizing
for (int i = 0; i < NVALS; i++) {
- xHrVals[i] = new Double(startTime + i * delta);
- yHrVals[i] = new Double(60);
- xRrVals[i] = new Double(startTime + i * delta);
- yRrVals[i] = new Double(100);
+ xHrVals[i] = startTime + i * delta;
+ yHrVals[i] = 60d;
+ xRrVals[i] = startTime + i * delta;
+ yRrVals[i] = 100d;
}
- hrFormatter = new LineAndPointFormatter(Color.RED,
- null, null, null);
+ hrFormatter = new LineAndPointFormatter(Color.RED, null, null, null);
hrFormatter.setLegendIconEnabled(false);
- hrSeries = new SimpleXYSeries(Arrays.asList(xHrVals),
- Arrays.asList(yHrVals),
- "HR");
-
- rrFormatter = new LineAndPointFormatter(Color.BLUE,
- null, null, null);
+ hrSeries = new SimpleXYSeries(Arrays.asList(xHrVals), Arrays.asList(yHrVals), "HR");
+ rrFormatter = new LineAndPointFormatter(Color.BLUE, null, null, null);
rrFormatter.setLegendIconEnabled(false);
- rrSeries = new SimpleXYSeries(Arrays.asList(xRrVals),
- Arrays.asList(yRrVals),
- "HR");
+ rrSeries = new SimpleXYSeries(Arrays.asList(xRrVals), Arrays.asList(yRrVals), "HR");
}
public SimpleXYSeries getHrSeries() {
- return (SimpleXYSeries) hrSeries;
+ return hrSeries;
}
public SimpleXYSeries getRrSeries() {
- return (SimpleXYSeries) rrSeries;
+ return rrSeries;
}
public XYSeriesFormatter getHrFormatter() {
@@ -94,8 +82,8 @@ public void addValues(PolarHrData polarHrData) {
yHrVals[i] = yHrVals[i + 1];
hrSeries.setXY(xHrVals[i], yHrVals[i], i);
}
- xHrVals[NVALS - 1] = new Double(time);
- yHrVals[NVALS - 1] = new Double(polarHrData.hr);
+ xHrVals[NVALS - 1] = (double) time;
+ yHrVals[NVALS - 1] = (double) polarHrData.hr;
hrSeries.setXY(xHrVals[NVALS - 1], yHrVals[NVALS - 1], NVALS - 1);
// Do RR
@@ -123,8 +111,8 @@ public void addValues(PolarHrData polarHrData) {
double rr;
for (int i = NVALS - nRrVals; i < NVALS; i++) {
rr = RR_SCALE * rrsMs.get(index++);
- xRrVals[i] = new Double(time - totalRR);
- yRrVals[i] = new Double(rr);
+ xRrVals[i] = time - totalRR;
+ yRrVals[i] = rr;
totalRR -= rr;
rrSeries.setXY(xRrVals[i], yRrVals[i], i);
}
diff --git a/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/main/res/layout/activity_ecg.xml b/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/main/res/layout/activity_ecg.xml
index 60a35f63..e2b87d01 100755
--- a/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/main/res/layout/activity_ecg.xml
+++ b/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/main/res/layout/activity_ecg.xml
@@ -1,8 +1,6 @@
-
@@ -13,9 +11,9 @@
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
- android:textSize="20sp"
android:textColor="#000000"
- app:layout_constraintBottom_toBottomOf="@+id/info"
+ android:textSize="20sp"
+ app:layout_constraintBottom_toBottomOf="@+id/info"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
@@ -29,8 +27,8 @@
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:textAlignment="center"
- android:textSize="30sp"
android:textColor="#C00000"
+ android:textSize="30sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
@@ -43,10 +41,10 @@
android:layout_width="fill_parent"
android:layout_height="304dp"
android:layout_marginTop="345dp"
- app:graphMarginTop="12dp"
+ app:graphBackgroundColor="@color/colorAccent"
app:graphMarginBottom="12dp"
+ app:graphMarginTop="12dp"
app:gridBackgroundColor="@color/colorAccent"
- app:graphBackgroundColor="@color/colorAccent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
@@ -58,4 +56,4 @@
app:renderMode="use_background_thread"
app:title="" />
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/main/res/layout/activity_hr.xml b/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/main/res/layout/activity_hr.xml
index 93a4d682..c16958ea 100755
--- a/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/main/res/layout/activity_hr.xml
+++ b/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/main/res/layout/activity_hr.xml
@@ -1,8 +1,6 @@
-
@@ -13,8 +11,8 @@
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
- android:textSize="20sp"
android:textColor="#000000"
+ android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="@+id/info2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
@@ -29,8 +27,8 @@
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:textAlignment="center"
- android:textSize="30sp"
android:textColor="#C00000"
+ android:textSize="30sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
@@ -43,35 +41,31 @@
android:layout_width="fill_parent"
android:layout_height="304dp"
android:layout_marginTop="345dp"
+ app:backgroundColor="@color/colorAccent"
+ app:graphBackgroundColor="@color/colorAccent"
+ app:graphMarginBottom="12dp"
+ app:graphMarginLeft="30dp"
+ app:graphMarginRight="5dp"
+ app:graphMarginTop="20dp"
+ app:gridBackgroundColor="@color/colorAccent"
+ app:gridInsetLeft="25dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0"
-
- app:paddingTop="5dp"
+ app:lineLabels="left"
app:paddingBottom="5dp"
app:paddingLeft="5dp"
app:paddingRight="5dp"
- app:backgroundColor="@color/colorAccent"
-
- app:gridBackgroundColor="@color/colorAccent"
- app:graphBackgroundColor="@color/colorAccent"
- app:graphMarginTop="20dp"
- app:graphMarginBottom="12dp"
- app:graphMarginLeft="30dp"
- app:graphMarginRight="5dp"
- app:gridInsetLeft="25dp"
- app:title="@string/hr_title"
- app:titleTextColor="#000000"
- app:titleTextSize="15dp"
+ app:paddingTop="5dp"
app:rangeTitle="@string/hr_range_title"
app:rangeTitleTextColor="#000000"
app:rangeTitleTextSize="14dp"
-
- app:lineLabels="left"
app:renderMode="use_background_thread"
- />
+ app:title="@string/hr_title"
+ app:titleTextColor="#000000"
+ app:titleTextSize="15dp" />
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/main/res/layout/activity_main.xml b/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/main/res/layout/activity_main.xml
index c0b5e648..e6aa002a 100755
--- a/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/main/res/layout/activity_main.xml
+++ b/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/main/res/layout/activity_main.xml
@@ -1,5 +1,5 @@
-
+ app:layout_constraintTop_toTopOf="parent" />
+ app:layout_constraintTop_toBottomOf="@+id/buttonSetID" />
+ app:layout_constraintVertical_bias="1.0" />
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/main/res/layout/device_id_dialog_layout.xml b/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/main/res/layout/device_id_dialog_layout.xml
index 0d3f68f5..164fc12e 100755
--- a/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/main/res/layout/device_id_dialog_layout.xml
+++ b/demos/Android-Demos/PolarSDK-ECG-HR-Demo/app/src/main/res/layout/device_id_dialog_layout.xml
@@ -6,8 +6,8 @@
android:paddingRight="20dp">
+ android:backgroundTint="@color/colorPrimary" />
\ No newline at end of file
diff --git a/demos/Android-Demos/PolarSDK-ECG-HR-Demo/build.gradle b/demos/Android-Demos/PolarSDK-ECG-HR-Demo/build.gradle
index 8d3ef8e5..fb8c2e23 100644
--- a/demos/Android-Demos/PolarSDK-ECG-HR-Demo/build.gradle
+++ b/demos/Android-Demos/PolarSDK-ECG-HR-Demo/build.gradle
@@ -1,17 +1,13 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
-
+
repositories {
google()
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.2.1'
-
-
- // NOTE: Do not place your application dependencies here; they belong
- // in the individual module build.gradle files
+ classpath 'com.android.tools.build:gradle:4.1.1'
}
}
diff --git a/demos/Android-Demos/PolarSDK-ECG-HR-Demo/gradle.properties b/demos/Android-Demos/PolarSDK-ECG-HR-Demo/gradle.properties
new file mode 100644
index 00000000..5465fec0
--- /dev/null
+++ b/demos/Android-Demos/PolarSDK-ECG-HR-Demo/gradle.properties
@@ -0,0 +1,2 @@
+android.enableJetifier=true
+android.useAndroidX=true
\ No newline at end of file
diff --git a/demos/Android-Demos/PolarSDK-ECG-HR-Demo/gradle/wrapper/gradle-wrapper.jar b/demos/Android-Demos/PolarSDK-ECG-HR-Demo/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 00000000..f3d88b1c
Binary files /dev/null and b/demos/Android-Demos/PolarSDK-ECG-HR-Demo/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/demos/Android-Demos/PolarSDK-ECG-HR-Demo/gradle/wrapper/gradle-wrapper.properties b/demos/Android-Demos/PolarSDK-ECG-HR-Demo/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 00000000..94a57f3a
--- /dev/null
+++ b/demos/Android-Demos/PolarSDK-ECG-HR-Demo/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Mon Nov 30 12:16:34 EET 2020
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
diff --git a/demos/Android-Demos/PolarSDK-ECG-HR-Demo/gradlew b/demos/Android-Demos/PolarSDK-ECG-HR-Demo/gradlew
new file mode 100755
index 00000000..2fe81a7d
--- /dev/null
+++ b/demos/Android-Demos/PolarSDK-ECG-HR-Demo/gradlew
@@ -0,0 +1,183 @@
+#!/usr/bin/env sh
+
+#
+# Copyright 2015 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+ echo "$*"
+}
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=`expr $i + 1`
+ done
+ case $i in
+ 0) set -- ;;
+ 1) set -- "$args0" ;;
+ 2) set -- "$args0" "$args1" ;;
+ 3) set -- "$args0" "$args1" "$args2" ;;
+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
+}
+APP_ARGS=`save "$@"`
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+exec "$JAVACMD" "$@"
diff --git a/demos/Android-Demos/PolarSDK-ECG-HR-Demo/gradlew.bat b/demos/Android-Demos/PolarSDK-ECG-HR-Demo/gradlew.bat
new file mode 100644
index 00000000..9618d8d9
--- /dev/null
+++ b/demos/Android-Demos/PolarSDK-ECG-HR-Demo/gradlew.bat
@@ -0,0 +1,100 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/examples/example-android/androidBleSdkTestApp/.gitignore b/examples/example-android/androidBleSdkTestApp/.gitignore
new file mode 100644
index 00000000..67446d05
--- /dev/null
+++ b/examples/example-android/androidBleSdkTestApp/.gitignore
@@ -0,0 +1,55 @@
+# Built application files
+*.apk
+*.ap_
+*.aab
+
+# Files for the ART/Dalvik VM
+*.dex
+
+# Java class files
+*.class
+
+# Generated files
+bin/
+gen/
+out/
+
+# Gradle files
+.gradle/
+build/
+
+# Signing files
+.signing/
+
+# Local configuration file (sdk path, etc)
+local.properties
+
+# Proguard folder generated by Eclipse
+proguard/
+
+# Log Files
+*.log
+
+# Android Studio
+/*/build/
+/*/local.properties
+/*/out
+/*/*/build
+/*/*/production
+captures/
+.navigation/
+*.ipr
+*~
+*.swp
+
+# Keystore files
+*.jks
+*.keystore
+
+
+# IntelliJ
+*.iml
+.idea/
+# Others
+.DS_Store
+
diff --git a/examples/example-android/androidBleSdkTestApp/app/build.gradle b/examples/example-android/androidBleSdkTestApp/app/build.gradle
index 961c3e62..ba39bf85 100644
--- a/examples/example-android/androidBleSdkTestApp/app/build.gradle
+++ b/examples/example-android/androidBleSdkTestApp/app/build.gradle
@@ -1,14 +1,14 @@
apply plugin: 'com.android.application'
android {
- compileSdkVersion 27
+ compileSdkVersion 29
defaultConfig {
applicationId "polar.com.androidblesdk"
minSdkVersion 21
- targetSdkVersion 27
+ targetSdkVersion 29
versionCode 1
versionName "1.0"
- testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+ testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
buildTypes {
release {
@@ -20,9 +20,7 @@ android {
defaultConfig {
multiDexEnabled true
}
- dexOptions {
- javaMaxHeapSize "2g"
- }
+
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
@@ -30,17 +28,14 @@ android {
}
dependencies {
- implementation fileTree(dir: 'libs', include: ['*.jar'])
-
implementation files('libs/polar-ble-sdk.aar')
implementation files('libs/polar-protobuf-release.aar')
implementation 'com.google.protobuf:protobuf-java:3.1.0'
implementation 'io.reactivex.rxjava3:rxjava:3.0.0'
- implementation group: 'commons-io', name: 'commons-io', version: '2.4'
+ implementation 'commons-io:commons-io:2.8.0'
implementation 'io.reactivex.rxjava3:rxandroid:3.0.0'
- implementation 'com.android.support:appcompat-v7:27.1.1'
- implementation 'com.android.support.constraint:constraint-layout:1.0.2'
- testImplementation 'junit:junit:4.12'
- androidTestImplementation 'com.android.support.test:runner:1.0.1'
- androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
+ implementation 'androidx.appcompat:appcompat:1.2.0'
+ testImplementation 'junit:junit:4.13.1'
+ androidTestImplementation 'androidx.test.ext:junit:1.1.2'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
diff --git a/examples/example-android/androidBleSdkTestApp/app/src/main/AndroidManifest.xml b/examples/example-android/androidBleSdkTestApp/app/src/main/AndroidManifest.xml
index 97c350e8..615e5530 100644
--- a/examples/example-android/androidBleSdkTestApp/app/src/main/AndroidManifest.xml
+++ b/examples/example-android/androidBleSdkTestApp/app/src/main/AndroidManifest.xml
@@ -13,12 +13,12 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
-
-
diff --git a/examples/example-android/androidBleSdkTestApp/app/src/main/java/polar/com/androidblesdk/MainActivity.java b/examples/example-android/androidBleSdkTestApp/app/src/main/java/polar/com/androidblesdk/MainActivity.java
index 1ff6df4c..5cfa51a3 100644
--- a/examples/example-android/androidBleSdkTestApp/app/src/main/java/polar/com/androidblesdk/MainActivity.java
+++ b/examples/example-android/androidBleSdkTestApp/app/src/main/java/polar/com/androidblesdk/MainActivity.java
@@ -3,8 +3,10 @@
import android.Manifest;
import android.os.Build;
import android.os.Bundle;
-import android.support.annotation.NonNull;
-import android.support.v7.app.AppCompatActivity;
+
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatActivity;
+
import android.util.Log;
import android.widget.Button;
@@ -31,7 +33,8 @@
import polar.com.sdk.api.model.PolarSensorSetting;
public class MainActivity extends AppCompatActivity {
- private final static String TAG = MainActivity.class.getSimpleName();
+ private static final String TAG = MainActivity.class.getSimpleName();
+ private static final String API_LOGGER_TAG = "API LOGGER";
PolarBleApi api;
Disposable broadcastDisposable;
Disposable ecgDisposable;
@@ -39,7 +42,7 @@ public class MainActivity extends AppCompatActivity {
Disposable ppgDisposable;
Disposable ppiDisposable;
Disposable scanDisposable;
- String DEVICE_ID = "218DDA23"; // or bt address like F5:A7:B8:EF:7A:D1 // TODO replace with your device id
+ String DEVICE_ID = "0A34442D"; // or bt address like F5:A7:B8:EF:7A:D1 // TODO replace with your device id
Disposable autoConnectDisposable;
PolarExerciseEntry exerciseEntry;
@@ -68,31 +71,31 @@ protected void onCreate(Bundle savedInstanceState) {
final Button H10RecordingStatus = this.findViewById(R.id.h10_recording_status);
final Button setTime = this.findViewById(R.id.set_time);
- api.setApiLogger(s -> Log.d(TAG,s));
+ api.setApiLogger(s -> Log.d(API_LOGGER_TAG, s));
- Log.d(TAG,"version: " + PolarBleApiDefaultImpl.versionInfo());
+ Log.d(TAG, "version: " + PolarBleApiDefaultImpl.versionInfo());
api.setApiCallback(new PolarBleApiCallback() {
@Override
public void blePowerStateChanged(boolean powered) {
- Log.d(TAG,"BLE power: " + powered);
+ Log.d(TAG, "BLE power: " + powered);
}
@Override
public void deviceConnected(@NonNull PolarDeviceInfo polarDeviceInfo) {
- Log.d(TAG,"CONNECTED: " + polarDeviceInfo.deviceId);
+ Log.d(TAG, "CONNECTED: " + polarDeviceInfo.deviceId);
DEVICE_ID = polarDeviceInfo.deviceId;
}
@Override
public void deviceConnecting(@NonNull PolarDeviceInfo polarDeviceInfo) {
- Log.d(TAG,"CONNECTING: " + polarDeviceInfo.deviceId);
+ Log.d(TAG, "CONNECTING: " + polarDeviceInfo.deviceId);
DEVICE_ID = polarDeviceInfo.deviceId;
}
@Override
public void deviceDisconnected(@NonNull PolarDeviceInfo polarDeviceInfo) {
- Log.d(TAG,"DISCONNECTED: " + polarDeviceInfo.deviceId);
+ Log.d(TAG, "DISCONNECTED: " + polarDeviceInfo.deviceId);
ecgDisposable = null;
accDisposable = null;
ppgDisposable = null;
@@ -101,101 +104,101 @@ public void deviceDisconnected(@NonNull PolarDeviceInfo polarDeviceInfo) {
@Override
public void ecgFeatureReady(@NonNull String identifier) {
- Log.d(TAG,"ECG READY: " + identifier);
+ Log.d(TAG, "ECG READY: " + identifier);
// ecg streaming can be started now if needed
}
@Override
public void accelerometerFeatureReady(@NonNull String identifier) {
- Log.d(TAG,"ACC READY: " + identifier);
+ Log.d(TAG, "ACC READY: " + identifier);
// acc streaming can be started now if needed
}
@Override
public void ppgFeatureReady(@NonNull String identifier) {
- Log.d(TAG,"PPG READY: " + identifier);
+ Log.d(TAG, "PPG READY: " + identifier);
// ohr ppg can be started
}
@Override
public void ppiFeatureReady(@NonNull String identifier) {
- Log.d(TAG,"PPI READY: " + identifier);
+ Log.d(TAG, "PPI READY: " + identifier);
// ohr ppi can be started
}
@Override
public void biozFeatureReady(@NonNull String identifier) {
- Log.d(TAG,"BIOZ READY: " + identifier);
+ Log.d(TAG, "BIOZ READY: " + identifier);
// ohr ppi can be started
}
@Override
public void hrFeatureReady(@NonNull String identifier) {
- Log.d(TAG,"HR READY: " + identifier);
+ Log.d(TAG, "HR READY: " + identifier);
// hr notifications are about to start
}
@Override
- public void disInformationReceived(@NonNull String identifier,@NonNull UUID uuid,@NonNull String value) {
- Log.d(TAG,"uuid: " + uuid + " value: " + value);
+ public void disInformationReceived(@NonNull String identifier, @NonNull UUID uuid, @NonNull String value) {
+ Log.d(TAG, "uuid: " + uuid + " value: " + value);
}
@Override
public void batteryLevelReceived(@NonNull String identifier, int level) {
- Log.d(TAG,"BATTERY LEVEL: " + level);
+ Log.d(TAG, "BATTERY LEVEL: " + level);
}
@Override
- public void hrNotificationReceived(@NonNull String identifier,@NonNull PolarHrData data) {
- Log.d(TAG,"HR value: " + data.hr + " rrsMs: " + data.rrsMs + " rr: " + data.rrs + " contact: " + data.contactStatus + "," + data.contactStatusSupported);
+ public void hrNotificationReceived(@NonNull String identifier, @NonNull PolarHrData data) {
+ Log.d(TAG, "HR value: " + data.hr + " rrsMs: " + data.rrsMs + " rr: " + data.rrs + " contact: " + data.contactStatus + "," + data.contactStatusSupported);
}
@Override
public void polarFtpFeatureReady(@NonNull String s) {
- Log.d(TAG,"FTP ready");
+ Log.d(TAG, "FTP ready");
}
});
list.setOnClickListener(v -> api.listExercises(DEVICE_ID).observeOn(AndroidSchedulers.mainThread()).subscribe(
polarExerciseEntry -> {
- Log.d(TAG,"next: " + polarExerciseEntry.date + " path: " + polarExerciseEntry.path + " id: " +polarExerciseEntry.identifier);
+ Log.d(TAG, "next: " + polarExerciseEntry.date + " path: " + polarExerciseEntry.path + " id: " + polarExerciseEntry.identifier);
exerciseEntry = polarExerciseEntry;
},
- throwable -> Log.e(TAG,"fetch exercises failed: " + throwable.getLocalizedMessage()),
- () -> Log.d(TAG,"complete")
+ throwable -> Log.e(TAG, "fetch exercises failed: " + throwable.getLocalizedMessage()),
+ () -> Log.d(TAG, "complete")
));
read.setOnClickListener(v -> {
- if(exerciseEntry != null) {
+ if (exerciseEntry != null) {
api.fetchExercise(DEVICE_ID, exerciseEntry).observeOn(AndroidSchedulers.mainThread()).subscribe(
- polarExerciseData -> Log.d(TAG,"exercise data count: " + polarExerciseData.hrSamples.size() + " samples: " + polarExerciseData.hrSamples),
- throwable -> Log.e(TAG,"Failed to read exercise: " + throwable.getLocalizedMessage())
+ polarExerciseData -> Log.d(TAG, "exercise data count: " + polarExerciseData.hrSamples.size() + " samples: " + polarExerciseData.hrSamples),
+ throwable -> Log.e(TAG, "Failed to read exercise: " + throwable.getLocalizedMessage())
);
}
});
remove.setOnClickListener(v -> {
- if(exerciseEntry != null) {
- api.removeExercise(DEVICE_ID,exerciseEntry).observeOn(AndroidSchedulers.mainThread()).subscribe(
- () -> Log.d(TAG,"ex removed ok"),
- throwable -> Log.d(TAG,"ex remove failed: " + throwable.getLocalizedMessage())
+ if (exerciseEntry != null) {
+ api.removeExercise(DEVICE_ID, exerciseEntry).observeOn(AndroidSchedulers.mainThread()).subscribe(
+ () -> Log.d(TAG, "ex removed ok"),
+ throwable -> Log.d(TAG, "ex remove failed: " + throwable.getLocalizedMessage())
);
}
});
broadcast.setOnClickListener(v -> {
- if(broadcastDisposable == null) {
+ if (broadcastDisposable == null) {
broadcastDisposable = api.startListenForPolarHrBroadcasts(null).subscribe(
- polarBroadcastData -> Log.d(TAG,"HR BROADCAST " +
+ polarBroadcastData -> Log.d(TAG, "HR BROADCAST " +
polarBroadcastData.polarDeviceInfo.deviceId + " HR: " +
polarBroadcastData.hr + " batt: " +
polarBroadcastData.batteryStatus),
- throwable -> Log.e(TAG,""+throwable.getLocalizedMessage()),
- () -> Log.d(TAG,"complete")
+ throwable -> Log.e(TAG, "" + throwable.getLocalizedMessage()),
+ () -> Log.d(TAG, "complete")
);
- }else{
+ } else {
broadcastDisposable.dispose();
broadcastDisposable = null;
}
@@ -218,30 +221,32 @@ public void polarFtpFeatureReady(@NonNull String s) {
});
autoConnect.setOnClickListener(view -> {
- if(autoConnectDisposable != null) {
+ if (autoConnectDisposable != null) {
autoConnectDisposable.dispose();
autoConnectDisposable = null;
}
autoConnectDisposable = api.autoConnectToDevice(-50, "180D", null).subscribe(
- () -> Log.d(TAG,"auto connect search complete"),
- throwable -> Log.e(TAG,"" + throwable.toString())
+ () -> Log.d(TAG, "auto connect search complete"),
+ throwable -> Log.e(TAG, "" + throwable.toString())
);
});
ecg.setOnClickListener(v -> {
- if(ecgDisposable == null) {
- ecgDisposable = api.requestEcgSettings(DEVICE_ID).toFlowable().flatMap((Function>) polarEcgSettings -> {
- PolarSensorSetting sensorSetting = polarEcgSettings.maxSettings();
- return api.startEcgStreaming(DEVICE_ID,sensorSetting);
- }).subscribe(
- polarEcgData -> {
- for( Integer microVolts : polarEcgData.samples ){
- Log.d(TAG," yV: " + microVolts);
- }
- },
- throwable -> Log.e(TAG, ""+throwable.toString()),
- () -> Log.d(TAG, "complete")
- );
+ if (ecgDisposable == null) {
+ ecgDisposable = api.requestEcgSettings(DEVICE_ID)
+ .toFlowable()
+ .flatMap((Function>) polarEcgSettings -> {
+ PolarSensorSetting sensorSetting = polarEcgSettings.maxSettings();
+ return api.startEcgStreaming(DEVICE_ID, sensorSetting);
+ }).subscribe(
+ polarEcgData -> {
+ for (Integer microVolts : polarEcgData.samples) {
+ Log.d(TAG, " yV: " + microVolts);
+ }
+ },
+ throwable -> Log.e(TAG, "" + throwable.toString()),
+ () -> Log.d(TAG, "complete")
+ );
} else {
// NOTE stops streaming if it is "running"
ecgDisposable.dispose();
@@ -250,19 +255,22 @@ public void polarFtpFeatureReady(@NonNull String s) {
});
acc.setOnClickListener(v -> {
- if(accDisposable == null) {
- accDisposable = api.requestAccSettings(DEVICE_ID).toFlowable().flatMap((Function>) settings -> {
- PolarSensorSetting sensorSetting = settings.maxSettings();
- return api.startAccStreaming(DEVICE_ID,sensorSetting);
- }).observeOn(AndroidSchedulers.mainThread()).subscribe(
- polarAccelerometerData -> {
- for( PolarAccelerometerData.PolarAccelerometerSample data : polarAccelerometerData.samples ){
- Log.d(TAG," x: " + data.x + " y: " + data.y + " z: "+ data.z);
- }
- },
- throwable -> Log.e(TAG,""+throwable.getLocalizedMessage()),
- () -> Log.d(TAG,"complete")
- );
+ if (accDisposable == null) {
+ accDisposable = api.requestAccSettings(DEVICE_ID)
+ .toFlowable()
+ .flatMap((Function>) settings -> {
+ PolarSensorSetting sensorSetting = settings.maxSettings();
+ return api.startAccStreaming(DEVICE_ID, sensorSetting);
+ }).observeOn(AndroidSchedulers.mainThread())
+ .subscribe(
+ polarAccelerometerData -> {
+ for (PolarAccelerometerData.PolarAccelerometerSample data : polarAccelerometerData.samples) {
+ Log.d(TAG, " x: " + data.x + " y: " + data.y + " z: " + data.z);
+ }
+ },
+ throwable -> Log.e(TAG, "" + throwable.getLocalizedMessage()),
+ () -> Log.d(TAG, "complete")
+ );
} else {
// NOTE dispose will stop streaming if it is "running"
accDisposable.dispose();
@@ -271,16 +279,19 @@ public void polarFtpFeatureReady(@NonNull String s) {
});
ppg.setOnClickListener(v -> {
- if(ppgDisposable == null) {
- ppgDisposable = api.requestPpgSettings(DEVICE_ID).toFlowable().flatMap((Function>) polarPPGSettings -> api.startOhrPPGStreaming(DEVICE_ID,polarPPGSettings.maxSettings())).subscribe(
- polarOhrPPGData -> {
- for( PolarOhrPPGData.PolarOhrPPGSample data : polarOhrPPGData.samples ){
- Log.d(TAG," ppg0: " + data.ppg0 + " ppg1: " + data.ppg1 + " ppg2: " + data.ppg2 + "ambient: " + data.ambient);
- }
- },
- throwable -> Log.e(TAG,""+throwable.getLocalizedMessage()),
- () -> Log.d(TAG,"complete")
- );
+ if (ppgDisposable == null) {
+ ppgDisposable = api.requestPpgSettings(DEVICE_ID)
+ .toFlowable()
+ .flatMap((Function>) polarPPGSettings -> api.startOhrPPGStreaming(DEVICE_ID, polarPPGSettings.maxSettings()))
+ .subscribe(
+ polarOhrPPGData -> {
+ for (PolarOhrPPGData.PolarOhrPPGSample data : polarOhrPPGData.samples) {
+ Log.d(TAG, " ppg0: " + data.ppg0 + " ppg1: " + data.ppg1 + " ppg2: " + data.ppg2 + "ambient: " + data.ambient);
+ }
+ },
+ throwable -> Log.e(TAG, "" + throwable.getLocalizedMessage()),
+ () -> Log.d(TAG, "complete")
+ );
} else {
ppgDisposable.dispose();
ppgDisposable = null;
@@ -288,17 +299,19 @@ public void polarFtpFeatureReady(@NonNull String s) {
});
ppi.setOnClickListener(v -> {
- if(ppiDisposable == null) {
- ppiDisposable = api.startOhrPPIStreaming(DEVICE_ID).observeOn(AndroidSchedulers.mainThread()).subscribe(
- ppiData -> {
- for(PolarOhrPPIData.PolarOhrPPISample sample : ppiData.samples) {
- Log.d(TAG, "ppi: " + sample.ppi
- + " blocker: " + sample.blockerBit + " errorEstimate: " + sample.errorEstimate);
- }
- },
- throwable -> Log.e(TAG,""+throwable.getLocalizedMessage()),
- () -> Log.d(TAG,"complete")
- );
+ if (ppiDisposable == null) {
+ ppiDisposable = api.startOhrPPIStreaming(DEVICE_ID)
+ .observeOn(AndroidSchedulers.mainThread())
+ .subscribe(
+ ppiData -> {
+ for (PolarOhrPPIData.PolarOhrPPISample sample : ppiData.samples) {
+ Log.d(TAG, "ppi: " + sample.ppi
+ + " blocker: " + sample.blockerBit + " errorEstimate: " + sample.errorEstimate);
+ }
+ },
+ throwable -> Log.e(TAG, "" + throwable.getLocalizedMessage()),
+ () -> Log.d(TAG, "complete")
+ );
} else {
ppiDisposable.dispose();
ppiDisposable = null;
@@ -306,50 +319,52 @@ public void polarFtpFeatureReady(@NonNull String s) {
});
scan.setOnClickListener(view -> {
- if(scanDisposable == null) {
- scanDisposable = api.searchForDevice().observeOn(AndroidSchedulers.mainThread()).subscribe(
- polarDeviceInfo -> Log.d(TAG, "polar device found id: " + polarDeviceInfo.deviceId + " address: " + polarDeviceInfo.address + " rssi: " + polarDeviceInfo.rssi + " name: " + polarDeviceInfo.name + " isConnectable: " + polarDeviceInfo.isConnectable),
- throwable -> Log.d(TAG, "" + throwable.getLocalizedMessage()),
- () -> Log.d(TAG, "complete")
- );
- }else{
+ if (scanDisposable == null) {
+ scanDisposable = api.searchForDevice()
+ .observeOn(AndroidSchedulers.mainThread())
+ .subscribe(
+ polarDeviceInfo -> Log.d(TAG, "polar device found id: " + polarDeviceInfo.deviceId + " address: " + polarDeviceInfo.address + " rssi: " + polarDeviceInfo.rssi + " name: " + polarDeviceInfo.name + " isConnectable: " + polarDeviceInfo.isConnectable),
+ throwable -> Log.d(TAG, "" + throwable.getLocalizedMessage()),
+ () -> Log.d(TAG, "complete")
+ );
+ } else {
scanDisposable.dispose();
scanDisposable = null;
}
});
- startH10Recording.setOnClickListener(view -> api.startRecording(DEVICE_ID,"TEST_APP_ID", PolarBleApi.RecordingInterval.INTERVAL_1S, PolarBleApi.SampleType.HR).subscribe(
- () -> Log.d(TAG,"recording started"),
- throwable -> Log.e(TAG,"recording start failed: " + throwable.getLocalizedMessage())
+ startH10Recording.setOnClickListener(view -> api.startRecording(DEVICE_ID, "TEST_APP_ID", PolarBleApi.RecordingInterval.INTERVAL_1S, PolarBleApi.SampleType.HR).subscribe(
+ () -> Log.d(TAG, "recording started"),
+ throwable -> Log.e(TAG, "recording start failed: " + throwable.getLocalizedMessage())
));
stopH10Recording.setOnClickListener(view -> api.stopRecording(DEVICE_ID).subscribe(
- () -> Log.d(TAG,"recording stopped"),
- throwable -> Log.e(TAG,"recording stop failed: " + throwable.getLocalizedMessage())
+ () -> Log.d(TAG, "recording stopped"),
+ throwable -> Log.e(TAG, "recording stop failed: " + throwable.getLocalizedMessage())
));
H10RecordingStatus.setOnClickListener(view -> api.requestRecordingStatus(DEVICE_ID).subscribe(
- pair -> Log.d(TAG,"recording on: " + pair.first + " ID: " + pair.second),
+ pair -> Log.d(TAG, "recording on: " + pair.first + " ID: " + pair.second),
throwable -> Log.e(TAG, "recording status failed: " + throwable.getLocalizedMessage())
));
setTime.setOnClickListener(v -> {
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
- api.setLocalTime(DEVICE_ID,calendar).subscribe(
- () -> Log.d(TAG,"time set to device"),
- throwable -> Log.d(TAG,"set time failed: " + throwable.getLocalizedMessage()));
+ api.setLocalTime(DEVICE_ID, calendar).subscribe(
+ () -> Log.d(TAG, "time set to device"),
+ throwable -> Log.d(TAG, "set time failed: " + throwable.getLocalizedMessage()));
});
- if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && savedInstanceState == null) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && savedInstanceState == null) {
this.requestPermissions(new String[]{Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION}, 1);
}
}
@Override
- public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
- if(requestCode == 1) {
- Log.d(TAG,"bt ready");
+ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
+ if (requestCode == 1) {
+ Log.d(TAG, "bt ready");
}
}
diff --git a/examples/example-android/androidBleSdkTestApp/app/src/main/res/layout/activity_main.xml b/examples/example-android/androidBleSdkTestApp/app/src/main/res/layout/activity_main.xml
index 7ef0d278..03087e45 100644
--- a/examples/example-android/androidBleSdkTestApp/app/src/main/res/layout/activity_main.xml
+++ b/examples/example-android/androidBleSdkTestApp/app/src/main/res/layout/activity_main.xml
@@ -1,105 +1,109 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/example-android/androidBleSdkTestApp/build.gradle b/examples/example-android/androidBleSdkTestApp/build.gradle
index 43c07085..fb8c2e23 100644
--- a/examples/example-android/androidBleSdkTestApp/build.gradle
+++ b/examples/example-android/androidBleSdkTestApp/build.gradle
@@ -1,17 +1,13 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
-
+
repositories {
google()
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.1.3'
-
-
- // NOTE: Do not place your application dependencies here; they belong
- // in the individual module build.gradle files
+ classpath 'com.android.tools.build:gradle:4.1.1'
}
}
diff --git a/examples/example-android/androidBleSdkTestApp/gradle.properties b/examples/example-android/androidBleSdkTestApp/gradle.properties
new file mode 100644
index 00000000..5465fec0
--- /dev/null
+++ b/examples/example-android/androidBleSdkTestApp/gradle.properties
@@ -0,0 +1,2 @@
+android.enableJetifier=true
+android.useAndroidX=true
\ No newline at end of file
diff --git a/examples/example-android/androidBleSdkTestApp/gradle/wrapper/gradle-wrapper.jar b/examples/example-android/androidBleSdkTestApp/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 00000000..f3d88b1c
Binary files /dev/null and b/examples/example-android/androidBleSdkTestApp/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/examples/example-android/androidBleSdkTestApp/gradle/wrapper/gradle-wrapper.properties b/examples/example-android/androidBleSdkTestApp/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 00000000..94a57f3a
--- /dev/null
+++ b/examples/example-android/androidBleSdkTestApp/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Mon Nov 30 12:16:34 EET 2020
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
diff --git a/examples/example-android/androidBleSdkTestApp/gradlew b/examples/example-android/androidBleSdkTestApp/gradlew
new file mode 100755
index 00000000..2fe81a7d
--- /dev/null
+++ b/examples/example-android/androidBleSdkTestApp/gradlew
@@ -0,0 +1,183 @@
+#!/usr/bin/env sh
+
+#
+# Copyright 2015 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+ echo "$*"
+}
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=`expr $i + 1`
+ done
+ case $i in
+ 0) set -- ;;
+ 1) set -- "$args0" ;;
+ 2) set -- "$args0" "$args1" ;;
+ 3) set -- "$args0" "$args1" "$args2" ;;
+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
+}
+APP_ARGS=`save "$@"`
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+exec "$JAVACMD" "$@"
diff --git a/examples/example-android/androidBleSdkTestApp/gradlew.bat b/examples/example-android/androidBleSdkTestApp/gradlew.bat
new file mode 100644
index 00000000..9618d8d9
--- /dev/null
+++ b/examples/example-android/androidBleSdkTestApp/gradlew.bat
@@ -0,0 +1,100 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/sources/Android/android-communications/.gitignore b/sources/Android/android-communications/.gitignore
new file mode 100644
index 00000000..67446d05
--- /dev/null
+++ b/sources/Android/android-communications/.gitignore
@@ -0,0 +1,55 @@
+# Built application files
+*.apk
+*.ap_
+*.aab
+
+# Files for the ART/Dalvik VM
+*.dex
+
+# Java class files
+*.class
+
+# Generated files
+bin/
+gen/
+out/
+
+# Gradle files
+.gradle/
+build/
+
+# Signing files
+.signing/
+
+# Local configuration file (sdk path, etc)
+local.properties
+
+# Proguard folder generated by Eclipse
+proguard/
+
+# Log Files
+*.log
+
+# Android Studio
+/*/build/
+/*/local.properties
+/*/out
+/*/*/build
+/*/*/production
+captures/
+.navigation/
+*.ipr
+*~
+*.swp
+
+# Keystore files
+*.jks
+*.keystore
+
+
+# IntelliJ
+*.iml
+.idea/
+# Others
+.DS_Store
+
diff --git a/sources/Android/android-communications/build.gradle b/sources/Android/android-communications/build.gradle
index bf4a5b3a..3e87acfa 100755
--- a/sources/Android/android-communications/build.gradle
+++ b/sources/Android/android-communications/build.gradle
@@ -1,6 +1,6 @@
apply plugin: 'com.android.library'
-if ( project.hasProperty("artifactoryUser") && project.hasProperty("artifactoryPassword") ) {
+if (project.hasProperty("artifactoryUser") && project.hasProperty("artifactoryPassword")) {
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'maven-publish'
}
@@ -14,15 +14,15 @@ def getVersion = { ->
standardOutput = stdout
}
def pattern = Pattern.compile("^([0-9]*)(\\.)([0-9]*)(.*)\$")
- def matcher = pattern.matcher(stdout.toString().trim());
- if( matcher.matches() ) {
+ def matcher = pattern.matcher(stdout.toString().trim())
+ if (matcher.matches()) {
String MAJOR = matcher.group(1)
String MINOR = matcher.group(3)
String PATCH = matcher.group(4)
- if( PATCH.length() != 0 ){
+ if (PATCH.length() != 0) {
// patch present
def patchMatcher = Pattern.compile("^(-)([0-9]*)(-.*)").matcher(PATCH)
- if( patchMatcher.matches() ){
+ if (patchMatcher.matches()) {
PATCH = patchMatcher.group(2)
} else {
PATCH = "0"
@@ -45,22 +45,22 @@ buildscript {
google()
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.4.1'
- if ( project.hasProperty("artifactoryUser") && project.hasProperty("artifactoryPassword") ) {
- classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.7.3"
+ classpath 'com.android.tools.build:gradle:4.1.1'
+ if (project.hasProperty("artifactoryUser") && project.hasProperty("artifactoryPassword")) {
+ classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.18.0"
}
}
}
android {
compileSdkVersion 29
- buildToolsVersion '28.0.3'
+ buildToolsVersion '29.0.3'
defaultConfig {
minSdkVersion 21
targetSdkVersion 29
- versionCode 13
- versionName "13"
+ versionCode 14
+ versionName "14"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes.all { buildType ->
@@ -86,12 +86,12 @@ android {
}
}
-if ( project.hasProperty("artifactoryUser") && project.hasProperty("artifactoryPassword") ) {
+if (project.hasProperty("artifactoryUser") && project.hasProperty("artifactoryPassword")) {
publishing {
publications {
aar(MavenPublication) {
groupId 'com.polar'
- version = getVersion()
+ version = getVersion()
artifactId project.getName()
// Tell maven to prepare the generated "*.aar" file for publishing
@@ -116,21 +116,17 @@ if ( project.hasProperty("artifactoryUser") && project.hasProperty("artifactoryP
}
defaults {
// Tell the Artifactory Plugin which artifacts should be published to Artifactory.
- /* publications {
- mavenJava(MavenPublication) {
- from components.java
- artifact (sourcesJar) {
- classifier = 'sources'
- }
- }
- }*/
+ /* publications {
+ mavenJava(MavenPublication) {
+ from components.java
+ artifact (sourcesJar) {
+ classifier = 'sources'
+ }
+ }
+ }*/
publications('aar')
- publishArtifacts = true
-
// Properties to be attached to the published artifacts.
properties = ['qa.level': 'basic', 'dev.team': 'core']
- // Publish generated POM files to Artifactory (true by default)
- publishPom = true
}
}
}
@@ -160,21 +156,16 @@ artifacts {
}
dependencies {
- implementation fileTree(include: ['*.jar'], dir: 'libs')
- if (project.hasProperty("buildSdk")) {
- implementation files('libs/polar-protobuf-release.aar')
- implementation 'com.google.protobuf:protobuf-java:3.1.0'
- } else {
- implementation project(':polar-protobuf')
- implementation 'com.google.protobuf:protobuf-java:3.1.0'
- }
- testImplementation 'junit:junit:4.13'
- testImplementation "org.mockito:mockito-core:3.2.4"
- testImplementation "io.mockk:mockk:1.9.3"
- androidTestImplementation 'androidx.test:runner:1.2.0'
- androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
+ compileOnly files('libs/polar-protobuf-release.aar')
+ implementation 'com.google.protobuf:protobuf-java:3.14.0'
implementation 'io.reactivex.rxjava3:rxandroid:3.0.0'
implementation 'io.reactivex.rxjava3:rxjava:3.0.0'
- implementation 'commons-io:commons-io:2.4'
- implementation 'com.android.support:support-annotations:28.0.0'
+ implementation 'commons-io:commons-io:2.8.0'
+ implementation 'androidx.annotation:annotation:1.1.0'
+ testImplementation 'junit:junit:4.13.1'
+ testImplementation "org.mockito:mockito-core:3.2.4"
+ testImplementation "io.mockk:mockk:1.9.3"
+ androidTestImplementation 'androidx.test.ext:junit:1.1.2'
+ androidTestImplementation 'androidx.test:runner:1.3.0'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
diff --git a/sources/Android/android-communications/gradle.properties b/sources/Android/android-communications/gradle.properties
index 256f7c47..d015431a 100644
--- a/sources/Android/android-communications/gradle.properties
+++ b/sources/Android/android-communications/gradle.properties
@@ -1,23 +1,2 @@
-## Project-wide Gradle settings.
-#
-# For more details on how to configure your build environment visit
-# http://www.gradle.org/docs/current/userguide/build_environment.html
-#
-# Specifies the JVM arguments used for the daemon process.
-# The setting is particularly useful for tweaking memory settings.
-# Default value: -Xmx10248m -XX:MaxPermSize=256m
-# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
-#
-# When configured, Gradle will run in incubating parallel mode.
-# This option should only be used with decoupled projects. More details, visit
-# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
-# org.gradle.parallel=true
-#Fri Jan 08 14:58:04 EET 2016
-#systemProp.https.nonProxyHosts=*.peg, *.grp, *.local, 193.143.6*.*, 192.168.*.*
-#systemProp.https.proxyPort=8080
-#systemProp.http.proxyHost=caterpillar.polar.fi
-#systemProp.http.nonProxyHosts=*.peg, *.grp, *.local, 193.143.6*.*, 192.168.*.*
-#systemProp.https.proxyHost=caterpillar.polar.fi
-#systemProp.http.proxyPort=8080
-android.useDeprecatedNdk=true
-org.gradle.daemon=true
\ No newline at end of file
+android.useAndroidX=true
+android.enableJetifier=true
\ No newline at end of file
diff --git a/sources/Android/android-communications/gradle/wrapper/gradle-wrapper.jar b/sources/Android/android-communications/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 00000000..f6b961fd
Binary files /dev/null and b/sources/Android/android-communications/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/sources/Android/android-communications/gradle/wrapper/gradle-wrapper.properties b/sources/Android/android-communications/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 00000000..897434a3
--- /dev/null
+++ b/sources/Android/android-communications/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Tue Sep 29 09:15:31 EEST 2020
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
diff --git a/sources/Android/android-communications/gradlew b/sources/Android/android-communications/gradlew
new file mode 100755
index 00000000..cccdd3d5
--- /dev/null
+++ b/sources/Android/android-communications/gradlew
@@ -0,0 +1,172 @@
+#!/usr/bin/env sh
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+ echo "$*"
+}
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
+}
+APP_ARGS=$(save "$@")
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
+if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
+ cd "$(dirname "$0")"
+fi
+
+exec "$JAVACMD" "$@"
diff --git a/sources/Android/android-communications/gradlew.bat b/sources/Android/android-communications/gradlew.bat
new file mode 100644
index 00000000..e95643d6
--- /dev/null
+++ b/sources/Android/android-communications/gradlew.bat
@@ -0,0 +1,84 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/sources/Android/android-communications/sdk/build.gradle b/sources/Android/android-communications/sdk/build.gradle
index db878b73..cde95e5a 100755
--- a/sources/Android/android-communications/sdk/build.gradle
+++ b/sources/Android/android-communications/sdk/build.gradle
@@ -10,15 +10,15 @@ def getVersion = { ->
standardOutput = stdout
}
def pattern = Pattern.compile("^([0-9]*)(\\.)([0-9]*)(.*)\$")
- def matcher = pattern.matcher(stdout.toString().trim());
- if( matcher.matches() ) {
+ def matcher = pattern.matcher(stdout.toString().trim())
+ if (matcher.matches()) {
String MAJOR = matcher.group(1)
String MINOR = matcher.group(3)
String PATCH = matcher.group(4)
- if( PATCH.length() != 0 ){
+ if (PATCH.length() != 0) {
// patch present
def patchMatcher = Pattern.compile("^(-)([0-9]*)(-.*)").matcher(PATCH)
- if( patchMatcher.matches() ){
+ if (patchMatcher.matches()) {
PATCH = patchMatcher.group(2)
} else {
PATCH = "0"
@@ -39,8 +39,8 @@ buildscript {
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.2.1'
- classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.0.1"
+ classpath 'com.android.tools.build:gradle:4.1.1'
+ classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.18.0"
}
}
@@ -48,7 +48,7 @@ publishing {
publications {
zip(MavenPublication) {
groupId 'com.polar'
- version = getVersion()
+ version = getVersion()
artifactId 'polar-ble-android-sdk'
artifact("polar-ble-sdk.zip")
}
@@ -81,7 +81,3 @@ artifactory {
}
}
}
-
-task wrapper(type: Wrapper){
- gradleVersion = '4.7'
-}
diff --git a/sources/Android/android-communications/sdk/build_sdk.sh b/sources/Android/android-communications/sdk/build_sdk.sh
index 2c024adb..c3932f91 100644
--- a/sources/Android/android-communications/sdk/build_sdk.sh
+++ b/sources/Android/android-communications/sdk/build_sdk.sh
@@ -6,11 +6,12 @@ if [ $# -ne 2 ]
exit 1
fi
cd ..
-gradle assembleRelease androidJavadocsJar -PbuildSdk
+./gradlew assembleRelease androidJavadocsJar
cp build/outputs/aar/android-communications-release.aar sdk/polar-ble-sdk.aar
-cp build/outputs/aar/android-communications-release.aar sdk/androidBleSdkTestApp/app/libs/polar-ble-sdk.aar
+cp build/outputs/aar/android-communications-release.aar ../../../polar-sdk-android/libs/polar-ble-sdk.aar
+cp build/outputs/aar/android-communications-release.aar ../../../examples/example-android/androidBleSdkTestApp/app/libs/polar-ble-sdk.aar
cp libs/polar-protobuf-release.aar sdk/polar-protobuf-release.aar
-cp libs/polar-protobuf-release.aar sdk/androidBleSdkTestApp/app/libs/polar-protobuf-release.aar
+cp libs/polar-protobuf-release.aar ../../../examples/example-android/androidBleSdkTestApp/app/libs/polar-protobuf-release.aar
rm -fr sdk/docs/
mkdir sdk/docs/
cp build/libs/android-communications-javadoc.jar sdk/docs/polar-ble-sdk-docs.jar
diff --git a/sources/Android/android-communications/src/androidTest/java/com/androidcommunications/polar/InstrumentedTests.kt b/sources/Android/android-communications/src/androidTest/java/com/androidcommunications/polar/InstrumentedTests.kt
index 81e5e6dc..8cdbc769 100644
--- a/sources/Android/android-communications/src/androidTest/java/com/androidcommunications/polar/InstrumentedTests.kt
+++ b/sources/Android/android-communications/src/androidTest/java/com/androidcommunications/polar/InstrumentedTests.kt
@@ -1,8 +1,8 @@
package com.androidcommunications.polar
import android.content.Context
-import androidx.test.InstrumentationRegistry
-import androidx.test.runner.AndroidJUnit4
+import androidx.test.platform.app.InstrumentationRegistry
+import androidx.test.ext.junit.runners.AndroidJUnit4
import com.androidcommunications.polar.api.ble.model.BleDeviceSession
import com.androidcommunications.polar.enpoints.ble.bluedroid.host.BDDeviceSessionImpl
import com.androidcommunications.polar.enpoints.ble.bluedroid.host.connection.ConnectionHandler
@@ -34,7 +34,7 @@ class InstrumentedTests {
@Before
fun setUp() {
targetContext = InstrumentationRegistry.getInstrumentation().targetContext
- connectionHandler = ConnectionHandler(targetContext, connectionInterface, scannerInterface, connectionHandlerObserver)
+ connectionHandler = ConnectionHandler(connectionInterface, scannerInterface, connectionHandlerObserver)
}
@Test
diff --git a/sources/Android/android-communications/src/main/AndroidManifest.xml b/sources/Android/android-communications/src/main/AndroidManifest.xml
index d498bcf5..b5e5e5b6 100755
--- a/sources/Android/android-communications/src/main/AndroidManifest.xml
+++ b/sources/Android/android-communications/src/main/AndroidManifest.xml
@@ -2,9 +2,7 @@
package="com.androidcommunications.polar">
-
-
diff --git a/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/BleDeviceListener.java b/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/BleDeviceListener.java
index 23a07c09..6d9c14ab 100755
--- a/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/BleDeviceListener.java
+++ b/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/BleDeviceListener.java
@@ -1,9 +1,9 @@
package com.androidcommunications.polar.api.ble;
import android.bluetooth.le.ScanFilter;
-import android.support.annotation.IntDef;
-import android.support.annotation.IntRange;
-import android.support.annotation.Nullable;
+import androidx.annotation.IntDef;
+import androidx.annotation.IntRange;
+import androidx.annotation.Nullable;
import android.util.Pair;
import com.androidcommunications.polar.api.ble.model.BleDeviceSession;
diff --git a/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/gatt/BleGattFactory.java b/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/gatt/BleGattFactory.java
index 434c96e4..ee33865b 100755
--- a/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/gatt/BleGattFactory.java
+++ b/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/gatt/BleGattFactory.java
@@ -1,6 +1,6 @@
package com.androidcommunications.polar.api.ble.model.gatt;
-import android.support.annotation.NonNull;
+import androidx.annotation.NonNull;
import com.androidcommunications.polar.api.ble.BleLogger;
import com.androidcommunications.polar.api.ble.model.gatt.client.BleBattClient;
diff --git a/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/gatt/client/BleBattClient.java b/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/gatt/client/BleBattClient.java
index 218a56bc..b9b09409 100644
--- a/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/gatt/client/BleBattClient.java
+++ b/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/gatt/client/BleBattClient.java
@@ -1,6 +1,6 @@
package com.androidcommunications.polar.api.ble.model.gatt.client;
-import android.support.annotation.NonNull;
+import androidx.annotation.NonNull;
import com.androidcommunications.polar.api.ble.exceptions.BleDisconnected;
import com.androidcommunications.polar.api.ble.model.gatt.BleGattBase;
diff --git a/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/gatt/client/BleDisClient.java b/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/gatt/client/BleDisClient.java
index 6fb1604c..d4f01341 100644
--- a/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/gatt/client/BleDisClient.java
+++ b/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/gatt/client/BleDisClient.java
@@ -1,6 +1,6 @@
package com.androidcommunications.polar.api.ble.model.gatt.client;
-import android.support.annotation.NonNull;
+import androidx.annotation.NonNull;
import android.util.Pair;
import com.androidcommunications.polar.api.ble.exceptions.BleAttributeError;
diff --git a/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/gatt/client/BleGapClient.java b/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/gatt/client/BleGapClient.java
index eba0b215..eba1a8f6 100644
--- a/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/gatt/client/BleGapClient.java
+++ b/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/gatt/client/BleGapClient.java
@@ -1,6 +1,6 @@
package com.androidcommunications.polar.api.ble.model.gatt.client;
-import android.support.annotation.NonNull;
+import androidx.annotation.NonNull;
import com.androidcommunications.polar.api.ble.exceptions.BleDisconnected;
import com.androidcommunications.polar.api.ble.model.gatt.BleGattBase;
diff --git a/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/gatt/client/BleH7SettingsClient.java b/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/gatt/client/BleH7SettingsClient.java
index b6111f11..750c6dba 100644
--- a/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/gatt/client/BleH7SettingsClient.java
+++ b/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/gatt/client/BleH7SettingsClient.java
@@ -1,6 +1,6 @@
package com.androidcommunications.polar.api.ble.model.gatt.client;
-import android.support.annotation.NonNull;
+import androidx.annotation.NonNull;
import com.androidcommunications.polar.api.ble.exceptions.BleCharacteristicNotFound;
import com.androidcommunications.polar.api.ble.exceptions.BleDisconnected;
diff --git a/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/gatt/client/BleHrClient.java b/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/gatt/client/BleHrClient.java
index 16766dd2..c7ad0d5d 100755
--- a/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/gatt/client/BleHrClient.java
+++ b/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/gatt/client/BleHrClient.java
@@ -1,6 +1,6 @@
package com.androidcommunications.polar.api.ble.model.gatt.client;
-import android.support.annotation.NonNull;
+import androidx.annotation.NonNull;
import com.androidcommunications.polar.api.ble.model.gatt.BleGattBase;
import com.androidcommunications.polar.api.ble.model.gatt.BleGattTxInterface;
diff --git a/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/gatt/client/BlePMDClient.java b/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/gatt/client/BlePMDClient.java
index 9e3860f9..b9079010 100644
--- a/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/gatt/client/BlePMDClient.java
+++ b/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/gatt/client/BlePMDClient.java
@@ -1,6 +1,6 @@
package com.androidcommunications.polar.api.ble.model.gatt.client;
-import android.support.annotation.NonNull;
+import androidx.annotation.NonNull;
import android.util.Pair;
import com.androidcommunications.polar.api.ble.BleLogger;
@@ -57,6 +57,7 @@ public class BlePMDClient extends BleGattBase {
private final AtomicSet>> afeOperationModeObservers = new AtomicSet<>();
private final AtomicSet>> sportIdObservers = new AtomicSet<>();
private final AtomicSet > biozObservers = new AtomicSet<>();
+ private final AtomicSet> rdObservers = new AtomicSet<>();
private byte[] pmdFeatureData = null;
private final Object mutexFeature = new Object();
@@ -547,6 +548,7 @@ public void reset(){
RxUtils.postDisconnectedAndClearList(biozObservers);
RxUtils.postDisconnectedAndClearList(afeOperationModeObservers);
RxUtils.postDisconnectedAndClearList(sportIdObservers);
+ RxUtils.postDisconnectedAndClearList(rdObservers);
synchronized (mutexFeature){
pmdFeatureData = null;
@@ -642,8 +644,10 @@ public void processServiceData(UUID characteristic, final byte[] data, int statu
}
break;
case GYRO:
- break;
default:
+ final byte[] rdData = new byte[data.length-1];
+ System.arraycopy(data,1,content,0,content.length);
+ RxUtils.emitNext(rdObservers, object -> object.onNext(rdData));
break;
}
} else {
@@ -885,6 +889,10 @@ public Flowable> monitorSportId(final boolean checkConnection) {
return RxUtils.monitorNotifications(sportIdObservers,txInterface,checkConnection);
}
+ public Flowable monitorRDData(final boolean checkConnection) {
+ return RxUtils.monitorNotifications(rdObservers,txInterface,checkConnection);
+ }
+
@Override
public Completable clientReady(boolean checkConnection) {
return Completable.concatArray(waitNotificationEnabled(PMD_CP,true),
diff --git a/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/gatt/client/BlePfcClient.java b/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/gatt/client/BlePfcClient.java
index d15e398b..cbb0031e 100644
--- a/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/gatt/client/BlePfcClient.java
+++ b/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/gatt/client/BlePfcClient.java
@@ -1,6 +1,6 @@
package com.androidcommunications.polar.api.ble.model.gatt.client;
-import android.support.annotation.NonNull;
+import androidx.annotation.NonNull;
import android.util.Pair;
import com.androidcommunications.polar.api.ble.exceptions.BleAttributeError;
diff --git a/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/gatt/client/BlePsdClient.java b/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/gatt/client/BlePsdClient.java
index 8aaf619d..e457c086 100644
--- a/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/gatt/client/BlePsdClient.java
+++ b/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/gatt/client/BlePsdClient.java
@@ -1,6 +1,6 @@
package com.androidcommunications.polar.api.ble.model.gatt.client;
-import android.support.annotation.NonNull;
+import androidx.annotation.NonNull;
import android.util.Pair;
import com.androidcommunications.polar.api.ble.exceptions.BleAttributeError;
diff --git a/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/gatt/client/BleRscClient.java b/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/gatt/client/BleRscClient.java
index e1a71d44..7c67c6a2 100644
--- a/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/gatt/client/BleRscClient.java
+++ b/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/gatt/client/BleRscClient.java
@@ -1,6 +1,6 @@
package com.androidcommunications.polar.api.ble.model.gatt.client;
-import android.support.annotation.NonNull;
+import androidx.annotation.NonNull;
import com.androidcommunications.polar.api.ble.BleLogger;
import com.androidcommunications.polar.api.ble.model.gatt.BleGattBase;
diff --git a/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/gatt/client/psftp/BlePsFtpClient.java b/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/gatt/client/psftp/BlePsFtpClient.java
index 4db1ad07..e9121067 100644
--- a/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/gatt/client/psftp/BlePsFtpClient.java
+++ b/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/gatt/client/psftp/BlePsFtpClient.java
@@ -1,6 +1,6 @@
package com.androidcommunications.polar.api.ble.model.gatt.client.psftp;
-import android.support.annotation.NonNull;
+import androidx.annotation.NonNull;
import android.util.Pair;
import com.androidcommunications.polar.api.ble.BleLogger;
diff --git a/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/polar/BlePolarDeviceIdUtility.java b/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/polar/BlePolarDeviceIdUtility.java
index 62d47563..fadc4899 100644
--- a/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/polar/BlePolarDeviceIdUtility.java
+++ b/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/api/ble/model/polar/BlePolarDeviceIdUtility.java
@@ -2,6 +2,7 @@
public class BlePolarDeviceIdUtility {
public static boolean isValidDeviceId(final String deviceId){
+ if (deviceId == null) return false;
if (deviceId.length() == 8) {
return checkSumForDeviceId(Long.parseLong(deviceId, 16), 8) == (Long.parseLong(deviceId, 16) & 0x000000000000000FL);
}
diff --git a/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/enpoints/ble/bluedroid/host/AttributeOperation.java b/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/enpoints/ble/bluedroid/host/AttributeOperation.java
index 4bb4c36c..bbdc741b 100644
--- a/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/enpoints/ble/bluedroid/host/AttributeOperation.java
+++ b/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/enpoints/ble/bluedroid/host/AttributeOperation.java
@@ -1,7 +1,7 @@
package com.androidcommunications.polar.enpoints.ble.bluedroid.host;
import android.bluetooth.BluetoothGattCharacteristic;
-import android.support.annotation.NonNull;
+import androidx.annotation.NonNull;
public class AttributeOperation implements Comparable{
diff --git a/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/enpoints/ble/bluedroid/host/BDDeviceListenerImpl.java b/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/enpoints/ble/bluedroid/host/BDDeviceListenerImpl.java
index 3693a07a..1e2bde87 100755
--- a/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/enpoints/ble/bluedroid/host/BDDeviceListenerImpl.java
+++ b/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/enpoints/ble/bluedroid/host/BDDeviceListenerImpl.java
@@ -8,7 +8,7 @@
import android.bluetooth.le.ScanFilter;
import android.content.Context;
import android.os.Build;
-import android.support.annotation.Nullable;
+import androidx.annotation.Nullable;
import com.androidcommunications.polar.api.ble.BleDeviceListener;
import com.androidcommunications.polar.api.ble.BleLogger;
diff --git a/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/enpoints/ble/bluedroid/host/BDDeviceSessionImpl.java b/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/enpoints/ble/bluedroid/host/BDDeviceSessionImpl.java
index 52a53caf..565e5121 100755
--- a/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/enpoints/ble/bluedroid/host/BDDeviceSessionImpl.java
+++ b/sources/Android/android-communications/src/main/java/com/androidcommunications/polar/enpoints/ble/bluedroid/host/BDDeviceSessionImpl.java
@@ -7,7 +7,7 @@
import android.bluetooth.BluetoothGattService;
import android.content.Context;
import android.os.Handler;
-import android.support.annotation.VisibleForTesting;
+import androidx.annotation.VisibleForTesting;
import com.androidcommunications.polar.BuildConfig;
import com.androidcommunications.polar.api.ble.BleLogger;
diff --git a/sources/Android/android-communications/src/main/java/polar/com/sdk/api/PolarBleApi.java b/sources/Android/android-communications/src/main/java/polar/com/sdk/api/PolarBleApi.java
index 36c2e592..a6479d04 100644
--- a/sources/Android/android-communications/src/main/java/polar/com/sdk/api/PolarBleApi.java
+++ b/sources/Android/android-communications/src/main/java/polar/com/sdk/api/PolarBleApi.java
@@ -1,9 +1,9 @@
// Copyright © 2019 Polar Electro Oy. All rights reserved.
package polar.com.sdk.api;
-import android.support.annotation.IntRange;
-import android.support.annotation.Nullable;
-import android.support.annotation.Size;
+import androidx.annotation.IntRange;
+import androidx.annotation.Nullable;
+import androidx.annotation.Size;
import android.util.Pair;
import java.util.Calendar;
diff --git a/sources/Android/android-communications/src/main/java/polar/com/sdk/api/PolarBleApiCallback.java b/sources/Android/android-communications/src/main/java/polar/com/sdk/api/PolarBleApiCallback.java
index f77247f9..edeb2cab 100644
--- a/sources/Android/android-communications/src/main/java/polar/com/sdk/api/PolarBleApiCallback.java
+++ b/sources/Android/android-communications/src/main/java/polar/com/sdk/api/PolarBleApiCallback.java
@@ -1,7 +1,7 @@
// Copyright © 2019 Polar Electro Oy. All rights reserved.
package polar.com.sdk.api;
-import android.support.annotation.NonNull;
+import androidx.annotation.NonNull;
import java.util.UUID;
diff --git a/sources/Android/android-communications/src/main/java/polar/com/sdk/api/PolarBleApiCallbackProvider.java b/sources/Android/android-communications/src/main/java/polar/com/sdk/api/PolarBleApiCallbackProvider.java
index 047caae3..d24975f3 100644
--- a/sources/Android/android-communications/src/main/java/polar/com/sdk/api/PolarBleApiCallbackProvider.java
+++ b/sources/Android/android-communications/src/main/java/polar/com/sdk/api/PolarBleApiCallbackProvider.java
@@ -1,6 +1,6 @@
// Copyright © 2019 Polar Electro Oy. All rights reserved.
package polar.com.sdk.api;
-import android.support.annotation.NonNull;
+import androidx.annotation.NonNull;
import java.util.UUID;
diff --git a/sources/Android/android-communications/src/main/java/polar/com/sdk/impl/BDBleApiImpl.java b/sources/Android/android-communications/src/main/java/polar/com/sdk/impl/BDBleApiImpl.java
index 8fe2de43..1b798a05 100644
--- a/sources/Android/android-communications/src/main/java/polar/com/sdk/impl/BDBleApiImpl.java
+++ b/sources/Android/android-communications/src/main/java/polar/com/sdk/impl/BDBleApiImpl.java
@@ -6,9 +6,10 @@
import android.content.Context;
import android.os.Build;
import android.os.ParcelUuid;
-import android.support.annotation.Nullable;
import android.util.Pair;
+import androidx.annotation.Nullable;
+
import com.androidcommunications.polar.api.ble.BleDeviceListener;
import com.androidcommunications.polar.api.ble.BleLogger;
import com.androidcommunications.polar.api.ble.exceptions.BleDisconnected;