# Case study: owning a production Android BLE stack · Alex Mitrovic
URL: https://alexmitrovic.com/work/ble-stack-ownership
Last updated: 2026-11-30

> How I took over the Android BLE layer of a connected-device product, made connections more stable and extracted the core into an SDK.

Connected device · Android

# Owning a production BLE stack

A connected-device product needed one person to own its Android BLE layer: device state, error recovery and every flow where a dropped connection meant a failed user action.

- **Client:** Connected-device company (NDA)

- **Role:** Senior Android engineer, BLE stack owner

- **Platform:** Android, Kotlin, Coroutines, Flow

- **Team:** Android, iOS, backend, embedded

[Image: A phone and a row of identical small Bluetooth sensors on a desk]**One app****Many devices**

In short

## What did I do?

I became the primary owner of the Android BLE layer of a connected-device product. I documented the architecture, rebuilt state handling and error recovery with Kotlin Flow, improved field diagnostics and extracted the core into a dedicated Android SDK.

KotlinCoroutinesFlowBluetoothGattAndroid SDKBLE

## Problem

The BLE code had grown with the product. State handling and error processing were spread across the app, which made connection problems hard to diagnose and risky to change. New developers needed a long time to understand it.

Add the concrete symptom, e.g. "users saw the device go offline after X minutes" or "support tickets about failed pairing".

## Approach

- Mapped and documented the existing architecture, so the team could onboard and change it safely.
- Refactored the Kotlin/Flow-based state handling and error processing, with clear connection states and recovery paths.
- Improved diagnostics, so field failures came with logs that explained them.
- Extracted the core functionality into a dedicated Android SDK, which reduced coupling and improved build performance.
- Worked through mobile-to-device integration issues together with the iOS, backend and embedded teams.

Under the hood

## What it took

The core change was making connection state *explicit*: one state per device, exposed as a `StateFlow`, with every transition and its cause in one place instead of flags spread across screens. Errors became values with a recovery path, not exceptions caught somewhere in the UI.

Once the BLE core had one clear interface, moving it into its own Android SDK module followed naturally: the app depends on the SDK's API, and the BLE internals can change without touching screens. It's the pattern described in [the GATT operation queue](https://alexmitrovic.com/blog/ble-gatt-operation-queue) and [connection drops](https://alexmitrovic.com/blog/ble-connection-drops-android).

## Result

Add numbers you can share, e.g. "connection success rate 78% → 99%", "BLE-related crash reports down X%", "reconnect time from X s to Y s".

A BLE layer with one owner, clear states and documentation the rest of the team can work from.

## What I'd do the same way again

Document before you refactor. The architecture map made every later change safer, and it's what let new developers work on the BLE code at all.

## Related

[**App in production****Device under test****Root cause, not patches** Service### BLE app rescueYour Bluetooth app drops connections, stalls updates or gets bad reviews. I stabilize the BLE layer, add diagnostics and hand it back documented.](https://alexmitrovic.com/services/ble-app-rescue)

[**Pixel****Second test phone****Peripheral** Expertise### Android BLE developerFreelance Android BLE developer: 8+ years of Android, primary owner of a production BLE stack. BluetoothGatt, scanning, bonding, OTA, tested on real phones.](https://alexmitrovic.com/android-ble-developer)

[**Build machine****Timer****Shorter coffee** Case study### Android build time: 3 min → 1 minAs Mobile Team Lead I cut a large Android codebase's build time from about 3 minutes to about 1, and built the team's knowledge base, AI skills and MCP servers.](https://alexmitrovic.com/work/faster-android-builds)

## Similar problem on your device?

Tell me what's breaking. No pitch deck needed.

[Book a free call](https://alexmitrovic.com/contact)

Free · NDA on request · reply within 1–2 working days
