Class that implements the BLE specific communication and extends the AComm class. More...
Public Member Functions | |
| BLEConnection (Context context, String address) | |
| Initialize new class instance based on descriptor string. More... | |
| int | BytesAvailable () |
| String | Descriptor () |
| Validate descriptor string from descriptorHint that may or may not have a v_id and p_id. Returns long. More... | |
| boolean | Connected () |
| void | Close () |
| void | CloseWithTimeout (int timeoutMs) |
| void | Open () |
| byte[] | Read () |
| void | Write (byte[] dataOut) |
Public Member Functions inherited from com.UniPRT.Sdk.Comm.AComm | |
| void | Read (OutputStream binDataIn) throws IOException |
| void | WaitForData (int msTimeOut) |
| Waits until data available BytesAvailable in current thread. Current thread sleeps until data received or timeout reached. Blocking call. More... | |
| void | Write (InputStream binReader) throws IOException |
| Write from input stream to output stream. More... | |
| void | WriteAndWaitForResponse (OutputStream binDataIn, InputStream binDataOut, int responseStartTimeOut, int responseEndTimeOut, String completetionToken) throws IOException |
| Write binDataOut stream data to output stream and return data received in binDataIn stream. Data returned is any data received or up to completion token if received. Wait for response timeout before returning. More... | |
| byte[] | WriteAndWaitForResponse (byte[] dataOut, int responseStartTimeOut, int responseEndTimeOut, String completetionToken) throws IOException |
| Write byte data to output stream and return data received. Data returned is any data received or up to completion token if received. Wait for response timeout before returning. More... | |
Static Public Member Functions | |
| static CompletableFuture< List< BluetoothDevice > > | scanDevicesForDuration (int seconds) |
Private Member Functions | |
| CompletableFuture< Void > | waitForDisconnectedAsync (int timeoutMs) |
| CompletableFuture< Void > | waitForConnectedAsync (int timeoutMs) |
| void | waitAck () throws InterruptedException |
| void | notifyAck () |
Private Attributes | |
| BluetoothDevice | device |
| BluetoothGatt | mBluetoothGatt |
| BluetoothGattCharacteristic | rxCharacteristic |
| BluetoothGattCharacteristic | txCharacteristic |
| String | deviceAddress = "" |
| ByteArrayOutputStream | byteArrayOutputStream = new ByteArrayOutputStream() |
| int | ble_mtu = 512 |
| boolean | isConnected = false |
| final Object | ackLock = new Object() |
| boolean | ackReceived = false |
| final Context | context |
| final Semaphore | semaphore = new Semaphore(1) |
| final BluetoothGattCallback | mGattCallback |
Static Private Attributes | |
| static final UUID | SERVICE_UUID = UUID.fromString("0000fff0-0000-1000-8000-00805f9b34fb") |
| static final UUID | TX_UUID = UUID.fromString("0000fff1-0000-1000-8000-00805f9b34fb") |
| static final UUID | RX_UUID = UUID.fromString("0000fff2-0000-1000-8000-00805f9b34fb") |
| static BluetoothAdapter | mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter() |
Class that implements the BLE specific communication and extends the AComm class.
| com.UniPRT.Sdk.Comm.BLEConnection.BLEConnection | ( | Context | context, |
| String | address | ||
| ) |
Initialize new class instance based on descriptor string.
| descriptor | Acceptable Formats:
|
References com.UniPRT.Sdk.Comm.BLEConnection.context.
| int com.UniPRT.Sdk.Comm.BLEConnection.BytesAvailable | ( | ) |
Get the number of bytes available to read.
Implements com.UniPRT.Sdk.Comm.IComm.
References com.UniPRT.Sdk.Comm.BLEConnection.byteArrayOutputStream.
| void com.UniPRT.Sdk.Comm.BLEConnection.Close | ( | ) |
Close the connection.
Implements com.UniPRT.Sdk.Comm.IComm.
References com.UniPRT.Sdk.Comm.BLEConnection.CloseWithTimeout().
| void com.UniPRT.Sdk.Comm.BLEConnection.CloseWithTimeout | ( | int | timeoutMs | ) |
| boolean com.UniPRT.Sdk.Comm.BLEConnection.Connected | ( | ) |
Check if connection is established.
Implements com.UniPRT.Sdk.Comm.IComm.
References com.UniPRT.Sdk.Comm.BLEConnection.isConnected.
Referenced by com.UniPRT.Sdk.Comm.BLEConnection.Open().
| String com.UniPRT.Sdk.Comm.BLEConnection.Descriptor | ( | ) |
Validate descriptor string from descriptorHint that may or may not have a v_id and p_id. Returns long.
descriptorHint accepted values:
Implements com.UniPRT.Sdk.Comm.IComm.
References com.UniPRT.Sdk.Comm.BLEConnection.deviceAddress.
|
private |
| void com.UniPRT.Sdk.Comm.BLEConnection.Open | ( | ) |
Open the connection.
Implements com.UniPRT.Sdk.Comm.IComm.
References com.UniPRT.Sdk.Comm.BLEConnection.CloseWithTimeout(), com.UniPRT.Sdk.Comm.BLEConnection.Connected(), com.UniPRT.Sdk.Comm.BLEConnection.context, com.UniPRT.Sdk.Comm.BLEConnection.device, com.UniPRT.Sdk.Comm.BLEConnection.deviceAddress, com.UniPRT.Sdk.Comm.BLEConnection.mBluetoothAdapter, com.UniPRT.Sdk.Comm.BLEConnection.mBluetoothGatt, com.UniPRT.Sdk.Comm.BLEConnection.mGattCallback, and com.UniPRT.Sdk.Comm.BLEConnection.waitForConnectedAsync().
| byte [] com.UniPRT.Sdk.Comm.BLEConnection.Read | ( | ) |
Read all available bytes.
Implements com.UniPRT.Sdk.Comm.IComm.
References com.UniPRT.Sdk.Comm.BLEConnection.byteArrayOutputStream, and com.UniPRT.Sdk.Comm.BLEConnection.semaphore.
|
static |
|
private |
References com.UniPRT.Sdk.Comm.BLEConnection.ackLock, and com.UniPRT.Sdk.Comm.BLEConnection.ackReceived.
Referenced by com.UniPRT.Sdk.Comm.BLEConnection.Write().
|
private |
References com.UniPRT.Sdk.Comm.BLEConnection.isConnected.
Referenced by com.UniPRT.Sdk.Comm.BLEConnection.Open().
|
private |
References com.UniPRT.Sdk.Comm.BLEConnection.isConnected.
Referenced by com.UniPRT.Sdk.Comm.BLEConnection.CloseWithTimeout().
| void com.UniPRT.Sdk.Comm.BLEConnection.Write | ( | byte[] | dataOut | ) |
Write all bytes from the array passed in.
| dataOut | Byte array to write. |
Implements com.UniPRT.Sdk.Comm.IComm.
References com.UniPRT.Sdk.Comm.BLEConnection.ble_mtu, com.UniPRT.Sdk.Comm.BLEConnection.mBluetoothGatt, com.UniPRT.Sdk.Comm.BLEConnection.rxCharacteristic, and com.UniPRT.Sdk.Comm.BLEConnection.waitAck().
|
private |
|
private |
|
private |
Referenced by com.UniPRT.Sdk.Comm.BLEConnection.Write().
|
private |
|
private |
|
private |
|
private |
|
private |
|
staticprivate |
|
private |
|
private |
Referenced by com.UniPRT.Sdk.Comm.BLEConnection.Open().
|
staticprivate |
|
private |
Referenced by com.UniPRT.Sdk.Comm.BLEConnection.Write().
|
private |
Referenced by com.UniPRT.Sdk.Comm.BLEConnection.Read().
|
staticprivate |
|
staticprivate |
|
private |