开发了一个应用程序,它充当外围设备并与其他设备连接(仅限中央).
它在具有操作系统版本6.0的设备中运行良好,但在Nougat 7.0中遇到了一些问题.
我收集了一些日志,在开发者选项中启用“Bluetooth HCI snoop log”.
收集的日志:
W/bt_btm: btm_sec_disconnect : reason=19
W/bt_btif: btif_dm_generic_evt: event=33035
W/bt_btif: btif_dm_generic_evt: event=33035
W/bt_btm: btm_sec_send_hci_disconnect: handle:0x41, reason=0x13
W/bt_btif: btif_dm_generic_evt: event=33035
W/bt_btif: bta_gattc_conn_cback() - cif=3 connected=0 conn_id=3 reason=0x0016
W/bt_btif: bta_gattc_conn_cback() - cif=4 connected=0 conn_id=4 reason=0x0016
W/bt_btif: bta_gattc_conn_cback() - cif=5 connected=0 conn_id=5 reason=0x0016
W/bt_btif: bta_gattc_conn_cback() - cif=7 connected=0 conn_id=7 reason=0x0016
W/bt_btif: bta_dm_bl_change_cback : reason=22
W/bt_btif: bta_dm_bl_change_cback : reason=22
W/bt_btm: btm_sec_disconnected
W/bt_btif: conn.link_down.is_removed : 0
D/BtGatt.GattService: onClientConnected() serverIf: 6, connId=6, address=00:16:A4:13:1E:48, connected=false
W/bt_btif: btif_dm_upstreams_cback ev: BTA_DM_LINK_DOWN_EVT
W/bt_btif: BTA_DM_LINK_DOWN_EVT. Sending BT_ACL_STATE_DISCONNECTED
外围服务(代码):
private boolean addService() {
if (null == mGattServer) {
Logger.printLog(TAG, "mGattServer is null");
return false;
}
BluetoothGattService service = new BluetoothGattService(UUID_pService,
BluetoothGattService.SERVICE_TYPE_PRIMARY);
//Defined descriptor for CCC and CEP
final BluetoothGattDescriptor cccDescriptor = new BluetoothGattDescriptor(UUID.fromString("00002902-0000-1000-8000-00805f9b34fb"), BluetoothGattDescriptor.PERMISSION_READ_ENCRYPTED);
cccDescriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
final BluetoothGattDescriptor cepDescriptor = new BluetoothGattDescriptor(UUID.fromString("00002900-0000-1000-8000-00805f9b34fb"),