Organizing GATT Data Exchange with BLE Peripherals
Imagine you're developing an app to interact with a medical heart rate sensor via BLE. After connecting, you try to subscribe to heart rate notifications, but data doesn't arrive. On Android, you see status 133 error; on iOS, writing the characteristic returns an error. We've encountered this in over 20 BLE integration projects: medical sensors, fitness trackers, industrial controllers. One common task is subscribing to heart rate notifications or transferring large data volumes, like a 100 KB firmware. With the default MTU of 23 bytes, sending 100 KB takes about 5000 packets, which takes minutes. Requesting a larger MTU of 512 bytes reduces packets to ~200 and transfer time to seconds. We've developed a systematic approach to reliable BLE data exchange: from proper notification subscription to operation queues and MTU negotiation.
GATT Characteristic Operation Types
Each GATT characteristic has a set of properties flags that determine possible operations. Here's a quick reference table:
| Flag | iOS (CBCharacteristicProperties) | Android | Operation |
|---|---|---|---|
| Read | .read |
PROPERTY_READ |
One-time read |
| Write | .write |
PROPERTY_WRITE |
Write with acknowledgment |
| Write Without Response | .writeWithoutResponse |
PROPERTY_WRITE_NO_RESPONSE |
Fast write |
| Notify | .notify |
PROPERTY_NOTIFY |
Notifications without acknowledgment |
| Indicate | .indicate |
PROPERTY_INDICATE |
Notifications with acknowledgment |
Write Without Response is faster — no ACK from the device. Suitable for streaming (audio, sensor readings). Write is for commands where delivery guarantee is important.
MTU: How to Increase BLE Channel Throughput
By default, BLE MTU (Maximum Transmission Unit) is 23 bytes, with only 20 bytes of payload. To transfer 10 KB of data, that means 500 packets. If you request a larger MTU (e.g., 512), the number of packets drops to ~20 — saving up to 90% time. Here's how to do it on each platform:
| Platform | Default MTU | Automatic Negotiation | Manual Request |
|---|---|---|---|
| iOS | 23 | Yes (since iOS 9+) | Indirectly via maximum write length |
| Android | 23 | No | gatt.requestMtu(512) + callback onMtuChanged |
In practice, most BLE chips support MTU 247–512 bytes. This is critical for firmware or large configuration transfers.
How to Subscribe to BLE Notifications and Not Miss Data?
Notification subscription is the standard way to receive real-time data from a BLE device. On iOS, just call setNotifyValue(true, for:). But on Android, the process is more complex: you need not only to enable notifications locally, but also explicitly write the value ENABLE_NOTIFICATION_VALUE to the CCCD (Client Characteristic Configuration Descriptor) descriptor. Many developers skip this step — and notifications don't arrive.
iOS: Notify Subscription and Parsing
// Enable notify peripheral.setNotifyValue(true, for: characteristic) // Receive data func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) { guard error == nil, let data = characteristic.value else { return } // Example: sensor sends 3 bytes [flags, heartRate, energyExpended] guard data.count >= 2 else { return } let flags = data[0] let heartRate: Int if flags & 0x01 == 0 { // heart rate in 1 byte heartRate = Int(data[1]) } else { // heart rate in 2 bytes (little-endian) heartRate = Int(data[1]) | (Int(data[2]) << 8) } } Working with binary data via Data + byte offsets. If the device is non-standard and documentation is scarce, Wireshark + BLE sniffer help decode the protocol.
Android: Notify + CCCD Descriptor
Notifying requires two steps: enable notify locally and write the CCCD on the device:
fun enableNotification(gatt: BluetoothGatt, characteristic: BluetoothGattCharacteristic) { // Step 1: enable locally gatt.setCharacteristicNotification(characteristic, true) // Step 2: write descriptor to device val cccd = characteristic.getDescriptor( UUID.fromString("00002902-0000-1000-8000-00805f9b34fb") ) ?: return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { gatt.writeDescriptor(cccd, BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE) } else { @Suppress("DEPRECATION") cccd.value = BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE @Suppress("DEPRECATION") gatt.writeDescriptor(cccd) } } Step 2 is often missed — and notifications don't arrive. This is the most common mistake when working with notify.
Why Does Android Show status 133 Error and How to Avoid It?
One critical detail of Android BLE: you cannot perform multiple GATT operations simultaneously. Only one operation in flight. Send the next only after receiving the callback for the previous one. Violating this rule leads to status 133 error or data loss on most Android devices.
Solution — a queue:
class BleOperationQueue { private val queue: LinkedList<BleOperation> = LinkedList() private var operationInProgress = false fun enqueue(operation: BleOperation) { queue.add(operation) if (!operationInProgress) { executeNext() } } fun onOperationCompleted() { operationInProgress = false executeNext() } private fun executeNext() { val op = queue.poll() ?: return operationInProgress = true op.execute() } } BLE Exchange Implementation Process
We break down implementing reliable BLE exchange into stages:
- Analysis of the device protocol or GATT service specification.
- Design of the operation queue and data parsing scheme.
- Implementation on target platforms (iOS/Android) with MTU, connection, reconnection handling.
- Testing on real devices with various OS versions.
- Integration into the client's application and documentation delivery.
What's Included in the Work
As part of the service, we provide:
- Analysis and documentation of the current BLE device protocol.
- Source code for the data exchange module in Swift/Kotlin with operation queue and MTU support.
- Integration testing on 3+ real devices.
- Brief API documentation for the module.
- One month of consultation after delivery.
We guarantee stable notification subscription, correct command writing, and error handling on both platforms. Contact us for a preliminary assessment of your project. Get a consultation from our engineers if you're looking for a ready-made BLE integration solution or encountering data exchange errors.
Timeline and Pricing
Implementation timeline — from 3 to 10 days depending on binary protocol complexity and number of platforms. Pricing is calculated individually after requirement analysis.







