From 2069207f5468b0248b44114c081e7be9b396d6fa Mon Sep 17 00:00:00 2001 From: Samuele Perricone Date: Wed, 18 Nov 2020 11:42:53 +0100 Subject: [PATCH] Add details about new function from `EmpaStatusDelegate` --- .../com/empatica/sample/MainActivity.java | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/empatica/sample/MainActivity.java b/app/src/main/java/com/empatica/sample/MainActivity.java index 2121ad7..8750eac 100644 --- a/app/src/main/java/com/empatica/sample/MainActivity.java +++ b/app/src/main/java/com/empatica/sample/MainActivity.java @@ -4,6 +4,7 @@ import android.app.Activity; import android.app.AlertDialog; import android.bluetooth.BluetoothAdapter; +import android.bluetooth.le.ScanCallback; import android.content.DialogInterface; import android.content.Intent; import android.content.pm.PackageManager; @@ -233,7 +234,28 @@ public void didDiscoverDevice(EmpaticaDevice bluetoothDevice, String deviceName, @Override public void didFailedScanning(int errorCode) { - + + /* + A system error occurred while scanning. + @see https://developer.android.com/reference/android/bluetooth/le/ScanCallback + */ + switch (errorCode) { + case ScanCallback.SCAN_FAILED_ALREADY_STARTED: + Log.e(TAG,"Scan failed: a BLE scan with the same settings is already started by the app"); + break; + case ScanCallback.SCAN_FAILED_APPLICATION_REGISTRATION_FAILED: + Log.e(TAG,"Scan failed: app cannot be registered"); + break; + case ScanCallback.SCAN_FAILED_FEATURE_UNSUPPORTED: + Log.e(TAG,"Scan failed: power optimized scan feature is not supported"); + break; + case ScanCallback.SCAN_FAILED_INTERNAL_ERROR: + Log.e(TAG,"Scan failed: internal error"); + break; + default: + Log.e(TAG,"Scan failed with unknown error (errorCode=" + errorCode + ")"); + break; + } } @Override @@ -245,7 +267,10 @@ public void didRequestEnableBluetooth() { @Override public void bluetoothStateChanged() { - + // E4link detected a bluetooth adapter change + // Check bluetooth adapter and update your UI accordingly. + boolean isBluetoothOn = BluetoothAdapter.getDefaultAdapter().isEnabled(); + Log.i(TAG, "Bluetooth State Changed: " + isBluetoothOn); } @Override