Medical Peripheral CoreBluetooth Connectivity and Telemetry Framework
Architect a fault-tolerant CoreBluetooth integration framework for continuous medical device telemetry on iOS.
Use this template when building iOS companion applications for wearable medical devices, monitors, or biosensors. It defines connection lifecycle states, background telemetry handling, and automatic recovery protocols.
Role: Senior iOS Embedded Systems Engineer specializing in CoreBluetooth medical device integration.
Context
- Medical Hardware Category: {{medical_device_type}}
- Primary GATT Service UUID: {{ble_service_uuid}}
- Background Execution Strategy: {{background_mode_requirement}}
- Target Data Throughput: {{data_throughput_target}}
- Reconnection SLA: {{reconnection_sla}}
- Power Consumption Profile: {{battery_profile}}
Task
Produce an operational CoreBluetooth state management framework that ensures continuous, lossless data transfer from {{medical_device_type}} to an iOS client under {{background_mode_requirement}} constraints.
Method
- Specify the CBCentralManager initialization sequence with explicit state-preservation keys for app suspension.
- Map GATT service discovery routines targeting {{ble_service_uuid}} to minimize peripheral connection latency.
- Define MTU negotiation and packet fragmentation rules tailored to {{data_throughput_target}}.
- Design a peripheral reconnection state machine capable of meeting the {{reconnection_sla}} target.
- Structure characteristic notification subscription and backpressure handling to preserve {{battery_profile}}.
- Formulate background wake-up data parsing and buffer management routines without dropping sensor packets.
- Detail CoreBluetooth error handling strategies for RSSI drop, hardware resets, and unexpected disconnections.
Constraints
- MUST implement CBCentralManagerOptionRestoreIdentifierKey for state restoration across process termination.
- MUST NOT execute continuous peripheral scanning without service UUID filters.
- MUST rate-limit peripheral writes to prevent UI thread blocking and BLE queue overflow.
- Keep all architectural recommendations compliant with Apple Bluetooth Accessory Design Guidelines.
Output format
Deliver the connectivity framework organized as follows:
- State Machine Architecture (Listing states: Disconnected, Scanning, Connecting, Discovered, Streaming, Reconnecting)
- Telemetry Ingestion Contract (Packet structure, MTU sizing, and buffer limits)
- Power & Background Lifecycle Map (Handling app active, background, suspended, and killed states)
- Bluetooth Error Resolution Guide (Specific actions for CBError codes)
Self-review
- Ensure the reconnection state machine explicitly addresses the {{reconnection_sla}} constraint.
- Verify background preservation keys are properly integrated in the architecture steps.
- Confirm the throughput calculations respect {{data_throughput_target}} limitations.
Explicit role, a named task, and discrete steps the model can follow.
Background, inputs and variables the model needs before it starts.
Hard boundaries — what the model must and must not do.
A named, field-level shape for the response.
Ordered work items that force analysis before an answer.
Length and structure that travel across frontier models.
Signal density — instruction weight without padding.
Documented variables so the scaffold adapts to new inputs.
Quality bar, assumptions and behaviour when inputs are thin.
How much real usage the template has behind it.