我刚开始使用蓝牙,想通过蓝牙从身体秤(型号: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 的 NSData,此时比例已打开(因此此时不能进行测量)。我假设,实际测量数据正在由 8A21 特性更新。但是它不会通知我的代表,我不知道为什么。
查看syslog可以看到厂商官方app溢出日志如下:
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