Skip to content

BLE Device Management & Connectivity Overview

Overview

This module integrates local Bluetooth Low Energy (BLE) device management with real-time connectivity indicators to support efficient control and monitoring of Smarta hardware. It combines device discovery, connection management, data synchronization, and remote provisioning to deliver a robust screen that interfaces directly with the compatible Smarta devices.

Key Functionalities

Local BLE Device Management

  • Device Discovery and Scanning:

    • The system scans for nearby BLE devices that expose specific service identifiers, ensuring that only relevant devices (e.g., base stations or sensors with the "SMARTA" prefix) are discovered.
    • Scanning is initiated automatically when no device is connected and can be manually refreshed. A dedicated timeout ensures that scanning does not continue indefinitely.

    Local device
    Local device scanning

  • Secure Device Connection:

    • When a user selects a device, the system establishes a secure connection, halting the scanning process to prioritize connection stability.
    • Post-connection, the system discovers all available services and characteristics, preparing the channel for data exchange.
    • Users can disconnect from the current device, which triggers a new scanning session to detect alternative devices.

    Local device
    Local device connected

Device Connectivity Indicator and Configuration

  • Real-Time Device Data & Status:

    • The DeviceConnectivityIndicator component continuously reads and decodes BLE device data, including:
      • Current water level, min/max thresholds, and tank status
      • Device MAC and sensor MAC addresses (with segmented input and OCR scan on iOS)
      • Firmware version, APN, IMEI, RSSI, LTE/WiFi connectivity, and push notification token
      • Sensor calibration values (raw/known/now/height)
      • Device mute, triggers, and reboot-on-connectivity-loss states
    • All values are updated every 5 seconds while connected, and the UI reflects real-time changes.
  • User-Driven Configuration and Interaction:

    • Interactive modals allow users to:
      • View and update WiFi credentials (SSID auto-filled, password entry, encrypted BLE write)
      • Edit sensor MAC address (segmented input, OCR scan, validation, BLE write)
      • Set APN for LTE (modal input, BLE write)
      • Adjust min/max tank levels (modals, BLE write)
      • Calibrate sensor (modals for raw/known/now/height, BLE write)
      • Toggle device mute, triggers, and restart device (BLE commands)
      • Provision device for remote management (API call, modal)
    • All modals provide immediate feedback and error handling, with haptic feedback for key actions.
    • Push notification token can be sent to the device for remote alerts.

    Local device
    Local device WiFi configuration
    Local device
    Local device sensor MAC address configuration
    Local device
    Text Recognition (iOS only)
    Local device
    Local device LTE information
    Local device
    Local device provisioning

  • Device Control & Actions:

    • Users can start/stop the pump, restart the device, and toggle triggers/mute directly from the UI.
    • All actions are sent as BLE commands and provide instant feedback.
  • Robust Error Handling:

    • BLE errors, connection drops, and invalid data are handled gracefully, with user alerts and automatic UI updates.
    • The UI disables controls and shows loading indicators as needed during BLE operations.

Security & Data Integrity

  • Encrypted Communication:

    • WiFi credentials are encrypted using the device MAC as a key before being sent over BLE.
    • All sensitive actions require a valid BLE connection and/or authentication token.
  • Session & State Management:

    • The component manages modal visibility, BLE connection state, and device data in a robust, reactive manner.
    • State is reset on disconnect, and all modals are closed if the device disconnects.