Skip to content

Commit

Permalink
Add details about new function from EmpaStatusDelegate
Browse files Browse the repository at this point in the history
  • Loading branch information
samueleperricone committed Nov 18, 2020
1 parent 7432f22 commit 2069207
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions app/src/main/java/com/empatica/sample/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 2069207

Please sign in to comment.