public class BLEProtocol
extends BluetoothProtocol
| Modifier and Type | Class and Description |
|---|---|
static interface |
BLEProtocol.StepCode |
| Modifier and Type | Field and Description |
|---|---|
BLEConfig |
bleConfig |
java.util.List<android.bluetooth.BluetoothGatt> |
bluetoothGattList |
static long |
CONNECT_DELAY_MILLISECONDS |
static long |
RX_TX_DELAY_MILLISECONDS |
| Constructor and Description |
|---|
BLEProtocol(android.content.Context context,
android.bluetooth.BluetoothDevice mDevice) |
| Modifier and Type | Method and Description |
|---|---|
void |
_connect() |
void |
_disconnect() |
void |
connectToGatt() |
long |
discoverServices() |
void |
enableCharacteristicNotification(java.util.UUID svcUuid,
java.util.UUID charUuid,
byte[] enableType) |
static BLEProtocol |
fromAddress(android.content.Context context,
java.lang.String address)
Instantiate a BLE protocol object from the bluetooth address.
|
static BLEProtocol |
fromDevice(android.content.Context context,
android.bluetooth.BluetoothDevice bluetoothDevice)
Instantiate a BLE protocol object from the bluetooth address.
|
android.bluetooth.BluetoothDevice |
getBluetoothDevice() |
android.bluetooth.BluetoothGattCharacteristic |
getCharacteristic(android.bluetooth.BluetoothGatt gatt,
java.util.UUID svcUuid,
java.util.UUID charUuid) |
int |
getConnectionPriority() |
HostProtocol |
getType() |
boolean |
hasIotizeBufferService() |
byte[] |
read() |
byte[] |
send(byte[] message) |
void |
sendWithIndication(byte[] data)
BLE indications need to be acknowledged by the client whereas notifications do not
|
void |
sendWithNotification(byte[] data) |
void |
setCharacteristicNotification(java.util.UUID svcUuid,
java.util.UUID charUuid,
boolean enabled,
byte[] enableType) |
BLEProtocol |
setConnectionEventListener(OnConnectionStepProgress connectionEventListener) |
void |
setConnectionPriority(int connectionPriority) |
java.lang.String |
toString() |
void |
write(byte[] data) |
public static final long RX_TX_DELAY_MILLISECONDS
public static final long CONNECT_DELAY_MILLISECONDS
@NonNull public BLEConfig bleConfig
@NonNull public final java.util.List<android.bluetooth.BluetoothGatt> bluetoothGattList
public BLEProtocol(@NonNull
android.content.Context context,
@NonNull
android.bluetooth.BluetoothDevice mDevice)
public BLEProtocol setConnectionEventListener(OnConnectionStepProgress connectionEventListener)
public void setConnectionPriority(int connectionPriority)
public int getConnectionPriority()
public static BLEProtocol fromAddress(@NonNull android.content.Context context, @NonNull java.lang.String address) throws AdapterNotAvailableException
context - Android contextaddress - the bluetooth address of the deviceAdapterNotAvailableException - if Bluetooth adapter is not availablepublic static BLEProtocol fromDevice(@NonNull android.content.Context context, android.bluetooth.BluetoothDevice bluetoothDevice) throws AdapterNotAvailableException
context - Android contextbluetoothDevice - the android bluetooth device to connect toAdapterNotAvailableException - if Bluetooth adapter is not availablepublic void _connect()
throws java.lang.Exception
java.lang.Exceptionpublic void _disconnect()
throws java.lang.Exception
java.lang.Exceptionpublic void write(byte[] data)
throws java.lang.Exception
java.lang.Exceptionpublic void connectToGatt()
throws AdapterNotAvailableException
AdapterNotAvailableExceptionpublic byte[] send(byte[] message)
throws java.lang.Exception
java.lang.Exceptionpublic byte[] read()
throws java.lang.Exception
java.lang.Exceptionpublic void sendWithIndication(byte[] data)
throws CannotWriteCharacteristicException,
WritePacketIsTooBigException
data - data bytes to sendCannotWriteCharacteristicException - write characteristic failWritePacketIsTooBigException - when data packet is too bigpublic void sendWithNotification(@NonNull
byte[] data)
throws CannotWriteCharacteristicException,
WritePacketIsTooBigException
public HostProtocol getType()
public android.bluetooth.BluetoothGattCharacteristic getCharacteristic(android.bluetooth.BluetoothGatt gatt,
java.util.UUID svcUuid,
java.util.UUID charUuid)
throws ServiceNotAvailableException,
CharacteristicNotAvailableException
public boolean hasIotizeBufferService()
public void enableCharacteristicNotification(java.util.UUID svcUuid,
java.util.UUID charUuid,
byte[] enableType)
throws java.lang.Exception
java.lang.Exceptionpublic void setCharacteristicNotification(java.util.UUID svcUuid,
java.util.UUID charUuid,
boolean enabled,
byte[] enableType)
throws java.lang.Exception
java.lang.Exceptionpublic long discoverServices()
throws java.lang.Exception
java.lang.Exceptionpublic android.bluetooth.BluetoothDevice getBluetoothDevice()
public java.lang.String toString()