0

I wanted to know if somebody would help me with a technical challange: reading the Freestyle Libre sensor data in Swift. The glucose sensor for diabetic patients uses ISO 15693 protocol for communicating with other devices by vicinity.

For now, I have already established connection with the sensor using the NFC core NFCTagReaderSession class. Also, I have pulled data successfully using ReadSingleBlock function. The device sends back 8 bytes in a Data object and is not UTF8 encoded... so I am having problems to decode those response bytes.

I've seen some people decoding sensor data in C (arduino language) and Java, but conversion to Swift seems not to be straightforward.

I would really appreciate if someone could help me :)

For now, the reading function looks like this:

            case .iso15693(let tag):
            // Read one block of data
            tag.readSingleBlock(requestFlags: .highDataRate, blockNumber: 0, resultHandler: { result in
                switch result {
                case .success(let str):
                    print(str)
                case .failure(let error):
                    print(error)
                }
                })

And response from sensor looks like this:

Response from sensor (reading single block)

Cristik
  • 30,989
  • 25
  • 91
  • 127
  • "I've seen some people decoding sensor data in C (arduino language) and Java, but conversion to Swift seems not to be straightforward." Giving the examples or documentation on how to parse that data would help a lot I think... Also, instead of having the print `8 bytes`, you have a `Data` object, so do `print(thatData.map { String(format: "%02hhx", $0) }.joined())` – Larme Oct 04 '21 at 12:33
  • @Larme Thank you very much for your answer! https://github.com/JoernL/LimiTTer/blob/master/LimiTTer.ino - this is the repo wiht arduino reading code. This is some Java implementation: https://github.com/vicktor/FreeStyleLibre-NFC-Reader/blob/master/app/FreeStyleLibre/app/src/main/java/com/socialdiabetes/freestylelibre/Abbott.java – Solano Todeschini Oct 04 '21 at 12:43
  • Is the data even an encoded string? You mention it's *not* UTF8, but you don't say what it *is*. Also, you can't really expect to show us some Java/Arduino code and expect us to figure out your problem, you're expected to do a thorough attempt at implementing a solution yourself before making a question. – EmilioPelaez Oct 04 '21 at 13:42
  • 2
    Do you have a specification of the data format? Both linked code examples are of poor quality and it's not obvious how to reverse engineering what you are looking for. – Codo Oct 04 '21 at 13:53

0 Answers0