Data Types and Events

When working with Aidlab, Aidmed One and the Aidlab SDK, you will encounter various data types and events. This section will provide an overview of these and describe their role in using the SDK.

Data Types

Once a stable connection has been established, you can ask the device to transmit the data to your application at a rate that depends on the specific data type you've selected:

Python
Android
Apple Platforms
Flutter
Unity
async def did_connect(self, device):
    await device.collect([
        DataType.RESPIRATION_RATE,
        DataType.SKIN_TEMPERATURE])
override fun didConnect(device: Device) {
    device.collect(EnumSet.of(
            DataType.RESPIRATION_RATE,
            DataType.SKIN_TEMPERATURE,
    ), EnumSet.noneOf(DataType::class.java))
}
func didConnect(_ device: Device) {
    device.collect(dataTypes: [DataType.respirationRate, DataType.skinTemperature], dataTypesToStore: [])
}
@override
void didConnect(Device device) {
    device.collect([DataType.RESPIRATION_RATE, DataType.SKIN_TEMPERATURE], []);
}

The collect method, accepts a list of data types as its first parameter. These data types represent different categories of data that you might want to retrieve, such as Respiration Rate, Skin Temperature, and more.

Following is a detailed list of the data types that you can request from an Aidlab or Aidmed One:

Data type Description Minimum Firmware Version
ECG (Electrocardiogram) Each sample represents a specific moment in the heart's electrical activity and is measured in volts. 1.0.0+
Respiration Offers comprehensive data sufficient to create a graphical representation of the individual's breathing pattern in Ohms. 1.0.0+
Skin Temperature This data type retrieves the skin temperature in degrees Celsius. For Aidlab, an infrared skin temperature sensor is utilized, which provides an accurate reading within 20 seconds. As for Aidmed One, it employs a touch-based skin temperature sensor that stabilizes and gives accurate readings within 5 to 15 minutes, depending on the room temperature. Don't confuse skin temperature with body temperature. 1.0.0+
Activity You can request updates when the current type of activity changes. Aidlab can detect still, walking, running, automotive, and cycling. 2.1.0+
Steps Represents the count of steps detected since the previous update. 2.1.0+
RR These are intervals between consecutive heartbeats, derived from the ECG signal. Each RR value represents the time difference (in milliseconds) between successive heartbeats. 2.1.0+
Respiration Rate This measures the number of breaths taken per minute. 2.1.0+
Body Position Enumerates the possible positions of a body when lying on a bed with a device: prone, supine, left side, right side, unknown. 2.2.0+
Heart Rate This data type provides the total count of user's heartbeats, measured over a span of 1 minute. 2.2.0+
Sound Volume Readings from the microphone, with a maximum possible value of 65536 (very loud) and a minimum value of 0 (vacuum). Please note that due to Aidlab's limited computing power, simultaneous data acquisition from the microphone and the Motion sensor is not possible. Therefore, if you subscribe to both Sound Volume and Motion data types, only one type of data will be returned. 2.2.5+
Orientation Within this data type, two events are available with the following sets of values: RPY angles (roll, pitch, yaw) and the quaternions (qw, qx, qy, qz) of the user's orientation. Together with the Motion data type, it also enables the bodyweight workout classifier that can detect burpees, jumps, push-ups, and sit-ups. 2.2.6+
Motion Provides readings from the 9-axis motion sensor unit. This data type includes three subevents: acceleration (ax, ay, az), angular velocity (gx, gy, gz), and magnetic induction (mx, my, mz). Combined with the Orientation, it also powers a bodyweight workout classifier capable of identifying various exercises such as burpees, jumps, push-ups, and sit-ups. 2.2.6+
Pressure This data type represents readings from a nasal cannula, indicating the airflow through the nose. This unique measurement is exclusively available in the Aidmed One. It provides valuable data, especially in the field of sleep studies and various medical applications, including the monitoring of respiratory patterns and the detection of apnea events. 3.0.0+

Events

Each time a new data sample is ready, the Aidlab SDK will invoke the corresponding event handler in your application. You can learn more about the sample rates for each data type at Aidlab's support page.

The following table lists few of the most common events that you can expect to receive:

Python
Android
Apple Platforms
Flutter
Unity
async def did_connect(self, device)

def did_disconnect(self, device)

def did_receive_battery_level(self, device, state_of_charge)

def did_receive_ecg(self, device, timestamp, value)

def did_receive_respiration(self, device, timestamp, value)

def did_receive_respiration_rate(self, device, timestamp, value)

# And so on ...
fun didConnect(device: Device)

fun didDisconnect(device: Device, disconnectReason: DisconnectReason)

fun didReceiveBatteryLevel(device: Device, stateOfCharge: Int)

fun didReceiveECG(device: Device, timestamp: Long, value: Float)

fun didReceiveRespiration(device: Device, timestamp: Long, value: Float)

fun didReceiveRespirationRate(device: Device, timestamp: Long, value: Int)

// And so on ...
func didConnect(_ device: Device)

func didDisconnect(_ device: Device, reason: DisconnectReason)

func didReceiveBatteryLevel(_ device: Device, stateOfCharge: UInt8)

func didReceiveECG(_ device: Device, timestamp: UInt64, value: Float)

func didReceiveRespiration(_ device: Device, timestamp: UInt64, value: Float)

func didReceiveRespirationRate(_ device: Device, timestamp: UInt64, value: UInt32)

// And so on ...
void didConnect(Device device)

void didDisconnect(Device device, DisconnectReason reason)

void didReceiveBatteryLevel(Device device, int stateOfCharge)

void didReceiveECG(Device device, int timestamp, double value)

void didReceiveRespiration(Device device, int timestamp, double value)

void didReceiveRespirationRate(Device device, int timestamp, int value)

// And so on ...
void didConnectAidlab(IAidlab aidlab);

void didDisconnectAidlab(IAidlab aidlab, DisconnectReason reason);

void didReceiveBatteryLevel(IAidlab aidlab, int stateOfCharge);

void didReceiveECG(IAidlab aidlab, Int64 timestamp, float[] value);

void didReceiveRespiration(IAidlab aidlab, Int64 timestamp, float[] value);

void didReceiveRespirationRate(IAidlab aidlab, Int64 timestamp, int value);

// And so on ...

Each data comes with an associated timestamp, indicating the precise moment it was recorded by the Aidlab and Aidmed One. The timestamp's initial reference point is established when the Aidlab or Aidmed One is first paired. You can also change the time on your Aidlab or Aidmed One by calling the set_time method.

All subsequent data points are timestamped relative to this initial reference point, providing a clear timeline of the data collected. Furthermore, it is guaranteed that these timestamps will be provided in ascending order, ensuring the chronological integrity of the data.

This design pattern enables you to build highly responsive applications that can react to data in real time. Be sure to implement the appropriate event handlers in your application for each type of data you wish to receive.

Device Object

Each event in the Aidlab SDK is associated with a Device object. This object provides essential details about your device and facilitates interaction with it:

Python
Android
Apple Platforms
Flutter
class Device:

    firmware_revision: str
    hardware_revision: str
    serial_number: str
    manufacturer_name: str
    address: str

    async def connect(delegate: DeviceDelegate)

    async def disconnect()

    async def collect(self, data_types: list[DataType], data_types_to_store: Optional[List[DataType]] = None)

    async def start_synchronization()

    async def stop_synchronization()

    async def set_time(timestamp: float)

    def set_ecg_filtration_method(method: str)

    async def send(self, command: str)
class Device {

    val firmwareRevision: String?
    val hardwareRevision: String?
    val serialNumber: String?
    val manufacturerName: String?
    fun address(): String
    fun name(): String?

    fun connect(delegate: DeviceDelegate)

    fun collect(dataTypes: EnumSet<DataType>,
        dataTypesToStore: EnumSet<DataType>,
    )

    fun disconnect()

    fun startSynchronization()

    fun stopSynchronization()

    fun setECGFiltrationMethod(ecgFiltrationMethod: ECGFiltrationMethod)

    fun send(message: String)
}
public Device {

    public var name: String?
    public var firmwareRevision: String?
    public var hardwareRevision: String?
    public var serialNumber: String?
    public var manufacturerName: String?
    public var address: UUID
    public var rssi: NSNumber

    public var peripheral: CBPeripheral
    
    public func readRSSI() {

        peripheral.readRSSI()
    }

    public func connect(delegate: DeviceDelegate)

    public func collect(dataTypes: [DataType], dataTypesToStore: [DataType])

    public func disconnect()

    public func readRSSI()

    public func startSynchronization()

    public func stopSynchronization()

    public func setECGFiltrationMethod(_ ecgFiltrationMethod: ECGFiltrationMethod)

    public func send(_ message: String)
}
class Device {

    String? firmwareRevision;
    String? hardwareRevision;
    String? serialNumber;
    String? manufacturerName;
    String address;

    void connect(DeviceDelegate delegate);

    void collect(List<DataType> dataTypes, List<DataType> dataTypesToStore);

    void disconnect();

    void startSynchronization();

    void stopSynchronization();

    void setECGFiltrationMethod(ECGFiltrationMethod ecgFiltrationMethod);

    void send(String message);
}

results matching ""

    No results matching ""