【发布时间】:2019-12-20 19:21:21
【问题描述】:
有几篇关于这个问题的帖子没有公布任何解决方案。
想要访问内部 movesense 传感器数据(ECG、Acc…)但不使用 Android 或 iOS 平台(如 movesense 演示文稿 https://www.movesense.com/wp-content/uploads/2018/11/2018-11-06-Using-Movesense-CustomGATTService.pdf 所建议的那样),我至少有 1 周没有这样做。 我可以成功地创建自己的 GATT 特征并从 movesense 设备外部订阅它们。这很容易通过增加 samples/custom_gattsvc_app 几行来完成:
- 定义:
const uint16_t myCharUUID16 = 0x2A58; // this new characteristic will appear in the service as the third one in the sample
- 在 CustomGATTSvcClient::configGattSvc() 中:
WB_RES::GattProperty myCharProp = WB_RES::GattProperty::INDICATE;
myChar.props = wb::MakeArray<WB_RES::GattProperty>( &myCharProp, 1);
myChar.uuid = wb::MakeArray<uint8_t>( reinterpret_cast<const uint8_t*>(&myCharUUID16), 2);
customGattSvc.chars = wb::MakeArray<WB_RES::GattChar>(characteristics, 3); // 3 here since there are 3 characteristics now
- 访问 现在,您可以使用 BTLE 客户端(bluetility...)查看和订阅新服务,即使它目前没有执行任何操作。
问题从我这里开始:
在 CustomGATTSvcClient::onGetResult() 中,我尝试强制订阅 ECG 或 Acc,因为一旦创建了所有 BT 服务,CustomGATTSvcClient::onPostResult() 就会调用 onGetResult():
int32_t sampleRate = 10;
asyncSubscribe(WB_RES::LOCAL::MEAS_ACC_SAMPLERATE(),AsyncRequestOptions::Empty, sampleRate);
我没有实现 onSubscribeResult()
在 onNotify() 中,您应该能够每 1/10 秒通过
拦截来自白板的呼叫并使用新数据switch (resourceId.getConstId()) {
case WB_RES::LOCAL::MEAS_ACC_SAMPLERATE::ID:
{
// To see a blinking LED on each new Acc data
asyncPut(WB_RES::LOCAL::COMPONENT_LED(),AsyncRequestOptions::Empty, myFlippingBool);
myFlippingBool = ! myFlippingBool;
}
我观察到的:
A.当我 asyncSubscribe() ECG 或 Acc 时,不再调用样本的 WB_RES::LOCAL::MEAS_TEMP::LID 并且即使在成功订阅 0x2A1C 特征之后也不会向 BT 客户端发送更新。这意味着资源冲突会禁用所有通知?
B.订阅时(和以前一样)甚至是:
wb::Result result = getResource("Meas/Acc/10", mMyAccResourceId);
result = asyncSubscribe(mMyAccResourceId);
永远不会调用 onNotify() 方法,因为 LED 不会闪烁(即使在没有开关/案例的情况下直接执行 onNotify() 之后)
缺少有关 CustomGatt 的文档,并且似乎阻碍了许多人将传感器集成到其他平台(Raspberry Pi 或运行 BT 堆栈的通用处理器)上。 我之前尝试使用来自基本微控制器和 BT 模块的直接 AT 命令访问 movesense 平台,但没有成功(Movesense direct access to GATT endpoints),所以现在我转向 Raspberry 解决方案 + Qt 没有成功。
感谢您对此问题的任何示例或答案!
【问题讨论】: