# XBeats: A Real-Time Electrocardiogram Monitoring and Analysis System
## 3 XBeats System Architecture
### Hardware Specifications
#### 3.1.2 Data Transmission and Protocols  
Data transmission constitutes the second step of the data pipeline in the XBeats framework as the ECG patch continuously exchanges data with the backend system. Furthermore, the patients and their healthcare providers can display related vital information about the heart from the recorded ECG signals. The data transmission hardware comprises a multi-standard wireless MCU with an RF core that fully supports Bluetooth Low Energy 5.2 (BLE). The MCU enables seamless data transmission in real-time to the backend system. The BLE 5.2 upgrades the data transfer rate two times the rate of the previous Bluetooth 4.2 from 1 Mbps to 2 Mbps. The communication between BLE-based sensors and smart devices is governed by Generic Access Profile (GAP) and Generic Attribute (GATT) protocols [32].  
GATT defines how two BLE devices exchange data, while GAP constitutes a standard way for BLE devices to communicate with the outside world. A complete GATT transaction  
Figure 2: Data Acquisition flowchart of the ECG patch operation.  
constitutes three high-level, nested objects called Profiles, Services, and Characteristics. For instance, the Heart Rate Profile (HRP) is used in devices measuring heart rate [33]. The HRP profile has two mandatory services: heart rate and device information services. Complementary services can also be added, for instance, Battery Service (BAS) to indicate the battery's current level. BLE provides a versatile set of full-stack solutions to meet the needs for low-power wireless connectivity. However, a Profile [32] must be defined to exchange data between BLE-enabled peripherals. According to Bluetooth SIG [34], a profile with its related services can be selected from the Bluetooth SIG's predefined profiles and services if they match the application's specifications or develop custom services to match the application's specifications. There is no standard BLE profile to deliver the standard 12-lead ECG services [35]. Therefore, we create a customized BLE profile to enable XBeats to provide the designed services in our platform (i.e., operation modes and ECG data streaming).  
To that extent, our proposed ECG BLE \"Profile\" describes the number of GATT \"Services\" and GATT \"Characteristics\" that should be used to achieve the addressed functionalities of the proposed ECG patch. The BLE profile describes how services deliver the application's intended functionalities [33]. Figure 3 shows the designed \"ECG Profile\" with three services that correspond to operation modes defined on the ECG patch and the edge classification service. The first service in the ECG profile is the triggered mode containing three characteristics. The first characteristic holds information about the active number of leads. In contrast, the second characteristic is a flag that refers to the status of real-time streaming, whether it's currently enabled or disabled. The second \"Service\" is for the continuous operation mode where ECG leads are fixed to the standard 12-lead configuration, and the stream flag characteristic is enabled by default. Lastly, we implement the \"ECG Classification\" service for our novel dynamic modes of operation. The \"ECG Classification\" service contains two characteristics. The first characteristic holds the current heart condition results from the classification implemented on the edge device. The other \"Characteristic\" carries the recommended ECG leads to be activated based on the results from the classification function on the edge device.  
Figure 3: The Proposed BLE Profile for the ECG patch communications and data transmission protocols.