flutterchartsbluetooth-lowenergydevice

Plot ecg graph in flutter


I have a medical device that works with Bluetooth BLE, allowing me to measure ECG signals and pulses in BPM. When I integrated my device via Bluetooth with my Flutter application and read the characteristic responsible for ECG measurement, here is the data I received: value: (0x): C8-44-80-8E-37-C9

Is there a method to interpret these values and draw the ECG graph from them?


Solution

  • Short version: you must know how the device encodes the data in order to correctly interpret the data you receive, assuming that's data and not some interfacing special commands. Otherwise, you can make guesses and try to convert from bytes to the data.

    Long version: that piece of data you pasted (I assume it's not the complete) looks like some byte or hex value, but without having a precise idea of what that means, you won't go anywhere. Those bytes may be the bytes of an image you need to reconstruct, or maybe of a PDF file, or numeric values of a curve, or almost anything else. They may even be some special commands the instrument uses to communicate (something like telling "the measure has started").
    I just have faced a similar problem: a medical device was sending me a string that could be long up to 70000 or more characters. I had to contact the manufacturer to have a description of their outgoing protocol, because the string itself had no meaning: I suspected it was a base64-encoded string because sometimes there were some '=' at the end, but I could not be sure. In the end, the string, after being decoded was to be interpreted as a set of bytes representing a PNG image, but I could be sure of this only by looking at the instrument documentation. Otherwise, you just have to try different interpretations and hope to get it right.
    Just to give you an idea, once I had to work on a similar instrument: that time the string was not meant as a PNG image converted to bytes, but it was a chart. Each pair of bytes represented the value of the Nth value in the X axis: I just had to build a bar chart, with the bar at the N/2 position being as high as the value of Nth pair of bytes. Another example would be an instrument that measured Covid-19 antigenes reaction over a 15-minutes time: that instrument enveloped the real data in headers, while sending other information encoded with special characters. Using your data string as example, it was sending this kind of messages:

    I hope this can give you an idea of how many possibilities you have to wrongly interpret the data you're receiving. You'd really be better of with some manufacturer's documentation.