notifications - 通知和指示 - BLE、葡萄糖服务
问题描述
我正在尝试使用 Delphi 中的 TBluetoothLE 组件从带有蓝牙 LE 的葡萄糖设备(Contour One Plus)获取葡萄糖测量值。我可以: - 连接到设备 - 发现 GATT 服务 - 发现 GATT 特性,现在我尝试设置葡萄糖测量特性的通知和记录访问控制点特性的指示。
我写了两个启用程序:
- 血糖测量通知:
procedure TForm6.enableGlucoseMeasurementNotification(
const ACharacteristic: TBluetoothGattCharacteristic);
var
ADescriptor: TBluetoothGattDescriptor;
AValues : TBytes;
begin
BluetoothLE1.DiscoveredDevices[0].SetCharacteristicNotification(FGlucoseMeasurementGattCharact, true);
ADescriptor := FGlucoseMeasurementGattCharact.Descriptors[0]; // czy aby na pewno [0]... ?
SetLength(AValues, 2);
AValues[0] := $01;
AValues[1] := $00;
ADescriptor.SetValue(AValues);
BluetoothLE1.DiscoveredDevices[0].WriteDescriptor(ADescriptor);
end;
- 记录访问控制点的指示:
procedure TForm6.enableRecordAccessControlPointIndication(
const ACharacteristic: TBluetoothGattCharacteristic);
var
ADescriptor: TBluetoothGattDescriptor;
AValues: TBytes;
begin
BluetoothLE1.DiscoveredDevices[0].SetCharacteristicNotification(FRecordAccessControlPoint, true);
ADescriptor := FRecordAccessControlPoint.Descriptors[0];
SetLength(AValues, 2);
AValues[0] := $02;
AValues[1] := $00;
ADescriptor.SetValue(AValues);
BluetoothLE1.DiscoveredDevices[0].WriteDescriptor(ADescriptor);
end;
我基于 nRF Connect,但我不明白一些事情。我的问题是,我应该在哪里运行这两个程序?在 OnServicesDiscovered 中?我的程序正确吗?从 RACP 获取价值的下一步是什么?我应该只将字节值(例如 0x01)写入 RACP 吗?
解决方案
推荐阅读
- php - 如何在实时服务器上的 laravel 5.4 中发送电子邮件 Swift_TransportException 无法与主机 smtp.gmail.com 建立连接
- spring - Log4j2 未在 Linux 中使用 Spring Boot 创建日志文件
- .net - 如何在 csproj 文件中包装 MSBuild 错误任务的长文本
- asp.net-core - 无法使用 Jmeter 中的 Single Read Sampler 从 .net 核心信号器服务器读取文本
- java - 将 httpBasic 与 AuthenticationEntryPoint 一起使用
- typescript - 用于映射数组元素的 RxJS 运算符
- syntax - pub struct 属性上的“结构的字段‘0’是私有的”错误
- javascript - 使用 Lodash 链接或函数式 JS 挑战的数据操作
- google-chrome-extension - 调试时如何使用 chrome 黑盒内容脚本?
- python - 使用索引切片打印字符串中的每个单词