How To Auto Sync Data Between iOS Apps & Personal Healthcare Devices

What is a Personal Healthcare Device?

Personal healthcare devices are fantastic tools that enable us to monitor our vital health signs and track our progress and improvements. These devices can offer insights into many bodily functions, including heart health and blood glucose levels, without requiring medical procedures. By simply syncing one or more personal health monitoring devices with a smartphone app, you can easily access and analyze your health data.

What is Auto-Sync?

Auto-sync refers to the ongoing process of synchronizing data between two or more devices and updating changes automatically between them to maintain consistency. When it comes to health monitor devices, the term ‘auto-sync’ refers to syncing healthcare-specific vital data from a healthcare device to an iOS/Android App. Usually, healthcare devices provide wireless connectivity so that the data can be synced to a nearby smartphone wirelessly.

Benefits of Auto Sync Feature

Real-time tracking of health vital data
The automatic syncing of health data allows users to easily track their progress over time. By syncing their data to their smartphone, users can view their health metrics in an easy-to-read format and track their progress over days, weeks, and months. The auto-sync happens behind the scenes, and it helps in making the data available in real-time to any cloud user.

Sync across phones
AutoSync enables us to keep information automatically synchronized across phones/tablets so that we can continue working and playing from any device we pick up.

Auto-Sync Approaches

AutoSync implementation approaches vary between the connectivity options provided by the health monitor devices. Below are the most common connectivity options provided by today’s health monitoring devices like BP, glucose, or weight-scale devices:

1. Bluetooth connectivity (BLE or iBeacon)
2. Wi-Fi connectivity
3. 3g/4g/5g enabled devices

The AutoSync implementation with BLE/iBeacon-enabled devices is going to be discussed here, which dominates the overall market of health monitoring devices.

AutoSync via Bluetooth Connectivity

Most of today’s healthcare devices are capable of pairing & transferring data wirelessly with a smartphone. BLE (Bluetooth Low Energy) or iBeacon (Apple’s proprietary network which uses BLE) based health monitor devices are commonly available.

BLE is a wireless technology that operates in the 2.4 GHz ISM band and is designed to connect devices within a short range while consuming minimal power. In contrast, an iBeacon is simply a BLE device that broadcasts information in a specific format. The iBeacon technology was developed by Apple, and iOS can detect iBeacons that transmit three distinct values: UUID, major, and minor.

To synchronize data between an iOS app and a BLE/iBeacon-based health monitoring device, the following steps are typically taken:

1. Pair the iOS app with the BLE/iBeacon device.
2. Search for the device’s presence to initiate the synchronization process.
3. Establish a connection with the device.
4. Initiate the data transfer.
5. Retrieve the most recent data, if any.
6. Save the data to the local database along with a timestamp.
7. Close the connection.
8. Repeat steps 2 through 7 at specified intervals to maintain synchronization.

BLE Connection Procedure in iOS Swift

Core Bluetooth is an iOS framework developed by Apple that enables the creation of Bluetooth Low Energy applications for communicating with hardware devices. Core Bluetooth has several features.

1. Setting up an iOS device as BLE central or peripheral.
2. Handling low-level connection parameters.
3. Transferring data between BLE devices.
4. Error handling.

BLE Connection Process
The Core Bluetooth framework includes the necessary classes for an app to establish communication with mobile devices that use low-energy wireless technology. Here is the Bluetooth connection establishment process, where the information exchange between iOS App (Central) and a BLE peripheral is depicted.

The steps for establishing a BLE connection in Swift are explained below.

Scanning for a BLE peripheral & establishing a connection

Assuming the CBManager state is powered on, we can instruct the central to search for peripheral devices using the following steps:

central.scanForPeripherals(withServices: nil, options: nil)

The effect of this statement is that for each peripheral that the iPhone finds, there the CCentralManagerDelegate method centralManager(_:didDiscover:advertisementData:rssi:) gets called.

According to Apple’s documentation on Core Bluetooth, this method notifies the delegate when the central manager discovers a peripheral device during a scan. For each peripheral discovered, it provides information about the advertisement data in the form of a key-value pair dictionary and the RSSI.

When scanning for a peripheral, we need to stop scanning as soon as we locate the desired device and establish a connection with it. Additionally, we must keep a reference to this peripheral so that we can perform read/write operations. While it may be tempting to use the device name to identify the peripheral, this approach is not always the most reliable. Instead, it’s recommended to examine other information, such as the manufacturer ID, advertisement data, and service UUIDs, to ensure that we have the correct peripheral. The above example uses the peripheral name to identify a peripheral. Once the connection is established, we will be able to read/write actions using the self.myPeripheral object reference. Auto-sync implementation should be implemented in such a way that the read operation will get invoked on a specific interval to read the data from the BLE device.

Bluetooth Connectivity Challenges in iOS

When using BLE functionality in an iOS app, the most typical Bluetooth connectivity issues include the following:

1. BLE pairing/connectivity failures
2. BLE data transfer failure
3. Partner BLE device discovery failures
4. BLE access permissions

While developing iOS Apps for BLE/iBeacon, there can be some challenges in defining use cases depending on whether the app is in the foreground or background.  When an iOS app is in the background, it may exhibit different behavior than when it is in the foreground due to the limited availability of system resources.

Typically, when an app is in the background or suspended state, many of the common Bluetooth tasks are disabled by default. However, by declaring support for Bluetooth background execution modes, the app can be woken up from a suspended state to handle certain Bluetooth-related events. However, it’s important to note that the system may eventually terminate the app to free up memory for the current foreground app, which can cause any active or pending BLE connections to be lost. iOS Core Bluetooth stack provides options to save state information for the peripheral connections and restore the state when the app is re-launched.

Conclusion

Bluetooth Low Energy is the most popular technology that provides low power, and low latency connectivity, which makes it suitable for providing connectivity solutions in personal health monitoring devices. One of the main benefits of BLE is that it’s supported by virtually all modern smartphones, allowing users to directly interface with BLE-enabled devices using their phones. When it comes to troubleshooting, there are some Bluetooth technological mishaps in some of the iOS beta versions, so it is always suggested to pay attention while dealing with iOS version updates.

Sujith Joseph

<span class="TextRun SCXW243498844 BCX0" lang="EN-IN" xml:lang="EN-IN" data-contrast="auto"><span class="NormalTextRun SCXW243498844 BCX0" data-ccp-charstyle="ui-provider" data-ccp-charstyle-defn="{">Technology Architect having 15 years of experience in the field of design and development of mobile & web applications</span><span class="NormalTextRun SCXW243498844 BCX0" data-ccp-charstyle="ui-provider">,</span> <span class="NormalTextRun SCXW243498844 BCX0" data-ccp-charstyle="ui-provider">working majorly in the h</span><span class="NormalTextRun SCXW243498844 BCX0" data-ccp-charstyle="ui-provider">ealthcare</span><span class="NormalTextRun SCXW243498844 BCX0" data-ccp-charstyle="ui-provider"> domain. </span></span><span class="EOP SCXW243498844 BCX0" data-ccp-props="{"> </span>

Leave a comment

Your email address will not be published. Required fields are marked *

Share Post