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.
|
rx.Observable<java.lang.Byte> |
observeByteStream()
Observes byte from bluetooth's
InputStream. |
rx.Observable<java.lang.String> |
observeStringStream()
Observes string from bluetooth's
InputStream with '\r' (Carriage Return)
and '\n' (New Line) as delimiter. |
rx.Observable<java.lang.String> |
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 rx.Observable<java.lang.Byte> observeByteStream()
InputStream. Will be emitted per byte.Bytepublic rx.Observable<java.lang.String> observeStringStream()
InputStream with '\r' (Carriage Return)
and '\n' (New Line) as delimiter.Stringpublic rx.Observable<java.lang.String> 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()