react-native-sdk-ble-middleware-v2 0.1.0

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.
Files changed (39) hide show
  1. package/LICENSE +20 -0
  2. package/Middleware.podspec +21 -0
  3. package/README.md +187 -0
  4. package/android/build.gradle +77 -0
  5. package/android/gradle.properties +5 -0
  6. package/android/src/main/AndroidManifest.xml +2 -0
  7. package/android/src/main/java/com/middleware/MiddlewareModule.kt +23 -0
  8. package/android/src/main/java/com/middleware/MiddlewarePackage.kt +33 -0
  9. package/ios/Middleware.h +5 -0
  10. package/ios/Middleware.mm +21 -0
  11. package/lib/module/NativeMiddleware.js +3 -0
  12. package/lib/module/NativeMiddleware.js.map +1 -0
  13. package/lib/module/context/BLEContext.js +390 -0
  14. package/lib/module/context/BLEContext.js.map +1 -0
  15. package/lib/module/hooks/index.js +2 -0
  16. package/lib/module/hooks/index.js.map +1 -0
  17. package/lib/module/hooks/useBLE.js +167 -0
  18. package/lib/module/hooks/useBLE.js.map +1 -0
  19. package/lib/module/index.js +12 -0
  20. package/lib/module/index.js.map +1 -0
  21. package/lib/module/services/BLEMiddleware.js +252 -0
  22. package/lib/module/services/BLEMiddleware.js.map +1 -0
  23. package/lib/module/services/MockBLEManager.js +94 -0
  24. package/lib/module/services/MockBLEManager.js.map +1 -0
  25. package/lib/module/services/index.js +2 -0
  26. package/lib/module/services/index.js.map +1 -0
  27. package/lib/module/types/index.js +44 -0
  28. package/lib/module/types/index.js.map +1 -0
  29. package/package.json +179 -0
  30. package/react-native.config.js +8 -0
  31. package/src/NativeMiddleware.ts +7 -0
  32. package/src/context/BLEContext.tsx +487 -0
  33. package/src/hooks/index.ts +1 -0
  34. package/src/hooks/useBLE.ts +190 -0
  35. package/src/index.tsx +21 -0
  36. package/src/services/BLEMiddleware.ts +291 -0
  37. package/src/services/MockBLEManager.ts +96 -0
  38. package/src/services/index.ts +1 -0
  39. package/src/types/index.ts +97 -0
@@ -0,0 +1,390 @@
1
+ import React, { createContext, useContext, useState, useEffect } from 'react';
2
+ import bleMiddleware from '../services/BLEMiddleware';
3
+
4
+ /**
5
+ * BLE Context State
6
+ */
7
+
8
+ const BLEContext = /*#__PURE__*/createContext(undefined);
9
+
10
+ /**
11
+ * BLE Provider Component
12
+ * Manages all BLE state and operations
13
+ */
14
+ export const BLEProvider = ({
15
+ children
16
+ }) => {
17
+ const [bluetoothEnabled, setBluetoothEnabled] = useState(false);
18
+ const [isScanning, setIsScanning] = useState(false);
19
+ const [discoveredDevices, setDiscoveredDevices] = useState([]);
20
+ const [connectedDevices, setConnectedDevices] = useState(new Map());
21
+
22
+ // Legacy single device support (tracks the first/primary connected device)
23
+ const [connectedDeviceId, setConnectedDeviceId] = useState(null);
24
+
25
+ // Legacy notification states (for the primary device)
26
+ const [ff01Notification, setFF01Notification] = useState(null);
27
+ const [ff21Notification, setFF21Notification] = useState(null);
28
+ const [ff31Notification, setFF31Notification] = useState(null);
29
+ const [ff41Notification, setFF41Notification] = useState(null);
30
+ const [ff02Notification, setFF02Notification] = useState(null);
31
+
32
+ // Legacy infusion state (for the primary device)
33
+ const [isInfusionRunning, setIsInfusionRunning] = useState(false);
34
+ useEffect(() => {
35
+ const initialize = async () => {
36
+ // Wait for BLE middleware to initialize first
37
+ await bleMiddleware.waitForInitialization();
38
+
39
+ // Then setup BLE and event listeners
40
+ await setupBLE();
41
+ setupEventListeners();
42
+ };
43
+ initialize();
44
+ return () => {
45
+ bleMiddleware.removeAllListeners();
46
+ };
47
+ }, []);
48
+ const setupBLE = async () => {
49
+ try {
50
+ await requestPermissions();
51
+ const enabled = await bleMiddleware.isBluetoothEnabled();
52
+ setBluetoothEnabled(enabled);
53
+ } catch (error) {
54
+ console.error('Failed to setup BLE:', error);
55
+ }
56
+ };
57
+ const requestPermissions = async () => {
58
+ try {
59
+ await bleMiddleware.requestPermissions();
60
+ } catch (error) {
61
+ console.error('Failed to request permissions:', error);
62
+ }
63
+ };
64
+ const setupEventListeners = () => {
65
+ // Scan result event
66
+ bleMiddleware.on('scanResult', ({
67
+ device
68
+ }) => {
69
+ setDiscoveredDevices(prev => {
70
+ const exists = prev.find(d => d.id === device.id);
71
+ if (exists) {
72
+ return prev.map(d => d.id === device.id ? device : d);
73
+ }
74
+ return [...prev, device];
75
+ });
76
+ });
77
+
78
+ // Connected event
79
+ bleMiddleware.on('connected', ({
80
+ deviceId
81
+ }) => {
82
+ setConnectedDevices(prev => {
83
+ const newMap = new Map(prev);
84
+ newMap.set(deviceId, {
85
+ deviceId,
86
+ isConnected: true,
87
+ isInfusionRunning: false,
88
+ infusionLevel: null,
89
+ notifications: {
90
+ ff01: null,
91
+ ff21: null,
92
+ ff31: null,
93
+ ff41: null,
94
+ ff02: null
95
+ }
96
+ });
97
+ return newMap;
98
+ });
99
+
100
+ // Legacy: Set first connected device as primary
101
+ setConnectedDeviceId(prev => prev || deviceId);
102
+ console.log('✅ Device connected:', deviceId);
103
+ });
104
+
105
+ // Disconnected event
106
+ bleMiddleware.on('disconnected', ({
107
+ deviceId
108
+ }) => {
109
+ setConnectedDevices(prev => {
110
+ const newMap = new Map(prev);
111
+ newMap.delete(deviceId);
112
+ return newMap;
113
+ });
114
+
115
+ // Legacy: Update primary device
116
+ setConnectedDeviceId(prev => {
117
+ if (prev === deviceId) {
118
+ // If primary device disconnected, set new primary or null
119
+ const remaining = Array.from(connectedDevices.keys()).filter(id => id !== deviceId);
120
+ const newPrimary = remaining[0] || null;
121
+ // Update legacy infusion state
122
+ if (!newPrimary) {
123
+ setIsInfusionRunning(false);
124
+ }
125
+ return newPrimary;
126
+ }
127
+ return prev;
128
+ });
129
+ console.log('❌ Device disconnected:', deviceId);
130
+ });
131
+
132
+ // Scan failed event
133
+ bleMiddleware.on('BleManagerScanFailed', ({
134
+ error
135
+ }) => {
136
+ console.error('BLE Scan Failed:', error);
137
+ setIsScanning(false);
138
+ });
139
+
140
+ // Bluetooth state changed event
141
+ bleMiddleware.on('bluetoothStateChanged', ({
142
+ state
143
+ }) => {
144
+ setBluetoothEnabled(state === 'poweredOn');
145
+ });
146
+
147
+ // Characteristic changed event
148
+ bleMiddleware.on('characteristicChanged', event => {
149
+ console.log('Characteristic Changed Event:', event);
150
+ const {
151
+ characteristicUuid,
152
+ deviceId
153
+ } = event;
154
+ const uuidUpper = characteristicUuid === null || characteristicUuid === void 0 ? void 0 : characteristicUuid.toUpperCase();
155
+
156
+ // Update device-specific notifications
157
+ setConnectedDevices(prev => {
158
+ const newMap = new Map(prev);
159
+ const deviceState = newMap.get(deviceId);
160
+ if (deviceState) {
161
+ const updatedState = {
162
+ ...deviceState
163
+ };
164
+ if (uuidUpper === '0000FF01-0000-1000-8000-00805F9B34FB') {
165
+ updatedState.notifications.ff01 = event;
166
+ } else if (uuidUpper === '0000FF21-0000-1000-8000-00805F9B34FB') {
167
+ updatedState.notifications.ff21 = event;
168
+ } else if (uuidUpper === '0000FF31-0000-1000-8000-00805F9B34FB') {
169
+ updatedState.notifications.ff31 = event;
170
+ } else if (uuidUpper === '0000FF41-0000-1000-8000-00805F9B34FB') {
171
+ updatedState.notifications.ff41 = event;
172
+ } else if (uuidUpper === '0000FF02-0000-1000-8000-00805F9B34FB') {
173
+ updatedState.notifications.ff02 = event;
174
+ }
175
+ newMap.set(deviceId, updatedState);
176
+ }
177
+ return newMap;
178
+ });
179
+
180
+ // Legacy: Update global notifications for primary device
181
+ if (deviceId === connectedDeviceId) {
182
+ if (uuidUpper === '0000FF01-0000-1000-8000-00805F9B34FB') {
183
+ setFF01Notification(event);
184
+ } else if (uuidUpper === '0000FF21-0000-1000-8000-00805F9B34FB') {
185
+ setFF21Notification(event);
186
+ } else if (uuidUpper === '0000FF31-0000-1000-8000-00805F9B34FB') {
187
+ setFF31Notification(event);
188
+ } else if (uuidUpper === '0000FF41-0000-1000-8000-00805F9B34FB') {
189
+ setFF41Notification(event);
190
+ } else if (uuidUpper === '0000FF02-0000-1000-8000-00805F9B34FB') {
191
+ setFF02Notification(event);
192
+ } else {
193
+ console.log('⚠️ Unhandled characteristic:', characteristicUuid);
194
+ }
195
+ }
196
+ });
197
+ };
198
+ const startScan = async () => {
199
+ console.log('Starting device scan...');
200
+ try {
201
+ setDiscoveredDevices([]);
202
+ setIsScanning(true);
203
+ await bleMiddleware.startScan({
204
+ timeout: 10000,
205
+ allowDuplicates: false
206
+ });
207
+ } catch (error) {
208
+ console.error('Failed to start scan:', error);
209
+ setIsScanning(false);
210
+ }
211
+ };
212
+ const stopScan = async () => {
213
+ try {
214
+ await bleMiddleware.stopScan();
215
+ setIsScanning(false);
216
+ } catch (error) {
217
+ console.error('Failed to stop scan:', error);
218
+ }
219
+ };
220
+ const connectToDevice = async device => {
221
+ console.log('Connecting to device:', device);
222
+ try {
223
+ await bleMiddleware.connect(device.id);
224
+ console.log('Connected successfully');
225
+ } catch (error) {
226
+ console.error('Failed to connect:', error);
227
+ }
228
+ };
229
+ const disconnectDevice = async deviceId => {
230
+ try {
231
+ await bleMiddleware.disconnect(deviceId);
232
+ // State will be updated in the 'disconnected' event handler
233
+ console.log('Disconnected from device:', deviceId);
234
+ } catch (error) {
235
+ console.error('Failed to disconnect:', error);
236
+ }
237
+ };
238
+
239
+ // Multi-device query helpers
240
+ const getDeviceState = deviceId => {
241
+ return connectedDevices.get(deviceId);
242
+ };
243
+ const isDeviceConnected = deviceId => {
244
+ return connectedDevices.has(deviceId);
245
+ };
246
+ const getConnectedDeviceIds = () => {
247
+ return Array.from(connectedDevices.keys());
248
+ };
249
+ const startInfusion = async deviceId => {
250
+ try {
251
+ await bleMiddleware.startInfusion(deviceId);
252
+
253
+ // Update device-specific state
254
+ setConnectedDevices(prev => {
255
+ const newMap = new Map(prev);
256
+ const deviceState = newMap.get(deviceId);
257
+ if (deviceState) {
258
+ newMap.set(deviceId, {
259
+ ...deviceState,
260
+ isInfusionRunning: true
261
+ });
262
+ }
263
+ return newMap;
264
+ });
265
+
266
+ // Legacy: Update global state if this is the primary device
267
+ if (deviceId === connectedDeviceId) {
268
+ setIsInfusionRunning(true);
269
+ }
270
+ console.log('✅ Infusion started successfully for device:', deviceId);
271
+ } catch (error) {
272
+ console.error('Failed to start infusion:', error);
273
+ throw error;
274
+ }
275
+ };
276
+ const stopInfusion = async deviceId => {
277
+ try {
278
+ await bleMiddleware.stopInfusion(deviceId);
279
+
280
+ // Update device-specific state
281
+ setConnectedDevices(prev => {
282
+ const newMap = new Map(prev);
283
+ const deviceState = newMap.get(deviceId);
284
+ if (deviceState) {
285
+ newMap.set(deviceId, {
286
+ ...deviceState,
287
+ isInfusionRunning: false
288
+ });
289
+ }
290
+ return newMap;
291
+ });
292
+
293
+ // Legacy: Update global state if this is the primary device
294
+ if (deviceId === connectedDeviceId) {
295
+ setIsInfusionRunning(false);
296
+ }
297
+ console.log('✅ Infusion stopped successfully for device:', deviceId);
298
+ } catch (error) {
299
+ console.error('Failed to stop infusion:', error);
300
+ throw error;
301
+ }
302
+ };
303
+ const setInfusionLevel = async (deviceId, level) => {
304
+ try {
305
+ await bleMiddleware.setInfusionLevel(deviceId, level);
306
+
307
+ // Update device-specific state
308
+ setConnectedDevices(prev => {
309
+ const newMap = new Map(prev);
310
+ const deviceState = newMap.get(deviceId);
311
+ if (deviceState) {
312
+ newMap.set(deviceId, {
313
+ ...deviceState,
314
+ infusionLevel: level
315
+ });
316
+ }
317
+ return newMap;
318
+ });
319
+ console.log(`✅ Infusion level set to ${level} successfully for device:`, deviceId);
320
+ } catch (error) {
321
+ console.error('Failed to set infusion level:', error);
322
+ throw error;
323
+ }
324
+ };
325
+ const readCharacteristic = async (deviceId, serviceUuid, characteristicUuid) => {
326
+ try {
327
+ return await bleMiddleware.readCharacteristic(deviceId, serviceUuid, characteristicUuid);
328
+ } catch (error) {
329
+ console.error('Failed to read characteristic:', error);
330
+ throw error;
331
+ }
332
+ };
333
+ const writeCharacteristic = async (deviceId, serviceUuid, characteristicUuid, data, options) => {
334
+ try {
335
+ await bleMiddleware.writeCharacteristic(deviceId, serviceUuid, characteristicUuid, data, options);
336
+ } catch (error) {
337
+ console.error('Failed to write characteristic:', error);
338
+ throw error;
339
+ }
340
+ };
341
+ const setUserRole = role => {
342
+ bleMiddleware.setUserRole(role);
343
+ };
344
+ const getUserRole = () => {
345
+ return bleMiddleware.getUserRole();
346
+ };
347
+ const value = {
348
+ bluetoothEnabled,
349
+ isScanning,
350
+ discoveredDevices,
351
+ connectedDevices,
352
+ connectedDeviceId,
353
+ isInfusionRunning,
354
+ ff01Notification,
355
+ ff21Notification,
356
+ ff31Notification,
357
+ ff41Notification,
358
+ ff02Notification,
359
+ startScan,
360
+ stopScan,
361
+ connectToDevice,
362
+ disconnectDevice,
363
+ requestPermissions,
364
+ getDeviceState,
365
+ isDeviceConnected,
366
+ getConnectedDeviceIds,
367
+ startInfusion,
368
+ stopInfusion,
369
+ setInfusionLevel,
370
+ readCharacteristic,
371
+ writeCharacteristic,
372
+ setUserRole,
373
+ getUserRole
374
+ };
375
+ return /*#__PURE__*/React.createElement(BLEContext.Provider, {
376
+ value: value
377
+ }, children);
378
+ };
379
+
380
+ /**
381
+ * Hook to access BLE context
382
+ */
383
+ export const useBLEContext = () => {
384
+ const context = useContext(BLEContext);
385
+ if (!context) {
386
+ throw new Error('useBLEContext must be used within a BLEProvider');
387
+ }
388
+ return context;
389
+ };
390
+ //# sourceMappingURL=BLEContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","createContext","useContext","useState","useEffect","bleMiddleware","BLEContext","undefined","BLEProvider","children","bluetoothEnabled","setBluetoothEnabled","isScanning","setIsScanning","discoveredDevices","setDiscoveredDevices","connectedDevices","setConnectedDevices","Map","connectedDeviceId","setConnectedDeviceId","ff01Notification","setFF01Notification","ff21Notification","setFF21Notification","ff31Notification","setFF31Notification","ff41Notification","setFF41Notification","ff02Notification","setFF02Notification","isInfusionRunning","setIsInfusionRunning","initialize","waitForInitialization","setupBLE","setupEventListeners","removeAllListeners","requestPermissions","enabled","isBluetoothEnabled","error","console","on","device","prev","exists","find","d","id","map","deviceId","newMap","set","isConnected","infusionLevel","notifications","ff01","ff21","ff31","ff41","ff02","log","delete","remaining","Array","from","keys","filter","newPrimary","state","event","characteristicUuid","uuidUpper","toUpperCase","deviceState","get","updatedState","startScan","timeout","allowDuplicates","stopScan","connectToDevice","connect","disconnectDevice","disconnect","getDeviceState","isDeviceConnected","has","getConnectedDeviceIds","startInfusion","stopInfusion","setInfusionLevel","level","readCharacteristic","serviceUuid","writeCharacteristic","data","options","setUserRole","role","getUserRole","value","createElement","Provider","useBLEContext","context","Error"],"sources":["BLEContext.tsx"],"sourcesContent":["import React, { createContext, useContext, useState, useEffect } from 'react';\nimport type {\n BLEDevice,\n CharacteristicNotification,\n DeviceConnectionState,\n UserRole,\n} from '../types';\nimport bleMiddleware from '../services/BLEMiddleware';\n\n/**\n * BLE Context State\n */\ninterface BLEContextState {\n // Connection state\n bluetoothEnabled: boolean;\n isScanning: boolean;\n discoveredDevices: BLEDevice[];\n connectedDevices: Map<string, DeviceConnectionState>;\n\n // Legacy single device support (for backward compatibility)\n connectedDeviceId: string | null;\n isInfusionRunning: boolean;\n ff01Notification: CharacteristicNotification | null;\n ff21Notification: CharacteristicNotification | null;\n ff31Notification: CharacteristicNotification | null;\n ff41Notification: CharacteristicNotification | null;\n ff02Notification: CharacteristicNotification | null;\n\n // Actions\n startScan: () => Promise<void>;\n stopScan: () => Promise<void>;\n connectToDevice: (device: BLEDevice) => Promise<void>;\n disconnectDevice: (deviceId: string) => Promise<void>;\n requestPermissions: () => Promise<void>;\n\n // Multi-device queries\n getDeviceState: (deviceId: string) => DeviceConnectionState | undefined;\n isDeviceConnected: (deviceId: string) => boolean;\n getConnectedDeviceIds: () => string[];\n\n // Infusion actions\n startInfusion: (deviceId: string) => Promise<void>;\n stopInfusion: (deviceId: string) => Promise<void>;\n setInfusionLevel: (deviceId: string, level: number) => Promise<void>;\n\n // Characteristic operations\n readCharacteristic: (\n deviceId: string,\n serviceUuid: string,\n characteristicUuid: string\n ) => Promise<any>;\n writeCharacteristic: (\n deviceId: string,\n serviceUuid: string,\n characteristicUuid: string,\n data: string,\n options?: { withResponse?: boolean }\n ) => Promise<void>;\n\n // User role management\n setUserRole: (role: UserRole) => void;\n getUserRole: () => UserRole;\n}\n\nconst BLEContext = createContext<BLEContextState | undefined>(undefined);\n\n/**\n * BLE Provider Component\n * Manages all BLE state and operations\n */\nexport const BLEProvider: React.FC<{ children: React.ReactNode }> = ({\n children,\n}) => {\n const [bluetoothEnabled, setBluetoothEnabled] = useState(false);\n const [isScanning, setIsScanning] = useState(false);\n const [discoveredDevices, setDiscoveredDevices] = useState<BLEDevice[]>([]);\n const [connectedDevices, setConnectedDevices] = useState<\n Map<string, DeviceConnectionState>\n >(new Map());\n\n // Legacy single device support (tracks the first/primary connected device)\n const [connectedDeviceId, setConnectedDeviceId] = useState<string | null>(\n null\n );\n\n // Legacy notification states (for the primary device)\n const [ff01Notification, setFF01Notification] =\n useState<CharacteristicNotification | null>(null);\n const [ff21Notification, setFF21Notification] =\n useState<CharacteristicNotification | null>(null);\n const [ff31Notification, setFF31Notification] =\n useState<CharacteristicNotification | null>(null);\n const [ff41Notification, setFF41Notification] =\n useState<CharacteristicNotification | null>(null);\n const [ff02Notification, setFF02Notification] =\n useState<CharacteristicNotification | null>(null);\n\n // Legacy infusion state (for the primary device)\n const [isInfusionRunning, setIsInfusionRunning] = useState(false);\n\n useEffect(() => {\n const initialize = async () => {\n // Wait for BLE middleware to initialize first\n await bleMiddleware.waitForInitialization();\n\n // Then setup BLE and event listeners\n await setupBLE();\n setupEventListeners();\n };\n\n initialize();\n\n return () => {\n bleMiddleware.removeAllListeners();\n };\n }, []);\n\n const setupBLE = async () => {\n try {\n await requestPermissions();\n const enabled = await bleMiddleware.isBluetoothEnabled();\n setBluetoothEnabled(enabled);\n } catch (error) {\n console.error('Failed to setup BLE:', error);\n }\n };\n\n const requestPermissions = async () => {\n try {\n await bleMiddleware.requestPermissions();\n } catch (error) {\n console.error('Failed to request permissions:', error);\n }\n };\n\n const setupEventListeners = () => {\n // Scan result event\n bleMiddleware.on('scanResult', ({ device }: any) => {\n setDiscoveredDevices((prev) => {\n const exists = prev.find((d) => d.id === device.id);\n if (exists) {\n return prev.map((d) => (d.id === device.id ? device : d));\n }\n return [...prev, device];\n });\n });\n\n // Connected event\n bleMiddleware.on('connected', ({ deviceId }: any) => {\n setConnectedDevices((prev) => {\n const newMap = new Map(prev);\n newMap.set(deviceId, {\n deviceId,\n isConnected: true,\n isInfusionRunning: false,\n infusionLevel: null,\n notifications: {\n ff01: null,\n ff21: null,\n ff31: null,\n ff41: null,\n ff02: null,\n },\n });\n return newMap;\n });\n\n // Legacy: Set first connected device as primary\n setConnectedDeviceId((prev) => prev || deviceId);\n console.log('✅ Device connected:', deviceId);\n });\n\n // Disconnected event\n bleMiddleware.on('disconnected', ({ deviceId }: any) => {\n setConnectedDevices((prev) => {\n const newMap = new Map(prev);\n newMap.delete(deviceId);\n return newMap;\n });\n\n // Legacy: Update primary device\n setConnectedDeviceId((prev) => {\n if (prev === deviceId) {\n // If primary device disconnected, set new primary or null\n const remaining = Array.from(connectedDevices.keys()).filter(\n (id) => id !== deviceId\n );\n const newPrimary = remaining[0] || null;\n // Update legacy infusion state\n if (!newPrimary) {\n setIsInfusionRunning(false);\n }\n return newPrimary;\n }\n return prev;\n });\n\n console.log('❌ Device disconnected:', deviceId);\n });\n\n // Scan failed event\n bleMiddleware.on('BleManagerScanFailed', ({ error }: any) => {\n console.error('BLE Scan Failed:', error);\n setIsScanning(false);\n });\n\n // Bluetooth state changed event\n bleMiddleware.on('bluetoothStateChanged', ({ state }: any) => {\n setBluetoothEnabled(state === 'poweredOn');\n });\n\n // Characteristic changed event\n bleMiddleware.on('characteristicChanged', (event: any) => {\n console.log('Characteristic Changed Event:', event);\n const { characteristicUuid, deviceId } = event;\n const uuidUpper = characteristicUuid?.toUpperCase();\n\n // Update device-specific notifications\n setConnectedDevices((prev) => {\n const newMap = new Map(prev);\n const deviceState = newMap.get(deviceId);\n if (deviceState) {\n const updatedState = { ...deviceState };\n if (uuidUpper === '0000FF01-0000-1000-8000-00805F9B34FB') {\n updatedState.notifications.ff01 = event;\n } else if (uuidUpper === '0000FF21-0000-1000-8000-00805F9B34FB') {\n updatedState.notifications.ff21 = event;\n } else if (uuidUpper === '0000FF31-0000-1000-8000-00805F9B34FB') {\n updatedState.notifications.ff31 = event;\n } else if (uuidUpper === '0000FF41-0000-1000-8000-00805F9B34FB') {\n updatedState.notifications.ff41 = event;\n } else if (uuidUpper === '0000FF02-0000-1000-8000-00805F9B34FB') {\n updatedState.notifications.ff02 = event;\n }\n newMap.set(deviceId, updatedState);\n }\n return newMap;\n });\n\n // Legacy: Update global notifications for primary device\n if (deviceId === connectedDeviceId) {\n if (uuidUpper === '0000FF01-0000-1000-8000-00805F9B34FB') {\n setFF01Notification(event);\n } else if (uuidUpper === '0000FF21-0000-1000-8000-00805F9B34FB') {\n setFF21Notification(event);\n } else if (uuidUpper === '0000FF31-0000-1000-8000-00805F9B34FB') {\n setFF31Notification(event);\n } else if (uuidUpper === '0000FF41-0000-1000-8000-00805F9B34FB') {\n setFF41Notification(event);\n } else if (uuidUpper === '0000FF02-0000-1000-8000-00805F9B34FB') {\n setFF02Notification(event);\n } else {\n console.log('⚠️ Unhandled characteristic:', characteristicUuid);\n }\n }\n });\n };\n\n const startScan = async () => {\n console.log('Starting device scan...');\n try {\n setDiscoveredDevices([]);\n setIsScanning(true);\n await bleMiddleware.startScan({ timeout: 10000, allowDuplicates: false });\n } catch (error) {\n console.error('Failed to start scan:', error);\n setIsScanning(false);\n }\n };\n\n const stopScan = async () => {\n try {\n await bleMiddleware.stopScan();\n setIsScanning(false);\n } catch (error) {\n console.error('Failed to stop scan:', error);\n }\n };\n\n const connectToDevice = async (device: BLEDevice) => {\n console.log('Connecting to device:', device);\n try {\n await bleMiddleware.connect(device.id);\n console.log('Connected successfully');\n } catch (error) {\n console.error('Failed to connect:', error);\n }\n };\n\n const disconnectDevice = async (deviceId: string) => {\n try {\n await bleMiddleware.disconnect(deviceId);\n // State will be updated in the 'disconnected' event handler\n console.log('Disconnected from device:', deviceId);\n } catch (error) {\n console.error('Failed to disconnect:', error);\n }\n };\n\n // Multi-device query helpers\n const getDeviceState = (\n deviceId: string\n ): DeviceConnectionState | undefined => {\n return connectedDevices.get(deviceId);\n };\n\n const isDeviceConnected = (deviceId: string): boolean => {\n return connectedDevices.has(deviceId);\n };\n\n const getConnectedDeviceIds = (): string[] => {\n return Array.from(connectedDevices.keys());\n };\n\n const startInfusion = async (deviceId: string) => {\n try {\n await bleMiddleware.startInfusion(deviceId);\n\n // Update device-specific state\n setConnectedDevices((prev) => {\n const newMap = new Map(prev);\n const deviceState = newMap.get(deviceId);\n if (deviceState) {\n newMap.set(deviceId, {\n ...deviceState,\n isInfusionRunning: true,\n });\n }\n return newMap;\n });\n\n // Legacy: Update global state if this is the primary device\n if (deviceId === connectedDeviceId) {\n setIsInfusionRunning(true);\n }\n\n console.log('✅ Infusion started successfully for device:', deviceId);\n } catch (error) {\n console.error('Failed to start infusion:', error);\n throw error;\n }\n };\n\n const stopInfusion = async (deviceId: string) => {\n try {\n await bleMiddleware.stopInfusion(deviceId);\n\n // Update device-specific state\n setConnectedDevices((prev) => {\n const newMap = new Map(prev);\n const deviceState = newMap.get(deviceId);\n if (deviceState) {\n newMap.set(deviceId, {\n ...deviceState,\n isInfusionRunning: false,\n });\n }\n return newMap;\n });\n\n // Legacy: Update global state if this is the primary device\n if (deviceId === connectedDeviceId) {\n setIsInfusionRunning(false);\n }\n\n console.log('✅ Infusion stopped successfully for device:', deviceId);\n } catch (error) {\n console.error('Failed to stop infusion:', error);\n throw error;\n }\n };\n\n const setInfusionLevel = async (deviceId: string, level: number) => {\n try {\n await bleMiddleware.setInfusionLevel(deviceId, level);\n\n // Update device-specific state\n setConnectedDevices((prev) => {\n const newMap = new Map(prev);\n const deviceState = newMap.get(deviceId);\n if (deviceState) {\n newMap.set(deviceId, {\n ...deviceState,\n infusionLevel: level,\n });\n }\n return newMap;\n });\n\n console.log(\n `✅ Infusion level set to ${level} successfully for device:`,\n deviceId\n );\n } catch (error) {\n console.error('Failed to set infusion level:', error);\n throw error;\n }\n };\n\n const readCharacteristic = async (\n deviceId: string,\n serviceUuid: string,\n characteristicUuid: string\n ) => {\n try {\n return await bleMiddleware.readCharacteristic(\n deviceId,\n serviceUuid,\n characteristicUuid\n );\n } catch (error) {\n console.error('Failed to read characteristic:', error);\n throw error;\n }\n };\n\n const writeCharacteristic = async (\n deviceId: string,\n serviceUuid: string,\n characteristicUuid: string,\n data: string,\n options?: { withResponse?: boolean }\n ) => {\n try {\n await bleMiddleware.writeCharacteristic(\n deviceId,\n serviceUuid,\n characteristicUuid,\n data,\n options\n );\n } catch (error) {\n console.error('Failed to write characteristic:', error);\n throw error;\n }\n };\n\n const setUserRole = (role: UserRole) => {\n bleMiddleware.setUserRole(role);\n };\n\n const getUserRole = (): UserRole => {\n return bleMiddleware.getUserRole();\n };\n\n const value: BLEContextState = {\n bluetoothEnabled,\n isScanning,\n discoveredDevices,\n connectedDevices,\n connectedDeviceId,\n isInfusionRunning,\n ff01Notification,\n ff21Notification,\n ff31Notification,\n ff41Notification,\n ff02Notification,\n startScan,\n stopScan,\n connectToDevice,\n disconnectDevice,\n requestPermissions,\n getDeviceState,\n isDeviceConnected,\n getConnectedDeviceIds,\n startInfusion,\n stopInfusion,\n setInfusionLevel,\n readCharacteristic,\n writeCharacteristic,\n setUserRole,\n getUserRole,\n };\n\n return <BLEContext.Provider value={value}>{children}</BLEContext.Provider>;\n};\n\n/**\n * Hook to access BLE context\n */\nexport const useBLEContext = (): BLEContextState => {\n const context = useContext(BLEContext);\n if (!context) {\n throw new Error('useBLEContext must be used within a BLEProvider');\n }\n return context;\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,aAAa,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,SAAS,QAAQ,OAAO;AAO7E,OAAOC,aAAa,MAAM,2BAA2B;;AAErD;AACA;AACA;;AAq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BAAqB;IACrBC,aAAa;IACbC,YAAY;IACZC,gBAAgB;IAChBE,kBAAkB;IAClBE,mBAAmB;IACnBG,WAAW;IACXE;EACF,CAAC;EAED,oBAAOrG,KAAA,CAAAuG,aAAA,CAACjG,UAAU,CAACkG,QAAQ;IAACF,KAAK,EAAEA;EAAM,GAAE7F,QAA8B,CAAC;AAC5E,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMgG,aAAa,GAAGA,CAAA,KAAuB;EAClD,MAAMC,OAAO,GAAGxG,UAAU,CAACI,UAAU,CAAC;EACtC,IAAI,CAACoG,OAAO,EAAE;IACZ,MAAM,IAAIC,KAAK,CAAC,iDAAiD,CAAC;EACpE;EACA,OAAOD,OAAO;AAChB,CAAC","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export * from './useBLE';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from './useBLE';\n"],"mappings":"AAAA,cAAc,UAAU","ignoreList":[]}
@@ -0,0 +1,167 @@
1
+ import { useBLEContext } from '../context/BLEContext';
2
+
3
+ /**
4
+ * Hook to access BLE functionality
5
+ * Provides easy access to BLE operations and state
6
+ */
7
+ export const useBLE = () => {
8
+ const context = useBLEContext();
9
+ return {
10
+ // State
11
+ bluetoothEnabled: context.bluetoothEnabled,
12
+ isScanning: context.isScanning,
13
+ discoveredDevices: context.discoveredDevices,
14
+ // Multi-device support
15
+ connectedDevices: context.connectedDevices,
16
+ getDeviceState: context.getDeviceState,
17
+ isDeviceConnected: context.isDeviceConnected,
18
+ getConnectedDeviceIds: context.getConnectedDeviceIds,
19
+ // Legacy single device support (for backward compatibility)
20
+ connectedDeviceId: context.connectedDeviceId,
21
+ isInfusionRunning: context.isInfusionRunning,
22
+ // Actions
23
+ startScan: context.startScan,
24
+ stopScan: context.stopScan,
25
+ connectToDevice: context.connectToDevice,
26
+ disconnectDevice: context.disconnectDevice,
27
+ requestPermissions: context.requestPermissions,
28
+ // Infusion control
29
+ startInfusion: context.startInfusion,
30
+ stopInfusion: context.stopInfusion,
31
+ setInfusionLevel: context.setInfusionLevel,
32
+ // Characteristic operations
33
+ readCharacteristic: context.readCharacteristic,
34
+ writeCharacteristic: context.writeCharacteristic,
35
+ // User role management
36
+ setUserRole: context.setUserRole,
37
+ getUserRole: context.getUserRole
38
+ };
39
+ };
40
+
41
+ /**
42
+ * Hook to access characteristic notifications
43
+ */
44
+ export const useBLENotifications = () => {
45
+ const context = useBLEContext();
46
+ return {
47
+ ff21Notification: context.ff21Notification,
48
+ ff31Notification: context.ff31Notification,
49
+ ff41Notification: context.ff41Notification,
50
+ ff02Notification: context.ff02Notification
51
+ };
52
+ };
53
+
54
+ /**
55
+ * Hook to get connection status
56
+ */
57
+ export const useBLEConnection = () => {
58
+ const context = useBLEContext();
59
+ return {
60
+ isConnected: context.connectedDeviceId !== null,
61
+ connectedDeviceId: context.connectedDeviceId,
62
+ disconnect: context.disconnectDevice
63
+ };
64
+ };
65
+
66
+ /**
67
+ * Hook to access discovered devices
68
+ */
69
+ export const useBLEDevices = () => {
70
+ const context = useBLEContext();
71
+ return {
72
+ devices: context.discoveredDevices,
73
+ isScanning: context.isScanning,
74
+ startScan: context.startScan,
75
+ stopScan: context.stopScan
76
+ };
77
+ };
78
+
79
+ /**
80
+ * Hook for infusion control
81
+ */
82
+ export const useBLEInfusion = () => {
83
+ const context = useBLEContext();
84
+ return {
85
+ isInfusionRunning: context.isInfusionRunning,
86
+ startInfusion: context.startInfusion,
87
+ stopInfusion: context.stopInfusion,
88
+ setInfusionLevel: context.setInfusionLevel,
89
+ connectedDeviceId: context.connectedDeviceId
90
+ };
91
+ };
92
+
93
+ /**
94
+ * Hook for characteristic operations
95
+ */
96
+ export const useBLECharacteristics = () => {
97
+ const context = useBLEContext();
98
+ return {
99
+ readCharacteristic: context.readCharacteristic,
100
+ writeCharacteristic: context.writeCharacteristic,
101
+ connectedDeviceId: context.connectedDeviceId
102
+ };
103
+ };
104
+
105
+ /**
106
+ * Hook for multi-device management
107
+ * Provides access to all connected devices and their states
108
+ */
109
+ export const useBLEMultiDevice = () => {
110
+ const context = useBLEContext();
111
+ return {
112
+ connectedDevices: context.connectedDevices,
113
+ getDeviceState: context.getDeviceState,
114
+ isDeviceConnected: context.isDeviceConnected,
115
+ getConnectedDeviceIds: context.getConnectedDeviceIds,
116
+ connectToDevice: context.connectToDevice,
117
+ disconnectDevice: context.disconnectDevice
118
+ };
119
+ };
120
+
121
+ /**
122
+ * Hook for specific device notifications
123
+ * @param deviceId - The device ID to get notifications for
124
+ */
125
+ export const useBLEDeviceNotifications = deviceId => {
126
+ const context = useBLEContext();
127
+ if (!deviceId) {
128
+ return {
129
+ ff21Notification: null,
130
+ ff31Notification: null,
131
+ ff41Notification: null,
132
+ ff02Notification: null
133
+ };
134
+ }
135
+ const deviceState = context.getDeviceState(deviceId);
136
+ return {
137
+ ff21Notification: (deviceState === null || deviceState === void 0 ? void 0 : deviceState.notifications.ff21) || null,
138
+ ff31Notification: (deviceState === null || deviceState === void 0 ? void 0 : deviceState.notifications.ff31) || null,
139
+ ff41Notification: (deviceState === null || deviceState === void 0 ? void 0 : deviceState.notifications.ff41) || null,
140
+ ff02Notification: (deviceState === null || deviceState === void 0 ? void 0 : deviceState.notifications.ff02) || null
141
+ };
142
+ };
143
+
144
+ /**
145
+ * Hook for specific device infusion control
146
+ * @param deviceId - The device ID to control infusion for
147
+ */
148
+ export const useBLEDeviceInfusion = deviceId => {
149
+ const context = useBLEContext();
150
+ const deviceState = deviceId ? context.getDeviceState(deviceId) : undefined;
151
+ return {
152
+ deviceId,
153
+ isConnected: deviceId ? context.isDeviceConnected(deviceId) : false,
154
+ isInfusionRunning: (deviceState === null || deviceState === void 0 ? void 0 : deviceState.isInfusionRunning) || false,
155
+ infusionLevel: (deviceState === null || deviceState === void 0 ? void 0 : deviceState.infusionLevel) || null,
156
+ startInfusion: deviceId ? () => context.startInfusion(deviceId) : async () => {
157
+ throw new Error('No device selected');
158
+ },
159
+ stopInfusion: deviceId ? () => context.stopInfusion(deviceId) : async () => {
160
+ throw new Error('No device selected');
161
+ },
162
+ setInfusionLevel: deviceId ? level => context.setInfusionLevel(deviceId, level) : async () => {
163
+ throw new Error('No device selected');
164
+ }
165
+ };
166
+ };
167
+ //# sourceMappingURL=useBLE.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useBLEContext","useBLE","context","bluetoothEnabled","isScanning","discoveredDevices","connectedDevices","getDeviceState","isDeviceConnected","getConnectedDeviceIds","connectedDeviceId","isInfusionRunning","startScan","stopScan","connectToDevice","disconnectDevice","requestPermissions","startInfusion","stopInfusion","setInfusionLevel","readCharacteristic","writeCharacteristic","setUserRole","getUserRole","useBLENotifications","ff21Notification","ff31Notification","ff41Notification","ff02Notification","useBLEConnection","isConnected","disconnect","useBLEDevices","devices","useBLEInfusion","useBLECharacteristics","useBLEMultiDevice","useBLEDeviceNotifications","deviceId","deviceState","notifications","ff21","ff31","ff41","ff02","useBLEDeviceInfusion","undefined","infusionLevel","Error","level"],"sources":["useBLE.ts"],"sourcesContent":["import { useBLEContext } from '../context/BLEContext';\n\n/**\n * Hook to access BLE functionality\n * Provides easy access to BLE operations and state\n */\nexport const useBLE = () => {\n const context = useBLEContext();\n\n return {\n // State\n bluetoothEnabled: context.bluetoothEnabled,\n isScanning: context.isScanning,\n discoveredDevices: context.discoveredDevices,\n\n // Multi-device support\n connectedDevices: context.connectedDevices,\n getDeviceState: context.getDeviceState,\n isDeviceConnected: context.isDeviceConnected,\n getConnectedDeviceIds: context.getConnectedDeviceIds,\n\n // Legacy single device support (for backward compatibility)\n connectedDeviceId: context.connectedDeviceId,\n isInfusionRunning: context.isInfusionRunning,\n\n // Actions\n startScan: context.startScan,\n stopScan: context.stopScan,\n connectToDevice: context.connectToDevice,\n disconnectDevice: context.disconnectDevice,\n requestPermissions: context.requestPermissions,\n\n // Infusion control\n startInfusion: context.startInfusion,\n stopInfusion: context.stopInfusion,\n setInfusionLevel: context.setInfusionLevel,\n\n // Characteristic operations\n readCharacteristic: context.readCharacteristic,\n writeCharacteristic: context.writeCharacteristic,\n\n // User role management\n setUserRole: context.setUserRole,\n getUserRole: context.getUserRole,\n };\n};\n\n/**\n * Hook to access characteristic notifications\n */\nexport const useBLENotifications = () => {\n const context = useBLEContext();\n\n return {\n ff21Notification: context.ff21Notification,\n ff31Notification: context.ff31Notification,\n ff41Notification: context.ff41Notification,\n ff02Notification: context.ff02Notification,\n };\n};\n\n/**\n * Hook to get connection status\n */\nexport const useBLEConnection = () => {\n const context = useBLEContext();\n\n return {\n isConnected: context.connectedDeviceId !== null,\n connectedDeviceId: context.connectedDeviceId,\n disconnect: context.disconnectDevice,\n };\n};\n\n/**\n * Hook to access discovered devices\n */\nexport const useBLEDevices = () => {\n const context = useBLEContext();\n\n return {\n devices: context.discoveredDevices,\n isScanning: context.isScanning,\n startScan: context.startScan,\n stopScan: context.stopScan,\n };\n};\n\n/**\n * Hook for infusion control\n */\nexport const useBLEInfusion = () => {\n const context = useBLEContext();\n\n return {\n isInfusionRunning: context.isInfusionRunning,\n startInfusion: context.startInfusion,\n stopInfusion: context.stopInfusion,\n setInfusionLevel: context.setInfusionLevel,\n connectedDeviceId: context.connectedDeviceId,\n };\n};\n\n/**\n * Hook for characteristic operations\n */\nexport const useBLECharacteristics = () => {\n const context = useBLEContext();\n\n return {\n readCharacteristic: context.readCharacteristic,\n writeCharacteristic: context.writeCharacteristic,\n connectedDeviceId: context.connectedDeviceId,\n };\n};\n\n/**\n * Hook for multi-device management\n * Provides access to all connected devices and their states\n */\nexport const useBLEMultiDevice = () => {\n const context = useBLEContext();\n\n return {\n connectedDevices: context.connectedDevices,\n getDeviceState: context.getDeviceState,\n isDeviceConnected: context.isDeviceConnected,\n getConnectedDeviceIds: context.getConnectedDeviceIds,\n connectToDevice: context.connectToDevice,\n disconnectDevice: context.disconnectDevice,\n };\n};\n\n/**\n * Hook for specific device notifications\n * @param deviceId - The device ID to get notifications for\n */\nexport const useBLEDeviceNotifications = (deviceId: string | null) => {\n const context = useBLEContext();\n\n if (!deviceId) {\n return {\n ff21Notification: null,\n ff31Notification: null,\n ff41Notification: null,\n ff02Notification: null,\n };\n }\n\n const deviceState = context.getDeviceState(deviceId);\n\n return {\n ff21Notification: deviceState?.notifications.ff21 || null,\n ff31Notification: deviceState?.notifications.ff31 || null,\n ff41Notification: deviceState?.notifications.ff41 || null,\n ff02Notification: deviceState?.notifications.ff02 || null,\n };\n};\n\n/**\n * Hook for specific device infusion control\n * @param deviceId - The device ID to control infusion for\n */\nexport const useBLEDeviceInfusion = (deviceId: string | null) => {\n const context = useBLEContext();\n\n const deviceState = deviceId ? context.getDeviceState(deviceId) : undefined;\n\n return {\n deviceId,\n isConnected: deviceId ? context.isDeviceConnected(deviceId) : false,\n isInfusionRunning: deviceState?.isInfusionRunning || false,\n infusionLevel: deviceState?.infusionLevel || null,\n startInfusion: deviceId\n ? () => context.startInfusion(deviceId)\n : async () => {\n throw new Error('No device selected');\n },\n stopInfusion: deviceId\n ? () => context.stopInfusion(deviceId)\n : async () => {\n throw new Error('No device selected');\n },\n setInfusionLevel: deviceId\n ? (level: number) => context.setInfusionLevel(deviceId, level)\n : async () => {\n throw new Error('No device selected');\n },\n };\n};\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,uBAAuB;;AAErD;AACA;AACA;AACA;AACA,OAAO,MAAMC,MAAM,GAAGA,CAAA,KAAM;EAC1B,MAAMC,OAAO,GAAGF,aAAa,CAAC,CAAC;EAE/B,OAAO;IACL;IACAG,gBAAgB,EAAED,OAAO,CAACC,gBAAgB;IAC1CC,UAAU,EAAEF,OAAO,CAACE,UAAU;IAC9BC,iBAAiB,EAAEH,OAAO,CAACG,iBAAiB;IAE5C;IACAC,gBAAgB,EAAEJ,OAAO,CAACI,gBAAgB;IAC1CC,cAAc,EAAEL,OAAO,CAACK,cAAc;IACtCC,iBAAiB,EAAEN,OAAO,CAACM,iBAAiB;IAC5CC,qBAAqB,EA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AiB,EAAE,CAAA4B,WAAW,aAAXA,WAAW,uBAAXA,WAAW,CAAE5B,iBAAiB,KAAI,KAAK;IAC1DoC,aAAa,EAAE,CAAAR,WAAW,aAAXA,WAAW,uBAAXA,WAAW,CAAEQ,aAAa,KAAI,IAAI;IACjD9B,aAAa,EAAEqB,QAAQ,GACnB,MAAMpC,OAAO,CAACe,aAAa,CAACqB,QAAQ,CAAC,GACrC,YAAY;MACV,MAAM,IAAIU,KAAK,CAAC,oBAAoB,CAAC;IACvC,CAAC;IACL9B,YAAY,EAAEoB,QAAQ,GAClB,MAAMpC,OAAO,CAACgB,YAAY,CAACoB,QAAQ,CAAC,GACpC,YAAY;MACV,MAAM,IAAIU,KAAK,CAAC,oBAAoB,CAAC;IACvC,CAAC;IACL7B,gBAAgB,EAAEmB,QAAQ,GACrBW,KAAa,IAAK/C,OAAO,CAACiB,gBAAgB,CAACmB,QAAQ,EAAEW,KAAK,CAAC,GAC5D,YAAY;MACV,MAAM,IAAID,KAAK,CAAC,oBAAoB,CAAC;IACvC;EACN,CAAC;AACH,CAAC","ignoreList":[]}
@@ -0,0 +1,12 @@
1
+ // Export types
2
+ export * from './types';
3
+
4
+ // Export BLE Middleware service
5
+ export { default as bleMiddleware } from './services/BLEMiddleware';
6
+
7
+ // Export Context and Provider
8
+ export { BLEProvider, useBLEContext } from './context/BLEContext';
9
+
10
+ // Export hooks
11
+ export { useBLE, useBLENotifications, useBLEConnection, useBLEDevices, useBLEInfusion, useBLECharacteristics, useBLEMultiDevice, useBLEDeviceNotifications, useBLEDeviceInfusion } from './hooks/useBLE';
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["default","bleMiddleware","BLEProvider","useBLEContext","useBLE","useBLENotifications","useBLEConnection","useBLEDevices","useBLEInfusion","useBLECharacteristics","useBLEMultiDevice","useBLEDeviceNotifications","useBLEDeviceInfusion"],"sources":["index.tsx"],"sourcesContent":["// Export types\nexport * from './types';\n\n// Export BLE Middleware service\nexport { default as bleMiddleware } from './services/BLEMiddleware';\n\n// Export Context and Provider\nexport { BLEProvider, useBLEContext } from './context/BLEContext';\n\n// Export hooks\nexport {\n useBLE,\n useBLENotifications,\n useBLEConnection,\n useBLEDevices,\n useBLEInfusion,\n useBLECharacteristics,\n useBLEMultiDevice,\n useBLEDeviceNotifications,\n useBLEDeviceInfusion,\n} from './hooks/useBLE';\n"],"mappings":"AAAA;AACA,cAAc,SAAS;;AAEvB;AACA,SAASA,OAAO,IAAIC,aAAa,QAAQ,0BAA0B;;AAEnE;AACA,SAASC,WAAW,EAAEC,aAAa,QAAQ,sBAAsB;;AAEjE;AACA,SACEC,MAAM,EACNC,mBAAmB,EACnBC,gBAAgB,EAChBC,aAAa,EACbC,cAAc,EACdC,qBAAqB,EACrBC,iBAAiB,EACjBC,yBAAyB,EACzBC,oBAAoB,QACf,gBAAgB","ignoreList":[]}