Closed WangManAndroid closed 5 years ago
When the interface was stuck on connecting , I found that the log was print as follows: onClientRegistered() - status=0 clientIf=6 onClientConnectionState() - status=133 clientIf=6 device=98:12:88:77:00:0B
Hi @WangManAndroid different versions of Android have different Ble scanners. The Bluetooth scanner compat library is a backward compatible library that will give you a scanner instance based on the Android version.
I recommend you try the latest dev branch. Error 133 is a connection timeout. Also newer phones have always been more robust when it comes to reconnecting after provisioning, specially in Android Oreo onwards because it's very rarely you can see error 133. Still there was a bug that was stopping the UI navigating back to the scanning fragment. So it looks like the app was stuck but ideally it found the device and failed to connect and it should have gone back to the scanner fragment. Could you try the latest version in the Dev branch and let me know if you face this?
ok i`ll try it , Thanks for your reply
the Dev branch while provisioning cannot see status=133 but while scaning unprovisioned node then connecting it ,maby apare status=133 not every times
what causes status=133? i found the lower android version easier apare status=133, how to avoid?
It's usually a connection timeout. Sometimes you may find a device during a Bluetooth scan but might fail to connect. This case also happen of a device is turned off during the connection process. Usually it's thrown after about 30 seconds which is the default connection supervision timeout on Android. What you can also do is, when this error occurs, you can check if the status is 133 in the on connection status changed and try to reconnect.
thank your reply !
today I found new problems while Discovering services gatt.discoverServices(); @Override public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) { // It's possible here callback> status=133 }
in some android phone will heppen For example, some of xiaomi's mobile phones
Yeah this is possible, you just have to work around it in my opinion. Sometimes this depends on the Android version on certain devices. You can also try turning on/off the bluetooth on the device to see if it helps?
thanks your reply! yes I did like you said, it work! but Is there any other way?
Well the only way around this is to make sure all the bluetooth related communication is done in the UI Thread and add some delays before connecting etc.
public static BluetoothLeScannerCompat getScanner() { if (mInstance != null) return mInstance; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) return mInstance = new BluetoothLeScannerImplOreo(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) return mInstance = new BluetoothLeScannerImplMarshmallow(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) return mInstance = new BluetoothLeScannerImplLollipop(); return mInstance = new BluetoothLeScannerImplJB(); }
in my xiaomi 4>>will get BluetoothLeScannerImplMarshmallow (android 6.0) xiaomi mix 2>> will get BluetoothLeScannerImplOreo( android 8.0)could you tell me the diffrence of this?
i found xiaomi mix2 can scan provinsioned device easier than xiaomi 4, You can't even scan it on xiammi 4, i don
t know the reaseon of this condition , whiling provinsioning , onProvisioningComplete,
public void onProvisioningComplete(final ProvisionedMeshNode provisionedMeshNode) { provisionedMeshNode.setIsProvisioned(true); Debuger.d("onProvisioningComplete............"); mMeshNode = provisionedMeshNode; mIsProvisioningComplete = true;in this place the xiaomi 4 rescan so hard and you can't even scan it on xiammi 4, Is this a compatibility issue?