2

我们基于Nordic nRF51蓝牙低功耗芯片开发设备,whitch作为外设模式,并且有android应用,whitch作为蓝牙中枢。应用程序开始广告,我们的设备与手机配对(出现要求 PIN 码的弹出对话框)。

我们在某些手机上遇到了非常奇怪的问题,尤其是在小米手机上(我使用的是小米红米 Note 3 Pro):蓝牙配对只有在手机连接到 ADB 时才能正常工作:

  1. 我在没有连接手机的 USB 数据线的情况下开始做广告
  2. 出现 PIN 码对话框
  3. 我输入有效的 PIN 码
  4. 我可以看到蓝牙对已创建,但设备停止通信并在蓝牙对创建后立即断开连接。

如果我将 USB 线插入手机以在 Android Studio 中查看 logcat,一切正常 - 蓝牙配对工作正常,设备可以与手机进行通信!此问题仅在某些型号的手机中出现。我还尝试在 Android Studio 中修改“发布”设置以禁用优化并在发布版本中添加错误信息,但这并没有解决问题。

Logcat(配对正常):

D/GATT: StartSearch

        [ 02-08 15:31:58.797  5676: 5875 E/         ]
        GKI_timer_update no work to be done when expected work
D/BluetoothGattServer: registerCallback()
D/BluetoothGattServer: registerCallback() - UUID=042e51cd-6278-4200-9b36-480576e8bcc0
D/BluetoothGattServer: onServerRegistered() - status=0 serverIf=5
D/BluetoothGattServer: addService() - service: 6e400004-b5a3-f393-e0a9-e50e24dcca9e
D/BluetoothGattServer: onServiceAdded() - service=6e400004-b5a3-f393-e0a9-e50e24dcca9estatus=0
D/GattServer: Our gatt server service was added.
D/BluetoothLeAdvertiser: onClientRegistered() - status=0 clientIf=6
D/advertise: onStartSuccess

             [ 02-08 15:31:59.397  5676: 5875 E/         ]
             GKI_timer_update no work to be done when expected work
D/BluetoothGattServer: onServerConnectionState() - status=0 serverIf=5 device=F9:D4:DB:18:27:49
D/GattServer: Our gatt server connection state changed, new state 
D/GattServer: 2

              [ 02-08 15:31:59.407  5676: 5875 E/         ]
              GKI_timer_update no work to be done when expected work
D/GattServer: Our gatt server descriptor was written.
I/GattServer: SUBSCRIBE !!!
D/BluetoothGattServer: onServerConnectionState() - status=0 serverIf=5 device=F9:D4:DB:18:27:49
D/GattServer: Our gatt server connection state changed, new state 
D/GattServer: 0
D/BluetoothGattServer: onServerConnectionState() - status=0 serverIf=5 device=F9:D4:DB:18:27:49
D/GattServer: Our gatt server connection state changed, new state 
D/GattServer: 2
D/QueryManager: Send command 06 02 62 

        [ 02-08 15:32:14.757  5676: 5875 E/         ]
        GKI_timer_update no work to be done when expected work
D/Gatt: Send data 00 06 02 62 00 , MAC: F9:D4:DB:18:27:49
D/GattServer: onNotificationSent
D/GattServer: We have received a write request for one of our hosted characteristics: 6e400002-b5a3-f393-e0a9-e50e24dcca9e
D/GattServer: data = 00 02 06 62 9B C1 C1 C1 C1 C1 C1 C1 00 
D/QueryManager: Send command 06 02 22 00 
D/GattServer: onNotificationSent
D/Gatt: Send data 00 06 02 22 C1 00 , MAC: F9:D4:DB:18:27:49
D/GattServer: We have received a write request for one of our hosted characteristics: 6e400002-b5a3-f393-e0a9-e50e24dcca9e
D/GattServer: data = 00 02 06 22 C1 00 
D/BluetoothGattServer: onServerConnectionState() - status=0 serverIf=5 device=F9:D4:DB:18:27:49
D/GattServer: Our gatt server connection state changed, new state 
D/GattServer: 0

可能有某种方法可以在应用程序中显示 logcat,而无需在没有 USB 的情况下进行 ADB 连接,或者我错过了日志中的某些内容。

我也不明白这一行: GKI_timer_update no work to be done when expected work

4

0 回答 0