Skip to content

Develop - Optimization#134

Merged
sameerasw merged 3 commits into
mainfrom
develop
Jul 24, 2026
Merged

Develop - Optimization#134
sameerasw merged 3 commits into
mainfrom
develop

Conversation

@sameerasw

Copy link
Copy Markdown
Owner

This pull request introduces several improvements and refactorings to BLE and network connection management, device name handling, and service lifecycle in the AirSync app. The main focus is on streamlining BLE sync settings observation, reducing blocking calls, enhancing device name matching logic, and clarifying the separation between BLE and Wi-Fi connections. It also updates how device discovery and notification updates are handled to be more efficient and responsive.

BLE and DataStore Management:

  • Refactored BleGattServer to observe BLE sync enabled state via a coroutine and a cached variable (isBleSyncEnabled), replacing repeated blocking reads from DataStoreManager. This improves responsiveness and efficiency when checking BLE sync status. [1] [2] [3]
  • Added a static getContext() method to AirSyncApp for easier access to the application context when needed.

Device Name Handling and Matching:

  • Updated BleTransportBridge.sendDeviceName() to use a persisted device name from DataStoreManager if available, falling back to a utility method, and made the context parameter optional.
  • Improved device name matching in WakeupHandler by normalizing names (trimming, lowercasing, and replacing special characters) for more reliable connection and key retrieval.

Service and Notification Lifecycle:

  • Modified AirSyncService to cache the last connected device and observe changes via a coroutine, reducing redundant blocking calls and ensuring notifications stay updated in real time. [1] [2] [3]
  • Refactored device discovery and wakeup logic in AirSyncService to use coroutines for non-blocking initialization and state changes. [1] [2]

Wi-Fi and BLE Connection Handling:

  • Clarified logic to ensure Wi-Fi WebSocket disconnects do not affect BLE connections, and improved detection of Wi-Fi connection status before disconnecting or reconnecting. [1] [2] [3]
  • Updated auto-reconnect and disconnect logic in WebSocketUtil to better distinguish between Wi-Fi and BLE, avoid unnecessary reconnects when authenticated via BLE, and use coroutines for state updates. [1] [2] [3] [4] [5] [6]

Other Improvements:

  • Enhanced device matching logic in WakeupHandler to handle edge cases and fallback scenarios more gracefully, including single-device environments.
  • Minor adjustments to ensure discovery broadcasts and auto-reconnects are only triggered when appropriate, considering both BLE and Wi-Fi states.

These changes collectively improve the app’s efficiency, reliability, and maintainability, especially around BLE and Wi-Fi connection management.

@sameerasw sameerasw self-assigned this Jul 24, 2026
@sameerasw sameerasw added the enhancement New feature or request label Jul 24, 2026
@sameerasw
sameerasw merged commit b85f22c into main Jul 24, 2026
1 check passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in AirSync Features and Bugs Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant