blob: 375aebb514c90545ae729e3891e1925728585201 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
package org.qtproject.qt.android.bluetooth;
import android.bluetooth.BluetoothGattCharacteristic;
import android.os.Build;
import java.util.UUID;
public class QtBluetoothGattCharacteristic extends BluetoothGattCharacteristic {
public QtBluetoothGattCharacteristic(UUID uuid, int properties, int permissions,
int minimumValueLength, int maximumValueLength) {
super(uuid, properties, permissions);
minValueLength = minimumValueLength;
maxValueLength = maximumValueLength;
}
public int minValueLength;
public int maxValueLength;
// Starting from API 33 Android Bluetooth deprecates characteristic local value caching by
// deprecating the getValue() and setValue() accessors. For peripheral role we store the value
// locally in the characteristic as a convenience - looking up the value on the C++ side would
// be somewhat complicated. This should be safe as all accesses to this class are synchronized.
// For clarity: For API levels below 33 we still need to use the setValue() of the base class
// because Android internally uses getValue() with APIs below 33.
public boolean setLocalValue(byte[] value) {
if (Build.VERSION.SDK_INT >= 33) {
m_localValue = value;
return true;
} else {
return setValue(value);
}
}
public byte[] getLocalValue()
{
if (Build.VERSION.SDK_INT >= 33)
return m_localValue;
else
return getValue();
}
private byte[] m_localValue = null;
}
|