@moddable/typings 5.3.0 → 5.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ble/bleclient.d.ts +175 -0
- package/ble/bleserver.d.ts +303 -0
- package/ble/btutils.d.ts +117 -0
- package/ble/connection.d.ts +25 -0
- package/ble/gap.d.ts +109 -0
- package/ble/gatt.d.ts +186 -0
- package/ble/sm.d.ts +70 -0
- package/package.json +1 -1
- package/ble.d.ts +0 -732
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2022-2025 Richard Lea, Satoshi Tanaka
|
|
3
|
+
*
|
|
4
|
+
* This file is part of the Moddable SDK Tools.
|
|
5
|
+
*
|
|
6
|
+
* The Moddable SDK Tools is free software: you can redistribute it and/or modify
|
|
7
|
+
* it under the terms of the GNU General Public License as published by
|
|
8
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
* (at your option) any later version.
|
|
10
|
+
*
|
|
11
|
+
* The Moddable SDK Tools is distributed in the hope that it will be useful,
|
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
* GNU General Public License for more details.
|
|
15
|
+
*
|
|
16
|
+
* You should have received a copy of the GNU General Public License
|
|
17
|
+
* along with the Moddable SDK Tools. If not, see <http://www.gnu.org/licenses/>.
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
declare module "bleclient" {
|
|
22
|
+
|
|
23
|
+
import { GAP } from "gap";
|
|
24
|
+
import { Client, Service, Characteristic, Descriptor } from "gatt";
|
|
25
|
+
import { IOCapability } from "sm";
|
|
26
|
+
|
|
27
|
+
type gapScanFilterPolicies =
|
|
28
|
+
typeof GAP.ScanFilterPolicy.NONE |
|
|
29
|
+
typeof GAP.ScanFilterPolicy.NOT_RESOLVED_DIRECTED |
|
|
30
|
+
typeof GAP.ScanFilterPolicy.WHITELIST |
|
|
31
|
+
typeof GAP.ScanFilterPolicy.WHITELIST_NOT_RESOLVED_DIRECTED;
|
|
32
|
+
|
|
33
|
+
type securityParameters = {
|
|
34
|
+
encryption?: boolean,
|
|
35
|
+
bonding?: boolean,
|
|
36
|
+
mitm?: boolean,
|
|
37
|
+
ioCapability?: IOCapability,
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The `BLEClient` class provides access to the BLE client features.
|
|
42
|
+
*/
|
|
43
|
+
export class BLEClient {
|
|
44
|
+
|
|
45
|
+
securityParameters: securityParameters
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Applications must wait for the `onReady` callback before calling
|
|
49
|
+
* other `BLEClient` functions
|
|
50
|
+
*/
|
|
51
|
+
onReady(): void
|
|
52
|
+
|
|
53
|
+
onSecurityParameters(params: securityParameters): void
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The `startScanning` function enables scanning for nearby peripherals.
|
|
58
|
+
*
|
|
59
|
+
* @param params If params is not provided, the default scan properties are used.
|
|
60
|
+
* @url https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/network/ble/ble.md#startscanningparams
|
|
61
|
+
*/
|
|
62
|
+
startScanning(params?: {
|
|
63
|
+
active: boolean,
|
|
64
|
+
duplicates: boolean,
|
|
65
|
+
filterPolicy: gapScanFilterPolicies,
|
|
66
|
+
interval: number,
|
|
67
|
+
window: number,
|
|
68
|
+
}): void;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Called when one or more times for each peripheral device discovered.
|
|
72
|
+
* @param device
|
|
73
|
+
* @url https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/network/ble/ble.md#ondiscovereddevice
|
|
74
|
+
*/
|
|
75
|
+
onDiscovered(device: Client): void;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Disables scanning for nearby peripherals.
|
|
79
|
+
*/
|
|
80
|
+
stopScanning(): void;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Initiates a connection request between the `BLEClient` and a target peripheral `device`.
|
|
84
|
+
* @param device
|
|
85
|
+
*/
|
|
86
|
+
connect(device: Client): void;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Called when the client connects to a target peripheral `device`.
|
|
90
|
+
* @param device
|
|
91
|
+
* @url https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/network/ble/ble.md#onconnecteddevice
|
|
92
|
+
*/
|
|
93
|
+
onConnected(device: Client): void;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Called when the peripheral signal strength is read.
|
|
97
|
+
* @param device
|
|
98
|
+
* @param rssi
|
|
99
|
+
* @url https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/network/ble/ble.md#onrssidevice-rssi
|
|
100
|
+
*/
|
|
101
|
+
onRSSI(device: Client, rssi: number): void;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Called when the MTU exchange procedure has been completed.
|
|
105
|
+
* @param device
|
|
106
|
+
* @param mtu
|
|
107
|
+
* @url https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/network/ble/ble.md#onmtuexchangeddevice-mtu
|
|
108
|
+
*/
|
|
109
|
+
onMTUExchanged(device: Client, mtu: number): void;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Called when the client connection is closed.
|
|
113
|
+
* @param device
|
|
114
|
+
* @url https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/network/ble/ble.md#ondisconnecteddevice
|
|
115
|
+
*/
|
|
116
|
+
onDisconnected(device: Client): void;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Called when service discovery completes.
|
|
120
|
+
* @param services
|
|
121
|
+
* @url https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/network/ble/ble.md#onservicesservices
|
|
122
|
+
*/
|
|
123
|
+
onServices(services: Service[]): void;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Called when characteristic discovery completes.
|
|
127
|
+
* @param characteristics
|
|
128
|
+
* @url https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/network/ble/ble.md#oncharacteristicscharacteristics
|
|
129
|
+
*/
|
|
130
|
+
onCharacteristics(characteristics: Characteristic[]): void;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Called when a characteristic is read by the `readValue` function.
|
|
134
|
+
* @param characteristic
|
|
135
|
+
* @param value
|
|
136
|
+
* @url https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/network/ble/ble.md#oncharacteristicvaluecharacteristic-value
|
|
137
|
+
*/
|
|
138
|
+
onCharacteristicValue(characteristic: Characteristic, value: any): void;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Called when notifications are enabled and the peripheral notifies the characteristic value.
|
|
142
|
+
* @param characteristic
|
|
143
|
+
* @param buffer
|
|
144
|
+
* @url https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/network/ble/ble.md#oncharacteristicnotificationcharacteristic-value
|
|
145
|
+
*/
|
|
146
|
+
onCharacteristicNotification(characteristic: Characteristic, buffer: number[]): void;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Called when notifications have been enabled for the `characteristic`.
|
|
150
|
+
* @param characteristic
|
|
151
|
+
* @param buffer
|
|
152
|
+
* @url https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/network/ble/ble.md#oncharacteristicnotificationenabledcharacteristic
|
|
153
|
+
*/
|
|
154
|
+
onCharacteristicNotificationEnabled(characteristic: Characteristic): void;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Called when notifications have been disabled for the `characteristic`.
|
|
158
|
+
* @param characteristic
|
|
159
|
+
* @url https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/network/ble/ble.md#oncharacteristicnotificationdisabledcharacteristic
|
|
160
|
+
*/
|
|
161
|
+
onCharacteristicNotificationDisabled(characteristic: Characteristic): void;
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Called when a descriptor is read by the `readValue` function.
|
|
165
|
+
* @param descriptor
|
|
166
|
+
* @param value
|
|
167
|
+
* @url https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/network/ble/ble.md#ondescriptorvaluedescriptor-value
|
|
168
|
+
*/
|
|
169
|
+
onDescriptorValue(descriptor: Descriptor, value: any): void;
|
|
170
|
+
|
|
171
|
+
close(): void
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export { BLEClient as default };
|
|
175
|
+
}
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2022 Richard Lea
|
|
3
|
+
*
|
|
4
|
+
* This file is part of the Moddable SDK Tools.
|
|
5
|
+
*
|
|
6
|
+
* The Moddable SDK Tools is free software: you can redistribute it and/or modify
|
|
7
|
+
* it under the terms of the GNU General Public License as published by
|
|
8
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
* (at your option) any later version.
|
|
10
|
+
*
|
|
11
|
+
* The Moddable SDK Tools is distributed in the hope that it will be useful,
|
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
* GNU General Public License for more details.
|
|
15
|
+
*
|
|
16
|
+
* You should have received a copy of the GNU General Public License
|
|
17
|
+
* along with the Moddable SDK Tools. If not, see <http://www.gnu.org/licenses/>.
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
declare module "bleserver" {
|
|
22
|
+
|
|
23
|
+
import { GAP } from "gap";
|
|
24
|
+
import { Bytes } from "btutils";
|
|
25
|
+
import { Characteristic, Client } from "gatt";
|
|
26
|
+
import { IOCapability } from "sm";
|
|
27
|
+
|
|
28
|
+
type ManufacturerSpec = {
|
|
29
|
+
/**
|
|
30
|
+
* The `identifier` property is a number corresponding to the
|
|
31
|
+
* _Company Identifier Code_.
|
|
32
|
+
*/
|
|
33
|
+
identifier: string | number,
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The `data` property is an array of numbers corresponding
|
|
37
|
+
* to additional manufacturer specific data.
|
|
38
|
+
*/
|
|
39
|
+
data: number[],
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
type gapScanFilterPolicies =
|
|
43
|
+
typeof GAP.ScanFilterPolicy.NONE |
|
|
44
|
+
typeof GAP.ScanFilterPolicy.NOT_RESOLVED_DIRECTED |
|
|
45
|
+
typeof GAP.ScanFilterPolicy.WHITELIST |
|
|
46
|
+
typeof GAP.ScanFilterPolicy.WHITELIST_NOT_RESOLVED_DIRECTED;
|
|
47
|
+
|
|
48
|
+
type AdvertisementData = {
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The advertised flags value.
|
|
52
|
+
*/
|
|
53
|
+
flags?: number;
|
|
54
|
+
/**
|
|
55
|
+
* Array of UUID objects corresponding to _Incomplete List
|
|
56
|
+
* of 16 bit Service UUIDs_
|
|
57
|
+
*/
|
|
58
|
+
incompleteUUID16List?: Bytes[],
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Array of UUID objects corresponding to _Complete List of
|
|
62
|
+
* 16 bit Service UUIDs_
|
|
63
|
+
*/
|
|
64
|
+
completeUUID16List?: Bytes[],
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Array of UUID objects corresponding to _Incomplete List of
|
|
68
|
+
* 128 bit Service UUIDs_
|
|
69
|
+
*/
|
|
70
|
+
incompleteUUID128List?: Bytes[],
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Array of UUID objects corresponding to _Complete List of
|
|
74
|
+
* 128 bit Service UUIDs_
|
|
75
|
+
*/
|
|
76
|
+
completeUUID128List?: Bytes[],
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* String corresponding to the _Shortened Local Name_.
|
|
80
|
+
*/
|
|
81
|
+
shortName?: string,
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* String corresponding to the _Complete Local Name_.
|
|
85
|
+
*/
|
|
86
|
+
completeName?: string,
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Object corresponding to the _Manufacturer Specific Data_.
|
|
90
|
+
*/
|
|
91
|
+
manufacturerSpecific?: ManufacturerSpec,
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Number corresponding to the TX Power Level.
|
|
95
|
+
*/
|
|
96
|
+
txPowerLevel?: number,
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Object corresponding to the _Slave Connection Interval Range_.
|
|
100
|
+
*/
|
|
101
|
+
connectionInterval?: {
|
|
102
|
+
/**
|
|
103
|
+
* A number corresponding to the minimum connection interval value.
|
|
104
|
+
*/
|
|
105
|
+
intervalMin: number,
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* A number corresponding to the maximum connection interval value.
|
|
109
|
+
*/
|
|
110
|
+
intervalMax: number,
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Array of UUID objects corresponding to the _List of 16 bit Service
|
|
115
|
+
* Solicitation UUIDs_.
|
|
116
|
+
*/
|
|
117
|
+
solicitationUUID16List?: Bytes[],
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Array of UUID objects corresponding to the _List of 128 bit Service
|
|
121
|
+
* Solicitation UUIDs_.
|
|
122
|
+
*/
|
|
123
|
+
solicitationUUID128List?: Bytes[],
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Object corresponding to the _Service Data - 16 bit UUID_.
|
|
127
|
+
*/
|
|
128
|
+
serviceDataUUID16?: {
|
|
129
|
+
/**
|
|
130
|
+
* An object corresponding to the 16-bit Service UUID.
|
|
131
|
+
*/
|
|
132
|
+
uuid: Bytes,
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* An array of numbers corresponding to additional service data.
|
|
136
|
+
*/
|
|
137
|
+
data: number[],
|
|
138
|
+
},
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Object corresponding to the _Service Data - 128 bit UUID_.
|
|
142
|
+
*/
|
|
143
|
+
serviceDataUUID128?: {
|
|
144
|
+
/**
|
|
145
|
+
* An object corresponding to the 128-bit Service UUID.
|
|
146
|
+
*/
|
|
147
|
+
uuid: Bytes,
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* An array of numbers corresponding to additional service data.
|
|
151
|
+
*/
|
|
152
|
+
data: number[],
|
|
153
|
+
},
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Number corresponding to the _Appearance_.
|
|
157
|
+
*/
|
|
158
|
+
appearance?: number,
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Address object corresponding to the _Public Target Address_.
|
|
162
|
+
*/
|
|
163
|
+
publicAddress?: Bytes,
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Address object corresponding to the _Random Target Address_.
|
|
167
|
+
*/
|
|
168
|
+
randomAddress?: Bytes,
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Number corresponding to the _Advertising Interval_.
|
|
172
|
+
*/
|
|
173
|
+
advertisingInterval?: number,
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Number corresponding to the _LE Role_.
|
|
177
|
+
*/
|
|
178
|
+
role?: number,
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* String corresponding to the _Uniform Resource Identifier_.
|
|
182
|
+
*/
|
|
183
|
+
uri?: string,
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Provides access to the BLE server features.
|
|
188
|
+
*/
|
|
189
|
+
export class BLEServer {
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Configures the device security requirements and I/O capabilities.
|
|
193
|
+
*/
|
|
194
|
+
set securityParameters(params: {
|
|
195
|
+
encryption?: boolean,
|
|
196
|
+
bonding?: boolean,
|
|
197
|
+
mitm?: boolean,
|
|
198
|
+
ioCapability?: IOCapability,
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* set/get the Bluetooth peripheral device name.
|
|
203
|
+
*/
|
|
204
|
+
deviceName: string;
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* The Bluetooth peripheral's local address as a
|
|
208
|
+
* `Bytes` object.
|
|
209
|
+
*
|
|
210
|
+
* @url https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/network/ble/ble.md#localaddress
|
|
211
|
+
*/
|
|
212
|
+
readonly localAddress: Bytes;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Applications must wait for the `onReady` callback
|
|
216
|
+
* before calling other `BLEServer` functions.
|
|
217
|
+
*/
|
|
218
|
+
onReady(): void;
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Starts broadcasting advertisement and scan response packets.
|
|
222
|
+
* The function is also used to configure discoverable and connectable modes.
|
|
223
|
+
*
|
|
224
|
+
* @param params
|
|
225
|
+
* @url https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/network/ble/ble.md#startadvertisingparams
|
|
226
|
+
*/
|
|
227
|
+
startAdvertising(params: {
|
|
228
|
+
advertisingData: AdvertisementData,
|
|
229
|
+
connectable?: boolean,
|
|
230
|
+
discoverable?: boolean,
|
|
231
|
+
fast?: boolean,
|
|
232
|
+
filterPolicy?: gapScanFilterPolicies,
|
|
233
|
+
scanResponseData?: any,
|
|
234
|
+
}): void;
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Stops broadcasting Bluetooth advertisements.
|
|
238
|
+
*
|
|
239
|
+
* @url https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/network/ble/ble.md#stopadvertising
|
|
240
|
+
*/
|
|
241
|
+
stopAdvertising(): void;
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Send a characteristic value change notification to the connected client.
|
|
245
|
+
*
|
|
246
|
+
* @param characteristic
|
|
247
|
+
* @param value
|
|
248
|
+
* @url https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/network/ble/ble.md#notifyvaluecharacteristic-value
|
|
249
|
+
*/
|
|
250
|
+
notifyValue(characteristic: Characteristic, value: any): void;
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Called when a client enables notifications on the `characteristic`.
|
|
254
|
+
*
|
|
255
|
+
* @param characteristic
|
|
256
|
+
*/
|
|
257
|
+
onCharacteristicNotifyEnabled(characteristic: Characteristic): void;
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Called when a client writes a service characteristic value on demand.
|
|
261
|
+
*
|
|
262
|
+
* @param characteristic
|
|
263
|
+
* @param value
|
|
264
|
+
* @url https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/network/ble/ble.md#oncharacteristicwrittencharacteristic-value
|
|
265
|
+
*/
|
|
266
|
+
onCharacteristicWritten(characteristic: Characteristic, value: any): void;
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Called when a client reads a service characteristic value on demand.
|
|
270
|
+
*
|
|
271
|
+
* @param characteristic
|
|
272
|
+
* @url https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/network/ble/ble.md#oncharacteristicreadcharacteristic
|
|
273
|
+
*/
|
|
274
|
+
onCharacteristicRead(characteristic: Characteristic): Uint8Array | number[] | number | void;
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Terminate the BLE client connection.
|
|
278
|
+
*/
|
|
279
|
+
disconnect(): void;
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Called when a client connects to the `BLEServer`.
|
|
283
|
+
*
|
|
284
|
+
* @param device
|
|
285
|
+
* @url https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/network/ble/ble.md#ondisconnecteddevice-1
|
|
286
|
+
*/
|
|
287
|
+
onConnected(device: Client): void;
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Called when the client connection is closed.
|
|
291
|
+
*
|
|
292
|
+
* @param device
|
|
293
|
+
*/
|
|
294
|
+
onDisconnected(device: Client): void;
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Terminate any BLE client connection and release all BLE resources.
|
|
298
|
+
*/
|
|
299
|
+
close(): void;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
export { BLEServer as default };
|
|
303
|
+
}
|
package/ble/btutils.d.ts
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2022-2025 Richard Lea, Satoshi Tanaka
|
|
3
|
+
*
|
|
4
|
+
* This file is part of the Moddable SDK Tools.
|
|
5
|
+
*
|
|
6
|
+
* The Moddable SDK Tools is free software: you can redistribute it and/or modify
|
|
7
|
+
* it under the terms of the GNU General Public License as published by
|
|
8
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
* (at your option) any later version.
|
|
10
|
+
*
|
|
11
|
+
* The Moddable SDK Tools is distributed in the hope that it will be useful,
|
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
* GNU General Public License for more details.
|
|
15
|
+
*
|
|
16
|
+
* You should have received a copy of the GNU General Public License
|
|
17
|
+
* along with the Moddable SDK Tools. If not, see <http://www.gnu.org/licenses/>.
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
type ManufacturerSpec = {
|
|
22
|
+
/**
|
|
23
|
+
* The `identifier` property is a number corresponding to the
|
|
24
|
+
* _Company Identifier Code_.
|
|
25
|
+
*/
|
|
26
|
+
identifier: string | number,
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The `data` property is an array of numbers corresponding
|
|
30
|
+
* to additional manufacturer specific data.
|
|
31
|
+
*/
|
|
32
|
+
data: number[],
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
declare module "btutils" {
|
|
36
|
+
|
|
37
|
+
export class Bytes extends ArrayBuffer {
|
|
38
|
+
constructor(bytes: string | ArrayBufferLike, littleEndian?: boolean)
|
|
39
|
+
/**
|
|
40
|
+
* The `equals` function returns `true` if the instance
|
|
41
|
+
* ArrayBuffer data equals the data contained in `buffer`.
|
|
42
|
+
*
|
|
43
|
+
* @param bytes
|
|
44
|
+
* @url https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/network/ble/ble.md#equalsbuffer
|
|
45
|
+
*/
|
|
46
|
+
equals(bytes: Bytes): boolean;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The `toString` function returns a printable hex string of the Bytes contents. The string is formatted in big endian order with separators.
|
|
50
|
+
* https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/network/ble/ble.md#tostring
|
|
51
|
+
*/
|
|
52
|
+
toString(): string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Provides Accessor functions to read common advertisement and
|
|
57
|
+
* scan response data types as JavaScript properties.
|
|
58
|
+
*
|
|
59
|
+
* @url https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/network/ble/ble.md#class-advertisement
|
|
60
|
+
*/
|
|
61
|
+
export interface Advertisement {
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Contains the raw advertisement data bytes.
|
|
65
|
+
*/
|
|
66
|
+
buffer: ArrayBuffer;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Number corresponding to the Appearance.
|
|
70
|
+
*/
|
|
71
|
+
appearance: number;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The advertised complete local name.
|
|
75
|
+
*/
|
|
76
|
+
completeName: string;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The advertised shortened local name.
|
|
80
|
+
*/
|
|
81
|
+
shortName: string;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* An object containing the advertised manufacturer specific data.
|
|
85
|
+
*/
|
|
86
|
+
manufacturerSpecific: ManufacturerSpec;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* The advertised flags value.
|
|
90
|
+
*/
|
|
91
|
+
flags: number;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* The advertised complete 16-bit UUID list.
|
|
95
|
+
*/
|
|
96
|
+
completeUUID16List: Array<string | number>;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* The advertised incomplete 16-bit UUID list.
|
|
100
|
+
*/
|
|
101
|
+
incompleteUUID16List: Array<string | number>;
|
|
102
|
+
|
|
103
|
+
findIndex(type: number, index?: number): number;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Convert a Bluetooth UUID expressed as a hex string to a `Bytes` instance.
|
|
108
|
+
* @param strings
|
|
109
|
+
*/
|
|
110
|
+
export function uuid(strings: TemplateStringsArray): Bytes;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Convert a Bluetooth address expressed as a hex string to a `Bytes` instance.
|
|
114
|
+
* @param strings
|
|
115
|
+
*/
|
|
116
|
+
export function address(strings: TemplateStringsArray): Bytes;
|
|
117
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2022 Richard Lea
|
|
3
|
+
*
|
|
4
|
+
* This file is part of the Moddable SDK Tools.
|
|
5
|
+
*
|
|
6
|
+
* The Moddable SDK Tools is free software: you can redistribute it and/or modify
|
|
7
|
+
* it under the terms of the GNU General Public License as published by
|
|
8
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
* (at your option) any later version.
|
|
10
|
+
*
|
|
11
|
+
* The Moddable SDK Tools is distributed in the hope that it will be useful,
|
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
* GNU General Public License for more details.
|
|
15
|
+
*
|
|
16
|
+
* You should have received a copy of the GNU General Public License
|
|
17
|
+
* along with the Moddable SDK Tools. If not, see <http://www.gnu.org/licenses/>.
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
declare module "connection" {
|
|
22
|
+
export class Connection {
|
|
23
|
+
disconnect(): void;
|
|
24
|
+
}
|
|
25
|
+
}
|