我喜欢使用 RaspberryPi 充当心率传感器,并通过 BLTH 将这些数据传输到其他健康/运动应用程序。最后,使用 python 和 bluez 一切正常,我可以创建 BLTH GATT 服务器并通过服务 0x180d 宣传 HR 数据。
最后一个问题是我无法更改通用访问 (0x1800) 中 BLTH 的外观。出现是在这里找到UUID:0x2A01。
我尝试通过 bluetoothctl 手动方式执行此操作:菜单广告外观 833(用于心率)外观在背面广告
这将失败:无法注册广告:org.bluez.Error.Failed
不管我将外观更改为哪个值(即使该值众所周知并被接受),它也会使广告失败。如果我关闭外观,它将开始广告。任何提示,做什么或我刚刚错过了什么?我已经将 bluez 从 5.50 更新到 5.54 也在实验模式下使用了 bluez
非常感谢您的帮助
我正在Alert Notification Profile (ANP) in Bluetooth Low Energy
三星 Galaxy S3 和外围设备之间工作。
我在Android Developer Site 上找不到与特定 UUID 的 ANP相关的任何信息。
但是在ANCS Specifications
(iOS Developer Site) 中,他们定义了特定的 UUID 的 ANCS:
Apple 通知中心服务是主要服务,其服务 UUID 为 7905F431-B5CE-4E99-A40F-4B1E122D00D0。
我对这种不同感到担心,所以任何人都可以告诉我:
What is specific UUID's ANP in Android?
P/s :从 Wiki 中的 UUID,我知道这一点:
任何人都可以创建一个 UUID 并使用它来识别某些东西,并有合理的信心,即任何人都不会无意中创建相同的标识符来识别其他东西。
但实际上,Google Developer 还没有确认具体的 UUID 的 ANP 吗?
我正在尝试使用以下代码读取特征并获取其值
private byte[] val;
mBluetoothLeService.readCharacteristic(characteristic);// reads it
val=characteristic.getValue();
String s=new String(val);
Run Code Online (Sandbox Code Playgroud)
我的应用程序崩溃给出错误"应用程序可能在其主线程上做了太多工作."
我也试过了
private String s;
mBluetoothLeService.readCharacteristic(characteristic);// reads it
s=characteristic.getStringValue(0);
Run Code Online (Sandbox Code Playgroud)
但错误是一样的
我调试了我的代码以检查它是否获得了值
private String s;
mBluetoothLeService.readCharacteristic(characteristic);// reads it
s=characteristic.getStringValue(0);
system.out.println(s);
Run Code Online (Sandbox Code Playgroud)
它显示正确的值,但在运行代码为Android App时.我犯了同样的错误.
我通过相同的蓝牙LE设备同时使用两种不同的特性时遇到了问题.它只记录第一个特征而不是第二个特征.如果我切换它们,它仍然会记录第一个,但不是第二个.第一和第二特征都需要注册和接收.如果它有帮助,我使用运行4.4.2的三星Galaxy S4.
以下是调用setCharacteristicNotification()的代码部分
if (mBluetoothBeaconGatt != null && mBluetoothBeaconGatt.getService(UUID_CUSTOM_SERVICE) != null) {
characteristicBracelet = mBluetoothBeaconGatt.getService(UUID_CUSTOM_SERVICE)
.getCharacteristic(UUID_CUSTOM_BRACELET);
characteristicBeacon = mBluetoothBeaconGatt.getService(UUID_CUSTOM_SERVICE)
.getCharacteristic(UUID_CUSTOM_BEACON);
if(characteristicBracelet != null) {
Log.i(TAG, "Init Bracelet Characteristics");
this.setCharacteristicNotification(characteristicBracelet,
true);
}
if(characteristicBeacon != null) {
Log.i(TAG, "Init Beacon Characteristics");
this.setCharacteristicNotification(characteristicBeacon, true);
}
}
Run Code Online (Sandbox Code Playgroud)
setCharacteristicNotification
if (UUID_CUSTOM_BEACON.equals(characteristic.getUuid())) {
if (mBluetoothBeaconGatt != null) {
Log.i(TAG, "Enabling indication for beacon");
mBluetoothBeaconGatt.setCharacteristicNotification(characteristic, enabled);
BluetoothGattDescriptor descriptor = characteristic
.getDescriptor(UUID
.fromString(CustomGattAttributes.CLIENT_CHARACTERISTIC_CONFIG));
descriptor
.setValue((enabled) ? BluetoothGattDescriptor.ENABLE_INDICATION_VALUE
: BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE);
mBluetoothBeaconGatt.writeDescriptor(descriptor);
}
} else if (UUID_CUSTOM_BRACELET.equals(characteristic.getUuid())) {
if (mBluetoothBraceletGatt …
Run Code Online (Sandbox Code Playgroud) 我写了一个程序连接到心率建模,但我不知道如何解释数据.以下是从第一个输出开始的示例:
心率为:16-40-15-04-6D-02-8C-01-0C-04-24-04-AB-03-7B-02-B4-01
心率是:16-40-20-04
心率是:16-40-8F-03
心率是:16-40-10-04
...
心率是:16-40-F7-03
心率是:16-40-05-04
心率是:16-40-31-04
心率是:16-40-F8-02-47-01
心率是:16-40-A5-03
...
心率是:16-40-D4-02
心率是:16-40-FE-03
心率是:16-40-15-05
心率是:16-3C-97-03
心率是:16-3D-64-03-78-03
心率是:16-3D-4F-04
心率是:06-3D
...
心率是:16-3E-3D-04
心率是:16-3E-17-04-78-03
这是获取和转换数据的代码:
void hrMeasurementChanged( GattCharacteristic sender, GattValueChangedEventArgs eventArgs)
{
byte[] hrData = new byte[eventArgs.CharacteristicValue.Length];
Windows.Storage.Streams.DataReader.FromBuffer(
eventArgs.CharacteristicValue).ReadBytes(hrData);
var hrValue = BitConverter.ToString(hrData);
Debug.WriteLine("heart rate is : " +hrValue);
}
Run Code Online (Sandbox Code Playgroud)
这个页面解释了它,但我不确定如何解释数据:https: //www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.characteristic.heart_rate_measurement.xml
谢谢.
我得到了这个不公布其服务的Nordic nRF52 BLE外围设备。我可以连接到它,但是无法在iOS上发现服务。由于我知道服务UUID,因此我尝试将它们传递给discoverServices
函数。但这是行不通的。
大约30秒后,它终于断开连接。
在外围设备上,GAP广告标记设置为General Discoverable
。使用LightBlue
或之类的应用程序,nRF Connect
我看到外围设备的名称和UUID,但没有任何服务。与LightBlue应用程序连接时,几秒钟后显示错误(Timeout interrogating the peripheral
)。
在Android上,发现未发布的服务就可以了。
从《核心蓝牙编程指南》开始,它基本上应该可以工作:
建立与外围设备的连接后,您可以浏览其数据。探索外围设备必须提供的第一步是发现其可用的服务。由于外围设备可以发布的数据量受到大小限制,因此您可能会发现外围设备提供的服务多于其发布的(在其广告包中)所提供的服务。您可以通过调用外围设备的discoverServices:方法来发现外围设备提供的所有服务,如下所示:
[peripheral discoverServices:nil];
有谁知道SDK的区别是什么,以及是否有可能像Android一样在iOS上发现未发布的服务?
我了解到,缓存外设时,iOS能够直接连接,跳过发现过程。但是将外围设备缓存后,需要配对一次。有没有办法手动设置缓存?
感谢任何帮助,谢谢!
我正在尝试将我的信标连接到 Gattservice。在回调 onConnectionStateChange 中,它总是失败,我得到了
状态代码 133 和 257。
Somehwere 写道,133 代表许多联系。在我的代码中,有一些带有 gatt.disconnect() 的行。我不知道如何解决它,因为所有其他 gatt 示例都是相同的。如果发现错误很重要,我正在使用 Android 6.0.1 版本和 API 23。这是我的代码:
public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
if(status == BluetoothGatt.GATT_SUCCESS) {
switch (newState) {
case BluetoothProfile.STATE_CONNECTED:
mBleDevices.add(gatt.getDevice());
Log.i("Beacons", "STATE_CONNECTED");
runOnUiThread(new Runnable() {
@Override
public void run() {
mBluetoothGatt.discoverServices();
}
});
break;
case BluetoothProfile.STATE_DISCONNECTED:
Log.e("Beacons", "STATE_DISCONNECTED");
mBleDevices.remove(gatt.getDevice());
mBluetoothGatt.disconnect();
mBluetoothGatt = null;
break;
default:
Log.e("Beacons", "STATE_OTHER");
}
} else {
Log.e("Beacons", "ERROR WITH CONNECTING " + status);
mBleDevices.remove(gatt.getDevice());
}
} …
Run Code Online (Sandbox Code Playgroud) 我的应用程序能够成功连接到 BLE 外围设备(这是一个 OBDII/J1939 设备)设备。
2018-01-24 14:58:38,413 INFO LogUtil - GATT Server Status = (0) : BLE_HCI_STATUS_CODE_SUCCESS(0x00)
2018-01-24 14:58:38,414 INFO LogUtil - GATT Server New State = (2) : STATE_CONNECTED
2018-01-24 14:58:38,414 INFO LogUtil - Connected to GATT server.
Run Code Online (Sandbox Code Playgroud)
应用程序开始与设备通信,但一段时间后它onConnectionStateChange
在BluetoothGattCallback
. 以下是来自应用程序的日志:
2018-01-24 15:07:46,396 INFO LogUtil - GATT Server Status = (40) : BLE_HCI_INSTANT_PASSED(0x28)
2018-01-24 15:07:46,397 INFO LogUtil - GATT Server New State = (0) : STATE_DISCONNECTED
2018-01-24 15:07:46,398 INFO LogUtil - Disconnected from GATT server.
Run Code Online (Sandbox Code Playgroud)
无法找到 …
蓝牙 LE 自行车速度和踏频传感器根据 Gatt 特性测量数据发送测量数据。对于曲柄节奏,这是:
我想了解上次启动事件时间是如何定义的。文档使它听起来像一个时间戳,但因为它是一个 1/1024 秒的 16 位整数,所以大约 1 分钟后就会溢出。所以我怀疑这实际上是一个时间间隔。以下是时间尺度上的一系列事件。消息 B 发送 n+2 作为曲柄转数,但B 的最后一次曲柄事件时间是多少?
我是 Kotlin 的 Android 开发新手,我正在开发一个应用程序来搜索 BLE 设备。我能够打印服务(uuids)及其特征(uuids)。我没有任何特定的信标可以连接。我只是用我的应用程序进行搜索并获取我周围的 BLE 设备列表。我随机连接到其中一个并将其服务打印到控制台。我的问题是,我如何知道我正在连接的设备正在播放什么广告以及我可以从中读取什么。我没有从这些 uuid 中得到任何想法。如果您需要更多相关信息,请告诉我。
printGattTable: Service 00001801-0000-1000-8000-00805f9b34fb
Characteristics:
|--00002a05-0000-1000-8000-00805f9b34fb
Service d0611e78-bbb4-4591-a5f8-487910ae4366
Characteristics:
|--8667556c-9a37-4c91-84ed-54ee27d90049
Service 9fa480e0-4967-4542-9390-d343dc5d04ae
Characteristics:
|--af0badb1-5b99-43cd-917a-a77bc549e3cc
Service 0000180f-0000-1000-8000-00805f9b34fb
Characteristics:
|--00002a19-0000-1000-8000-00805f9b34fb
Service 00001805-0000-1000-8000-00805f9b34fb
Characteristics:
|--00002a2b-0000-1000-8000-00805f9b34fb
|--00002a0f-0000-1000-8000-00805f9b34f
Run Code Online (Sandbox Code Playgroud)