Filter results by

Simband Talks to SAMI

A plethora of wearable wellness devices are and will be hitting the market in the coming days, and we all know it’s just the beginning. In this article, we’ll talk about how one such wearable device—Simband—enables continues monitoring and remote access to users’ data.

The continuous monitoring of vital signs will open up a new horizon for researchers and scientists. Theories and hypotheses of the medical, wellness and fitness worlds will be tried and tested with a large, diverse population, enabling insights and revolutionary findings that are hard to imagine.

Such vital-sign monitoring will also trigger and benefit behavior change, preventative health care and countless other possibilities. For example, Heart Rate Variability (HRV) is helpful in a variety of applications, such as monitoring meditation and stress, and has many clinical applications.

The building block to achieve groundbreaking insights is continuous monitoring of vital signs with subsecond accuracy, which I think will be a key differentiator and contributor. This means tons of data generation in real time. Storing the data on local storage and offloading to cloud then becomes one of the most fundamental building blocks of the future. SAMI is the service of choice to offload data, generated by one such continuous monitoring device—Simband.

Simband

Simband is an example and concept of what a digital-health continuous monitoring device should be. It is an open developer platform for researchers, scientists and startups to accelerate innovation.

Simband has a good amount of local storage to store continuously generated data, but this won’t be sufficient when it comes to long hours/days worth of data. Storing the data in the cloud should be the optimal solution. However, storing data should not be analogous to uploading pictures to your personal cloud, opening them a few times, and keeping them around to show to your kids. This should not be the case when we are talking about vital signs. A wearable should only occupy a wrist’s real estate if it can help us learn from and improve our habits.

SAMI is not another dropbox where you file your pictures away. Rather, it’s a place to store and share your health and IoT data with third-party services that will generate insights to make you healthy, wise and preventative—because prevention is better than cure!

Simsense

Integrating SAMI with Simband came very naturally. We had complete freedom on how we structured data in Simband, because all we had to do was send data-packs and SAMI would interpret them (thanks to the Manifest—more on this later). SAMI allows historical data analysis, cross-user analysis and pattern search.

I am already getting excited with the potential, but the core question is: Can I do cross-data analysis with the multiple smart devices I own? Well, the answer is yes. SAMI is designed to accept data in any format and enables diverse devices to communicate to each other. Think wearables, home automation, IoT, anything! (As long as it can go online.) This opens up a new paradigm for developers to create services and applications that span multiple devices and contexts—something that until recently was next-to-impossible.

Some devices or applications like to talk to SAMI using REST. In Simband, we like to open a socket and push data as fast as we can. For that, we use WebSockets. By using WebSockets, you can set up a connection between the device and server to send messages in real-time.

That’s great, but how does SAMI understand the message format and interpret it the way you want it to? Using the Manifest, SAMI interprets inbound data and stores it—the way you want it to be stored, in your desired fashion and format. Once you define the Manifest for your choice of device, SAMI can make its data available to other services and devices.

The Manifest we defined for Simband determines how SAMI should interpret an incoming data-pack from Simband (think mapping and categorizing). These data-packs are referred to as messages in SAMI’s world. Once in SAMI, each data-pack in Simband can be accessed as a SAMI message via regular SAMI APIs.

Let’s see what these data-packs are, and how they look in Simband’s world!

Simband constructs a data-pack/message for each stream. Simband generates many data streams from its sensors. We want to store as much as possible in SAMI, but we also want to be mindful to store only what matters. For this reason we created a simple configuration file using JSON to define which streams should be sent to SAMI and any metadata to go with it. This is an example for one stream:

"BIOZ_I": 
  {
   "rate": 128,
   "type": "com.samsung.simband.bioImpedance",
   "index": 0,
   "category": "signal",
   "description": "Bio Impedance (I)",
   "visibility": "sami",
   "samiFieldID": "bioImpedanceI" 
  }

BIOZ_I is a stream name in Simband, which is sampled at a rate of 128Hz with a unique URI type to be identified in Simband. This stream has a category of ‘signal’ (which means continuous) and has a real name or description ‘Bio Impedance (I)’. Since this stream has visibility ‘sami’, we can locate this stream in SAMI with its unique SAMI name (samiFieldID) ‘bioImpedanceI’. Quite informative, isn’t it?! (Note: Only a stream with "visibility": "sami" in Simband JSON configuration file will be sent to SAMI.)

A simple way to look at this is: “data-pack” = “sensor data (numbers)” + “metadata”.

Most of the data-pack is in binary format, and to ensure the integrity of data during transmission, Simband encodes the data-pack to Base64. SAMI decodes the data-pack (decodeBase64()is defined in the Simband Manifest as part of the interpreter) and constructs the message structure as defined in the Simband Manifest. Let’s look at few snippets from the Simband Manifest on how it handles decoding messages:

This is a simplified function only for demonstration purposes, which is called to decode each Base64 message:

static def getFloatArray(def samples) {
        def bytes = EncodingGroovyMethods.decodeBase64(samples)
        FloatBuffer pcm = ByteBuffer.wrap(bytes).order(ByteOrder.LITTLE_ENDIAN)
        .asFloatBuffer();
        def pcmArray = [];
        while (pcm.hasRemaining()) {
            pcmArray.add(pcm.get())
        }
        return pcmArray
    }

Below is a Manifest Framework with an overview of how the Simband Manifest maps FieldDescriptor(for purposes of understanding only):

@Override
  List<Field> normalize(String input) {
    def slurper = new JsonSlurper()
    def json = slurper.parseText(input)

    // now we return the Field to the system
    return [
      new Field(STATUS, (String)json.status)
    ]
  }

  @Override
    List<FieldDescriptor> getFields() {
        return [PAYLOAD_OBJECT, STREAM_OBJECT, SAMPLE_RATE,
        KNOWN_BIOZ_I,
    }
}

Let’s see how this stream looks after decoded and structured by the Simband Manifest:

{
"payload":{
  "field":"bioImpedanceI",
  "samples":"mwJ/RQuTf0X0k35Fdr9+RRFJf==",
  "stream":"3b865aa54642c330cbdd3170",
  "type":"com.samsung.simband.bioImpedance",
  "index":0},
  "bioImpedanceI":[
    4080.1628,4089.1902,4073.247,4075.9663,4084.5667,4078.542,4084.9988,],
  "sampleRate":128.0
}

SAMI decodes the message and categorizes the information as defined by the Manifest. The payload contains field(samiFieldID), samples(payload Base64-encoded), stream(hash of stream definition), type(unique URI) and index. Apart from the original payload, the structure contains decoded data and sampleRate for that signal.

Since Simband sends data in real-time using WebSockets, we get the ability to visualize the data in real-time. Let’s do that!

ECGStreaming

On top of this, SAMI marks each message with time of arrival (cts) and also stores time of generation (ts) of each message from the source, which is very helpful to time co-relate the messages.

This was the small story behind how a continuous monitoring device like Simband has implemented a WebSocket connection to store data in SAMI. It might look overwhelming, but it’s actually quite simple!

The future of wearables is not wearables—it’s analyzing the data. Generating insights, triggering behavior change and making life better, little by little!

BTW, this is what it looks like on Simband!

ECGStreaming

Get the ARTIK Newsletter

You like your news fresh! Sign up now and you will be the first to know about our latest software releases, coding tips, upcoming events, new blog posts and more!

By providing your contact information, you agree to our Privacy Policy and Terms of Use, confirm you are an adult 18 years or older, and authorize Samsung™ ARTIK to contact you by email with information about Samsung™ ARTIK products, events, and updates for Samsung IoT Solutions. You may unsubscribe at any time by clicking the link provided in our communications.