Waveform Measurements

Waveform attributes allow the device to send several measurement values in a single MQTT message.
This is useful when the device measurement frequency is high or when the amount of data sent in a single measurement is big and might be costly.

A good example for waveform usage might be a device that sends ECG data every 40ms.
In this case, the device needs to send a single decimal biomarker 25 times a second.

The attribute is a JSON object and includes:

  • Total number of measurements.
  • Frequency of measurements in a single second.
  • Array of numbers (measurements as integers or decimals).

The following example shows how to send an ECG waveform attribute.
The example represents sending a single HR measurement and 100 values of ECG measurement taken in a 2-second time period

{
  "metadata": {
    "timestamp":1641985478161, // MANDATORY
     "context":"VVVJRHMgb2YgcGFpZW5kSWQgYW5kIHNlc3Npb25JZA=="
  },
  "data":{
     "hr": 5, // just an example
     "ecg": {
        "metadata": {
              "frequency": 50,
              "size": 100
        },
        "data":  <base64> //  (300 measurements max)
     }
  }
}

The following table only references the attributes related to the waveform

Attribute JSON Name

Description

Format

metadata

General metadata about the attribute.

timestamp

Event time, in milliseconds, in UTC.
Mandatory.
Note: in relation to waveform the timestamp represents the timestamp of the last measurement in the waveform. The rest of the measurements times are calculated backwards using the frequency.

Epoch time in milliseconds.
Example: 1641985478161

data

The waveform attribute data encoded in base64.

base64 encoded value array.
The maximum number of measurements per data attribute is 300.

data.metadata.frequency

The number of data points per second.

Integer

data.metadata.size

The total number of data points.

Integer

To create the waveform data, convert each value in the array to 4 bytes, then convert the whole array to base64 and add it to the JSON message.
The bytes values should be concatenated without any characters or separation bytes between them.
BioT will deserialize the base64 data and then divide it in to 4 byte chunks before decoding its numerical values.
You can use this tool for testing.
For example, if you want to send the array of values:
10,20,30,40
The binary representation of it will be (Note that new lines are only for comfort and should not be part of the data):

00000000000000000000000000001010
00000000000000000000000000010100
00000000000000000000000000011110
00000000000000000000000000101000

And the base64 representation will be:

AAAACgAAABQAAAAeAAAAKA==

Did this page help you?