繁体   English   中英

如何在iOS上使用BLE(蓝牙低功耗)从人体秤以CBPeripheral形式获取数据

[英]How to get data from body scale as CBPeripheral using BLE (Bluetooth Low Energy) on iOS

我刚开始使用蓝牙,想通过蓝牙从体重秤(型号:adeVital Analysis BA 1401)读取身体成分测量值。

将iPhone设置为Central并将其连接到电子秤(即CBPeripheral)时,我可以读取电子秤的设备信息,例如硬件修订号,制造商等。但是我无法获得实际的测量数据。

我遍历了所有服务和特性并设置了通知标志。

[peripheral setNotifyValue:YES forCharacteristic:aCharacteristic]

对于每个特征。 和委托方法

- (void) peripheral:(CBPeripheral *)peripheral didUpdateNotificationStateForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error {

被正确调用。 当我检查更新的外围设备时,我发现:

<CBCharacteristic: 0x1740949b0, UUID = 8A82, properties = 0x20, value = <a1014711 f3000000 00000000 00000000 00000000>, notifying = YES>

这一切都在秤打开时发生(尚未测量任何东西)。 现在,当我踩秤并完成测量时,它会显示一个蓝牙图标,指示数据传输,但是iOS应用程序未收到任何通知。 我想念什么?

总结如下:外设连接到中央并测量之前更新特性,但是此后,不再发出通知。

更新后的CBCharacteristic中的值是否可以是我必须以某种方式订阅以获取实际数据的服务的UUID?

希望有人可以帮助我

编辑:

可能相关,以下是我收到的服务和特性:

Services:
"<CBService: 0x17407dc40, isPrimary = YES, UUID = Device Information>",
"<CBService: 0x174070f80, isPrimary = YES, UUID = 7802>"

Characteristics
"<CBCharacteristic: 0x1740959a0, UUID = Serial Number String, properties = 0x2, value = (null), notifying = NO>",
"<CBCharacteristic: 0x174095900, UUID = Hardware Revision String, properties = 0x2, value = (null), notifying = NO>",
"<CBCharacteristic: 0x1740952c0, UUID = Firmware Revision String, properties = 0x2, value = (null), notifying = NO>",
"<CBCharacteristic: 0x1740958b0, UUID = Manufacturer Name String, properties = 0x2, value = (null), notifying = NO>",
"<CBCharacteristic: 0x174095860, UUID = Software Revision String, properties = 0x2, value = (null), notifying = NO>"

"<CBCharacteristic: 0x170095ea0, UUID = 8A21, properties = 0x20, value = (null), notifying = NO>",
"<CBCharacteristic: 0x170095e50, UUID = 8A22, properties = 0x20, value = (null), notifying = NO>",
"<CBCharacteristic: 0x1700952c0, UUID = 8A20, properties = 0x2, value = (null), notifying = NO>",
"<CBCharacteristic: 0x170095e00, UUID = 8A81, properties = 0x8, value = (null), notifying = NO>",
"<CBCharacteristic: 0x170095db0, UUID = 8A82, properties = 0x20, value = (null), notifying = NO>"

编辑2:

CBCharacteristics具有以下属性:

8A20 = Read
8A21 = Indicate
8A22 = Indicate
8A81 = Write
8A82 = Indicate

所有其他属性均为BOOL NO

当我打开有关8A21、8A22和8A82的通知时,我一开始就从8A82收到了一个N​​SData,打开了比例尺(因此该点不能作为测量值)。 我假设实际测量数据正在通过8A21特性进行更新。 但是它不会通知我的代表,我也不知道为什么。

查看系统日志,您可以看到制造商的官方应用程序将日志溢出,如下所示:

Feb 20 14:19:49 i6S lifesensehealth1_1[4163]: message = receive push data(<a1018b3b 02000000 00000000 00000000 00000000>),with command(a1), from characteristic(8A82)
Feb 20 14:19:49 i6S lifesensehealth1_1[4163]: message = receive randomnumber (37456641)
Feb 20 14:19:49 i6S lifesensehealth1_1[4163]: message = next step is :operating_receive_random_number
Feb 20 14:19:49 i6S lifesensehealth1_1[4163]: message = next step is :operating_write_xor_results
Feb 20 14:19:49 i6S lifesensehealth1_1[4163]: message = write command with data:<200eff57 c5>
Feb 20 14:19:49 i6S lifesensehealth1_1[4163]: message = write command data((null)) to characteristic(8A81)
Feb 20 14:19:49 i6S lifesensehealth1_1[4163]: message = write success with status - operating_write_xor_results
Feb 20 14:19:49 i6S lifesensehealth1_1[4163]: message = next step is :operating_write_utc_time
Feb 20 14:19:49 i6S lifesensehealth1_1[4163]: message = write command with data:<02033b8b 0b>
Feb 20 14:19:49 i6S lifesensehealth1_1[4163]: message = write command data((null)) to characteristic(8A81)
Feb 20 14:19:49 i6S lifesensehealth1_1[4163]: message = write success with status - operating_write_utc_time
Feb 20 14:19:49 i6S lifesensehealth1_1[4163]: message = next step is :operating_write_disconnect
Feb 20 14:19:49 i6S lifesensehealth1_1[4163]: message = write command with data:<22>
Feb 20 14:19:49 i6S lifesensehealth1_1[4163]: message = write command data((null)) to characteristic(8A81)
Feb 20 14:19:49 i6S lifesensehealth1_1[4163]: message = write success with status - operating_write_disconnect
Feb 20 14:19:49 i6S lifesensehealth1_1[4163]: message = next step is :operating_uploaded_results_process

您需要首先将某些数据写入特定的特征。 在我的情况下,该特性是8A81 我编写了一个UTC时间代码的字节数组,该代码是通过无法在此处发布的算法生成的。 尝试向其中写入任何5字节长的数组/字符,看看会发生什么(例如: [1,1,1,1,1]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM