-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question] get Paired Devices #428
Comments
This library uses RxAndroidBle and RxBluetoothKit. This librarires offers this feature but unfortunately I didn't find it* in FlutterBleLib... Don't sure why. EDIT: *for android For RxAndroidBle: For native iOS: https://developer.apple.com/documentation/corebluetooth/cbcentralmanager/1518924-retrieveconnectedperipherals For native Android: https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#getBondedDevices() |
The iOS method is exposed as |
Thank you. |
Ah, this explains why flutter_blue does it like this: https://github.com/pauldemarco/flutter_blue/blob/2ccdc68d474c158ae7cfbcae993e430a578173ec/android/src/main/java/com/pauldemarco/flutter_blue/FlutterBluePlugin.java#L173 |
I wrote a method in Java to handle fetching boundedDevices: @RequiresPermission(Manifest.permission.BLUETOOTH)
private void getPairedDevices(@NonNull final MethodChannel.Result result) {
Log.d(TAG, "Get paired devices");
bleAdapter.getKnownDevices(deviceIdentifiers.toArray(new String[deviceIdentifiers.size()]) ,new OnSuccessCallback<Device[]>() { final SafeMainThreadResolver resolver = new SafeMainThreadResolver<>(new OnSuccessCallback<Device[]>() {
@Override @Override
public void onSuccess(Device[] devices) { public void onSuccess(Device[] devices) {
Log.d(TAG, "Found known devices" + devices.length); try {
resolver.onSuccess(devices); result.success(devicesResultJsonConverter.toJson(devices));
} catch (JSONException e) {
e.printStackTrace();
result.error(null, e.getMessage(), null);
}
} }
}, new OnErrorCallback() { }, new OnErrorCallback() {
@Override @Override
public void onError(BleError error) { public void onError(BleError error) {
resolver.onError(error); Log.e(TAG, "Get paired devices error " + error.reason + " " + error.internalMessage);
result.error(String.valueOf(error.errorCode.code), error.reason, bleErrorJsonConverter.toJson(error));
} }
}); });
Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
List<Device> devices = new ArrayList<>();
for (int i = 0; i < pairedDevices.size(); i++) {
BluetoothDevice blDevice = pairedDevices.iterator().next();
Device device = new Device(blDevice.getAddress(), blDevice.getName());
devices.add(device);
}
Log.d(TAG, "Found paired devices" + devices.size());
resolver.onSuccess(devices);
}
} But I am getting an error from my forked Branch: MissingPluginException(Noimplementation found for method getPairedDevices on channel flutter_ble_lib) |
@Ahmadre This issue has to be fixed in MultiPlatformBleAdapter, but we didn't have the time to take care of it yet. |
Are there any updates on this? I'm currently in the situation that I need to get a device that could potentially already be paired with my android phone. |
Sorry, no updates yet. I finally have some time for the libraries, so work on FlutterBleLib and BLEmulator has started, but I'm unable to give you any timeline for this issue right now. |
Same problem, hope update to can getting Paired Devices, thanks. |
Also need this functionality |
any updated regarding this |
Hello you all, firstly let me say that you guys did an awesome job creating this library, the example folder is helpful as well.
But I'm not sure where I can find how to get the Bonded devices (Paired ones), and how to connect to this devices?
Thanks a lot.
The text was updated successfully, but these errors were encountered: