Project completed

Xamarin BLE device companion

A cross-platform C# application that discovers, pairs with and controls a Bluetooth Low Energy hardware device, including full GATT service discovery and real-time notifications.

Overview

A companion application for a custom BLE hardware device, built in C# with Xamarin so a single codebase could reach Android and iOS. The app had to do what BLE apps actually do: find the device, connect reliably, enumerate what it offers, and keep a live channel open.

How it works

After scanning, the app connects and walks the device’s GATT tree to discover services and characteristics. Reads and writes are mapped onto the device’s protocol, and subscriptions to characteristic notifications push incoming measurements into the UI in real time. Connection state is explicit, so the interface reflects reconnects and dropped links instead of freezing on stale data.

The hard parts

  • Discovery is not deterministic. Service and characteristic order varies between platforms and firmware revisions, so the app resolves capabilities by UUID and tolerates missing optional characteristics.
  • Notifications arrive on a background thread. Marshalling them safely to the UI, without losing bursts of data, was most of the work.
  • BLE is lossy. Writes can fail mid-transfer; retries had to be idempotent and the protocol tolerant of a partially delivered command.

What I took away

BLE is an excellent teacher of state-machine thinking. The lessons from this project, such as explicit connection state, capability-based feature detection and idempotent writes, reappeared later in Wi-Fi and BLE provisioning for IoT products, where the same failure modes exist with even less control over the other end.