TEJVONTechnologies Pvt. Ltd.
Case study

Connected Products and IoT · 2 min read

A production BLE stack for a connected device

A Bluetooth Low Energy stack built for production: an explicit connection state machine, a serialised command queue, fragmentation for large payloads, integrity checks and secure pairing.

Client
Connected hardware company
Industry
Connected hardware
Capabilities
Connected Products and IoT, Mobile Apps
Status
Delivered

Highlights

  • Connection failure rate reduced in production
  • Race-condition GATT failures eliminated by serialising every operation
  • Features send and receive whole messages; the protocol stays in one layer

The challenge

Device onboarding kept failing and BLE connections dropped in the field. Every failure became a support ticket, and users who could not connect did not come back. The app also had to exchange payloads of around 10 KB over a link that carries about 20 bytes per write by default.

Our solution

  1. 01Modelled the connection as an explicit state machine with 12 distinct states, so every event has a defined transition and every failure recovers to a known state.
  2. 02Sent every GATT operation through one command queue with timeouts, removing the overlapping operations that Android silently drops.
  3. 03Added a fragmentation and reassembly protocol sized to the negotiated MTU, with checksums so a missing or reordered chunk can never pass as valid data.
  4. 04Protected pairing against man-in-the-middle attacks, so commands and data cannot be intercepted or injected.
  5. 05Implemented both the central (Android app) and peripheral roles in Kotlin, so the whole handshake could be tested without waiting for hardware.

What we delivered

  • Lifecycle-aware BLE session management with adaptive retry and MTU negotiation
  • Priority command queue with a timeout on every operation
  • Fragmentation and reassembly over GATT for payloads of around 10 KB
  • CRC-16 integrity checks on every message
  • Handshake state machine and anti-MITM security layer
  • Mapper layer between protocol frames and the Room database

Impact

Connection failure rate reduced in production
Race-condition GATT failures eliminated by serialising every operation
Features send and receive whole messages; the protocol stays in one layer

Technology

KotlinAndroid BLE (GATT)Coroutines and FlowMVIRoomHilt

Have a problem like this?

Start with a free 1-hour architecture review with a senior engineer.

Talk to our engineers