forked from agro1desenvolvimento/capacitor-bluetooth-serial
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdefinitions.ts
134 lines (103 loc) · 3.04 KB
/
definitions.ts
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import {PluginListenerHandle} from "@capacitor/core";
export interface BluetoothSerialPlugin {
isEnabled(): Promise<BluetoothState>;
/**
* Checks whether Bluetooth can be enabled on the device.
*
* @return {Promise<BluetoothState>} A promise that resolves to the current state of Bluetooth, indicating if it can be enabled.
*/
canEnable(): Promise<BluetoothState>;
/**
* Enables the Bluetooth functionality on the device.
*
* @return {Promise<BluetoothState>} A promise that resolves to the current state of Bluetooth after enabling it, encapsulated as a `BluetoothState` object.
*/
enable(): Promise<BluetoothState>;
/**
* Disable bluetooth (turn bluetooth off)
* @since 0.0.5
*/
disable(): Promise<BluetoothState>;
/**
* Start to listen bluetooth state changes (will emit a 'onEnabledChanged' event when state changed)
* @since 0.0.5
*/
startEnabledNotifications(): Promise<void>;
/**
* Stop to listen bluetooth state changes
* @since 0.0.5
*/
stopEnabledNotifications(): Promise<void>;
scan(): Promise<BluetoothScanResult>;
connect(options: BluetoothConnectOptions): Promise<void>;
connectInsecure(options: BluetoothConnectOptions): Promise<void>;
disconnect(options: BluetoothConnectOptions): Promise<void>;
isConnected(options: BluetoothConnectOptions): Promise<BluetoothConnectResult>;
read(options: BluetoothReadOptions): Promise<BluetoothReadResult>;
readUntil(options: BluetoothReadUntilOptions): Promise<BluetoothReadResult>;
write(options: BluetoothWriteOptions): Promise<void>;
startNotifications(options: BluetoothStartNotificationsOptions): Promise<void>;
stopNotifications(options: BluetoothStopNotificationsOptions): Promise<void>;
/**
* Listen for device input value
* @since 0.0.5
*/
addListener(
eventName: 'onRead',
listenerFunc: (result: BluetoothReadResult) => void,
): Promise<PluginListenerHandle>;
/**
* Listen for bluetooth state changed
* @since 0.0.5
*/
addListener(
eventName: 'onEnabledChanged',
listenerFunc: (result: BluetoothState) => void,
): Promise<PluginListenerHandle>;
/**
*
* @since 0.0.5
*/
removeAllListeners(): Promise<void>;
}
export interface BluetoothState {
enabled: boolean;
}
export interface BluetoothScanResult {
devices: BluetoothDevice[];
}
export interface BluetoothConnectResult {
connected: boolean;
}
export interface BluetoothReadResult {
value: string;
}
export interface BluetoothDevice {
name: string;
id: string;
address: string;
class: number;
uuid: string;
rssi: number;
}
export interface BluetoothConnectOptions {
address: string;
}
export interface BluetoothReadOptions {
address: string;
}
export interface BluetoothReadUntilOptions {
address: string;
delimiter: string;
}
export interface BluetoothWriteOptions {
address: string;
value: string;
}
export interface BluetoothStartNotificationsOptions {
address: string;
delimiter: string;
}
export interface BluetoothStopNotificationsOptions {
address: string;
}