forked from innoveit/react-native-ble-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
167 lines (148 loc) · 4.32 KB
/
index.d.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
declare module "react-native-ble-manager" {
export interface Peripheral {
id: string;
rssi: number;
name?: string;
advertising: AdvertisingData;
}
export interface AdvertisingData {
isConnectable?: boolean;
localName?: string;
manufacturerData?: any;
serviceUUIDs?: string[];
txPowerLevel?: number;
}
export interface StartOptions {
showAlert?: boolean;
restoreIdentifierKey?: string;
queueIdentifierKey?: string;
forceLegacy?: boolean;
}
export function start(options?: StartOptions): Promise<void>;
export interface ScanOptions {
numberOfMatches?: number;
matchMode?: number;
scanMode?: number;
reportDelay?: number;
phy?: number;
legacy?: boolean;
}
export function scan(
serviceUUIDs: string[],
seconds: number,
allowDuplicates?: boolean,
options?: ScanOptions
): Promise<void>;
export function stopScan(): Promise<void>;
export function connect(peripheralID: string): Promise<void>;
export function disconnect(
peripheralID: string,
force?: boolean
): Promise<void>;
export function checkState(): void;
export function startNotification(
peripheralID: string,
serviceUUID: string,
characteristicUUID: string
): Promise<void>;
/// Android only
export function startNotificationUseBuffer(
peripheralID: string,
serviceUUID: string,
characteristicUUID: string,
buffer: number
): Promise<void>;
export function stopNotification(
peripheralID: string,
serviceUUID: string,
characteristicUUID: string
): Promise<void>;
export function read(
peripheralID: string,
serviceUUID: string,
characteristicUUID: string
): Promise<any>;
export function write(
peripheralID: string,
serviceUUID: string,
characteristicUUID: string,
data: any,
maxByteSize?: number
): Promise<void>;
export function writeWithoutResponse(
peripheralID: string,
serviceUUID: string,
characteristicUUID: string,
data: any,
maxByteSize?: number,
queueSleepTime?: number
): Promise<void>;
export function readRSSI(peripheralID: string): Promise<void>;
export function getConnectedPeripherals(
serviceUUIDs: string[]
): Promise<Peripheral[]>;
export function getDiscoveredPeripherals(): Promise<Peripheral[]>;
export function isPeripheralConnected(
peripheralID: string,
serviceUUIDs: string[]
): Promise<boolean>;
// [Android only API 21+]
export enum ConnectionPriority {
balanced = 0,
high = 1,
low = 2,
}
export function requestConnectionPriority(
peripheralID: string,
connectionPriority: ConnectionPriority
): Promise<void>;
/// Android only
export function enableBluetooth(): Promise<void>;
// [Android only]
export function refreshCache(peripheralID: string): Promise<void>;
// [Android only API 21+]
export function requestMTU(peripheralID: string, mtu: number): Promise<number>;
export function createBond(
peripheralID: string,
peripheralPin?: string
): Promise<void>;
export function removeBond(peripheralID: string): Promise<void>;
export function getBondedPeripherals(): Promise<Peripheral[]>;
export function removePeripheral(peripheralID: string): Promise<void>;
// [Android only]
export function setName(name: string): void;
export interface Service {
uuid: string;
}
export interface Descriptor {
value: string;
uuid: string;
}
export interface Characteristic {
// See https://developer.apple.com/documentation/corebluetooth/cbcharacteristicproperties
properties: {
Broadcast?: "Broadcast";
Read?: "Read";
WriteWithoutResponse?: "WriteWithoutResponse";
Write?: "Write";
Notify?: "Notify";
Indicate?: "Indicate";
AuthenticatedSignedWrites?: "AuthenticatedSignedWrites";
ExtendedProperties?: "ExtendedProperties";
NotifyEncryptionRequired?: "NotifyEncryptionRequired";
IndicateEncryptionRequired?: "IndicateEncryptionRequired";
}
characteristic: string;
service: string;
descriptors?: Descriptor[];
}
export interface PeripheralInfo extends Peripheral {
serviceUUIDs?: string[];
characteristics?: Characteristic[];
services?: Service[];
}
export function retrieveServices(
peripheralID: string,
serviceUUIDs?: string[]
): Promise<PeripheralInfo>;
}