@hangtime/grip-connect 0.8.4 → 0.8.5
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/deno.json +1 -1
- package/package.json +22 -3
- package/src/models/base.model.ts +2 -2
- package/src/models/device.model.ts +5 -2
- package/tsconfig.cjs.json +15 -0
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +0 -1
- package/dist/interfaces/base.interface.d.ts +0 -18
- package/dist/interfaces/base.interface.d.ts.map +0 -1
- package/dist/interfaces/base.interface.js +0 -2
- package/dist/interfaces/base.interface.js.map +0 -1
- package/dist/interfaces/callback.interface.d.ts +0 -56
- package/dist/interfaces/callback.interface.d.ts.map +0 -1
- package/dist/interfaces/callback.interface.js +0 -2
- package/dist/interfaces/callback.interface.js.map +0 -1
- package/dist/interfaces/command.interface.d.ts +0 -92
- package/dist/interfaces/command.interface.d.ts.map +0 -1
- package/dist/interfaces/command.interface.js +0 -2
- package/dist/interfaces/command.interface.js.map +0 -1
- package/dist/interfaces/device/climbro.interface.d.ts +0 -7
- package/dist/interfaces/device/climbro.interface.d.ts.map +0 -1
- package/dist/interfaces/device/climbro.interface.js +0 -2
- package/dist/interfaces/device/climbro.interface.js.map +0 -1
- package/dist/interfaces/device/entralpi.interface.d.ts +0 -53
- package/dist/interfaces/device/entralpi.interface.d.ts.map +0 -1
- package/dist/interfaces/device/entralpi.interface.js +0 -2
- package/dist/interfaces/device/entralpi.interface.js.map +0 -1
- package/dist/interfaces/device/forceboard.interface.d.ts +0 -64
- package/dist/interfaces/device/forceboard.interface.d.ts.map +0 -1
- package/dist/interfaces/device/forceboard.interface.js +0 -2
- package/dist/interfaces/device/forceboard.interface.js.map +0 -1
- package/dist/interfaces/device/kilterboard.interface.d.ts +0 -16
- package/dist/interfaces/device/kilterboard.interface.d.ts.map +0 -1
- package/dist/interfaces/device/kilterboard.interface.js +0 -2
- package/dist/interfaces/device/kilterboard.interface.js.map +0 -1
- package/dist/interfaces/device/motherboard.interface.d.ts +0 -54
- package/dist/interfaces/device/motherboard.interface.d.ts.map +0 -1
- package/dist/interfaces/device/motherboard.interface.js +0 -2
- package/dist/interfaces/device/motherboard.interface.js.map +0 -1
- package/dist/interfaces/device/mysmartboard.interface.d.ts +0 -7
- package/dist/interfaces/device/mysmartboard.interface.d.ts.map +0 -1
- package/dist/interfaces/device/mysmartboard.interface.js +0 -2
- package/dist/interfaces/device/mysmartboard.interface.js.map +0 -1
- package/dist/interfaces/device/progressor.interface.d.ts +0 -28
- package/dist/interfaces/device/progressor.interface.d.ts.map +0 -1
- package/dist/interfaces/device/progressor.interface.js +0 -2
- package/dist/interfaces/device/progressor.interface.js.map +0 -1
- package/dist/interfaces/device/smartboard-pro.interface.d.ts +0 -7
- package/dist/interfaces/device/smartboard-pro.interface.d.ts.map +0 -1
- package/dist/interfaces/device/smartboard-pro.interface.js +0 -2
- package/dist/interfaces/device/smartboard-pro.interface.js.map +0 -1
- package/dist/interfaces/device/wh-c06.interface.d.ts +0 -7
- package/dist/interfaces/device/wh-c06.interface.d.ts.map +0 -1
- package/dist/interfaces/device/wh-c06.interface.js +0 -2
- package/dist/interfaces/device/wh-c06.interface.js.map +0 -1
- package/dist/interfaces/device.interface.d.ts +0 -203
- package/dist/interfaces/device.interface.d.ts.map +0 -1
- package/dist/interfaces/device.interface.js +0 -2
- package/dist/interfaces/device.interface.js.map +0 -1
- package/dist/interfaces/download.interface.d.ts +0 -16
- package/dist/interfaces/download.interface.d.ts.map +0 -1
- package/dist/interfaces/download.interface.js +0 -2
- package/dist/interfaces/download.interface.js.map +0 -1
- package/dist/interfaces/index.d.ts +0 -10
- package/dist/interfaces/index.d.ts.map +0 -1
- package/dist/interfaces/index.js +0 -2
- package/dist/interfaces/index.js.map +0 -1
- package/dist/models/base.model.d.ts +0 -13
- package/dist/models/base.model.d.ts.map +0 -1
- package/dist/models/base.model.js +0 -22
- package/dist/models/base.model.js.map +0 -1
- package/dist/models/device/climbro.model.d.ts +0 -11
- package/dist/models/device/climbro.model.d.ts.map +0 -1
- package/dist/models/device/climbro.model.js +0 -15
- package/dist/models/device/climbro.model.js.map +0 -1
- package/dist/models/device/entralpi.model.d.ts +0 -64
- package/dist/models/device/entralpi.model.d.ts.map +0 -1
- package/dist/models/device/entralpi.model.js +0 -240
- package/dist/models/device/entralpi.model.js.map +0 -1
- package/dist/models/device/forceboard.model.d.ts +0 -73
- package/dist/models/device/forceboard.model.d.ts.map +0 -1
- package/dist/models/device/forceboard.model.js +0 -312
- package/dist/models/device/forceboard.model.js.map +0 -1
- package/dist/models/device/kilterboard.model.d.ts +0 -144
- package/dist/models/device/kilterboard.model.d.ts.map +0 -1
- package/dist/models/device/kilterboard.model.js +0 -287
- package/dist/models/device/kilterboard.model.js.map +0 -1
- package/dist/models/device/motherboard.model.d.ts +0 -110
- package/dist/models/device/motherboard.model.d.ts.map +0 -1
- package/dist/models/device/motherboard.model.js +0 -378
- package/dist/models/device/motherboard.model.js.map +0 -1
- package/dist/models/device/mysmartboard.model.d.ts +0 -11
- package/dist/models/device/mysmartboard.model.d.ts.map +0 -1
- package/dist/models/device/mysmartboard.model.js +0 -15
- package/dist/models/device/mysmartboard.model.js.map +0 -1
- package/dist/models/device/progressor.model.d.ts +0 -39
- package/dist/models/device/progressor.model.d.ts.map +0 -1
- package/dist/models/device/progressor.model.js +0 -216
- package/dist/models/device/progressor.model.js.map +0 -1
- package/dist/models/device/smartboard-pro.model.d.ts +0 -11
- package/dist/models/device/smartboard-pro.model.d.ts.map +0 -1
- package/dist/models/device/smartboard-pro.model.js +0 -52
- package/dist/models/device/smartboard-pro.model.js.map +0 -1
- package/dist/models/device/wh-c06.model.d.ts +0 -57
- package/dist/models/device/wh-c06.model.d.ts.map +0 -1
- package/dist/models/device/wh-c06.model.js +0 -167
- package/dist/models/device/wh-c06.model.js.map +0 -1
- package/dist/models/device.model.d.ts +0 -408
- package/dist/models/device.model.d.ts.map +0 -1
- package/dist/models/device.model.js +0 -718
- package/dist/models/device.model.js.map +0 -1
- package/dist/models/index.d.ts +0 -10
- package/dist/models/index.d.ts.map +0 -1
- package/dist/models/index.js +0 -10
- package/dist/models/index.js.map +0 -1
|
@@ -1,408 +0,0 @@
|
|
|
1
|
-
import { BaseModel } from "./../models/base.model.js";
|
|
2
|
-
import type { IDevice, Service } from "../interfaces/device.interface.js";
|
|
3
|
-
import type { ActiveCallback, NotifyCallback, WriteCallback } from "../interfaces/callback.interface.js";
|
|
4
|
-
import type { DownloadPacket } from "../interfaces/download.interface.js";
|
|
5
|
-
import type { Commands } from "../interfaces/command.interface.js";
|
|
6
|
-
export declare abstract class Device extends BaseModel implements IDevice {
|
|
7
|
-
/**
|
|
8
|
-
* Filters to identify the device during Bluetooth scanning.
|
|
9
|
-
* Used to match devices that meet specific criteria such as name, service UUIDs, etc.
|
|
10
|
-
* @type {BluetoothLEScanFilter[]}
|
|
11
|
-
* @public
|
|
12
|
-
* @readonly
|
|
13
|
-
*/
|
|
14
|
-
readonly filters: BluetoothLEScanFilter[];
|
|
15
|
-
/**
|
|
16
|
-
* Array of services provided by the device.
|
|
17
|
-
* Services represent functionalities that the device supports, such as weight measurement, battery information, or custom services.
|
|
18
|
-
* @type {Service[]}
|
|
19
|
-
* @public
|
|
20
|
-
* @readonly
|
|
21
|
-
*/
|
|
22
|
-
readonly services: Service[];
|
|
23
|
-
/**
|
|
24
|
-
* Reference to the `BluetoothDevice` object representing this device.
|
|
25
|
-
* This is the actual device object obtained from the Web Bluetooth API after a successful connection.
|
|
26
|
-
* @type {BluetoothDevice | undefined}
|
|
27
|
-
* @public
|
|
28
|
-
*/
|
|
29
|
-
bluetooth?: BluetoothDevice;
|
|
30
|
-
/**
|
|
31
|
-
* Object representing the set of commands available for this device.
|
|
32
|
-
* These commands allow communication with the device to perform various operations such as starting measurements, retrieving data, or calibrating the device.
|
|
33
|
-
* @type {Commands}
|
|
34
|
-
* @public
|
|
35
|
-
* @readonly
|
|
36
|
-
*/
|
|
37
|
-
readonly commands: Commands;
|
|
38
|
-
/**
|
|
39
|
-
* The BluetoothRemoteGATTServer interface of the Web Bluetooth API represents a GATT Server on a remote device.
|
|
40
|
-
* @type {BluetoothRemoteGATTServer | undefined}
|
|
41
|
-
* @private
|
|
42
|
-
*/
|
|
43
|
-
private server;
|
|
44
|
-
/**
|
|
45
|
-
* The last message written to the device.
|
|
46
|
-
* @type {string | Uint8Array | null}
|
|
47
|
-
* @protected
|
|
48
|
-
*/
|
|
49
|
-
protected writeLast: string | Uint8Array | null;
|
|
50
|
-
/**
|
|
51
|
-
* Indicates whether the device is currently active.
|
|
52
|
-
* @type {boolean}
|
|
53
|
-
*/
|
|
54
|
-
protected isActive: boolean;
|
|
55
|
-
/**
|
|
56
|
-
* Configuration for threshold and duration.
|
|
57
|
-
*/
|
|
58
|
-
private activeConfig;
|
|
59
|
-
/**
|
|
60
|
-
* Maximum mass recorded from the device, initialized to "0".
|
|
61
|
-
* @type {string}
|
|
62
|
-
* @protected
|
|
63
|
-
*/
|
|
64
|
-
protected massMax: string;
|
|
65
|
-
/**
|
|
66
|
-
* Average mass calculated from the device data, initialized to "0".
|
|
67
|
-
* @type {string}
|
|
68
|
-
* @protected
|
|
69
|
-
*/
|
|
70
|
-
protected massAverage: string;
|
|
71
|
-
/**
|
|
72
|
-
* Total sum of all mass data points recorded from the device.
|
|
73
|
-
* Used to calculate the average mass.
|
|
74
|
-
* @type {number}
|
|
75
|
-
* @protected
|
|
76
|
-
*/
|
|
77
|
-
protected massTotalSum: number;
|
|
78
|
-
/**
|
|
79
|
-
* Number of data points received from the device.
|
|
80
|
-
* Used to calculate the average mass.
|
|
81
|
-
* @type {number}
|
|
82
|
-
* @protected
|
|
83
|
-
*/
|
|
84
|
-
protected dataPointCount: number;
|
|
85
|
-
/**
|
|
86
|
-
* Array of DownloadPacket entries.
|
|
87
|
-
* This array holds packets that contain data downloaded from the device.
|
|
88
|
-
* @type {DownloadPacket[]}
|
|
89
|
-
* @protected
|
|
90
|
-
*/
|
|
91
|
-
protected downloadPackets: DownloadPacket[];
|
|
92
|
-
/**
|
|
93
|
-
* Represents the current tare value for calibration.
|
|
94
|
-
* @type {number}
|
|
95
|
-
*/
|
|
96
|
-
private tareCurrent;
|
|
97
|
-
/**
|
|
98
|
-
* Indicates whether the tare calibration process is active.
|
|
99
|
-
* @type {boolean}
|
|
100
|
-
*/
|
|
101
|
-
private tareActive;
|
|
102
|
-
/**
|
|
103
|
-
* Timestamp when the tare calibration process started.
|
|
104
|
-
* @type {number | null}
|
|
105
|
-
*/
|
|
106
|
-
private tareStartTime;
|
|
107
|
-
/**
|
|
108
|
-
* Array holding the samples collected during tare calibration.
|
|
109
|
-
* @type {number[]}
|
|
110
|
-
*/
|
|
111
|
-
private tareSamples;
|
|
112
|
-
/**
|
|
113
|
-
* Duration time for the tare calibration process.
|
|
114
|
-
* @type {number}
|
|
115
|
-
*/
|
|
116
|
-
private tareDuration;
|
|
117
|
-
/**
|
|
118
|
-
* Optional callback for handling write operations.
|
|
119
|
-
* @callback NotifyCallback
|
|
120
|
-
* @param {massObject} data - The data passed to the callback.
|
|
121
|
-
* @type {NotifyCallback | undefined}
|
|
122
|
-
* @protected
|
|
123
|
-
*/
|
|
124
|
-
protected notifyCallback: NotifyCallback;
|
|
125
|
-
/**
|
|
126
|
-
* Optional callback for handling write operations.
|
|
127
|
-
* @callback WriteCallback
|
|
128
|
-
* @param {string} data - The data passed to the callback.
|
|
129
|
-
* @type {WriteCallback | undefined}
|
|
130
|
-
* @protected
|
|
131
|
-
*/
|
|
132
|
-
protected writeCallback: WriteCallback;
|
|
133
|
-
/**
|
|
134
|
-
* Optional callback for handling write operations.
|
|
135
|
-
* @callback ActiveCallback
|
|
136
|
-
* @param {string} data - The data passed to the callback.
|
|
137
|
-
* @type {ActiveCallback | undefined}
|
|
138
|
-
* @protected
|
|
139
|
-
*/
|
|
140
|
-
protected activeCallback: ActiveCallback;
|
|
141
|
-
/**
|
|
142
|
-
* Event listener for handling the 'gattserverdisconnected' event.
|
|
143
|
-
* This listener delegates the event to the `onDisconnected` method.
|
|
144
|
-
*
|
|
145
|
-
* @private
|
|
146
|
-
* @type {(event: Event) => void}
|
|
147
|
-
*/
|
|
148
|
-
private onDisconnectedListener;
|
|
149
|
-
/**
|
|
150
|
-
* A map that stores notification event listeners keyed by characteristic UUIDs.
|
|
151
|
-
* This allows for proper addition and removal of event listeners associated with each characteristic.
|
|
152
|
-
*
|
|
153
|
-
* @private
|
|
154
|
-
* @type {Map<string, EventListener>}
|
|
155
|
-
*/
|
|
156
|
-
private notificationListeners;
|
|
157
|
-
constructor(device: Partial<IDevice>);
|
|
158
|
-
/**
|
|
159
|
-
* Sets the callback function to be called when the activity status changes,
|
|
160
|
-
* and optionally sets the configuration for threshold and duration.
|
|
161
|
-
*
|
|
162
|
-
* This function allows you to specify a callback that will be invoked whenever
|
|
163
|
-
* the activity status changes, indicating whether the device is currently active.
|
|
164
|
-
* It also allows optionally configuring the threshold and duration used to determine activity.
|
|
165
|
-
*
|
|
166
|
-
* @param {ActiveCallback} callback - The callback function to be set. This function
|
|
167
|
-
* receives a boolean value indicating the new activity status.
|
|
168
|
-
* @param {object} [options] - Optional configuration object containing the threshold and duration.
|
|
169
|
-
* @param {number} [options.threshold=2.5] - The threshold value for determining activity.
|
|
170
|
-
* @param {number} [options.duration=1000] - The duration (in milliseconds) to monitor the input for activity.
|
|
171
|
-
* @returns {void}
|
|
172
|
-
* @public
|
|
173
|
-
*
|
|
174
|
-
* @example
|
|
175
|
-
* device.active((isActive) => {
|
|
176
|
-
* console.log(`Device is ${isActive ? 'active' : 'inactive'}`);
|
|
177
|
-
* }, { threshold: 3.0, duration: 1500 });
|
|
178
|
-
*/
|
|
179
|
-
active: (callback: ActiveCallback, options?: {
|
|
180
|
-
threshold?: number;
|
|
181
|
-
duration?: number;
|
|
182
|
-
}) => void;
|
|
183
|
-
/**
|
|
184
|
-
* Checks if a dynamic value is active based on a threshold and duration.
|
|
185
|
-
*
|
|
186
|
-
* This function assesses whether a given dynamic value surpasses a specified threshold
|
|
187
|
-
* and remains active for a specified duration. If the activity status changes from
|
|
188
|
-
* the previous state, the callback function is called with the updated activity status.
|
|
189
|
-
*
|
|
190
|
-
* @param {number} input - The dynamic value to check for activity status.
|
|
191
|
-
* @returns {Promise<void>} A promise that resolves once the activity check is complete.
|
|
192
|
-
*
|
|
193
|
-
* @example
|
|
194
|
-
* await device.activityCheck(5.0);
|
|
195
|
-
*/
|
|
196
|
-
protected activityCheck: (input: number) => Promise<void>;
|
|
197
|
-
/**
|
|
198
|
-
* Connects to a Bluetooth device.
|
|
199
|
-
* @param {Function} [onSuccess] - Optional callback function to execute on successful connection. Default logs success.
|
|
200
|
-
* @param {Function} [onError] - Optional callback function to execute on error. Default logs the error.
|
|
201
|
-
* @public
|
|
202
|
-
*
|
|
203
|
-
* @example
|
|
204
|
-
* device.connect(
|
|
205
|
-
* () => console.log("Connected successfully"),
|
|
206
|
-
* (error) => console.error("Connection failed:", error)
|
|
207
|
-
* );
|
|
208
|
-
*/
|
|
209
|
-
connect: (onSuccess?: () => void, onError?: (error: Error) => void) => Promise<void>;
|
|
210
|
-
/**
|
|
211
|
-
* Disconnects the device if it is currently connected.
|
|
212
|
-
* - Removes all notification listeners from the device's characteristics.
|
|
213
|
-
* - Removes the 'gattserverdisconnected' event listener.
|
|
214
|
-
* - Attempts to gracefully disconnect the device's GATT server.
|
|
215
|
-
* - Resets relevant properties to their initial states.
|
|
216
|
-
* @returns {void}
|
|
217
|
-
* @public
|
|
218
|
-
*
|
|
219
|
-
* @example
|
|
220
|
-
* device.disconnect();
|
|
221
|
-
*/
|
|
222
|
-
disconnect: () => void;
|
|
223
|
-
/**
|
|
224
|
-
* Converts the `downloadPackets` array into a CSV formatted string.
|
|
225
|
-
* @returns {string} A CSV string representation of the `downloadPackets` data, with each packet on a new line.
|
|
226
|
-
* @private
|
|
227
|
-
*
|
|
228
|
-
* @example
|
|
229
|
-
* const csvData = device.downloadToCSV();
|
|
230
|
-
* console.log(csvData);
|
|
231
|
-
*/
|
|
232
|
-
protected downloadToCSV: () => string;
|
|
233
|
-
/**
|
|
234
|
-
* Converts an array of DownloadPacket objects to a JSON string.
|
|
235
|
-
* @returns {string} JSON string representation of the data.
|
|
236
|
-
* @private
|
|
237
|
-
*
|
|
238
|
-
* @example
|
|
239
|
-
* const jsonData = device.downloadToJSON();
|
|
240
|
-
* console.log(jsonData);
|
|
241
|
-
*/
|
|
242
|
-
protected downloadToJSON: () => string;
|
|
243
|
-
/**
|
|
244
|
-
* Converts an array of DownloadPacket objects to an XML string.
|
|
245
|
-
* @returns {string} XML string representation of the data.
|
|
246
|
-
* @private
|
|
247
|
-
*
|
|
248
|
-
* @example
|
|
249
|
-
* const xmlData = device.downloadToXML();
|
|
250
|
-
* console.log(xmlData);
|
|
251
|
-
*/
|
|
252
|
-
protected downloadToXML: () => string;
|
|
253
|
-
/**
|
|
254
|
-
* Exports the data in the specified format (CSV, JSON, XML) with a filename format:
|
|
255
|
-
* 'data-export-YYYY-MM-DD-HH-MM-SS.{format}'.
|
|
256
|
-
*
|
|
257
|
-
* @param {('csv' | 'json' | 'xml')} [format='csv'] - The format in which to download the data.
|
|
258
|
-
* Defaults to 'csv'. Accepted values are 'csv', 'json', and 'xml'.
|
|
259
|
-
*
|
|
260
|
-
* @returns {Promise<void>} Resolves when the data has been downloaded/written
|
|
261
|
-
* @public
|
|
262
|
-
*
|
|
263
|
-
* @example
|
|
264
|
-
* await device.download('json');
|
|
265
|
-
*/
|
|
266
|
-
download: (format?: "csv" | "json" | "xml") => Promise<void>;
|
|
267
|
-
/**
|
|
268
|
-
* Returns UUIDs of all services associated with the device.
|
|
269
|
-
* @returns {string[]} Array of service UUIDs.
|
|
270
|
-
* @protected
|
|
271
|
-
*
|
|
272
|
-
* @example
|
|
273
|
-
* const serviceUUIDs = device.getAllServiceUUIDs();
|
|
274
|
-
* console.log(serviceUUIDs);
|
|
275
|
-
*/
|
|
276
|
-
protected getAllServiceUUIDs: () => string[];
|
|
277
|
-
/**
|
|
278
|
-
* Returns the Bluetooth instance available for the current environment.
|
|
279
|
-
* In browsers, it returns the native Web Bluetooth API (i.e. `navigator.bluetooth`).
|
|
280
|
-
* In a Node, Bun, or Deno environment, it dynamically imports the `webbluetooth` package.
|
|
281
|
-
* {@link https://github.com/thegecko/webbluetooth}
|
|
282
|
-
*
|
|
283
|
-
* @returns {Promise<Bluetooth>} A promise that resolves to the Bluetooth instance.
|
|
284
|
-
* @throws {Error} If Web Bluetooth is not available in the current environment.
|
|
285
|
-
*/
|
|
286
|
-
protected getBluetooth(): Promise<Bluetooth>;
|
|
287
|
-
/**
|
|
288
|
-
* Handles notifications received from a characteristic.
|
|
289
|
-
* @param {DataView} value - The notification event.
|
|
290
|
-
*
|
|
291
|
-
* @example
|
|
292
|
-
* device.handleNotifications(someCharacteristic);
|
|
293
|
-
*/
|
|
294
|
-
protected handleNotifications: (value: DataView) => void;
|
|
295
|
-
/**
|
|
296
|
-
* Checks if a Bluetooth device is connected.
|
|
297
|
-
* @returns {boolean} A boolean indicating whether the device is connected.
|
|
298
|
-
* @public
|
|
299
|
-
*
|
|
300
|
-
* @example
|
|
301
|
-
* if (device.isConnected()) {
|
|
302
|
-
* console.log('Device is connected');
|
|
303
|
-
* } else {
|
|
304
|
-
* console.log('Device is not connected');
|
|
305
|
-
* }
|
|
306
|
-
*/
|
|
307
|
-
isConnected: () => boolean;
|
|
308
|
-
/**
|
|
309
|
-
* Sets the callback function to be called when notifications are received.
|
|
310
|
-
* @param {NotifyCallback} callback - The callback function to be set.
|
|
311
|
-
* @returns {void}
|
|
312
|
-
* @public
|
|
313
|
-
*
|
|
314
|
-
* @example
|
|
315
|
-
* device.notify((data) => {
|
|
316
|
-
* console.log('Received notification:', data);
|
|
317
|
-
* });
|
|
318
|
-
*/
|
|
319
|
-
notify: (callback: NotifyCallback) => void;
|
|
320
|
-
/**
|
|
321
|
-
* Handles the 'connected' event.
|
|
322
|
-
* @param {Function} onSuccess - Callback function to execute on successful connection.
|
|
323
|
-
* @public
|
|
324
|
-
*
|
|
325
|
-
* @example
|
|
326
|
-
* device.onConnected(() => {
|
|
327
|
-
* console.log('Device connected successfully');
|
|
328
|
-
* });
|
|
329
|
-
*/
|
|
330
|
-
protected onConnected: (onSuccess: () => void) => Promise<void>;
|
|
331
|
-
/**
|
|
332
|
-
* Handles the 'disconnected' event.
|
|
333
|
-
* @param {Event} event - The 'disconnected' event.
|
|
334
|
-
* @public
|
|
335
|
-
*
|
|
336
|
-
* @example
|
|
337
|
-
* device.onDisconnected(event);
|
|
338
|
-
*/
|
|
339
|
-
protected onDisconnected: (event: Event) => void;
|
|
340
|
-
/**
|
|
341
|
-
* Reads the value of the specified characteristic from the device.
|
|
342
|
-
* @param {string} serviceId - The service ID where the characteristic belongs.
|
|
343
|
-
* @param {string} characteristicId - The characteristic ID to read from.
|
|
344
|
-
* @param {number} [duration=0] - The duration to wait before resolving the promise, in milliseconds.
|
|
345
|
-
* @returns {Promise<string | undefined>} A promise that resolves when the read operation is completed.
|
|
346
|
-
* @public
|
|
347
|
-
*
|
|
348
|
-
* @example
|
|
349
|
-
* const value = await device.read('battery', 'level', 1000);
|
|
350
|
-
* console.log('Battery level:', value);
|
|
351
|
-
*/
|
|
352
|
-
read: (serviceId: string, characteristicId: string, duration?: number) => Promise<string | undefined>;
|
|
353
|
-
/**
|
|
354
|
-
* Initiates the tare calibration process.
|
|
355
|
-
* @param {number} duration - The duration time for tare calibration.
|
|
356
|
-
* @returns {boolean} A boolean indicating whether the tare calibration was successful.
|
|
357
|
-
* @public
|
|
358
|
-
*
|
|
359
|
-
* @example
|
|
360
|
-
* const success = device.tare(5000);
|
|
361
|
-
* if (success) {
|
|
362
|
-
* console.log('Tare calibration started');
|
|
363
|
-
* } else {
|
|
364
|
-
* console.log('Tare calibration failed to start');
|
|
365
|
-
* }
|
|
366
|
-
*/
|
|
367
|
-
tare(duration?: number): boolean;
|
|
368
|
-
/**
|
|
369
|
-
* Apply tare calibration to the provided sample.
|
|
370
|
-
* @param {number} sample - The sample to calibrate.
|
|
371
|
-
* @returns {number} The calibrated tare value.
|
|
372
|
-
* @protected
|
|
373
|
-
*
|
|
374
|
-
* @example
|
|
375
|
-
* const calibratedSample = device.applyTare(rawSample);
|
|
376
|
-
* console.log('Calibrated sample:', calibratedSample);
|
|
377
|
-
*/
|
|
378
|
-
protected applyTare(sample: number): number;
|
|
379
|
-
/**
|
|
380
|
-
* Updates the timestamp of the last device interaction.
|
|
381
|
-
* This method sets the updatedAt property to the current date and time.
|
|
382
|
-
* @protected
|
|
383
|
-
*
|
|
384
|
-
* @example
|
|
385
|
-
* device.updateTimestamp();
|
|
386
|
-
* console.log('Last updated:', device.updatedAt);
|
|
387
|
-
*/
|
|
388
|
-
protected updateTimestamp: () => void;
|
|
389
|
-
/**
|
|
390
|
-
* Writes a message to the specified characteristic of a Bluetooth device and optionally provides a callback to handle responses.
|
|
391
|
-
* @param {string} serviceId - The service UUID of the Bluetooth device containing the target characteristic.
|
|
392
|
-
* @param {string} characteristicId - The characteristic UUID where the message will be written.
|
|
393
|
-
* @param {string | Uint8Array | undefined} message - The message to be written to the characteristic. It can be a string or a Uint8Array.
|
|
394
|
-
* @param {number} [duration=0] - Optional. The time in milliseconds to wait before resolving the promise. Defaults to 0 for immediate resolution.
|
|
395
|
-
* @param {WriteCallback} [callback=writeCallback] - Optional. A custom callback to handle the response after the write operation is successful.
|
|
396
|
-
* @returns {Promise<void>} A promise that resolves once the write operation is complete.
|
|
397
|
-
* @public
|
|
398
|
-
* @throws {Error} Throws an error if the characteristic is undefined.
|
|
399
|
-
*
|
|
400
|
-
* @example
|
|
401
|
-
* // Example usage of the write function with a custom callback
|
|
402
|
-
* await Progressor.write("progressor", "tx", ProgressorCommands.GET_BATT_VLTG, 250, (data) => {
|
|
403
|
-
* console.log(`Battery voltage: ${data}`);
|
|
404
|
-
* });
|
|
405
|
-
*/
|
|
406
|
-
write: (serviceId: string, characteristicId: string, message: string | Uint8Array | undefined, duration?: number, callback?: WriteCallback) => Promise<void>;
|
|
407
|
-
}
|
|
408
|
-
//# sourceMappingURL=device.model.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"device.model.d.ts","sourceRoot":"","sources":["../../src/models/device.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAA;AACzE,OAAO,KAAK,EAAE,cAAc,EAAc,cAAc,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAA;AACpH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAA;AACzE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAA;AAElE,8BAAsB,MAAO,SAAQ,SAAU,YAAW,OAAO;IAC/D;;;;;;OAMG;IACH,QAAQ,CAAC,OAAO,EAAE,qBAAqB,EAAE,CAAA;IAEzC;;;;;;OAMG;IACH,QAAQ,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAA;IAE5B;;;;;OAKG;IACH,SAAS,CAAC,EAAE,eAAe,CAAA;IAE3B;;;;;;OAMG;IACH,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAA;IAE3B;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAuC;IAErD;;;;OAIG;IACH,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAAO;IACtD;;;OAGG;IACH,SAAS,CAAC,QAAQ,UAAQ;IAC1B;;OAEG;IACH,OAAO,CAAC,YAAY,CAGnB;IAED;;;;OAIG;IACH,SAAS,CAAC,OAAO,EAAE,MAAM,CAAA;IAEzB;;;;OAIG;IACH,SAAS,CAAC,WAAW,EAAE,MAAM,CAAA;IAE7B;;;;;OAKG;IACH,SAAS,CAAC,YAAY,EAAE,MAAM,CAAA;IAE9B;;;;;OAKG;IAC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