randyJok
randyJok
关闭蓝牙,并重新打开后,会有部分Android机型出现,旧的已经连接的BleDevice.getName()为null,但实际存储在MultipleBluetoothController哈希表中的BleBluetooth依然没变 因此,当我们重新扫描蓝牙,扫描到新的设备进行连接时,实际上并没有更新在MultipleBluetoothController的哈希表中的BleBluetooth, 依然是使用断开蓝牙前的BleBluetooth, 所以会出现name为null,但是连接又成功的情况 目前我的解决办法是,将BleDevice中的getKey()方法进行修改,去掉名字前缀,以mac地址为准,即可解决

重新扫描后,会出现一个新的问题,经过验证,在三星和google的手机上,当关闭蓝牙时,对于已经连接过的设备,removeBleBluetooth()方法并不会调用,但是国产机基本都会调用。这就会导致扫描到设备进行重新连接时,会出现连接成功,但是setMtu和发现服务会失败的情况。 所以一旦手动关闭蓝牙,需要在蓝牙关闭的通知里面,将BleBluetooth移除掉。