- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试从我的移动设备(扫描仪)写入已连接的可穿戴设备(广播设备)中的描述符。
在可穿戴设备上,我将描述符定义为
readCharacteristic = new BluetoothGattCharacteristic(Constants.READ_CHAR_UUID,
BluetoothGattCharacteristic.PROPERTY_READ | BluetoothGattCharacteristic.PROPERTY_NOTIFY,
BluetoothGattCharacteristic.PERMISSION_READ);
readCharacteristic.addDescriptor(new BluetoothGattDescriptor(Constants.NOTIFY_DESC_UUID,
BluetoothGattDescriptor.PERMISSION_READ | BluetoothGattDescriptor.PERMISSION_WRITE));
在移动设备上,我尝试用
写入特性BluetoothGattDescriptor descriptor = readCharacteristic.getDescriptor(Constants.NOTIFY_DESC_UUID);
descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE)
不幸的是,这失败了,状态为 GATT_WRITE_NOT_PERMITTED
@Override
public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) {
}
在可穿戴 logcat 中,我看到 gatts_write_attr_perm_check - GATT_WRITE_NOT_PERMIT。
当我尝试写入特征时,同样的事情发生了。
奇怪的是,使用 iOS 扫描仪时写入成功。这意味着可穿戴部分是正确的。
我在 list 中有权限:
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
使用的设备:联系 5x 6.0.1 API 23,摩托 360 5.1.1 API 22
有谁知道如何解决这个描述符/特征写入问题?
最佳答案
From my mobile device(scanner) I am trying to write to a descriptor in a connected wearable(broadcaster).
在这种情况下,它应该是移动设备(中央)和连接的可穿戴设备(外围设备)。 scanner和broadcaster实际上并没有建立BLE连接。
关于写入失败,当应用程序尝试将数据写入数据库时,在函数 gatts_write_attr_perm_check
处被拒绝。代码如下:
else if (!(perm & GATT_WRITE_ALLOWED))
{
status = GATT_WRITE_NOT_PERMIT;
GATT_TRACE_ERROR( "gatts_write_attr_perm_check -GATT_WRITE_NOT_PERMIT");
}
所以,问题是记录的 perm 不符合 GATT_WRITE_ALLOWED,即
> (GATT_PERM_WRITE | GATT_PERM_WRITE_ENCRYPTED |\
> GATT_PERM_WRITE_ENC_MITM | GATT_PERM_WRITE_SIGNED |\
> GATT_PERM_WRITE_SIGNED_MITM)
那么,你能不能试一下:1) 取消配对设备并重新配对设备。2)启用高安全级别,例如启用 MITM。
我假设您想要启用通知,对吗?我无法获得您拥有的所有代码,但您也可以试试这个(引用自 Android 网站):
private BluetoothGatt mBluetoothGatt;
BluetoothGattCharacteristic characteristic;
boolean enabled;
...
mBluetoothGatt.setCharacteristicNotification(characteristic, enabled);
...
BluetoothGattDescriptor descriptor = characteristic.getDescriptor(
UUID.fromString(SampleGattAttributes.CLIENT_CHARACTERISTIC_CONFIG));
descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
mBluetoothGatt.writeDescriptor(descriptor);
关于java - 安卓蓝牙 : descriptor/characteristic write fails with GATT_WRITE_NOT_PERMITTED,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39289594/
我想知道是否有比我通常采用的方法更直接的方法来计算某种类型的变量...... 下面的例子可能最好地解释了它。我有一个包含 2 列的数据框(水果以及水果是否腐烂)。我想为每一行添加例如同类别水果腐烂的百
在 peripheral didDiscoverServices() 和 peripheral didDiscoverCharacteristicsForService() 中,我正在尝试以下操作:
我正在使用以下代码为使用 IOS 核心蓝牙的蓝牙特性(重置设备)写入 0xDE 值: ... NSData *bytes = [@"0xDE" dataUsingEncoding:NSUTF8Stri
尝试使用以下函数从特征中检索可读信息: peripheral.discoverDescriptors(for: characteristic) 稍后的委托(delegate)方法: func peri
我尝试使用 Swift 3 在 Xcode 中创建一个小型 iOS 应用程序。我尝试连接到 BLE 设备,然后读取电池电量。 我收到这样的回复: ...UUID = Battery Level, pr
我正在尝试读取来自 BT 设备的读数并将其转换为字符串。 , notifying = YES> 基于我在网上找到的例子我做了 let u16 = (characteristic.value! as N
关于 http://en.cppreference.com/w/cpp/numeric/random : The Mersenne twister is slower and has greater
我有一个 Android (Glass) 应用程序,它充当 BLE 中央并连接到一个BLE 外围设备(这是一个使用 Core Bluetooth 的 iOS 设备)。我正在尝试从 和 写入外围设备。
我正在使用 BLE 开发一个安卓应用程序。此应用程序的要求是更新具有各种输入的特定硬件中的电压变化。所以我在这个应用程序中启用了 BLE 通知 API。这将在一段时间内通知应用程序最新的硬件电压。 实
我正在将一个计步器连接到 android。当我在 setCharacteristicNotification 函数中执行以下行时,我得到的描述符为 Null BluetoothGattDescript
已关注 sample 我知道: 如何阅读特征值。 但我不知道: 如何将数据写入固件。 我试了几次,还是不行。 这是编码: if ((charaProp | BluetoothGattCharacter
在我的应用程序中,我发现我的外围设备具有给定的服务。然后,在继续之前,我会检查是否存在所有需要的特征。 当我为我的特征写入一个值时,回调 didWriteValueForCharacteristic:
我正在尝试从我的移动设备(扫描仪)写入已连接的可穿戴设备(广播设备)中的描述符。 在可穿戴设备上,我将描述符定义为 readCharacteristic = new BluetoothGattChar
我已经编写了一些 CoreBluetooth 代码,我可以发现设备,但我似乎无法发现我发现的外围设备的特征。谁有好的示例代码可供我用来验证我的代码? 这是我写的: #import "ViewContr
如何找出低功耗蓝牙 (BLE) 中的 MTU 与最大特征尺寸之间的关系? 我有一个运行“回声”程序的 BLE 开发板 - 所以无论它收到什么,它都会立即回复。 在我的 Android 设备上,如果我请
我有一组 n 个实数。我也有一套功能, f_1, f_2, ..., f_m. 这些函数中的每一个都将数字列表作为其参数。我还有一组 m 个范围, [l_1, u_1], [l_2, u_2], ..
因为我经常使用流,其中一些流处理大量数据,所以我认为预先分配一个近似大小的基于集合的收集器是个好主意,以防止昂贵的重新分配作为集合成长。所以我想出了这个,以及其他集合类型的类似方法: public s
我正在编写一个 Android BLE 应用程序,我正在尝试获取某个特性的权限。我已经设法使用 characteristic.getProperties() 获取特征属性,它返回一个非零值,但是,当我
我正在使用 [peripheral writeValue:startFrame forCharacteristic:cbWriteCharacteristic type:CBCharacteristi
我搜索了一下,发现这是一个可能重复的问题: Multiple CBPeripheral's for same device 我的问题是: 我有多项服务,它们加起来大约有30-40 个特征(是的,我需要
我是一名优秀的程序员,十分优秀!