Bluetoothを使い始めたばかりですが、体重計(型式:adeVital Analysis BA1401)の体組成測定値をBluetooth経由で読み取りたいです。
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>
これはすべて、スケールがオンになっているときに発生します (まだ何も測定していません)。体重計に乗って測定が完了すると、データ転送を示す Bluetooth アイコンが表示されますが、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 を表示すると、メーカーの公式アプリが次のようにログを流出していることがわかります。
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