One feature, two transports: BLE and WiFi behind a single interface
An equipment verification feature had to work over BLE or over the network, depending on the device. The feature code should not care which.
Surendra — Tejvon
Senior Android & BLE Engineer
On one project, an equipment verification feature needed to reach the device in two ways. Some setups talk to it directly over BLE. Others reach it over WiFi through an API. The user sees one feature and expects it to work either way.
The tempting approach is to check the connection type inside the feature and branch. That works for the first screen and becomes unmanageable by the third, because every new behaviour has to be written and tested twice in the same place.
We put the branch in the repository layer instead. The feature asks the repository to verify a piece of equipment. The repository decides which path to use and returns the same result type from both. The screens and view models have no idea which transport answered.
Behind that boundary, the BLE path has its own manager that deals with connection state and the serial protocol, and the network path has its own client. Each can be tested on its own.
The benefit showed up later, as it usually does. When the behaviour of one path changed, the change stayed inside that path. The feature code did not move.
Topics
Working on a similar challenge?
Let's discuss the architecture before you build.
BLE system design, OTA reliability, and connected product engineering — this is what TEJVON does every day.
Book a Technical Consultation