- Add 2-second timeout to profile fetch in getStoredUser() to ensure
app startup < 3 seconds even with slow network. Falls back to cached
user data on timeout.
- Implement early scan termination in BLEManager when devices found.
Scan now exits after 3 seconds once minimum devices are detected,
instead of always waiting full 10 seconds.
- Add PerformanceService for tracking app startup time, API response
times, and BLE operation durations with threshold checking.
- Integrate performance tracking in app/_layout.tsx to measure and
log startup duration in dev mode.
- Add comprehensive test suite for performance service and BLE
scan optimizations.
Performance targets:
- App startup: < 3 seconds
- BLE operations: < 10 seconds
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Add missing addEventListener/removeEventListener mocks in BLEContext cleanup tests
- Fix scanning simulation by calling scanDevices() instead of trying to set state directly
- Add explicit timeouts to bulkSetWiFi tests (10-15s) to accommodate MockBLEManager delays
- Update concurrent connection error message check to match actual error text
All 42 BLE tests now pass (36 bulk/concurrent + 6 cleanup)
- Add webBluetooth.ts with browser detection and compatibility checks
- Add WebBLEManager implementing IBLEManager for Web Bluetooth API
- Add BrowserNotSupported component showing clear error for Safari/Firefox
- Update services/ble/index.ts to use WebBLEManager on web platform
- Add comprehensive tests for browser detection and WebBLEManager
Works in Chrome/Edge/Opera, shows user-friendly error in unsupported browsers.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- BLEErrors.test.ts: Tests for BLEError class, parseBLEError function,
isBLEError, getErrorInfo, getRecoveryActionLabel, and BLELogger utilities
- BLEManager.bulk.test.ts: Tests for bulkDisconnect, bulkReboot, and
bulkSetWiFi operations including progress callbacks and edge cases
- BLEManager.wifi.test.ts: Tests for WiFi credential validation (SSID/password),
error scenarios, getWiFiList, getCurrentWiFi, and signal quality
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Add ReconnectConfig and ReconnectState types for configurable reconnect behavior
- Implement auto-reconnect in BLEManager with exponential backoff (default: 3 attempts, 1.5x multiplier)
- Add connection monitoring via device.onDisconnected() for unexpected disconnections
- Update BLEContext with reconnectingDevices state and reconnect actions
- Create ConnectionStatusIndicator component for visual connection feedback
- Enhance device settings screen with reconnect UI and manual reconnect capability
- Add comprehensive tests for reconnect logic and UI component
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Implemented a full sensor health monitoring system for WP sensors that
tracks connectivity, WiFi signal strength, communication quality, and
overall device health.
Features:
- Health status calculation (excellent/good/fair/poor/critical)
- WiFi signal quality monitoring (RSSI-based)
- Communication statistics tracking (success rate, response times)
- BLE connection metrics (RSSI, attempt/failure counts)
- Time-based status (online/warning/offline based on last seen)
- Health data caching and retrieval
Components:
- Added SensorHealthMetrics types with detailed health indicators
- Implemented getSensorHealth() and getAllSensorHealth() in BLEManager
- Created SensorHealthCard UI component for health visualization
- Added API endpoints for health history and reporting
- Automatic communication stats tracking on every BLE command
Testing:
- 12 new tests for health monitoring functionality
- All 89 BLE tests passing
- No linting errors
This enables proactive monitoring of sensor health to identify
connectivity issues, poor WiFi signal, or failing devices before they
impact user experience.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Prevents race conditions when multiple connection attempts are made
to the same device simultaneously by:
- Adding connectingDevices Set to track in-progress connections
- Checking for concurrent connections before starting new attempt
- Returning early if device is already connected
- Using finally block to ensure cleanup of connecting state
- Clearing connectingDevices set on cleanup
Includes comprehensive test suite for concurrent connection scenarios
including edge cases like rapid connect/disconnect cycles and cleanup
during connection attempts.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Add comprehensive connection state management to BLE Manager with:
- Connection state enum (DISCONNECTED, CONNECTING, CONNECTED, DISCOVERING, READY, DISCONNECTING, ERROR)
- State tracking for all devices with connection metadata
- Event emission system for state changes and connection events
- Event listeners for monitoring connection lifecycle
- Updated both RealBLEManager and MockBLEManager implementations
- Added test suite for state machine functionality
- Updated jest.setup.js with BLE mocks
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Implement proper cleanup of BLE scanning operations when users navigate
away from the add-sensor screen to prevent resource waste and potential
issues.
Changes:
- Add useFocusEffect hook to stop BLE scan when screen loses focus
- Remove unused imports (Device, WPDevice, connectDevice, etc.)
- Add comprehensive tests for BLE cleanup behavior
- Add tests for screen unmount/blur scenarios
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Implement comprehensive BLE cleanup functionality that properly
disconnects all devices and releases resources when user logs out.
Changes:
- Add cleanup() method to BLEManager and MockBLEManager
- Update IBLEManager interface to include cleanup
- Add cleanupBLE() to BLEContext to disconnect all devices
- Implement callback mechanism in api.ts for BLE cleanup on logout
- Wire up BLE cleanup in app layout to trigger on logout
- Add unit tests for BLE cleanup functionality
This ensures no BLE connections remain active after logout,
preventing resource leaks and potential connection issues.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>