CC2340R5: Inconsistent BLE Service Discovery on TI Module with Android 13/14 (Status 22 Error)

Part Number: CC2340R5

Tool/software:

Hi!

I'm encountering a recurring issue during BLE communication between our mobile application and a TI device module.

While initiating a connection, I’ve observed that the GATT connection is established immediately. However, when the mobile application attempts to discover the service list, the device is not responding. As a result, after a few seconds, the connection fails and is terminated with status code 22.

This issue occurs consistently on most of the android phones with Android version 13 & 14, and the connection only succeeds occasionally. This problem is not observed on the Motorola G54 phone. The device connects and communicates successfully every time on that particular model.

I have also tested using the SimpleLink Connect and LightBlue apps and observed the same issue. 

I am also attaching the log file for your reference. Could you please advise on what might be causing this behavior or suggest any steps to resolve or further investigate the issue?

Pass Case ( Moto G54 5G Android Version 14)



2025-08-18 13:48:21.466 11477-11477 TIBluetoothService      com.smit.fota_Simulation             D  Connecting to 10:CA:BF:77:AA:C9
2025-08-18 13:48:21.467 11477-11477 BluetoothGatt           com.smit.fota_Simulation             D  connect() - device: xx:xx:xx:xx:AA:C9, auto: false
2025-08-18 13:48:21.467 11477-11477 BluetoothGatt           com.smit.fota_Simulation             D  registerApp()
2025-08-18 13:48:21.467 11477-11477 BluetoothGatt           com.smit.fota_Simulation             D  registerApp() - UUID=2748bbac-bef8-45a7-91c8-f87f0569ebc1
2025-08-18 13:48:21.469 11477-11477 BluetoothAdapter        com.smit.fota_Simulation             D  isLeEnabled(): ON
2025-08-18 13:48:21.470 11477-11608 BluetoothGatt           com.smit.fota_Simulation             D  onClientRegistered() - status=0 clientIf=7
2025-08-18 13:48:21.475 11477-11477 TIBluetoothService      com.smit.fota_Simulation             D  Stopping BLE scan...
2025-08-18 13:48:21.475 11477-11477 TIBluetoothService      com.smit.fota_Simulation             D  Scan is not running.
2025-08-18 13:48:21.570 11477-11782 TIBluetoothService      com.smit.fota_Simulation             D  New Scan Result: 10:CA:BF:77:A9:B2
2025-08-18 13:48:21.571 11477-11782 TIBluetoothService      com.smit.fota_Simulation             D  Ui Updated
2025-08-18 13:48:22.222 11477-11608 BluetoothGatt           com.smit.fota_Simulation             D  onClientConnectionState() - status=0 clientIf=7 device=xx:xx:xx:xx:AA:C9
2025-08-18 13:48:22.223 11477-11608 TIBluetoothService      com.smit.fota_Simulation             D  onConnectionStateChange: triggered
2025-08-18 13:48:22.223 11477-11608 TIBluetoothService      com.smit.fota_Simulation             D  Connected to 10:CA:BF:77:AA:C9
2025-08-18 13:48:22.223 11477-11608 BluetoothGatt           com.smit.fota_Simulation             D  discoverServices() - device: xx:xx:xx:xx:AA:C9
2025-08-18 13:48:22.643 11477-11608 BluetoothGatt           com.smit.fota_Simulation             D  onConnectionUpdated() - Device=xx:xx:xx:xx:AA:C9 interval=6 latency=0 timeout=500 status=0
2025-08-18 13:48:22.820 11477-11608 BluetoothGatt           com.smit.fota_Simulation             D  onSearchComplete() = Device=xx:xx:xx:xx:AA:C9 Status=0
2025-08-18 13:48:22.821 11477-11608 TIBluetoothService      com.smit.fota_Simulation             D  Services discovered
2025-08-18 13:48:22.821 11477-11608 TIBluetoothService      com.smit.fota_Simulation             D  Service UUID: 00001800-0000-1000-8000-00805f9b34fb
2025-08-18 13:48:22.823 11477-11608 TIBluetoothService      com.smit.fota_Simulation             D  Characteristic UUID: 00002a00-0000-1000-8000-00805f9b34fb
2025-08-18 13:48:22.823 11477-11608 TIBluetoothService      com.smit.fota_Simulation             D  Characteristic UUID: 00002a01-0000-1000-8000-00805f9b34fb
2025-08-18 13:48:22.824 11477-11608 TIBluetoothService      com.smit.fota_Simulation             D  Characteristic UUID: 00002a04-0000-1000-8000-00805f9b34fb
2025-08-18 13:48:22.824 11477-11608 TIBluetoothService      com.smit.fota_Simulation             D  Characteristic UUID: 00002aa6-0000-1000-8000-00805f9b34fb
2025-08-18 13:48:22.824 11477-11608 TIBluetoothService      com.smit.fota_Simulation             D  Characteristic UUID: 00002ac9-0000-1000-8000-00805f9b34fb
2025-08-18 13:48:22.825 11477-11608 TIBluetoothService      com.smit.fota_Simulation             D  chars List  :[android.bluetooth.BluetoothGattCharacteristic@7543f20, android.bluetooth.BluetoothGattCharacteristic@cdad0d9, android.bluetooth.BluetoothGattCharacteristic@5a33a9e, android.bluetooth.BluetoothGattCharacteristic@690497f, android.bluetooth.BluetoothGattCharacteristic@90e2d4c] 
2025-08-18 13:48:22.826 11477-11608 TIBluetoothService      com.smit.fota_Simulation             D  Service UUID: 00001801-0000-1000-8000-00805f9b34fb
2025-08-18 13:48:22.827 11477-11608 TIBluetoothService      com.smit.fota_Simulation             D  Characteristic UUID: 00002a05-0000-1000-8000-00805f9b34fb
2025-08-18 13:48:22.827 11477-11608 TIBluetoothService      com.smit.fota_Simulation             D  chars List  :[android.bluetooth.BluetoothGattCharacteristic@7543f20, android.bluetooth.BluetoothGattCharacteristic@cdad0d9, android.bluetooth.BluetoothGattCharacteristic@5a33a9e, android.bluetooth.BluetoothGattCharacteristic@690497f, android.bluetooth.BluetoothGattCharacteristic@90e2d4c, android.bluetooth.BluetoothGattCharacteristic@19ea195] 
2025-08-18 13:48:22.828 11477-11608 TIBluetoothService      com.smit.fota_Simulation             D  Service UUID: f000ffd0-0451-4000-b000-000000000000
2025-08-18 13:48:22.829 11477-11608 TAG                     com.smit.fota_Simulation             D  Setmode: called USER_APPLICATION
2025-08-18 13:48:22.829 11477-11608 TIBluetoothService      com.smit.fota_Simulation             D  Characteristic UUID: f000ffd1-0451-4000-b000-000000000000
2025-08-18 13:48:22.830 11477-11608 TIBluetoothService      com.smit.fota_Simulation             D  chars List  :[android.bluetooth.BluetoothGattCharacteristic@7543f20, android.bluetooth.BluetoothGattCharacteristic@cdad0d9, android.bluetooth.BluetoothGattCharacteristic@5a33a9e, android.bluetooth.BluetoothGattCharacteristic@690497f, android.bluetooth.BluetoothGattCharacteristic@90e2d4c, android.bluetooth.BluetoothGattCharacteristic@19ea195, android.bluetooth.BluetoothGattCharacteristic@40462aa]  
2025-08-18 13:48:22.880 11477-11608 BluetoothGatt           com.smit.fota_Simulation             D  onConnectionUpdated() - Device=xx:xx:xx:xx:AA:C9 interval=39 latency=0 timeout=500 status=0







Failed case (all other phones with android 14 & 13)


2025-08-18 13:50:50.455 12824-12824 BluetoothGatt           com.smit.fota_Simulation             D  connect() - device: xx:xx:xx:xx:AA:C9, auto: false
2025-08-18 13:50:50.455 12824-12824 BluetoothGatt           com.smit.fota_Simulation             D  registerApp()
2025-08-18 13:50:50.456 12824-12824 BluetoothGatt           com.smit.fota_Simulation             D  registerApp() - UUID=827c5b85-f164-4286-94e1-3219ed4c8a14
2025-08-18 13:50:50.461 12824-13990 BluetoothGatt           com.smit.fota_Simulation             D  onClientRegistered() - status=0 clientIf=6
2025-08-18 13:50:50.638 12824-13990 BluetoothGatt           com.smit.fota_Simulation             D  onClientConnectionState() - status=0 clientIf=6 device=xx:xx:xx:xx:AA:C9
2025-08-18 13:50:50.638 12824-13990 TIBluetoothService      com.smit.fota_Simulation             D  onConnectionStateChange: triggered 2
2025-08-18 13:50:50.638 12824-13990 TIBluetoothService      com.smit.fota_Simulation             D  Connected to 10:CA:BF:77:AA:C9
2025-08-18 13:50:50.639 12824-13990 TIBluetoothService      com.smit.fota_Simulation             D  GATT: android.bluetooth.BluetoothGatt@5b6500f
2025-08-18 13:50:50.639 12824-13990 BluetoothGatt           com.smit.fota_Simulation             D  discoverServices() - device: 
2025-08-18 13:50:50.640 12824-13990 TIBluetoothService      com.smit.fota_Simulation             D  Connected to XX:XX:XX:XX:AA:C9
2025-08-18 13:50:51.051 12824-13990 BluetoothGatt           com.smit.fota_Simulation             D  onConnectionUpdated() - Device=xx:xx:xx:xx:AA:C9 interval=6 latency=0 timeout=500 status=0
2025-08-18 13:51:05.710 12824-13990 BluetoothGatt           com.smit.fota_Simulation             D  onSearchComplete() = Device=xx:xx:xx:xx:AA:C9 Status=0
2025-08-18 13:51:05.710 12824-13990 TIBluetoothService      com.smit.fota_Simulation             D  Services discovered
2025-08-18 13:51:05.711 12824-14146 BluetoothGatt           com.smit.fota_Simulation             D  onClientConnectionState() - status=22 clientIf=6 device=xx:xx:xx:xx:AA:C9
2025-08-18 13:51:05.711 12824-14146 TIBluetoothService      com.smit.fota_Simulation             D  onConnectionStateChange: triggered 0
2025-08-18 13:51:05.711 12824-14146 TIBluetoothService      com.smit.fota_Simulation             D  Disconnected from 10:CA:BF:77:AA:C9
2025-08-18 13:51:05.711 12824-14146 BluetoothGatt           com.smit.fota_Simulation             D  close()
2025-08-18 13:51:05.711 12824-14146 BluetoothGatt           com.smit.fota_Simulation             D  unregisterApp() - mClientIf=6
2025-08-18 13:51:05.715 12824-14146 TIBluetoothService      com.smit.fota_Simulation             E  Connection failed with status: 22
2025-08-18 13:51:05.717 12824-12824 TIBluetoothService      com.smit.fota_Simulation             I  getInstance: 

  • Hi !

    The error 0x22 and 0x08 mean that the connection or request has timed out (see GATT error codes in Android-BLE-Library). However, error 22 (and not 0x22) means that your central has chosen to disconnect . This disconnection happens half a second after your device called discoverServices, could you tell me the connection parameters you are using ? If the timeout value for the connection parameters are a lot less or a lot more than 500ms, I don't think timing out is the issue here.

    The first debugging step I would take is to check that you pass the right parameters to the discoverServices function : in the success logs, the discoverServices call log gives the device it's discovering (discoverServices() - device: xx:xx:xx:xx:AA:C9). In the failure logs, the device logs are empty (discoverServices() - device: ). 

    Kind regards,
    Maxence

  • Hi Maxence,

    Thanks for pointing that out.

    I’m currently calling gatt.discoverServices() in the standard way in Kotlin. I am also attaching my code snippet for your reference. 

    Please let me know if any further information is required. 

    //Function to connect with a selected device.
    
    fun connectToDevice(device: BluetoothDevice): Boolean {
    
            try {
                logManager.saveLogToFile("Connect to device initiated with MAC ID: ${device.address ?: ""} name: ${device.name ?: ""}")
            } catch (_: Exception) {
            }
            _isConnecting.value = true
            _connectionStatus.value = "Connecting..."
    
            Log.d(TAG, "Connecting to ${device.address}")
            
            device.connectGatt(context, false, bluetoothGattCallback)
          
            connecteddDevice = device
            stopScan()
    
            return true
        }
    
     
    //Bluetooth Gatt Callback to handle bluetooth responses
    
    private val bluetoothGattCallback = object : BluetoothGattCallback() {
    
            @SuppressLint("MissingPermission")
            override fun onConnectionStateChange(gatt: BluetoothGatt, status: Int, newState: Int) {
                super.onConnectionStateChange(gatt, status, newState)
                Log.d(TAG, "onConnectionStateChange: triggered $newState")
                if (newState == BluetoothGatt.STATE_CONNECTING) {
                    _connectionStatus.value = "Connecting..."
                    Log.d(TAG, "onConnectionStateChange: Connecting")
                }
                if (newState == BluetoothGatt.STATE_DISCONNECTING) {
                    _connectionStatus.value = "Disconnecting..."
                    Log.d(TAG, "onConnectionStateChange: Disconnecting")
                }
    
                if (newState == BluetoothGatt.STATE_CONNECTED) {
                    Log.d(TAG, "Connected to ${gatt.device.address}")
                    bluetoothGatt = gatt
                    storage.saveStringData(storage.macId, gatt.device.address)
                    Log.d(TAG, "GATT: " + gatt);
                    gatt.discoverServices()
                    Log.d(TAG, "Connected to ${gatt.device}")
                }
                if (newState == BluetoothGatt.STATE_DISCONNECTED) {
                    _connectionStatus.value = "Disconnected"
                    _isConnecting.value = false
                    Log.d(TAG, "Disconnected from ${gatt.device.address}")
                    try {
                        bluetoothGatt?.close()
                        bluetoothGatt = null
                        connecteddDevice = null
                    } catch (_: Exception) {
                    }
    
                    if (status != BluetoothGatt.GATT_SUCCESS) {
                        Log.e(TAG, "Connection failed with status: $status")
                    }
                }
            }
    
    
    
            override fun onServicesDiscovered(gatt: BluetoothGatt, status: Int) {
                super.onServicesDiscovered(gatt, status)
                if (status == BluetoothGatt.GATT_SUCCESS) {
                    Log.d(TAG, "Services discovered")
                    // Now discover characteristics for each service
                    for (service in gatt.services) {
                        Log.d(TAG, "Service UUID: ${service.uuid}")
                        if (service.uuid.toString()
                                .uppercase() == TiBleConstants.ResetService.SERVICE_ID.uppercase()
                        ) {
                            applicationViewModel.setMode(DeviceMode.USER_APPLICATION)
                        }
                        if (service.uuid.toString()
                                .uppercase() == TiBleConstants.OADService.SERVICE_ID.uppercase()
                        ) {
                            applicationViewModel.setMode(DeviceMode.PERSISTENT_APPLICATION)
                        }
    
                        // Discover characteristics
                        for (characteristic in service.characteristics) {
                            Log.d(TAG, "Characteristic UUID: ${characteristic.uuid}")
                            list.add(characteristic)
                        }
                        Log.d(TAG, "chars List  :${list} ")
                        val updatedServices = _serviceList.value.toMutableMap()
                        updatedServices[service.uuid.toString()] = list
                        _serviceList.value = updatedServices
                    }
    
                    _connectionStatus.value = "Connected"
                    _isConnecting.value = false
                    if (applicationViewModel.deviceMode.value == DeviceMode.PERSISTENT_APPLICATION) {
                        subscribeForNotificationResponse()
                    }
    
                } else {
                    Log.e(TAG, "Failed to discover services with status $status")
                }
            }
    
    
            
        }

    Thanks & Regards

    Debasish Paul

  • Hi,

    I cannot really help you with your code, as I have never used Kotlin nor the BLE library you are using.

    As I said previously, I would first check things like the return value of your call to discoverServices, which seem to be erroneous on another device. Maybe different android version change the way your library is used. Next, If no amount of Kotlin debugging helps, I would try to use a BLE sniffer to see the packets that are being exchanged, and which is causing the problem.

    You can also try to ask your question on a forum for the BLE library you are using to connect, as the issue seems to come from your central and not the CC2340R5 peripheral.

    Kind regards.