小米BLE配对仅适用于调试

时间:2017-02-08 13:30:57

标签: android bluetooth bluetooth-lowenergy nrf51 bluetooth-peripheral

我们开发基于Nordic nRF51蓝牙低功耗芯片的设备,whitch在外设模式下运行,并具有android应用,whitch充当蓝牙中心。 应用程序开始广告,我们的设备与电话配对(弹出对话框请求输入PIN码)。

我们在某些手机上遇到了一个非常奇怪的问题,特别是在小米手机上(我使用的是小米Redmi Note 3 Pro):只有当手机连接到亚行时,蓝牙配对才能正常工作:

  1. 我开始做广告而没有连接到手机的USB线
  2. 出现了PIN码对话框
  3. 我输入有效的PIN码
  4. 我可以看到已经创建了蓝牙对,但设备会在创建蓝牙对后停止通信并立即断开连接。
  5. 如果我将USB线连接到手机上以便在Android工作室中看到logcat一切正常 - 蓝牙配对工作正常,设备可以与手机进行通信!仅在某些型号的手机中出现此问题。我也尝试修改"发布" Android studio中的设置禁用优化并在发布版本中添加bebug信息,但它不能解决问题。

    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无法完成预期的工作

0 个答案:

没有答案