Removed all console.log, console.error, console.warn, console.info, and console.debug statements from the main source code to clean up production output. Changes: - Removed 400+ console statements from TypeScript/TSX files - Cleaned BLE services (BLEManager.ts, MockBLEManager.ts) - Cleaned API services, contexts, hooks, and components - Cleaned WiFi setup and sensor management screens - Preserved console statements in test files (*.test.ts, __tests__/) - TypeScript compilation verified successfully 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
43 lines
1.7 KiB
TypeScript
43 lines
1.7 KiB
TypeScript
// BLE Service entry point
|
|
|
|
import * as Device from 'expo-device';
|
|
import { IBLEManager } from './types';
|
|
|
|
// Determine if BLE is available (real device vs simulator)
|
|
export const isBLEAvailable = Device.isDevice;
|
|
|
|
// Lazy singleton - only create BLEManager when first accessed
|
|
let _bleManager: IBLEManager | null = null;
|
|
|
|
function getBLEManager(): IBLEManager {
|
|
if (!_bleManager) {
|
|
// Dynamic import to prevent crash on Android startup
|
|
if (isBLEAvailable) {
|
|
const { RealBLEManager } = require('./BLEManager');
|
|
_bleManager = new RealBLEManager();
|
|
} else {
|
|
const { MockBLEManager } = require('./MockBLEManager');
|
|
_bleManager = new MockBLEManager();
|
|
}
|
|
}
|
|
return _bleManager!; // Non-null assertion - we just assigned it above
|
|
}
|
|
|
|
// Proxy object that lazily initializes the real manager
|
|
export const bleManager: IBLEManager = {
|
|
scanDevices: () => getBLEManager().scanDevices(),
|
|
stopScan: () => getBLEManager().stopScan(),
|
|
connectDevice: (deviceId: string) => getBLEManager().connectDevice(deviceId),
|
|
disconnectDevice: (deviceId: string) => getBLEManager().disconnectDevice(deviceId),
|
|
isDeviceConnected: (deviceId: string) => getBLEManager().isDeviceConnected(deviceId),
|
|
sendCommand: (deviceId: string, command: string) => getBLEManager().sendCommand(deviceId, command),
|
|
getWiFiList: (deviceId: string) => getBLEManager().getWiFiList(deviceId),
|
|
setWiFi: (deviceId: string, ssid: string, password: string) => getBLEManager().setWiFi(deviceId, ssid, password),
|
|
getCurrentWiFi: (deviceId: string) => getBLEManager().getCurrentWiFi(deviceId),
|
|
rebootDevice: (deviceId: string) => getBLEManager().rebootDevice(deviceId),
|
|
cleanup: () => getBLEManager().cleanup(),
|
|
};
|
|
|
|
// Re-export types
|
|
export * from './types';
|