@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/gap.d.ts ADDED
@@ -0,0 +1,109 @@
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 "gap" {
22
+
23
+ const enum gapAddressTypes {
24
+ PUBLIC = 0,
25
+ RANDOM = 1,
26
+ RPA_PUBLIC = 2,
27
+ RPA_RANDOM = 3,
28
+ }
29
+
30
+ export const GAP: {
31
+ readonly SCAN_FAST_INTERVAL: 0x0030, // TGAP(scan_fast_interval) 30ms to 60ms
32
+ readonly SCAN_FAST_WINDOW: 0x0030, // TGAP(scan_fast_window) 30ms
33
+ readonly SCAN_SLOW_INTERVAL1: 0x0800, // TGAP(scan_slow_interval1) 1.28s
34
+ readonly SCAN_SLOW_WINDOW1: 0x0012, // TGAP(scan_slow_window1) 11.25ms
35
+ readonly SCAN_SLOW_INTERVAL2: 0x1000, // TGAP(scan_slow_interval2) 2.56s
36
+ readonly SCAN_SLOW_WINDOW2: 0x0024, // TGAP(scan_slow_window2) 22.5ms
37
+ readonly ADV_FAST_INTERVAL1: { // TGAP(adv_fast_interval1) 30ms to 60ms
38
+ min: 0x0030,
39
+ max: 0x0060
40
+ },
41
+ readonly ADV_FAST_INTERVAL2: { // TGAP(adv_fast_interval2) 100ms to 150ms
42
+ min: 0x00A0,
43
+ max: 0x00F0,
44
+ },
45
+ readonly ADV_SLOW_INTERVAL: { // TGAP(adv_slow_interval) 1s to 1.2s
46
+ min: 0x0640,
47
+ max: 0x0780,
48
+ },
49
+ readonly ADType: {
50
+ /* Service UUID */
51
+ INCOMPLETE_UUID16_LIST: 0x02,
52
+ COMPLETE_UUID16_LIST: 0x03,
53
+ INCOMPLETE_UUID128_LIST: 0x06,
54
+ COMPLETE_UUID128_LIST: 0x07,
55
+ /* Local Name */
56
+ SHORTENED_LOCAL_NAME: 0x08,
57
+ COMPLETE_LOCAL_NAME: 0x09,
58
+ /* Flags */
59
+ FLAGS: 0x01,
60
+ /* Manufacturer Specific Data */
61
+ MANUFACTURER_SPECIFIC_DATA: 0xFF,
62
+ /* TX Power Level */
63
+ TX_POWER_LEVEL: 0x0A,
64
+ SLAVE_CONNECTION_INTERVAL_RANGE: 0x12,
65
+ /* Service Solicitation */
66
+ SOLICITATION_UUID16_LIST: 0x14,
67
+ SOLICITATION_UUID128_LIST: 0x15,
68
+ /* Service Data */
69
+ SERVICE_DATA_UUID16: 0x16,
70
+ SERVICE_DATA_UUID128: 0x21,
71
+ /* Appearance */
72
+ APPEARANCE: 0x19,
73
+ /* Public Target Address */
74
+ PUBLIC_TARGET_ADDRESS: 0x17,
75
+ /* Random Target Address */
76
+ RANDOM_TARGET_ADDRESS: 0x18,
77
+ /* Advertising Interval */
78
+ ADVERTISING_INTERVAL: 0x1A,
79
+ /* LE Bluetooth Device Address */
80
+ LE_BLUETOOTH_DEVICE_ADDRESS: 0x1B,
81
+ /* LE Role */
82
+ LE_ROLE: 0x1C,
83
+ /* URI */
84
+ URI: 0x24,
85
+ },
86
+ MAX_AD_LENGTH: 31,
87
+ ADFlag: {
88
+ LE_LIMITED_DISCOVERABLE_MODE: 0x01,
89
+ LE_GENERAL_DISCOVERABLE_MODE: 0x02,
90
+ NO_BR_EDR: 0x04,
91
+ LE_BR_EDR_CONTROLLER: 0x08,
92
+ LE_BR_EDR_HOST: 0x10,
93
+ },
94
+ AddressType: typeof gapAddressTypes,
95
+ ScanFilterPolicy: {
96
+ NONE: 0,
97
+ WHITELIST: 1,
98
+ NOT_RESOLVED_DIRECTED: 2,
99
+ WHITELIST_NOT_RESOLVED_DIRECTED: 3,
100
+ },
101
+ AdvFilterPolicy: {
102
+ NONE: 0,
103
+ WHITELIST_SCANS: 1,
104
+ WHITELIST_CONNECTIONS: 2,
105
+ WHITELIST_SCANS_CONNECTIONS: 3
106
+ },
107
+ }
108
+ export { GAP as default };
109
+ }
package/ble/gatt.d.ts ADDED
@@ -0,0 +1,186 @@
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 "gatt" {
22
+
23
+ import { Bytes, Advertisement } from "btutils";
24
+ import { GAP } from "gap";
25
+ import { Authorization } from "sm";
26
+
27
+ type getAddressType = (typeof GAP.AddressType);
28
+
29
+ export interface Client {
30
+ connection: number,
31
+ address: Bytes,
32
+ addressType: getAddressType,
33
+ scanResponse: Advertisement,
34
+ rssi: number,
35
+
36
+ /**
37
+ * Read the connected peripheral's signal strength.
38
+ *
39
+ * @url https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/network/ble/ble.md#readrssi
40
+ */
41
+ readRSSI(): void;
42
+
43
+ /**
44
+ * Discover a single GATT primary service by UUID.
45
+ *
46
+ * @param uuid
47
+ */
48
+ discoverPrimaryService(uuid: Bytes): void;
49
+
50
+ /**
51
+ * Discover all the peripheral's GATT primary services.
52
+ * Discovered services are returned to the `onServices` callback.
53
+ */
54
+ discoverAllPrimaryServices(): void;
55
+
56
+ /**
57
+ * Finds and returns the service identified by `uuid`.
58
+ *
59
+ * @param uuid
60
+ */
61
+ findServiceByUUID(uuid: Bytes): void;
62
+
63
+ /**
64
+ * Request a higher MTU once the peripheral connection has been established.
65
+ * @param mtu
66
+ */
67
+ exchangeMTU(mtu: number): void
68
+
69
+ /**
70
+ * Terminates the peripheral function.
71
+ */
72
+ close(): void;
73
+ }
74
+
75
+ /**
76
+ * A single Peripheral GATT service.
77
+ */
78
+ export interface Service {
79
+ connection: number;
80
+ uuid: Bytes;
81
+ start: number;
82
+ end: number;
83
+ characteristics: Characteristic[];
84
+
85
+ /**
86
+ * Discover all the service characteristics. Discovered characteristics
87
+ * are returned to the `onCharacteristics` callback.
88
+ */
89
+ discoverAllCharacteristics(): void;
90
+
91
+ /**
92
+ * Discover a single service characteristic by UUID.
93
+ *
94
+ * @param uuid
95
+ * @url https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/network/ble/ble.md#discovercharacteristicuuid
96
+ */
97
+ discoverCharacteristic(uuid: Bytes): void;
98
+
99
+ /**
100
+ * finds and returns the characteristic identified by `uuid`.
101
+ * @param uuid
102
+ */
103
+ findCharacteristicByUUID(uuid: Bytes): void;
104
+ }
105
+
106
+ /**
107
+ * A single service Characteristic.
108
+ *
109
+ * @url https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/network/ble/ble.md#class-characteristic
110
+ */
111
+ export interface Characteristic {
112
+ connection: number;
113
+ uuid: Bytes;
114
+ service: Service;
115
+ handle: number;
116
+ name: string;
117
+ type: string;
118
+ descriptors: Descriptor[];
119
+ properties: number;
120
+
121
+ /**
122
+ * Discover all the characteristic's descriptors.
123
+ * Discovered descriptors are returned to the `onDescriptors` callback.
124
+ */
125
+ discoverAllDescriptors(): void;
126
+
127
+
128
+ /* Enable characteristic value change notifications.
129
+ *
130
+ * @url https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/network/ble/ble.md#enablenotifications
131
+ */
132
+ enableNotifications(): void;
133
+
134
+ /**
135
+ * Enable characteristic value change notifications.
136
+ *
137
+ * @url https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/network/ble/ble.md#enablenotifications
138
+ */
139
+ disableNotifications(): void;
140
+
141
+ /**
142
+ * Disable characteristic value change notifications.
143
+ * @param auth
144
+ * @url https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/network/ble/ble.md#disablenotifications
145
+ */
146
+ readValue(auth: Authorization): void;
147
+
148
+ /**
149
+ * Write a characteristic value on demand.
150
+ * @param value
151
+ * @url https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/network/ble/ble.md#writewithoutresponsevalue
152
+ */
153
+ writeWithoutResponse(value: any): void;
154
+ }
155
+
156
+ /**
157
+ * A single Characteristic descriptor.
158
+ *
159
+ * @url https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/network/ble/ble.md#class-descriptor
160
+ */
161
+ export interface Descriptor {
162
+ connection: number;
163
+ uuid: string;
164
+ characteristic: Characteristic;
165
+ handle: number;
166
+ name: string;
167
+ type: string;
168
+
169
+ /**
170
+ * Read a descriptor value on demand.
171
+ *
172
+ * @param auth
173
+ * @url https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/network/ble/ble.md#readvalueauth-1
174
+ */
175
+ readValue(auth?: number): void;
176
+
177
+ writeWithoutResponse(value: any): void;
178
+
179
+ /**
180
+ * Write a descriptor value.
181
+ * @param value
182
+ * @url https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/network/ble/ble.md#writevaluevalue
183
+ */
184
+ writeValue(value: any): void;
185
+ }
186
+ }
package/ble/sm.d.ts ADDED
@@ -0,0 +1,70 @@
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 "sm" {
22
+
23
+ import { GAP } from "gap";
24
+
25
+ type getAddressType = (typeof GAP.AddressType);
26
+
27
+ /**
28
+ * @url https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/network/ble/ble.md#class-sm
29
+ */
30
+ export const enum IOCapability {
31
+ NoInputNoOutput = 0,
32
+ DisplayOnly = 1,
33
+ KeyboardOnly = 2,
34
+ KeyboardDisplay = 3,
35
+ DisplayYesNo = 4,
36
+ }
37
+
38
+ export const enum Authorization {
39
+ None = 0,
40
+ NoMITM = 1,
41
+ MITM = 2,
42
+ SignedNoMITM = 3,
43
+ SignedMITM = 4
44
+ }
45
+
46
+ /**
47
+ * Provides objects used to configure BLE client and server security requirements
48
+ * and device capabilities.
49
+ */
50
+ export class SM {
51
+
52
+
53
+ /**
54
+ * Delete all bonding information and encryption keys
55
+ * from persistent storage.
56
+ *
57
+ * https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/network/ble/ble.md#deleteallbondings
58
+ */
59
+ static deleteAllBondings(): void;
60
+
61
+ /**
62
+ * Delete stored bonding information for the peer device with the provided
63
+ * `address` and `addressType`.
64
+ *
65
+ * @param address Contains peer device Bluetooth address
66
+ * @param addressType Peer device Bluetooth address type.
67
+ */
68
+ static deleteBonding(address: ArrayBuffer, addressType: getAddressType): void;
69
+ }
70
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moddable/typings",
3
- "version": "5.3.0",
3
+ "version": "5.4.1",
4
4
  "main": "",
5
5
  "types": [
6
6
  "xs.d.ts",