Skip to content
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

您好,BleRssiDevice 对象能支持转换为BluetoothDevice吗? #104

Open
PPLLock opened this issue Sep 26, 2022 · 1 comment
Open

Comments

@PPLLock
Copy link

PPLLock commented Sep 26, 2022

您好,感谢分享这个框架,BleRssiDevice 对象能支持转换为BluetoothDevice吗?我们接入第三方蓝牙SDK,需要传入BluetoothDevice对象类型完成初始化,我看到库中所有的扫描和连接对象都是BleRssDevice

@StrikeZXA
Copy link

我也和你查找类似的方法,但也找不到,基于3.3.1版本直接修改了源码

下载框架后,在自己工程引入core,然后按下面修改即可

类BleWrapperCallback的onLeScan方法修改成如下
@Override public void onLeScan(BluetoothDevice originalDevice, T device, int rssi, byte[] scanRecord) { }

类ScanRequest修改成如下
@Override public void onLeScan(BluetoothDevice device, int rssi, byte[] scanRecord) { if (device == null) return; String address = device.getAddress(); T bleDevice = getDevice(address); if (bleDevice == null) { bleDevice = (T) Ble.options().getFactory().create(address, device.getName()); bleDevice.setDeviceType(device.getType()); if (bleScanCallback != null) { bleScanCallback.onLeScan(device,bleDevice, rssi, scanRecord); } if (bleWrapperCallback != null){ bleWrapperCallback.onLeScan(device,bleDevice, rssi, scanRecord); } scanDevices.put(device.getAddress(), bleDevice); } else { if (!Ble.options().isIgnoreRepeat) {//无需过滤 if (bleScanCallback != null) { bleScanCallback.onLeScan(device,bleDevice, rssi, scanRecord); } if (bleWrapperCallback != null){ bleWrapperCallback.onLeScan(device,bleDevice, rssi, scanRecord); } } } }

类BleScanCallback
public abstract void onLeScan(BluetoothDevice originalDevice, T device, int rssi, byte[] scanRecord);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants