Jasonchenlijian / FastBle

Android Bluetooth Low Energy (BLE) Fast Development Framework. It uses simple ways to filter, scan, connect, read ,write, notify, readRssi, setMTU, and multiConnection.
Apache License 2.0
5.28k stars 1.22k forks source link

Urgent :: Samsung Device weird Issue. #541

Open sw-tt-kushanshah opened 2 years ago

sw-tt-kushanshah commented 2 years ago

Hi @Jasonchenlijian and @liaolintao,

recently i face weird issue on samsung device operating android 11 and 12 OS. when i read or write command it will compare with key with below function of MultipleBluetoothController

public synchronized BleBluetooth getBleBluetooth(BleDevice bleDevice) { if (bleDevice != null) { if (bleLruHashMap.containsKey(bleDevice.getKey())) { return bleLruHashMap.get(bleDevice.getKey()); } } return null; }

in this bleLruHashMap has name null & mac address and in BleDevice has name & mac address. i m attaching snap for reference. ISSUE comes very first time when i install app and after restart device first launch(It will throw 102 - device not connected default Error handle).

I have apply ScanRule as below.

-------------------------------START OF CODE---------------------------------------- val scanRuleConfig = BleScanRuleConfig.Builder() .setServiceUuids(null) .setDeviceName(true, "") .setDeviceMac(SharedPref.instance!!.getValueFromPreferences(getString(R.string.pref_device_mac))) .setAutoConnect(true) .setScanTimeOut(18000000) .build() BleManager.getInstance().initScanRule(scanRuleConfig) -----------------------------------------END OF CODE------------------------------------------------

Image Reference 1

image

Image Reference 2

image

Help Appreciated. thanks in advance.