AndroidのGATT特性を読むための適切な方法は何ですか?
-
21-12-2019 - |
質問
Android API 18でBluetooth低エネルギーGATT特性の値を読み取ろうとすると、私は次のジレンマに遭遇しました:特性に保存されている値を取り出すための適切な方法は何ですか?そしてこの行動が起こるべきレベルのスタックのどのレベルで起こるか?
私自身の研究を行う際に、私が理解していることに2つの可能な方法があることにつまずいた:
- Bluetoothgatt .ReadCharactical(BluetoothGatch特性)
-
BluetoothgattCharactical .getValue()
public void onClick(View v){ byteValue = mBTValueCharacteristic.getValue(); if ((byteValue[0] & 0x01) == 1) byteValue[0] = 0x00; else byteValue[0] = 0x01; mBTValueCharacteristic.setValue(byteValue); mBTGatt.writeCharacteristic(mBTValueCharacteristic); }
解決
BluetoothGatt.readCharacteristic(BluetoothGattCharacteristic characteristic)
.
この関数は、Bluetoothからの特性値を使用してBluetoothGattCharacticオブジェクトを(Androidデバイス上で)更新しています。
BluetoothGattCharacteristic.getValue()
.
この関数は、BluetoothGattChatticalisticオブジェクトの単なるゲッター関数です。AndroidとBluetoothデバイスの間の取引はありません。
所属していません StackOverflow