StealthTech Docs
Index

libstealthtech Architecture

Crate Dependency Graph

stealthtech (CLI) ──► libstealthtech-core ──► btleplug (platform BLE)
                           ├── ble::{Scanner, Connection, GATT}
                           └── device::StealthTechDevice
                                    │
                      libstealthtech-protocol  (shared, no native deps)
                           ├── characteristics (UUIDs, constants)
                           ├── commands (encode/decode)
                           └── state (DeviceState tracking)
                                    │
              ┌─────────────────────┼─────────────────────┐
              ▼                     ▼                     ▼
    libstealthtech-core   libstealthtech-wasm   libstealthtech-bridge
       (BLE transport)     (Web Bluetooth)       (Swift/Kotlin FFI)

BLE Connection State Machine

stateDiagram-v2
    [*] --> Disconnected

    Disconnected --> Connecting : connect()
    Connecting --> Connected : GATT success
    Connecting --> Disconnected : timeout / error

    Connected --> Reconnecting : read/write failure
    Connected --> Disconnected : disconnect()

    Reconnecting --> Connected : reconnect success
    Reconnecting --> Disconnected : max attempts exceeded

States

StateDescription
DisconnectedNo active BLE connection. Initial state and terminal failure state.
ConnectingBLE connection attempt in progress. Includes GATT service discovery.
ConnectedActive BLE connection with discovered GATT profile. Ready for reads/writes.
ReconnectingAutomatic reconnection after an unexpected disconnection or failed operation. Uses exponential backoff up to a configurable maximum number of attempts.

Transitions

FromToTrigger
DisconnectedConnectingconnect() called by application
ConnectingConnectedBLE connection established and GATT services discovered
ConnectingDisconnectedConnection timeout or BLE error
ConnectedReconnectingA read or write operation fails due to connection loss
ConnectedDisconnecteddisconnect() called by application
ReconnectingConnectedReconnection succeeds and GATT profile is rediscovered
ReconnectingDisconnectedMaximum reconnection attempts exceeded

GATT Discovery Flow

sequenceDiagram
    participant App
    participant Scanner
    participant Connection
    participant GATT

    App->>Scanner: scan(duration)
    Scanner-->>App: Vec<DiscoveredDevice>

    App->>Connection: connect(device)
    Connection->>Connection: BLE connect (btleplug)
    Connection-->>App: Ok(Connection)

    App->>GATT: discover_services(connection)
    GATT->>GATT: enumerate services
    GATT->>GATT: enumerate characteristics per service
    GATT->>GATT: read values for each readable characteristic
    GATT-->>App: GattProfile { services, characteristics, values }

Discovery Steps

  1. Scan -- Scanner::scan() listens for BLE advertisements matching known StealthTech device names for a configurable duration.
  2. Connect -- Connection::connect() establishes a BLE connection to a discovered peripheral and performs initial GATT service discovery.
  3. Discover Services -- GATT::discover_services() walks the full GATT attribute table: services, included services, characteristics, and descriptors.
  4. Enumerate Characteristics -- For each service, all characteristics are recorded with their UUID, properties (Read/Write/Notify/etc.), and handle.
  5. Read Values -- Every characteristic with the Read property is read and its current value is captured as raw bytes.
  6. Return Profile -- The complete GattProfile struct is returned, containing all services, characteristics, and their current values.

Protocol Layer -- Characteristic Map

All characteristics have been fully mapped. They share a base UUID encoding "excelpoint.com" in ASCII (65786365-6c70-6f69-6e74-2e636f6d), with the last 2 bytes varying per characteristic. See rust/protocol/src/characteristics.rs.

SuffixConstantNamePurpose
0001CHAR_UPSTREAMUpStreamNotify -- device → host status updates
0002CHAR_DEVICE_INFODeviceInfoWrite -- request state dump / firmware version
0003CHAR_EQ_CONTROLEqControlWrite -- volume, bass, treble, center, rear, mute, quiet, preset
0004CHAR_AUDIO_PATHAudioPathWrite -- balance, power
0005CHAR_PLAYER_CONTROLPlayerControlWrite -- BT media play/pause/skip
0006CHAR_SYSTEM_LAYOUTSystemLayoutWrite -- configuration shape
0007CHAR_SOURCESourceWrite -- input source selection
0008CHAR_COVERINGCoveringWrite -- fabric type for acoustic tuning
0009CHAR_USER_SETTINGUserSettingWrite -- user preferences
000aCHAR_OTAOTAWrite -- over-the-air firmware update

Services

ServiceConstantUUID
StealthTechSERVICE_STEALTHTECH65786365-6c70-6f69-6e74-2e636f6d0000
Generic AccessSERVICE_GENERIC_ACCESS0x1800
Generic AttributeSERVICE_GENERIC_ATTRIBUTE0x1801
Device InformationSERVICE_DEVICE_INFORMATION0x180A

See protocol-mapping.html for the complete protocol specification and reverse-engineering.html for the RE methodology guide.