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>
119 lines
2.7 KiB
TypeScript
119 lines
2.7 KiB
TypeScript
// Mock BLE Manager для iOS Simulator (Bluetooth недоступен)
|
|
|
|
import { IBLEManager, WPDevice, WiFiNetwork, WiFiStatus } from './types';
|
|
|
|
const delay = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));
|
|
|
|
export class MockBLEManager implements IBLEManager {
|
|
private connectedDevices = new Set<string>();
|
|
private mockDevices: WPDevice[] = [
|
|
{
|
|
id: 'mock-743',
|
|
name: 'WP_497_81a14c',
|
|
mac: '142B2F81A14C',
|
|
rssi: -55,
|
|
wellId: 497,
|
|
},
|
|
{
|
|
id: 'mock-769',
|
|
name: 'WP_523_81aad4',
|
|
mac: '142B2F81AAD4',
|
|
rssi: -67,
|
|
wellId: 523,
|
|
},
|
|
];
|
|
|
|
async scanDevices(): Promise<WPDevice[]> {
|
|
await delay(2000); // Simulate scan delay
|
|
return this.mockDevices;
|
|
}
|
|
|
|
stopScan(): void {
|
|
}
|
|
|
|
async connectDevice(deviceId: string): Promise<boolean> {
|
|
await delay(1000);
|
|
this.connectedDevices.add(deviceId);
|
|
return true;
|
|
}
|
|
|
|
async disconnectDevice(deviceId: string): Promise<void> {
|
|
await delay(500);
|
|
this.connectedDevices.delete(deviceId);
|
|
}
|
|
|
|
isDeviceConnected(deviceId: string): boolean {
|
|
return this.connectedDevices.has(deviceId);
|
|
}
|
|
|
|
async sendCommand(deviceId: string, command: string): Promise<string> {
|
|
await delay(500);
|
|
|
|
// Simulate responses
|
|
if (command === 'pin|7856') {
|
|
return 'pin|ok';
|
|
}
|
|
if (command === 'w') {
|
|
return 'mac,142b2f81a14c|w|3|FrontierTower,-55|HomeNetwork,-67|TP-Link_5G,-75';
|
|
}
|
|
if (command === 'a') {
|
|
return 'mac,142b2f81a14c|a|FrontierTower,-67';
|
|
}
|
|
if (command.startsWith('W|')) {
|
|
return 'mac,142b2f81a14c|W|ok';
|
|
}
|
|
|
|
return 'ok';
|
|
}
|
|
|
|
async getWiFiList(deviceId: string): Promise<WiFiNetwork[]> {
|
|
await delay(1500);
|
|
|
|
return [
|
|
{ ssid: 'FrontierTower', rssi: -55 },
|
|
{ ssid: 'HomeNetwork', rssi: -67 },
|
|
{ ssid: 'TP-Link_5G', rssi: -75 },
|
|
{ ssid: 'Office-WiFi', rssi: -80 },
|
|
];
|
|
}
|
|
|
|
async setWiFi(
|
|
deviceId: string,
|
|
ssid: string,
|
|
password: string
|
|
): Promise<boolean> {
|
|
await delay(2000);
|
|
return true;
|
|
}
|
|
|
|
async getCurrentWiFi(deviceId: string): Promise<WiFiStatus | null> {
|
|
await delay(1000);
|
|
|
|
return {
|
|
ssid: 'FrontierTower',
|
|
rssi: -67,
|
|
connected: true,
|
|
};
|
|
}
|
|
|
|
async rebootDevice(deviceId: string): Promise<void> {
|
|
await delay(500);
|
|
this.connectedDevices.delete(deviceId);
|
|
}
|
|
|
|
/**
|
|
* Cleanup all BLE connections and state
|
|
* Should be called on app logout to properly release resources
|
|
*/
|
|
async cleanup(): Promise<void> {
|
|
|
|
// Disconnect all connected devices
|
|
const deviceIds = Array.from(this.connectedDevices);
|
|
for (const deviceId of deviceIds) {
|
|
await this.disconnectDevice(deviceId);
|
|
}
|
|
|
|
this.connectedDevices.clear();
|
|
}
|
|
}
|