實作藍牙經典(Bluetooth Classic)通訊的類別,並繼承自 AComm 類別。 更多...
公開方法(Public Methods) | |
| BTClassicConnection (String descriptor) | |
| 根據 descriptor 字串初始化新實例。 更多... | |
| BTClassicConnection (long bt_address) | |
| 根據 macAddress 初始化新實例。 需先與印表機進行藍牙配對後才能連線。 更多... | |
| int | BytesAvailable () |
| String | Descriptor () |
| boolean | Connected () |
| void | Close () |
| void | Open () |
| byte[] | Read () |
| void | Write (byte[] dataOut) |
公開方法(Public Methods) 繼承自 com.UniPRT.Sdk.Comm.AComm | |
| void | Read (OutputStream binDataIn) throws IOException |
| void | WaitForData (int msTimeOut) |
| 等待當前執行緒有可用的資料 BytesAvailable。當前執行緒會休眠直到收到資料或超時為止。此為阻塞呼叫。 更多... | |
| void | Write (InputStream binReader) throws IOException |
| 從輸入流寫入輸出流。 更多... | |
| void | WriteAndWaitForResponse (OutputStream binDataIn, InputStream binDataOut, int responseStartTimeOut, int responseEndTimeOut, String completetionToken) throws IOException |
| 將 binDataOut 流資料寫入輸出流,並將接收到的資料返回到 binDataIn 流中。返回的資料是收到的資料或收到的完成標記。等待回應超時後返回。 更多... | |
| byte[] | WriteAndWaitForResponse (byte[] dataOut, int responseStartTimeOut, int responseEndTimeOut, String completetionToken) throws IOException |
| 將位元組資料寫入輸出流並返回接收到的資料。返回的資料是接收到的任何資料或收到的完成標記。等待回應超時後返回。 更多... | |
靜態公開方法(Static Public Methods) | |
| static long | DescriptorValidate (String descriptorHint) |
| 從 descriptorHint 驗證描述字串是否有效,可能包含或不包含 v_id 與 p_id。返回 long 值。 更多... | |
私有屬性 | |
| BluetoothAdapter | mBluetoothAdapter = null |
| BluetoothSocket | btSocket = null |
| OutputStream | OutStream = null |
| InputStream | InStream = null |
| long | _bt_address |
靜態私有屬性 | |
| static final UUID | MY_UUID_SECURE = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB") |
| static final int | BLOCK_SIZE = 1024 |
實作藍牙經典(Bluetooth Classic)通訊的類別,並繼承自 AComm 類別。
| com.UniPRT.Sdk.Comm.BTClassicConnection.BTClassicConnection | ( | String | descriptor | ) |
根據 descriptor 字串初始化新實例。
| descriptor | 可接受格式:
|
參考 com.UniPRT.Sdk.Comm.BTClassicConnection._bt_address, 及 com.UniPRT.Sdk.Comm.BTClassicConnection.DescriptorValidate().
| com.UniPRT.Sdk.Comm.BTClassicConnection.BTClassicConnection | ( | long | bt_address | ) |
根據 macAddress 初始化新實例。 需先與印表機進行藍牙配對後才能連線。
| [in] | macAddress | 透過藍牙 MAC 位址指定要連線的印表機,例如:0x0080A3123456L |
| int com.UniPRT.Sdk.Comm.BTClassicConnection.BytesAvailable | ( | ) |
Get the number of bytes available to read.
| void com.UniPRT.Sdk.Comm.BTClassicConnection.Close | ( | ) |
| boolean com.UniPRT.Sdk.Comm.BTClassicConnection.Connected | ( | ) |
Check if connection is established.
| String com.UniPRT.Sdk.Comm.BTClassicConnection.Descriptor | ( | ) |
Get the string descriptor of the connection.
|
static |
從 descriptorHint 驗證描述字串是否有效,可能包含或不包含 v_id 與 p_id。返回 long 值。
可接受的 descriptorHint 格式:
被參考於 com.UniPRT.Sdk.Comm.BTClassicConnection.BTClassicConnection().
| void com.UniPRT.Sdk.Comm.BTClassicConnection.Open | ( | ) |
Open the connection.
參考 com.UniPRT.Sdk.Comm.BTClassicConnection._bt_address, com.UniPRT.Sdk.Comm.BTClassicConnection.btSocket, com.UniPRT.Sdk.Comm.BTClassicConnection.Close(), com.UniPRT.Sdk.Comm.BTClassicConnection.InStream, com.UniPRT.Sdk.Comm.BTClassicConnection.mBluetoothAdapter, com.UniPRT.Sdk.Comm.BTClassicConnection.MY_UUID_SECURE, 及 com.UniPRT.Sdk.Comm.BTClassicConnection.OutStream.
| byte [] com.UniPRT.Sdk.Comm.BTClassicConnection.Read | ( | ) |
Read all available bytes.
參考 com.UniPRT.Sdk.Comm.BTClassicConnection.BytesAvailable(), 及 com.UniPRT.Sdk.Comm.BTClassicConnection.InStream.
| void com.UniPRT.Sdk.Comm.BTClassicConnection.Write | ( | byte[] | dataOut | ) |
Write all bytes from the array passed in.
| dataOut | Byte array to write. |
參考 com.UniPRT.Sdk.Comm.BTClassicConnection.BLOCK_SIZE, 及 com.UniPRT.Sdk.Comm.BTClassicConnection.OutStream.
|
private |
|
staticprivate |
|
private |
|
private |
|
private |
|
staticprivate |
|
private |