[英]BLE GATT server data format
I'm playing on this example: 我在玩这个例子:
https://doc-snapshots.qt.io/qt5-dev/qtbluetooth-heartrate-server-example.html https://doc-snapshots.qt.io/qt5-dev/qtbluetooth-heartrate-server-example.html
to better understand how to configure a GATT server. 以便更好地了解如何配置GATT服务器。 The example fakes a HeartRate profile.
该示例伪造了HeartRate配置文件。 In detail it creates a characteristic with this client descriptor:
详细地,它使用此客户端描述符创建一个特征:
const QLowEnergyDescriptorData clientConfig(QBluetoothUuid::ClientCharacteristicConfiguration, QByteArray(2, 0));
from here: 从这里:
https://developer.bluetooth.org/gatt/descriptors/Pages/DescriptorViewer.aspx?u=org.bluetooth.descriptor.gatt.client_characteristic_configuration.xml https://developer.bluetooth.org/gatt/descriptors/Pages/DescriptorViewer.aspx?u=org.bluetooth.descriptor.gatt.client_characteristic_configuration.xml
I understand it has both notifications and indications disabled by default (in fact I need to enable them from a client application in order to be notified). 我了解默认情况下它同时禁用了通知和指示(实际上,我需要从客户端应用程序启用它们才能得到通知)。
What I really don't understand is this code: 我真正不明白的是这段代码:
quint8 currentHeartRate = 60;
const auto heartbeatProvider = [&service, ¤tHeartRate, &valueChange]() {
QByteArray value;
value.append(char(0)); // Flags that specify the format of the value.
value.append(char(currentHeartRate)); // Actual value.
QLowEnergyCharacteristic characteristic = service->characteristic(QBluetoothUuid::HeartRateMeasurement);
service->writeCharacteristic(characteristic, value); // Potentially causes notification.
...
Well, it appends two bytes to the characteristic's value because it was defined above: 好吧,因为它是在上面定义的,所以它将两个字节附加到特征值上:
QLowEnergyCharacteristicData charData;
charData.setUuid(QBluetoothUuid::HeartRateMeasurement);
charData.setValue(QByteArray(2, 0));
but what does the first one mean? 但是第一个是什么意思?
value.append(char(0)); // Flags that specify the format of the value.
I cannot find any documentation about this "format". 我找不到有关此“格式”的任何文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.