我目前正在开发2个应用程序,其中一个模拟作为BLE外围设备,使用bluetoothadvertiser进行广告,另一个是客户端。 外围设备 BluetoothGattServerCallback - Honor8 Nougat 7.0 客户 BluetoothGattCallback - Nexus 7 2013 Marshmallow 6.0
我已设法使用以下方法成功连接:
bluetoothgatt = BTdevice.connectGatt(activity,false,callback);
Nexus 7连接Honor 8罚款,但是大约30秒左右连接超时后我收到错误:06-06 11:12:06.305 15683-15694/project.androidads I/BLE: ReportedConnectionChanged:GATT CONN LMP TIMEOUT Connection error:UNKNOWN (0)
客户日志:
06-06 11:11:25.992 15683-15683/project.androidads D/BluetoothGatt: connect() - device: 5A:89:20:7A:C2:C5, auto: false
06-06 11:11:25.993 15683-15683/project.androidads D/BluetoothGatt: registerApp()
06-06 11:11:25.993 15683-15683/project.androidads D/BluetoothGatt: registerApp() - UUID=dab3140d-6d26-48ef-b956-02c38aa3dfe8
06-06 11:11:25.995 15683-15694/project.androidads D/BluetoothGatt: onClientRegistered() - status=0 clientIf=6
06-06 11:11:26.488 15683-15710/project.androidads D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=6 device=5A:89:20:7A:C2:C5
06-06 11:11:26.490 15683-15710/project.androidads I/BLE: ReportedConnectionChanged:SUCCESS Connection error:GATT READ NOT PERMIT
06-06 11:11:26.490 15683-15710/project.androidads D/BluetoothGatt: discoverServices() - device: 5A:89:20:7A:C2:C5
06-06 11:11:26.491 15683-15710/project.androidads I/Tag: CONNECTED
06-06 11:11:26.491 15683-15710/project.androidads D/BluetoothAdapter: STATE_ON
06-06 11:11:26.499 15683-15710/project.androidads D/BluetoothGatt: onSearchComplete() = Device=5A:89:20:7A:C2:C5 Status=0
06-06 11:11:26.506 15683-15710/project.androidads I/BLE: Service:ccaa55ee-7777-aa14-8000-2742f1ba77cc
06-06 11:11:27.661 15683-15710/project.androidads D/BluetoothGatt: setCharacteristicNotification() - uuid: ccaa55ee-7777-aa14-aae1-112855353cc1 enable: true
06-06 11:11:27.661 15683-15710/project.androidads I/BLE: onCharacteristicRead UUID:ccaa55ee-7777-aa14-aae1-112855353cc1
06-06 11:11:27.662 15683-15710/project.androidads I/BLE: onCharacteristicRead:0
06-06 11:12:06.305 15683-15694/project.androidads D/BluetoothGatt: onClientConnectionState() - status=34 clientIf=6 device=5A:89:20:7A:C2:C5
06-06 11:12:06.305 15683-15694/project.androidads I/BLE: ReportedConnectionChanged:GATT CONN LMP TIMEOUT Connection error:UNKNOWN (0)
06-06 11:12:06.305 15683-15694/project.androidads D/BluetoothGatt: cancelOpen() - device: 5A:89:20:7A:C2:C5
06-06 11:12:06.306 15683-15694/project.androidads D/BluetoothGatt: close()
06-06 11:12:06.306 15683-15694/project.androidads D/BluetoothGatt: unregisterApp() - mClientIf=6
06-06 11:12:06.306 15683-15694/project.androidads I/TAG: FAILED:34and:0
外围日志:
06-06 11:11:24.918 22412-22424/project.androidads I/BLE: ReportedConnectionChanged:SUCCESS Connection error:GATT READ NOT PERMIT
06-06 11:11:24.918 22412-22424/project.androidads I/BLE: connected
06-06 11:11:26.179 22412-22425/project.androidads I/BLE: CharacteristicReadRequest Elasped:ccaa55ee-7777-aa14-aae1-112855353cc1
06-06 11:12:24.881 22412-22425/project.androidads I/BLE: ReportedConnectionChanged:SUCCESS Connection error:UNKNOWN (0)
06-06 11:12:24.881 22412-22425/project.androidads I/BLE: disconnected
这几天都在研究这个问题,我不确定我做错了什么,是代码还是存在硬件限制。很多帮助将不胜感激。