-
Notifications
You must be signed in to change notification settings - Fork 44
Description
BLE Challenges,
When searching for new sensor the system find them during scan
but fail or takes many tries to recognize them as having supported service.
Could not find the reason….
We may have too many sensor around?
==> Would it make sense to scan only for supported services? to improve probability of support?
in BleScannerSDK21 add:
private final ScanSettings settings = new ScanSettings.Builder()
.setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY)
.build();
private final ScanFilter HrFilter = new ScanFilter.Builder()
.setServiceUuid(ParcelUuid.fromString("0000180d-0000-1000-8000-00805f9b34fb"))
.build();
private final ScanFilter CscFilter = new ScanFilter.Builder()
.setServiceUuid(ParcelUuid.fromString("00001816-0000-1000-8000-00805f9b34fb"))
.build();
private final ArrayList<ScanFilter> Uuidfilters = new ArrayList<ScanFilter>(Arrays.asList(HrFilter, CscFilter));
and replace startScan parameters:
scanner.startScan(Uuidfilters, settings, callback);
// scanner.startScan(callback);
Issues are open on this subject:
#70
Workaround (last resort) not very elegent:
- Edit the configuration database with name & mac address ;-(
- Or configure the address of sensors?
——————
After we have Sensors recognized as supported and enabled.
Getting them connected is complex exercise, We have « Connecting… » for a while.
Some time, rescan or disable & enable works?
In order to keep connection and being able to work in parallel the system use
connectGatt( context, « autoConnect » …)
found that BLE on Android is not as straight forward as we would expect
It looks that one of key element to connect with « autoConnect » is to have the sensor in the cash beforehand.
But we have difficulty to get there…..
Workaround to have servers in the cache, if they have disappeared, e.g. reboot, Bluetooth off and back on…:
- before launching AAT connect and disconnect the sensors to get them in « cache » with e.g. with nRF Connect
Good articles with references which may help:
https://medium.com/@martijn.van.welie/making-android-ble-work-part-1-a736dcd53b02
https://medium.com/@martijn.van.welie/making-android-ble-work-part-2-47a3cdaade07
and code examples:
https://github.com/NordicSemiconductor/Android-BLE-Library/blob/master/ble/src/main/java/no/nordicsemi/android/ble/BleManager.java#L140
https://github.com/NordicSemiconductor/Android-BLE-Library/blob/master/ble/src/main/java/no/nordicsemi/android/ble/BleManager.java#L563
https://github.com/weliem/blessed-android/blob/master/blessed/src/main/java/com/welie/blessed/BluetoothCentral.java#L543
https://github.com/weliem/blessed-android/blob/master/blessed/src/main/java/com/welie/blessed/BluetoothCentral.java#L563
https://github.com/weliem/blessed-android/blob/master/blessed/src/main/java/com/welie/blessed/BluetoothCentral.java#L609