Design a BLE Command Handler
WhoopiOS Engineer · Technical ScreenLast updated
This question evaluates a candidate's understanding of BLE communication, concurrency control, command queuing and sequencing, timeout and failure policies, lifecycle and cancellation handling, and testability for production-grade mobile applications.
Design a Bluetooth Low Energy (BLE) command handler for an iOS application.
The app needs to send commands to a wearable device over BLE. Commands must be processed strictly one at a time:
- A command may not be sent until all earlier commands have completed.
- After sending a command, the handler must wait for either:
- the expected response from the device, or
- a timeout.
- If a command times out, the handler should unblock the queue and continue handling subsequent commands according to a clearly defined failure policy.
- Multiple parts of the app may enqueue commands concurrently.
- The design should be suitable for production use in a mobile app, including lifecycle, cancellation, error handling, and testability considerations.
Explain the architecture, key data structures, concurrency model, timeout handling, response matching, and how you would validate the design.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.