Multi Device Automation for Bluetooth operations using Micro Controllers
Premise: This is a multi device scenario where a Device A [SMP or TV] is paired to a Device B [Remote/Game controller] over a BT/BLE connection.
Objective: We need to automate button press on the Remote and test the interactions between the two devices.
Device Interactions: Interactions could be like validating if the remote key event is intercepted by the app on the Device A. Validating if the Remote was able to pair over BT to the Device A. Did the device start the discovery to connect to the Remote. Testing the Device B firmware update.
Approach: I have seen two approaches for this automation framework. One would be to physically press the remote button using some smart mechanical button pusher. Other would be to rework the remote by exposing the button pins, connecting it to the micro controller and sending serial commands over the serial port. If this sounds super vague or confusing, we will be elaborating this further so hold on to your queries as we dive deep ahead. The approach one may seem straight forward to understand but it will face serious limitations like coordinating latency of hand movement, wear and tear, programming the blueprint of the buttons, changing UI on the remote, etc. This approach is somewhat suitable for a device having couple of buttons or if reworking the device is not at all an option. So, further we will be discussing about the second approach which has a significant advantage over the first approach.
TV: This is Device A and it could be a Streaming media device , TV, etc
Remote: This is Device B which connects to the Device A over BT/BLE connection
Arduino Board: Micro-controller used to send signals to the Remote.
Host Machine: Executes the automation script to interact with Arduino and Device A over USB/TCP connection.
Reworking the remote: Based on the blueprint of the remote, we would need exposed pins to connect to the Arduino board. This is not a trivial step, here we would need to purchase the Arduino parts, program the script to define the serial commands for each pin on the board and then connect the remote to the board using jumper cables. Since we are connecting the Devices under test over BT it would be important to put both device A and B in a RF chamber, a.k.a. BT shield boxes/rooms. Details about how to achieve this is beyond the scope of this document and would need a separate discussion.
End to End workflow: The automation framework can be designed to use the above hardware setup to execute the commands for Device A and the Arduino over serial port. A basic workflow would be to pair the remote to the Device. The script can be written to follow the following steps:
1. Connect to the Device A over usb using lets say adb [for android devices]
2. Connect to the Arduino board over USB serial port like /dev/ttyACM0
3. Wait for the Device to bootup
4. Make sure the Device started Bluetooth discovery
5. Send the serial command to the Arduino to start Remote discovery
6. Check the adb logs for BT component to ensure Bonding completes successfully