-
-
Notifications
You must be signed in to change notification settings - Fork 62
Expand file tree
/
Copy pathSimpleBluetoothDeviceInterface.kt
More file actions
60 lines (49 loc) · 1.65 KB
/
SimpleBluetoothDeviceInterface.kt
File metadata and controls
60 lines (49 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package com.harrysoft.androidbluetoothserial
import java.io.InputStream
import java.io.OutputStream
interface SimpleBluetoothDeviceInterface {
/**
* @return The BluetoothSerialDevice instance that the interface is wrapping.
*/
val device: BluetoothSerialDevice
fun sendMessage(message: String)
/**
* Set all of the listeners for the interfact
*
* @param messageReceivedListener Receive message callback
* @param messageSentListener Send message callback (indicates that a message was successfully sent)
* @param errorListener Error callback
*/
fun setListeners(messageReceivedListener: OnMessageReceivedListener?,
messageSentListener: OnMessageSentListener?,
errorListener: OnErrorListener?)
/**
* Set the message received listener
*
* @param listener Receive message callback
*/
fun setMessageReceivedListener(listener: OnMessageReceivedListener?)
/**
* Set the message sent listener
*
* @param listener Send message callback (indicates that a message was successfully sent)
*/
fun setMessageSentListener(listener: OnMessageSentListener?)
/**
* Set the error listener
*
* @param listener Error callback
*/
fun setErrorListener(listener: OnErrorListener?)
interface OnMessageReceivedListener {
fun onMessageReceived(message: String)
}
interface OnMessageSentListener {
fun onMessageSent(message: String)
}
interface OnErrorListener {
fun onError(error: Throwable)
}
fun getOutputStream(): OutputStream
fun getInputStream(): InputStream
}