jjzjj

mBluetoothGatt

全部标签

Android BLE 无法从设备接收 Gatt 特性通知

当我在特性上写入值时,我试图从设备接收通知,但我没有收到任何消息。我在特性上启用通知,然后写入值。我已经看到设备中的特性已经改变了它的值,但我无法收到通知。这是我的代码:设备Activity:publicclassDevicesActivityextendsActivity{privateBLEServicemBluetoothLeService;privateStringmDeviceAddress;privatebooleanmConnected=false;privateBluetoothGattCharacteristicmNotifyCharacteristic;privat

android - 多次重新连接后 onConnectionStateChange 中的状态为 GATT_FAILURE

我通过以下方式连接到ble设备:mBluetoothGatt=device.connectGatt(this.context,false,mGattCallback);比mBluetoothGatt.disconnect();但如果我做的很快,那么我会在mGattCallback的onConnectionStateChange中收到status=BluetoothGatt.GATT_FAILURE然后我无法再次连接到GATT,即使关闭/打开蓝牙也是如此。只有应用强制停止才能解决问题 最佳答案 通过在状态为STATE_DISCONNE

android - mBluetoothGatt.getService(uuid) 返回 null

在我的应用程序中,我传递助听器服务的UUID编号,如来自谷歌的BLE示例,即0000a00-0000-1000-8000-00805f9b34fb但是getservice返回null意味着BluetoothGatt不支持该服务。为什么会这样,谁能帮帮我。 最佳答案 您必须首先根据文档发现给定设备的所有服务。Thisfunctionrequiresthatservicediscoveryhasbeencompletedforthegivendevice.http://developer.android.com/reference/an

android - 无法读取特性。安卓蓝牙

我想从我的远程BLE设备的特定特征读取数据到我的Android平板电脑Nexus7。问题是,即使不调用readCharacteristic,我也可以通过启用该特征的通知来接收数据。但是我无法在未启用通知的情况下通过调用readCharacteristic成功读取特征。mBluetoothGatt.readCharacteristic(characteristic)返回false。因此函数onCharacteristicRead从未被触发。我还检查了属性值BluetoothGattCharacteristic.PROPERTY_READ,它是30。有没有人对这里发生的事情有一些想法?我真