Core BLE system: - BLEManager: Real BLE device scanning and connection (iOS/Android) - MockBLEManager: Simulator-safe mock for development - BLEContext: React context for BLE state management - BLEProvider: Added to app/_layout.tsx Bluetooth permissions: - iOS: NSBluetoothAlwaysUsageDescription, NSBluetoothPeripheralUsageDescription - Android: BLUETOOTH, BLUETOOTH_ADMIN, BLUETOOTH_CONNECT, BLUETOOTH_SCAN, ACCESS_FINE_LOCATION Dependencies: - react-native-ble-plx@3.5.0 - expo-device@8.0.10 - react-native-base64@0.2.2 Simulator support: - Auto-detects iOS simulator via expo-device - Falls back to MockBLEManager with fake devices - No crashes or permission errors in development
18 lines
492 B
TypeScript
18 lines
492 B
TypeScript
// BLE Service entry point
|
|
|
|
import * as Device from 'expo-device';
|
|
import { RealBLEManager } from './BLEManager';
|
|
import { MockBLEManager } from './MockBLEManager';
|
|
import { IBLEManager } from './types';
|
|
|
|
// Determine if BLE is available (real device vs simulator)
|
|
export const isBLEAvailable = Device.isDevice;
|
|
|
|
// Export singleton instance
|
|
export const bleManager: IBLEManager = isBLEAvailable
|
|
? new RealBLEManager()
|
|
: new MockBLEManager();
|
|
|
|
// Re-export types
|
|
export * from './types';
|