我正在使用带有bluez版本4.101的Linux计算机.我正在以从属模式与BLE设备通信.我正在尝试从BLE设备读取数据.但是当我这样做时,读取失败并出现以下错误:"属性需要在读/写之前进行身份验证".我可以从许多其他特征中读取数据,但我在这个上失败了.我正在使用的命令是
-gatttool -b 11:22:33:44:55:66 --char-read
我需要做什么才能阅读这些数据?
注意:我可以从iPhone上读取这些数据.但我需要配对,所以也许这是一个配对问题.
我正在尝试使用Adafruit Bluefruit LE(蓝牙4模块)与arduino进行通信,所有内容都已设置并配对,但我在GattCharacteristic上遇到了ValueChanged事件的问题,它在30之间的某个地方停止发射和40次.
以下是此设置代码:
public class Bluetooth
{
async public void Initialize()
{
var devices = await DeviceInformation.FindAllAsync(GattDeviceService.GetDeviceSelectorFromUuid(new Guid("6E400001-B5A3-F393-E0A9-E50E24DCCA9E")), null);
GattDeviceService firstService = await GattDeviceService.FromIdAsync(devices[0].Id);
GattCharacteristic rxCharacteristic = firstService.GetCharacteristics(new Guid("6E400003-B5A3-F393-E0A9-E50E24DCCA9E")).First();
await rxCharacteristic.WriteClientCharacteristicConfigurationDescriptorAsync(GattClientCharacteristicConfigurationDescriptorValue.Notify);
rxCharacteristic.ValueChanged += rxCharacteristicValueChanged;
}
private void rxCharacteristicValueChanged(GattCharacteristic characteristic, GattValueChangedEventArgs e)
{
Console.WriteLine(e.CharacteristicValue.ToArray()[6]);
}
}
Run Code Online (Sandbox Code Playgroud)
我需要清除哪种缓冲区或类似的东西?它看起来不像它的缓冲区相关,因为如果我将发送的数据减半,我不会得到两次调用,但我可能是错的.Arduino报告说它仍然在发送数据(通过串行链接,我可以看到蓝牙库仍然试图以任何速率发送数据.我不确定如何验证数据是否实际发送)
任何帮助将不胜感激,甚至建议检查的事情.
如果我们在一个字符上调用setCharacteristicNotification,而不是在值Change上给出远程通知?如何在蓝牙LE中的中央设备上启用远程通知?
我正在开发一款正在扫描BLE设备的Android应用程序.每当我找到一台设备时,我都会收到:
byte[] scanRecord, BluetoothDevice device, int rssi
来自
BluetoothAdapter.startLeScan()
然后我将字节数组转换为ScanRecord对象:
ScanRecord.parseFromBytes()
我现在从我的Eddystone(来自toString()
方法)获得以下信息.
`com.reelyactive.blesdk.support.ble.ScanRecord [mAdvertiseFlags=6, mServiceUuids=[0000feaa-0000-1000-8000-00805f9b34fb], mManufacturerSpecificData={}, mServiceData={0000feaa-0000-1000-8000-00805f9b34fb=[16, -36, 2, 107, 110, 116, 107, 46, 105, 111, 47, 101, 100, 100, 121, 115, 116, 111, 110, 101], 0000d00d-0000-1000-8000-00805f9b34fb=[67, 77, 103, 52, 50, 57, 100]}, mTxPowerLevel=-12, mDeviceName=IIS_EDDY_003] IIS_EDDY_003`
Run Code Online (Sandbox Code Playgroud)
有人能告诉我,如何使用此信息将设备识别为Eddystone?服务uuids可能吗?我并不总是知道设备的名称或地址.
我在使用自己生成的 UUID(不使用蓝牙 SIG 保留的 16 位 UUID)在 Android BLE 中进行通信时遇到问题。
目标设备有两个 - 一个作为外围设备(三星 Galaxy Note 4/android 5.1.1),另一个作为中央设备(三星 Galaxy S5/android 5.0.1)。我将自己的服务的 UUID 和特性的 UUID 放在外围设备端。在中心一侧,它找不到特色,但找到服务。
这似乎是由于不使用这些特征 UUID 之一而是使用自定义生成的 UUID 引起的。下面是我自己生成的 UUID。
private static final UUID CUSTOM_SERVICE_UUID = UUID.fromString("abcd1111-0000-1000-8000-00805f9b34fb");
private static final UUID CUSTOM_CHARACTERISTIC_UUID = UUID.fromString("abcd1112-0000-1000-8000-00805f9b34fb");
Run Code Online (Sandbox Code Playgroud)
服务,发现很好,但有特色,没有。你有什么主意吗?
我正在尝试使用 BlueZ 堆栈(最新版本,5.39)在 Linux 上用 C 语言实现 ANCS 客户端。到目前为止,我可以使用Apple提供的服务请求UUID设置BLE广告数据。
我的设备确实出现在 iPhone (iOS 9) 设置中。我也可以连接到设备,但连接非常不稳定,这意味着有时会在一段时间后,并且总是当我关闭 iPhone 上的蓝牙设置子菜单时,连接会终止。它也没有绑定,断开连接后,设备没有显示在 iPhone 上的“我的设备”下。
我查看了hcidump,显然只是读取了一堆ATT数据,然后停了下来:
连接终止后是输出 pastebin 的下部。
现在,我的问题是,创建一个接收来自 iOS 设备通知的 ANCS 客户端的下一步是什么?我已经阅读了无数关于 BLE 和 ANCS 的文章和示例代码,但我仍然一无所知。
我是否必须在我的 C 代码中打开一个 L2CAP 套接字才能接受来自 iPhone 的连接?我已经试过了,没有用。我还尝试使用 gatttool 连接到 iPhone,而它已连接,但它显示“资源或设备繁忙”。
我会非常感谢在正确方向上的一些指示,下一步该怎么做。
我正在制作一个在 android 设备上运行的 Gatt 服务器应用程序,它运行良好。
但我有一个关于设备名称的问题。
我用我的“Nexus 5X”创建了这个应用程序,它的默认设备名称是“Nexus 5x”,Gatt 客户端可以很好地扫描这个设备。
但是,如果服务器运行在“Galaxy S7”上,客户端将无法找到服务器设备。
因此,我检查了服务器的设备名称,默认为“Samsung Galaxy S7”。将名称更改为“gal7”后,它工作正常。
在我的测试中,android gatt 服务器允许设备名称长度最大为 8 个字符。
“Nexus 5x”--> 很好
“Galaxy S7”--> 不好
“Nexus”--> 很好
“长名称设备”--> 坏
是否有任何原因(错误与否),gatt 服务器设备名称长度限制?
我正在开发一个 iOS 应用程序,该应用程序从支持蓝牙 LE 的设备读取脉搏血氧仪数据,在Swift 4.1 中使用iOS 11.4上的CoreBluetooth。
我有CBCentralManager搜索外围设备,我找到了我感兴趣的CBPeripheral,我验证它具有0x1822 脉搏血氧仪服务,如蓝牙 SIG此处所述。(您可能需要向蓝牙 SIG 注册才能访问该链接。它是免费的,但需要一两天的时间。)
之后,我连接到它,然后我发现服务:
func centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral) {
peripheral.discoverServices(nil)
}
Run Code Online (Sandbox Code Playgroud)
然后在我的外设中:didDiscoverServices我发现 GATT 特征:
func peripheral(_ peripheral: CBPeripheral, didDiscoverServices error: Error?){
for service in peripheral.services ?? [] {
if service.uuid.uuidString == "1822" {
peripheral.discoverCharacteristics(nil, for: service)
}
}
}
Run Code Online (Sandbox Code Playgroud)
从中我看到以下特征 ( CBCharacteristic.uuid ) 可用:0x2A5F、0x2A5E、0x2a60 和 0x2A52。然后我订阅更新0x2A5F,这是PLX连续测量 …
我们正在研究两个 Android 应用程序之间的蓝牙低功耗通信。一种是外围设备/服务器,一种是中央设备/客户端。如果数据发生变化,服务器将向客户端发送指示。然而,我们没有找到一种方法来确保数据确实在客户端得到了确认。我们如何知道客户端是否收到并确认了数据以便在服务器端做出相应的反应?
根据 Android 文档,BleutoothGattServer 有回调 onNotificationSent。 https://developer.android.com/reference/android/bluetooth/BluetoothGattServerCallback#onNotificationSent(android.bluetooth.BluetoothDevice,%20int)
然而,通过调试和做一些测试,似乎这个方法实际上只是在发送通知时被调用。无法保证该消息实际上已收到或确认。
以下是我们如何设置 GattServer 的特征
BluetoothGattService service = new BluetoothGattService(SERVICE_LOGIN_UUID,
BluetoothGattService.SERVICE_TYPE_PRIMARY);
// Write characteristic
BluetoothGattCharacteristic writeCharacteristic = new BluetoothGattCharacteristic(CHARACTERISTIC_LOGIN_UUID,
BluetoothGattCharacteristic.PROPERTY_WRITE | BluetoothGattCharacteristic.PROPERTY_READ| BluetoothGattCharacteristic.PROPERTY_INDICATE,
// Somehow this is not necessary, the client can still enable notifications
// | BluetoothGattCharacteristic.PROPERTY_NOTIFY,
BluetoothGattCharacteristic.PERMISSION_WRITE | BluetoothGattCharacteristic.PERMISSION_READ);
service.addCharacteristic(writeCharacteristic);
mGattServer.addService(service);
Run Code Online (Sandbox Code Playgroud)
然后我们通过调用此通知客户
mHandler.post(() -> {
BluetoothGattService service = mGattServer.getService(SERVICE_LOGIN_UUID);
BluetoothGattCharacteristic characteristic = service.getCharacteristic(uuid);
log("Notifying characteristic " + characteristic.getUuid().toString()
+ ", new value: " + StringUtils.byteArrayInHexFormat(value));
characteristic.setValue(value);
boolean confirm = BluetoothUtils.requiresConfirmation(characteristic); …
Run Code Online (Sandbox Code Playgroud) 我正在考虑为自定义应用程序实现几个 GATT 服务,但我现在陷入了研究困境。我知道服务 uuid 不是随机的,有些部分定义良好,其他部分仍然让我感到困惑。
例如,设备信息服务似乎被宣传为 0000180a-xxx 我可以在https://www.bluetooth.com/specifications/gatt/services/中找到“180a” ,但例如子字段“型号字符串”具有 id 00002a24-xxx,一个完全不同的前缀,也没有在同一列表中定义,而是在这里: https: //www.bluetooth.com/specifications/gatt/characteristics/。我怎样才能获得所有这些前缀的列表?
我用 xxx 标记的部分似乎与我的手机找到的随机设备相同。是否有某个地方概述了如何构建 uuid 以及我可以将哪些“安全”前缀用于我自己的 GATT 服务?