public class BluetoothConnection
extends java.lang.Object
| Constructor and Description |
|---|
BluetoothConnection(android.bluetooth.BluetoothSocket socket)
Container for simplifying read and write from/to
BluetoothSocket. |
| Modifier and Type | Method and Description |
|---|---|
void |
closeConnection()
Close the streams and socket connection.
|
<any> |
observeByteStream()
Observes byte from bluetooth's
InputStream. |
<any> |
observeStringStream()
Observes string from bluetooth's
InputStream with '\r' (Carriage Return)
and '\n' (New Line) as delimiter. |
<any> |
observeStringStream(int... delimiter)
Observes string from bluetooth's
InputStream. |
boolean |
send(byte oneByte)
Send one byte to bluetooth output stream.
|
boolean |
send(byte[] bytes)
Send array of bytes to bluetooth output stream.
|
boolean |
send(java.lang.String text)
Send string of text to bluetooth output stream.
|
public BluetoothConnection(android.bluetooth.BluetoothSocket socket)
throws java.lang.Exception
BluetoothSocket.socket - bluetooth socketjava.lang.Exception - if can't get input/output stream from the socketpublic <any> observeByteStream()
InputStream. Will be emitted per byte.Bytepublic <any> observeStringStream()
InputStream with '\r' (Carriage Return)
and '\n' (New Line) as delimiter.Stringpublic <any> observeStringStream(int... delimiter)
InputStream.delimiter - char(s) used for string delimiterStringpublic boolean send(byte oneByte)
oneByte - a bytepublic boolean send(byte[] bytes)
bytes - data to sendpublic boolean send(java.lang.String text)
text - text to sendpublic void closeConnection()