munim-bluetooth 0.1.0 → 0.2.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.
@@ -3,7 +3,252 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.MunimBluetooth = void 0;
6
+ exports.addListener = addListener;
7
+ exports.connect = connect;
8
+ exports.default = void 0;
9
+ exports.disconnect = disconnect;
10
+ exports.discoverServices = discoverServices;
11
+ exports.getAdvertisingData = getAdvertisingData;
12
+ exports.getConnectedDevices = getConnectedDevices;
13
+ exports.isBluetoothEnabled = isBluetoothEnabled;
14
+ exports.readCharacteristic = readCharacteristic;
15
+ exports.readRSSI = readRSSI;
16
+ exports.removeListeners = removeListeners;
17
+ exports.requestBluetoothPermission = requestBluetoothPermission;
18
+ exports.setServices = setServices;
19
+ exports.startAdvertising = startAdvertising;
20
+ exports.startScan = startScan;
21
+ exports.stopAdvertising = stopAdvertising;
22
+ exports.stopScan = stopScan;
23
+ exports.subscribeToCharacteristic = subscribeToCharacteristic;
24
+ exports.unsubscribeFromCharacteristic = unsubscribeFromCharacteristic;
25
+ exports.updateAdvertisingData = updateAdvertisingData;
26
+ exports.writeCharacteristic = writeCharacteristic;
7
27
  var _reactNativeNitroModules = require("react-native-nitro-modules");
8
- const MunimBluetooth = exports.MunimBluetooth = _reactNativeNitroModules.NitroModules.createHybridObject('MunimBluetooth');
28
+ const MunimBluetooth = _reactNativeNitroModules.NitroModules.createHybridObject('MunimBluetooth');
29
+
30
+ // ========== Peripheral Features ==========
31
+
32
+ /**
33
+ * Start advertising as a Bluetooth peripheral with supported advertising data.
34
+ *
35
+ * @param options - An object with serviceUUIDs (string[]) and supported advertising data types.
36
+ */
37
+ function startAdvertising(options) {
38
+ return MunimBluetooth.startAdvertising(options);
39
+ }
40
+
41
+ /**
42
+ * Update advertising data while advertising is active.
43
+ *
44
+ * @param advertisingData - The new advertising data to use.
45
+ */
46
+ function updateAdvertisingData(advertisingData) {
47
+ return MunimBluetooth.updateAdvertisingData(advertisingData);
48
+ }
49
+
50
+ /**
51
+ * Get current advertising data.
52
+ *
53
+ * @returns Promise resolving to current advertising data.
54
+ */
55
+ function getAdvertisingData() {
56
+ return MunimBluetooth.getAdvertisingData();
57
+ }
58
+
59
+ /**
60
+ * Stop BLE advertising.
61
+ */
62
+ function stopAdvertising() {
63
+ return MunimBluetooth.stopAdvertising();
64
+ }
65
+
66
+ /**
67
+ * Set GATT services and characteristics for the Bluetooth peripheral.
68
+ *
69
+ * @param services - An array of service objects, each with a uuid and an array of characteristics.
70
+ */
71
+ function setServices(services) {
72
+ return MunimBluetooth.setServices(services);
73
+ }
74
+
75
+ // ========== Central/Manager Features ==========
76
+
77
+ /**
78
+ * Check if Bluetooth is enabled on the device.
79
+ *
80
+ * @returns Promise resolving to true if Bluetooth is enabled, false otherwise.
81
+ */
82
+ function isBluetoothEnabled() {
83
+ return MunimBluetooth.isBluetoothEnabled();
84
+ }
85
+
86
+ /**
87
+ * Request Bluetooth permissions (Android) or check authorization status (iOS).
88
+ *
89
+ * @returns Promise resolving to true if permissions are granted, false otherwise.
90
+ */
91
+ function requestBluetoothPermission() {
92
+ return MunimBluetooth.requestBluetoothPermission();
93
+ }
94
+
95
+ /**
96
+ * Start scanning for BLE devices.
97
+ *
98
+ * @param options - Optional scan configuration including service UUIDs to filter by.
99
+ */
100
+ function startScan(options) {
101
+ return MunimBluetooth.startScan(options);
102
+ }
103
+
104
+ /**
105
+ * Stop scanning for BLE devices.
106
+ */
107
+ function stopScan() {
108
+ return MunimBluetooth.stopScan();
109
+ }
110
+
111
+ /**
112
+ * Connect to a BLE device.
113
+ *
114
+ * @param deviceId - The unique identifier of the device to connect to.
115
+ * @returns Promise resolving when connection is established or rejected.
116
+ */
117
+ function connect(deviceId) {
118
+ return MunimBluetooth.connect(deviceId);
119
+ }
120
+
121
+ /**
122
+ * Disconnect from a BLE device.
123
+ *
124
+ * @param deviceId - The unique identifier of the device to disconnect from.
125
+ */
126
+ function disconnect(deviceId) {
127
+ return MunimBluetooth.disconnect(deviceId);
128
+ }
129
+
130
+ /**
131
+ * Discover GATT services for a connected device.
132
+ *
133
+ * @param deviceId - The unique identifier of the connected device.
134
+ * @returns Promise resolving to array of discovered services.
135
+ */
136
+ function discoverServices(deviceId) {
137
+ return MunimBluetooth.discoverServices(deviceId);
138
+ }
139
+
140
+ /**
141
+ * Read a characteristic value from a connected device.
142
+ *
143
+ * @param deviceId - The unique identifier of the connected device.
144
+ * @param serviceUUID - The UUID of the service containing the characteristic.
145
+ * @param characteristicUUID - The UUID of the characteristic to read.
146
+ * @returns Promise resolving to the characteristic value.
147
+ */
148
+ function readCharacteristic(deviceId, serviceUUID, characteristicUUID) {
149
+ return MunimBluetooth.readCharacteristic(deviceId, serviceUUID, characteristicUUID);
150
+ }
151
+
152
+ /**
153
+ * Write a value to a characteristic on a connected device.
154
+ *
155
+ * @param deviceId - The unique identifier of the connected device.
156
+ * @param serviceUUID - The UUID of the service containing the characteristic.
157
+ * @param characteristicUUID - The UUID of the characteristic to write.
158
+ * @param value - The value to write (hex string).
159
+ * @param writeType - Optional write type: 'write' or 'writeWithoutResponse'. Defaults to 'write'.
160
+ * @returns Promise resolving when write is complete.
161
+ */
162
+ function writeCharacteristic(deviceId, serviceUUID, characteristicUUID, value, writeType) {
163
+ return MunimBluetooth.writeCharacteristic(deviceId, serviceUUID, characteristicUUID, value, writeType);
164
+ }
165
+
166
+ /**
167
+ * Subscribe to notifications/indications from a characteristic.
168
+ *
169
+ * @param deviceId - The unique identifier of the connected device.
170
+ * @param serviceUUID - The UUID of the service containing the characteristic.
171
+ * @param characteristicUUID - The UUID of the characteristic to subscribe to.
172
+ */
173
+ function subscribeToCharacteristic(deviceId, serviceUUID, characteristicUUID) {
174
+ return MunimBluetooth.subscribeToCharacteristic(deviceId, serviceUUID, characteristicUUID);
175
+ }
176
+
177
+ /**
178
+ * Unsubscribe from notifications/indications from a characteristic.
179
+ *
180
+ * @param deviceId - The unique identifier of the connected device.
181
+ * @param serviceUUID - The UUID of the service containing the characteristic.
182
+ * @param characteristicUUID - The UUID of the characteristic to unsubscribe from.
183
+ */
184
+ function unsubscribeFromCharacteristic(deviceId, serviceUUID, characteristicUUID) {
185
+ return MunimBluetooth.unsubscribeFromCharacteristic(deviceId, serviceUUID, characteristicUUID);
186
+ }
187
+
188
+ /**
189
+ * Get list of currently connected devices.
190
+ *
191
+ * @returns Promise resolving to array of connected device IDs.
192
+ */
193
+ function getConnectedDevices() {
194
+ return MunimBluetooth.getConnectedDevices();
195
+ }
196
+
197
+ /**
198
+ * Read RSSI (signal strength) for a connected device.
199
+ *
200
+ * @param deviceId - The unique identifier of the connected device.
201
+ * @returns Promise resolving to RSSI value in dBm.
202
+ */
203
+ function readRSSI(deviceId) {
204
+ return MunimBluetooth.readRSSI(deviceId);
205
+ }
206
+
207
+ // ========== Event Management ==========
208
+
209
+ /**
210
+ * Add an event listener.
211
+ *
212
+ * @param eventName - The name of the event to listen for.
213
+ */
214
+ function addListener(eventName) {
215
+ return MunimBluetooth.addListener(eventName);
216
+ }
217
+
218
+ /**
219
+ * Remove event listeners.
220
+ *
221
+ * @param count - Number of listeners to remove.
222
+ */
223
+ function removeListeners(count) {
224
+ return MunimBluetooth.removeListeners(count);
225
+ }
226
+
227
+ // ========== Type Exports ==========
228
+ // Default export for convenience
229
+ var _default = exports.default = {
230
+ // Peripheral
231
+ startAdvertising,
232
+ stopAdvertising,
233
+ updateAdvertisingData,
234
+ getAdvertisingData,
235
+ setServices,
236
+ // Central
237
+ isBluetoothEnabled,
238
+ requestBluetoothPermission,
239
+ startScan,
240
+ stopScan,
241
+ connect,
242
+ disconnect,
243
+ discoverServices,
244
+ readCharacteristic,
245
+ writeCharacteristic,
246
+ subscribeToCharacteristic,
247
+ unsubscribeFromCharacteristic,
248
+ getConnectedDevices,
249
+ readRSSI,
250
+ // Events
251
+ addListener,
252
+ removeListeners
253
+ };
9
254
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNativeNitroModules","require","MunimBluetooth","exports","NitroModules","createHybridObject"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;AAAA,IAAAA,wBAAA,GAAAC,OAAA;AAGO,MAAMC,cAAc,GAAAC,OAAA,CAAAD,cAAA,GACzBE,qCAAY,CAACC,kBAAkB,CAAqB,gBAAgB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_reactNativeNitroModules","require","MunimBluetooth","NitroModules","createHybridObject","startAdvertising","options","updateAdvertisingData","advertisingData","getAdvertisingData","stopAdvertising","setServices","services","isBluetoothEnabled","requestBluetoothPermission","startScan","stopScan","connect","deviceId","disconnect","discoverServices","readCharacteristic","serviceUUID","characteristicUUID","writeCharacteristic","value","writeType","subscribeToCharacteristic","unsubscribeFromCharacteristic","getConnectedDevices","readRSSI","addListener","eventName","removeListeners","count","_default","exports","default"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,wBAAA,GAAAC,OAAA;AAUA,MAAMC,cAAc,GAClBC,qCAAY,CAACC,kBAAkB,CAAqB,gBAAgB,CAAC;;AAEvE;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASC,gBAAgBA,CAACC,OAKhC,EAAQ;EACP,OAAOJ,cAAc,CAACG,gBAAgB,CAACC,OAAO,CAAC;AACjD;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASC,qBAAqBA,CACnCC,eAAqC,EAC/B;EACN,OAAON,cAAc,CAACK,qBAAqB,CAACC,eAAe,CAAC;AAC9D;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASC,kBAAkBA,CAAA,EAAkC;EAClE,OAAOP,cAAc,CAACO,kBAAkB,CAAC,CAAC;AAC5C;;AAEA;AACA;AACA;AACO,SAASC,eAAeA,CAAA,EAAS;EACtC,OAAOR,cAAc,CAACQ,eAAe,CAAC,CAAC;AACzC;;AAEA;AACA;AACA;AACA;AACA;A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;EAC1BC,SAAS;EACTC,QAAQ;EACRC,OAAO;EACPE,UAAU;EACVC,gBAAgB;EAChBC,kBAAkB;EAClBG,mBAAmB;EACnBG,yBAAyB;EACzBC,6BAA6B;EAC7BC,mBAAmB;EACnBC,QAAQ;EACR;EACAC,WAAW;EACXE;AACF,CAAC","ignoreList":[]}
@@ -1,5 +1,231 @@
1
1
  "use strict";
2
2
 
3
3
  import { NitroModules } from 'react-native-nitro-modules';
4
- export const MunimBluetooth = NitroModules.createHybridObject('MunimBluetooth');
4
+ const MunimBluetooth = NitroModules.createHybridObject('MunimBluetooth');
5
+
6
+ // ========== Peripheral Features ==========
7
+
8
+ /**
9
+ * Start advertising as a Bluetooth peripheral with supported advertising data.
10
+ *
11
+ * @param options - An object with serviceUUIDs (string[]) and supported advertising data types.
12
+ */
13
+ export function startAdvertising(options) {
14
+ return MunimBluetooth.startAdvertising(options);
15
+ }
16
+
17
+ /**
18
+ * Update advertising data while advertising is active.
19
+ *
20
+ * @param advertisingData - The new advertising data to use.
21
+ */
22
+ export function updateAdvertisingData(advertisingData) {
23
+ return MunimBluetooth.updateAdvertisingData(advertisingData);
24
+ }
25
+
26
+ /**
27
+ * Get current advertising data.
28
+ *
29
+ * @returns Promise resolving to current advertising data.
30
+ */
31
+ export function getAdvertisingData() {
32
+ return MunimBluetooth.getAdvertisingData();
33
+ }
34
+
35
+ /**
36
+ * Stop BLE advertising.
37
+ */
38
+ export function stopAdvertising() {
39
+ return MunimBluetooth.stopAdvertising();
40
+ }
41
+
42
+ /**
43
+ * Set GATT services and characteristics for the Bluetooth peripheral.
44
+ *
45
+ * @param services - An array of service objects, each with a uuid and an array of characteristics.
46
+ */
47
+ export function setServices(services) {
48
+ return MunimBluetooth.setServices(services);
49
+ }
50
+
51
+ // ========== Central/Manager Features ==========
52
+
53
+ /**
54
+ * Check if Bluetooth is enabled on the device.
55
+ *
56
+ * @returns Promise resolving to true if Bluetooth is enabled, false otherwise.
57
+ */
58
+ export function isBluetoothEnabled() {
59
+ return MunimBluetooth.isBluetoothEnabled();
60
+ }
61
+
62
+ /**
63
+ * Request Bluetooth permissions (Android) or check authorization status (iOS).
64
+ *
65
+ * @returns Promise resolving to true if permissions are granted, false otherwise.
66
+ */
67
+ export function requestBluetoothPermission() {
68
+ return MunimBluetooth.requestBluetoothPermission();
69
+ }
70
+
71
+ /**
72
+ * Start scanning for BLE devices.
73
+ *
74
+ * @param options - Optional scan configuration including service UUIDs to filter by.
75
+ */
76
+ export function startScan(options) {
77
+ return MunimBluetooth.startScan(options);
78
+ }
79
+
80
+ /**
81
+ * Stop scanning for BLE devices.
82
+ */
83
+ export function stopScan() {
84
+ return MunimBluetooth.stopScan();
85
+ }
86
+
87
+ /**
88
+ * Connect to a BLE device.
89
+ *
90
+ * @param deviceId - The unique identifier of the device to connect to.
91
+ * @returns Promise resolving when connection is established or rejected.
92
+ */
93
+ export function connect(deviceId) {
94
+ return MunimBluetooth.connect(deviceId);
95
+ }
96
+
97
+ /**
98
+ * Disconnect from a BLE device.
99
+ *
100
+ * @param deviceId - The unique identifier of the device to disconnect from.
101
+ */
102
+ export function disconnect(deviceId) {
103
+ return MunimBluetooth.disconnect(deviceId);
104
+ }
105
+
106
+ /**
107
+ * Discover GATT services for a connected device.
108
+ *
109
+ * @param deviceId - The unique identifier of the connected device.
110
+ * @returns Promise resolving to array of discovered services.
111
+ */
112
+ export function discoverServices(deviceId) {
113
+ return MunimBluetooth.discoverServices(deviceId);
114
+ }
115
+
116
+ /**
117
+ * Read a characteristic value from a connected device.
118
+ *
119
+ * @param deviceId - The unique identifier of the connected device.
120
+ * @param serviceUUID - The UUID of the service containing the characteristic.
121
+ * @param characteristicUUID - The UUID of the characteristic to read.
122
+ * @returns Promise resolving to the characteristic value.
123
+ */
124
+ export function readCharacteristic(deviceId, serviceUUID, characteristicUUID) {
125
+ return MunimBluetooth.readCharacteristic(deviceId, serviceUUID, characteristicUUID);
126
+ }
127
+
128
+ /**
129
+ * Write a value to a characteristic on a connected device.
130
+ *
131
+ * @param deviceId - The unique identifier of the connected device.
132
+ * @param serviceUUID - The UUID of the service containing the characteristic.
133
+ * @param characteristicUUID - The UUID of the characteristic to write.
134
+ * @param value - The value to write (hex string).
135
+ * @param writeType - Optional write type: 'write' or 'writeWithoutResponse'. Defaults to 'write'.
136
+ * @returns Promise resolving when write is complete.
137
+ */
138
+ export function writeCharacteristic(deviceId, serviceUUID, characteristicUUID, value, writeType) {
139
+ return MunimBluetooth.writeCharacteristic(deviceId, serviceUUID, characteristicUUID, value, writeType);
140
+ }
141
+
142
+ /**
143
+ * Subscribe to notifications/indications from a characteristic.
144
+ *
145
+ * @param deviceId - The unique identifier of the connected device.
146
+ * @param serviceUUID - The UUID of the service containing the characteristic.
147
+ * @param characteristicUUID - The UUID of the characteristic to subscribe to.
148
+ */
149
+ export function subscribeToCharacteristic(deviceId, serviceUUID, characteristicUUID) {
150
+ return MunimBluetooth.subscribeToCharacteristic(deviceId, serviceUUID, characteristicUUID);
151
+ }
152
+
153
+ /**
154
+ * Unsubscribe from notifications/indications from a characteristic.
155
+ *
156
+ * @param deviceId - The unique identifier of the connected device.
157
+ * @param serviceUUID - The UUID of the service containing the characteristic.
158
+ * @param characteristicUUID - The UUID of the characteristic to unsubscribe from.
159
+ */
160
+ export function unsubscribeFromCharacteristic(deviceId, serviceUUID, characteristicUUID) {
161
+ return MunimBluetooth.unsubscribeFromCharacteristic(deviceId, serviceUUID, characteristicUUID);
162
+ }
163
+
164
+ /**
165
+ * Get list of currently connected devices.
166
+ *
167
+ * @returns Promise resolving to array of connected device IDs.
168
+ */
169
+ export function getConnectedDevices() {
170
+ return MunimBluetooth.getConnectedDevices();
171
+ }
172
+
173
+ /**
174
+ * Read RSSI (signal strength) for a connected device.
175
+ *
176
+ * @param deviceId - The unique identifier of the connected device.
177
+ * @returns Promise resolving to RSSI value in dBm.
178
+ */
179
+ export function readRSSI(deviceId) {
180
+ return MunimBluetooth.readRSSI(deviceId);
181
+ }
182
+
183
+ // ========== Event Management ==========
184
+
185
+ /**
186
+ * Add an event listener.
187
+ *
188
+ * @param eventName - The name of the event to listen for.
189
+ */
190
+ export function addListener(eventName) {
191
+ return MunimBluetooth.addListener(eventName);
192
+ }
193
+
194
+ /**
195
+ * Remove event listeners.
196
+ *
197
+ * @param count - Number of listeners to remove.
198
+ */
199
+ export function removeListeners(count) {
200
+ return MunimBluetooth.removeListeners(count);
201
+ }
202
+
203
+ // ========== Type Exports ==========
204
+
205
+ // Default export for convenience
206
+ export default {
207
+ // Peripheral
208
+ startAdvertising,
209
+ stopAdvertising,
210
+ updateAdvertisingData,
211
+ getAdvertisingData,
212
+ setServices,
213
+ // Central
214
+ isBluetoothEnabled,
215
+ requestBluetoothPermission,
216
+ startScan,
217
+ stopScan,
218
+ connect,
219
+ disconnect,
220
+ discoverServices,
221
+ readCharacteristic,
222
+ writeCharacteristic,
223
+ subscribeToCharacteristic,
224
+ unsubscribeFromCharacteristic,
225
+ getConnectedDevices,
226
+ readRSSI,
227
+ // Events
228
+ addListener,
229
+ removeListeners
230
+ };
5
231
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["NitroModules","MunimBluetooth","createHybridObject"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,4BAA4B;AAGzD,OAAO,MAAMC,cAAc,GACzBD,YAAY,CAACE,kBAAkB,CAAqB,gBAAgB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["NitroModules","MunimBluetooth","createHybridObject","startAdvertising","options","updateAdvertisingData","advertisingData","getAdvertisingData","stopAdvertising","setServices","services","isBluetoothEnabled","requestBluetoothPermission","startScan","stopScan","connect","deviceId","disconnect","discoverServices","readCharacteristic","serviceUUID","characteristicUUID","writeCharacteristic","value","writeType","subscribeToCharacteristic","unsubscribeFromCharacteristic","getConnectedDevices","readRSSI","addListener","eventName","removeListeners","count"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,4B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ACA;AACA,OAAO,SAASM,mBAAmBA,CAAA,EAAsB;EACvD,OAAO1B,cAAc,CAAC0B,mBAAmB,CAAC,CAAC;AAC7C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,QAAQA,CAACZ,QAAgB,EAAmB;EAC1D,OAAOf,cAAc,CAAC2B,QAAQ,CAACZ,QAAQ,CAAC;AAC1C;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASa,WAAWA,CAACC,SAAiB,EAAQ;EACnD,OAAO7B,cAAc,CAAC4B,WAAW,CAACC,SAAS,CAAC;AAC9C;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAACC,KAAa,EAAQ;EACnD,OAAO/B,cAAc,CAAC8B,eAAe,CAACC,KAAK,CAAC;AAC9C;;AAEA;;AAUA;AACA,eAAe;EACb;EACA7B,gBAAgB;EAChBK,eAAe;EACfH,qBAAqB;EACrBE,kBAAkB;EAClBE,WAAW;EACX;EACAE,kBAAkB;EAClBC,0BAA0B;EAC1BC,SAAS;EACTC,QAAQ;EACRC,OAAO;EACPE,UAAU;EACVC,gBAAgB;EAChBC,kBAAkB;EAClBG,mBAAmB;EACnBG,yBAAyB;EACzBC,6BAA6B;EAC7BC,mBAAmB;EACnBC,QAAQ;EACR;EACAC,WAAW;EACXE;AACF,CAAC","ignoreList":[]}
@@ -1,3 +1,162 @@
1
- import type { MunimBluetooth as MunimBluetoothSpec } from './specs/munim-bluetooth.nitro';
2
- export declare const MunimBluetooth: MunimBluetoothSpec;
1
+ import type { AdvertisingDataTypes, BLEDevice, ScanOptions, GATTService, CharacteristicValue } from './specs/munim-bluetooth.nitro';
2
+ /**
3
+ * Start advertising as a Bluetooth peripheral with supported advertising data.
4
+ *
5
+ * @param options - An object with serviceUUIDs (string[]) and supported advertising data types.
6
+ */
7
+ export declare function startAdvertising(options: {
8
+ serviceUUIDs: string[];
9
+ localName?: string;
10
+ manufacturerData?: string;
11
+ advertisingData?: AdvertisingDataTypes;
12
+ }): void;
13
+ /**
14
+ * Update advertising data while advertising is active.
15
+ *
16
+ * @param advertisingData - The new advertising data to use.
17
+ */
18
+ export declare function updateAdvertisingData(advertisingData: AdvertisingDataTypes): void;
19
+ /**
20
+ * Get current advertising data.
21
+ *
22
+ * @returns Promise resolving to current advertising data.
23
+ */
24
+ export declare function getAdvertisingData(): Promise<AdvertisingDataTypes>;
25
+ /**
26
+ * Stop BLE advertising.
27
+ */
28
+ export declare function stopAdvertising(): void;
29
+ /**
30
+ * Set GATT services and characteristics for the Bluetooth peripheral.
31
+ *
32
+ * @param services - An array of service objects, each with a uuid and an array of characteristics.
33
+ */
34
+ export declare function setServices(services: GATTService[]): void;
35
+ /**
36
+ * Check if Bluetooth is enabled on the device.
37
+ *
38
+ * @returns Promise resolving to true if Bluetooth is enabled, false otherwise.
39
+ */
40
+ export declare function isBluetoothEnabled(): Promise<boolean>;
41
+ /**
42
+ * Request Bluetooth permissions (Android) or check authorization status (iOS).
43
+ *
44
+ * @returns Promise resolving to true if permissions are granted, false otherwise.
45
+ */
46
+ export declare function requestBluetoothPermission(): Promise<boolean>;
47
+ /**
48
+ * Start scanning for BLE devices.
49
+ *
50
+ * @param options - Optional scan configuration including service UUIDs to filter by.
51
+ */
52
+ export declare function startScan(options?: ScanOptions): void;
53
+ /**
54
+ * Stop scanning for BLE devices.
55
+ */
56
+ export declare function stopScan(): void;
57
+ /**
58
+ * Connect to a BLE device.
59
+ *
60
+ * @param deviceId - The unique identifier of the device to connect to.
61
+ * @returns Promise resolving when connection is established or rejected.
62
+ */
63
+ export declare function connect(deviceId: string): Promise<void>;
64
+ /**
65
+ * Disconnect from a BLE device.
66
+ *
67
+ * @param deviceId - The unique identifier of the device to disconnect from.
68
+ */
69
+ export declare function disconnect(deviceId: string): void;
70
+ /**
71
+ * Discover GATT services for a connected device.
72
+ *
73
+ * @param deviceId - The unique identifier of the connected device.
74
+ * @returns Promise resolving to array of discovered services.
75
+ */
76
+ export declare function discoverServices(deviceId: string): Promise<GATTService[]>;
77
+ /**
78
+ * Read a characteristic value from a connected device.
79
+ *
80
+ * @param deviceId - The unique identifier of the connected device.
81
+ * @param serviceUUID - The UUID of the service containing the characteristic.
82
+ * @param characteristicUUID - The UUID of the characteristic to read.
83
+ * @returns Promise resolving to the characteristic value.
84
+ */
85
+ export declare function readCharacteristic(deviceId: string, serviceUUID: string, characteristicUUID: string): Promise<CharacteristicValue>;
86
+ /**
87
+ * Write a value to a characteristic on a connected device.
88
+ *
89
+ * @param deviceId - The unique identifier of the connected device.
90
+ * @param serviceUUID - The UUID of the service containing the characteristic.
91
+ * @param characteristicUUID - The UUID of the characteristic to write.
92
+ * @param value - The value to write (hex string).
93
+ * @param writeType - Optional write type: 'write' or 'writeWithoutResponse'. Defaults to 'write'.
94
+ * @returns Promise resolving when write is complete.
95
+ */
96
+ export declare function writeCharacteristic(deviceId: string, serviceUUID: string, characteristicUUID: string, value: string, writeType?: 'write' | 'writeWithoutResponse'): Promise<void>;
97
+ /**
98
+ * Subscribe to notifications/indications from a characteristic.
99
+ *
100
+ * @param deviceId - The unique identifier of the connected device.
101
+ * @param serviceUUID - The UUID of the service containing the characteristic.
102
+ * @param characteristicUUID - The UUID of the characteristic to subscribe to.
103
+ */
104
+ export declare function subscribeToCharacteristic(deviceId: string, serviceUUID: string, characteristicUUID: string): void;
105
+ /**
106
+ * Unsubscribe from notifications/indications from a characteristic.
107
+ *
108
+ * @param deviceId - The unique identifier of the connected device.
109
+ * @param serviceUUID - The UUID of the service containing the characteristic.
110
+ * @param characteristicUUID - The UUID of the characteristic to unsubscribe from.
111
+ */
112
+ export declare function unsubscribeFromCharacteristic(deviceId: string, serviceUUID: string, characteristicUUID: string): void;
113
+ /**
114
+ * Get list of currently connected devices.
115
+ *
116
+ * @returns Promise resolving to array of connected device IDs.
117
+ */
118
+ export declare function getConnectedDevices(): Promise<string[]>;
119
+ /**
120
+ * Read RSSI (signal strength) for a connected device.
121
+ *
122
+ * @param deviceId - The unique identifier of the connected device.
123
+ * @returns Promise resolving to RSSI value in dBm.
124
+ */
125
+ export declare function readRSSI(deviceId: string): Promise<number>;
126
+ /**
127
+ * Add an event listener.
128
+ *
129
+ * @param eventName - The name of the event to listen for.
130
+ */
131
+ export declare function addListener(eventName: string): void;
132
+ /**
133
+ * Remove event listeners.
134
+ *
135
+ * @param count - Number of listeners to remove.
136
+ */
137
+ export declare function removeListeners(count: number): void;
138
+ export type { AdvertisingDataTypes, BLEDevice, ScanOptions, GATTService, CharacteristicValue, };
139
+ declare const _default: {
140
+ startAdvertising: typeof startAdvertising;
141
+ stopAdvertising: typeof stopAdvertising;
142
+ updateAdvertisingData: typeof updateAdvertisingData;
143
+ getAdvertisingData: typeof getAdvertisingData;
144
+ setServices: typeof setServices;
145
+ isBluetoothEnabled: typeof isBluetoothEnabled;
146
+ requestBluetoothPermission: typeof requestBluetoothPermission;
147
+ startScan: typeof startScan;
148
+ stopScan: typeof stopScan;
149
+ connect: typeof connect;
150
+ disconnect: typeof disconnect;
151
+ discoverServices: typeof discoverServices;
152
+ readCharacteristic: typeof readCharacteristic;
153
+ writeCharacteristic: typeof writeCharacteristic;
154
+ subscribeToCharacteristic: typeof subscribeToCharacteristic;
155
+ unsubscribeFromCharacteristic: typeof unsubscribeFromCharacteristic;
156
+ getConnectedDevices: typeof getConnectedDevices;
157
+ readRSSI: typeof readRSSI;
158
+ addListener: typeof addListener;
159
+ removeListeners: typeof removeListeners;
160
+ };
161
+ export default _default;
3
162
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,IAAI,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;AAEzF,eAAO,MAAM,cAAc,oBAC4C,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,o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