aws / amazon-freertos-ble-android-sdk

Android SDK for FreeRTOS Bluetooth Devices.
Apache License 2.0
49 stars 41 forks source link

onClientConnectionState() - status=133 clientIf=7 #9

Closed ravirupareliya closed 2 years ago

ravirupareliya commented 4 years ago

Facing this error while connecting to ble in some android devices. Majorly it is in motorola, samsung and redmi. Specifically for OS 7.0 and 7.1.1

Other OS and device it is working perfect.

When I am trying to connect, it immediately calls onClientConnectionStatus with gatt error 133.

Any solution for this?

D/BluetoothGatt: onClientConnectionState() - status=133 clientIf=7 device={deviceId} I/AmazonFreeRTOSDevice: BLE connection state changed: 133; new state: BLE_DISCONNECTED

bxpan commented 4 years ago

The status error 133 means that the bluetooth connection is closed from the remote device it is trying to connect.

What is the bluetooth version on the phones that have issue? Are they different than those phones that worked?

Could you provide the full log from your phone as well as the full log from the device it is trying to connect to, from the beginning of your app launched till the issue happened?

ravirupareliya commented 4 years ago

Bluetooth version of device is 4.2, It is moto e4. I cannot find logs from device as I am not aware of it. About phone log this is what I am getting, it is trying to connect few times but then suddenly it gives 133 error.

D/BluetoothGatt: onClientConnectionState() - status=133 clientIf=7 device={deviceId} I/AmazonFreeRTOSDevice: BLE connection state changed: 133; new state: BLE_DISCONNECTED

Sometime it takes time to show 133 error and sometime it immediately throw 133 error.

Here is some logs which might be useful

I/AmazonFreeRTOSManager: Stopping ble device scan D/BluetoothLeScanner: stopScan D/BluetoothAdapter: getLeState() returning 12 D/BluetoothAdapter: STATE_ON I/BluetoothLeScanner: startRegisteration: mLeScanClients={com.amazon.aws.amazonfreertossdk.AmazonFreeRTOSManager$2@5400467=android.bluetooth.le.BluetoothLeScanner$BleScanCallbackWrapper@c437214},callback=com.amazon.aws.amaonfreertossdk.AmazonFreeRTOSManager$2@5400467 D/BluetoothGatt: onClientConnectionState() - status=133 clientIf=7 device=3C:71:BF:8A:8F:FA I/AmazonFreeRTOSDevice: BLE connection state changed: 133; new state: BLE_DISCONNECTED I/AmazonFreeRTOSDevice: Disconnected from GATT server.

bxpan commented 4 years ago

Are you using the demo app or your own app?

Do you see any of these logs? D/BluetoothGatt: connect() - device: 30:AE:A4:4A:FE:4A, auto: true D/BluetoothGatt: onClientRegistered() - status=0 clientIf=8 D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=8 device=30:AE:A4:4A:FE:4A I/FRD: Connected to GATT server. I/FRD: Discovered Ble gatt services successfully. Bonding state: 12

ravirupareliya commented 4 years ago

Yes, it is there, even sometimes it gets connected also. But those are rare cases, I mean it gets connected to device only once or twice out of 10 times.

ravibhagavandas commented 4 years ago

@ravirupareliya

  1. Which micro-controller device are you using on other end of the connection ? Could you also mention the Amazon FreeRTOS version running on the micro-controller device ?

  2. By default the demo app and Amazon FreeRTOS is configured to run on highest security mode ( secure connection only with MITM protection). This means there is a pairing procedure with numeric comparison immediately after the GATT connection. Are you getting any pairing notifications on the demo app? For successful pairing, you have to also accept the numeric comparison code on device through a serial terminal. Please check To discover and establish secure connections with your microcontroller over Bluetooth Low Energy section in documentation page for more details.

  3. Could you collect device side logs by connecting to the serial terminal port of the micro-controller device. Depending on the micro-controller device you are using, you can get the details on this from board specific getting started guides here.

abhidixi11 commented 2 years ago

I'm closing this issue, please feel free to open a new one.