Toolbox App V3: Device connection only works during scan



  • My device: Samsung Galaxy S5 SM-G900F, Android 6.0.1.

    Toolbox App v3.0.7.

    Steps:

    • Start the scan
    • Stop the scan once the target device has been discovered
    • Connect to it by using the "Connect" button

    Actual:

    • Connection will fail / timeout (the icon will stay yellow and eventually not connect). This happens about 5 out of 10 times.

    Expected:

    • Connection should work 100%

    Note:

    • If I connect to the device while scan is active, it will connect 10 out of 10 times.

    Logcat of a failed connection:

                FlurryAgent  W  Event count incremented: Connect_Request
                        +++  E  Entered DISCONNECTED state
              P_TaskManager  I  UPDATE(12319) addTask() - Adding task to queue: Connect(CREATED gas_monitor_0118 221977526 )
                             I  UPDATE(12319) print() - no current task [Connect(QUEUED gas_monitor_0118 221977526 )]
                        +++  E  Entered non-DISCONNECTED state
                             E  Entered non-DISCONNECTED state
              P_TaskManager  I  UPDATE(12319) print() - Connect(EXECUTING gas_monitor_0118 221977526 ) []
           BluetoothManager  D  getConnectionState()
                             D  getConnectedDevices
                             D  getConnectionState()
                             D  getConnectedDevices
                             D  getConnectionState()
                             D  getConnectedDevices
              BluetoothGatt  D  connect() - device: DC:0D:30:00:01:18, auto: false
                             D  registerApp()
                             D  registerApp() - UUID=5167a1e8-a1ef-48f7-b902-1042c745cd68
                             D  onClientRegistered() - status=0 clientIf=8
                             D  onClientConnectionState() - status=133 clientIf=8 device=DC:0D:30:00:01:18
    tenerProcessor [Native]  W  ABE(12266) onConnectionStateChange() [DC:0D:30:00:01:18] - GATT_ERROR(133) STATE_DISCONNECTED(0)
    _BleDeviceNativeManager  I  UPDATE(12319) updateNativeConnectionState() - STATE_DISCONNECTED(0)
                    PA_Task  I  UPDATE(12319) setState() - Connect(FAILED gas_monitor_0118 221977526 ) - 10603
              P_TaskManager  I  UPDATE(12319) print() - no current task []
              BluetoothGatt  D  close()
                             D  unregisterApp() - mClientIf=8
    P_ConnectionFailManager  W  UPDATE(12319) onConnectionFailed() - NATIVE_CONNECTION_FAILED, timing=EVENTUALLY
                FlurryAgent  W  Event count incremented: Connection_Failure
              P_TaskManager  I  UPDATE(12319) addTask() - Adding task to queue: Connect(CREATED gas_monitor_0118 157315255 )
                             I  UPDATE(12319) print() - no current task [Connect(QUEUED gas_monitor_0118 157315255 )]
                             I  UPDATE(12319) print() - Connect(EXECUTING gas_monitor_0118 157315255 ) []
           BluetoothManager  D  getConnectionState()
                             D  getConnectedDevices
                             D  getConnectionState()
                             D  getConnectedDevices
                             D  getConnectionState()
                             D  getConnectedDevices
              BluetoothGatt  D  connect() - device: DC:0D:30:00:01:18, auto: false
                             D  registerApp()
                             D  registerApp() - UUID=d42f7e42-20ed-45d6-a998-a8430f6ed556
                             D  onClientRegistered() - status=0 clientIf=8
                 BleManager  W  UPDATE(12319) update() - Update loop took longer to run than the current interval of 20ms
              BluetoothGatt  D  onClientConnectionState() - status=133 clientIf=8 device=DC:0D:30:00:01:18
    tenerProcessor [Native]  W  BOB(12265) onConnectionStateChange() [DC:0D:30:00:01:18] - GATT_ERROR(133) STATE_DISCONNECTED(0)
    _BleDeviceNativeManager  I  UPDATE(12319) updateNativeConnectionState() - STATE_DISCONNECTED(0)
                    PA_Task  I  UPDATE(12319) setState() - Connect(FAILED gas_monitor_0118 157315255 ) - 10824
              P_TaskManager  I  UPDATE(12319) print() - no current task []
              BluetoothGatt  D  close()
                             D  unregisterApp() - mClientIf=8
    P_ConnectionFailManager  W  UPDATE(12319) onConnectionFailed() - NATIVE_CONNECTION_FAILED, timing=EVENTUALLY
                FlurryAgent  W  Event count incremented: Connection_Failure
              P_TaskManager  I  UPDATE(12319) addTask() - Adding task to queue: Connect(CREATED gas_monitor_0118 82964516 )
                             I  UPDATE(12319) print() - no current task [Connect(QUEUED gas_monitor_0118 82964516 )]
                             I  UPDATE(12319) print() - Connect(EXECUTING gas_monitor_0118 82964516 ) []
           BluetoothManager  D  getConnectionState()
                             D  getConnectedDevices
                             D  getConnectionState()
                             D  getConnectedDevices
                             D  getConnectionState()
                             D  getConnectedDevices
              BluetoothGatt  D  connect() - device: DC:0D:30:00:01:18, auto: true
                             D  registerApp()
                             D  registerApp() - UUID=b10b7b03-d3ff-42d1-bd98-e28790e395a9
                             D  onClientRegistered() - status=0 clientIf=8
                             D  onAutoConnectionStatusCb()status =0
                 BleManager  W  UPDATE(12319) update() - Update loop took longer to run than the current interval of 20ms
                    PA_Task  I  UPDATE(12319) setState() - Connect(TIMED_OUT gas_monitor_0118 82964516 ) - 11363
              BluetoothGatt  D  close()
                             D  unregisterApp() - mClientIf=8
    P_ConnectionFailManager  W  UPDATE(12319) onConnectionFailed() - NATIVE_CONNECTION_FAILED, timing=TIMED_OUT
                FlurryAgent  W  Event count incremented: Connection_Failure
                        +++  E  Entered DISCONNECTED state
                             E  Entered DISCONNECTED state
              P_TaskManager  I  UPDATE(12319) print() - no current task []
                 BleManager  W  UPDATE(12319) update() - Update loop took longer to run than the current interval of 20ms
           P_BleManagerImpl  I  UPDATE(12319) update() - Update loop has entered IDLE state.
    


  • Now this is a unique case. This is pretty much exactly opposite of what usually happens. Usually its a scan that makes other operations not work correctly. Have you tried connecting to other peripherals to see if the same thing happens? I haven't seen this behavior with the devices we have around the office here. Does the same thing happen with the V2 version of the Toolbox?



  • Ryan,

    I have restarted the testing, results below.

    Device: Samsung Galaxy S5 SM-G900F, Android 6.0.1.

    Toolbox App: 1.0.30 (SB v2.52.17).

    1. Start the App
    2. Start scan
    3. Once my device is found, tap "connect"
    4. Once connected, tap "disconnect"
    5. Repeat from step 3) multiple times

    Step 3 would fail 2 out of 6 times.

    1. Kill app

    Note: The scanning seem to have stopped automatically.

    Logs are here:

    Toolbox App: 3.0.14 (SB unspecified).

    1. Start the App
    2. Start scan
    3. Once my device is found, tap "connect"
    4. Once connected, tap "disconnect"
    5. Repeat from step 3) multiple times

    => Works 6 out of 6 times.

    1. Kill app

    Note: The Toolbox UI shows the phone is still scanning.

    Logs are here:

    Toolbox App: 3.0.14 (SB unspecified).

    1. Start the App
    2. Start scan
    3. Once my device is found, tap "Stop Scan"
    4. Tap "connect" next to my device
    5. Once connected, tap "disconnect"
    6. Repeat from step 4) multiple times

    => Works 3 out of 7 times, then. (first 3 tries ok, then fails permanently)

    1. Kill app

    Logs are here:

    Screen Recording:

    Other notes:

    Sebastian



  • To answer your other question, I have just tested this with 2 other devices in V3, and when the scan is stopped, the connection can be established / disconnected multiple times without issue.



  • Try setting the delay between tasks option in the settings menu to something like .5 seconds (the value is in seconds). See if it improves the connection rate at all. I've heard sometimes delaying after service discovery can sometimes help with 133 gatt errors when connecting. This test should at least give us some proof that this is true or not.