Testing a mobile app with Bluetooth features is all about making sure that the app can connect to Bluetooth devices and that all Bluetooth-related features within the app work as expected.
In this article, I use a mobile app as an example that our team is working on. This app connects to a Bluetooth device using the Bluetooth Low Energy (BLE) protocol. It also supports simultaneous connections to multiple devices. Additionally, it includes a feature called ‘pairing’ (not to be confused with Classic Bluetooth pairing), so ‘pairing’ will be considered as part of app app-designed flow below. As a result of this, the app saves device IDs, allowing future access to them without scanning.
Before you start testing Bluetooth in your app, you need to understand the Bluetooth device you’ll be using, understand its functionalities, the data it collects and stores, and how the firmware works under different conditions. It would be helpful to get the details of the communication protocol from the firmware developer.
Here is some basic information about the most common Bluetooth modes available:
- Classic Bluetooth – Classic Bluetooth is primarily designed to transmit larger amounts of data at higher speeds over short distances between various devices, such as smartphones, laptops, speakers, hands-free devices, and other gadgets. It’s important to note that Classic Bluetooth consumes more power than the alternative mode of BLE.
- Bluetooth Low Energy (BLE) – Bluetooth Low Energy (also known as Bluetooth Smart or Bluetooth Light) is a type of Bluetooth that doesn’t use much power. It’s great for small, low-energy devices like fitness trackers and smartwatches.
‘Pairing’ and Connecting
The process of testing a mobile app with Bluetooth functionality involves confirming that the app can interact with Bluetooth devices. To establish a successful connection with a Bluetooth device, you need to confirm the required permissions based on the platform.
On Android 11 and lower, Google requires that apps using Bluetooth must request Location permission. Android 12 or higher use Nearby Devices permission group. Bluetooth permission should be accepted on iOS.
To confirm that connections work as expected when the permission is granted, you’ll want to test the following:
- Verify that the app can successfully find, ‘pair’, and establish connections with a Bluetooth device.
- Verify that the app can maintain stable connections when ‘paired’ with multiple devices.
It is possible for a user to deny the required permissions when prompted by the mobile application. In such cases, the app will not be able to perform certain actions related to Bluetooth functionality. To thoroughly test denied permissions you could try the following:
- How does the mobile app behave when the user denies permissions during the mobile app’s ‘pairing’ process with a Bluetooth device?
- After ‘pairing’, remove the permission in Settings and check if a connection can still be established.
- Enabling Location Services may be required for successful Bluetooth scanning on Android devices. Test the app’s behavior during and after the ‘pairing’ process when Location Services are turned off.
Transferring and Storing Data
BLE works like this: A device has services, and each service has characteristics. Each characteristic can have one or several types (read, write, notify). Any client, in our case a mobile app, can get a list of services and characteristics, and then:
- Send data to a write characteristic when needed.
- Read data from a read characteristic when needed.
- Subscribe to a notify characteristic and automatically receive new data when available.
The rest is the specifics of how the device and the app work, which can be organized in any way that suits your needs. You’ll want to test the app’s ability to send and receive data over Bluetooth connections, including the following:
- Is the data collected in real-time?
- If the Bluetooth device records and stores data, try collecting a large amount of data and then synchronizing it with the application during the next connection. Pay attention to how the data is displayed in the application.
Bluetooth Connection Range
You will need to test the way the app behaves at different distances between the mobile app and Bluetooth devices. Observe how the app handles connections when devices move in and out of range.
Reconnection and Interruptions
Test the app’s ability to automatically reconnect to Bluetooth devices after temporary disconnections. Verify that the app handles interruptions without crashing or losing data. The disconnection can be caused by one of the parties, or if the signal is lost:
- Different distances between the Bluetooth devices (move in and out of range)
- Use a Faraday bag to isolate your device
- Power Bluetooth device on/off
- Turn on/off Bluetooth on your mobile device
- Close/Reopen the app
- Sign out and then sign back into the app
- Restart the phone and then launch the app from the recently running apps
Background and Foreground Behavior
When the app is running in the foreground, it can actively communicate with Bluetooth devices and continuously receive real-time data from them without limitations. This data can then be instantly displayed to the user according to the app’s purpose.
Once an app is put into the background, its behavior might change depending on the platform. Most platforms restrict background processes to avoid power consumption and potential performance issues. Verify if the app can maintain Bluetooth connections and receive data while operating in the background.
Here are several verification options for online mode:
- Check the database to confirm if the background data was successfully sent to the server.
- Use another phone with the same account to run the app and receive updates.
- Use an HTTP debugging proxy server application to verify if the app sends the requests (e.g. Charles).
Updating the Firmware of the Bluetooth Device
Below, you’ll find testing notes to verify the firmware update functionality:
- Updating the device via the app should be possible when the devices are successfully connected to each other.
- Ensure that the app can retrieve data from the Bluetooth device about the current firmware version. You can also verify the version using other applications, such as nRF Connect and LightBlue. Please refer to the image below.
- How the mobile app interacts with the backend to display firmware update availability:
- The current device version is either lower or the same as the version available on the server.
- Additionally, it’s possible that your test device has a higher version than what’s on the server. For instance, this can occur if you’re using the app for Bluetooth Low Energy connectivity testing to update the firmware.
- How long does the download take, and how much time is required to complete the update?
- The device connection should automatically re-establish once the firmware update is completed (Users should observe a transition from ‘Device Connection Lost’ to ‘Device Connected.’ )
- How does the mobile app behave If the firmware downloading is interrupted (e.g., due to an interrupted internet connection or closing the app)?
- How does the mobile app behave If the firmware update process is interrupted (e.g., moving your device out of the Bluetooth range, turning off Bluetooth, or closing the app)?
Make sure to test how the app works without the internet. This is an important part of the testing if the app supports it.
A Tip From Experience
If you expected to see the green icon indicating a connection, but instead you see the red icon, try using BLE apps to check if your test device is visible there. If it is, there’s a good chance that there’s a bug in the app. Try to recall the steps you took and check the app’s logs for errors, if they are built into the app.
Bluetooth is complicated, and there are a lot of things that can prevent it from working as expected. That is why testing a Bluetooth app is so crucial to make sure it works in all of the various situations that will come up in the real world. Doing so carefully and thoroughly helps ensure the app functions smoothly for all of your users.