22 Şubat 2018 Perşembe

BluetoothGatt Sınıfı

Giriş
GATT için açıklama şöyle.
GATT is an acronym for the Generic Attribute Profile, and it defines the way that two Bluetooth Low Energy devices transfer data back and forth using concepts called Services and Characteristics. It makes use of a generic data protocol called the Attribute Protocol (ATT), which is used to store Services, Characteristics and related data in a simple lookup table using 16-bit IDs for each entry in the table.
readCharacteristics metodu
Açıklaması şöyle.
Calling readCharacteristic in sequence (without delay) will not work.

You have to wait for onCharacteristicRead for the first call before initiating the second one.

When you connect to the BLE device using connectGatt, you have to provide a BluetoothGattCallback. Implement onCharacteristicRead in that BluetoothGattCallback object, it will be called after each readCharacteristic actually finish. Inside that function you should read the next characteristic in queue until there is none.
Şöyle yaparız.
mGatt.readCharacteristic(...);

Hiç yorum yok:

Yorum Gönder