0

I try to convert my UInt8 array to an explicit value but I try in several ways but I can't get values that I can understand. How have i to do to get explicit values?.

My array of UInt8 :

[216, 61, 233, 124, 240, 144, 66, 244]

My code :

guard let characteristicData = characteristic.value else { return "Error" }
    let count = (characteristicData.count) / MemoryLayout<UInt8>.size
    var array = [UInt8](repeating: 0, count: count)
    characteristicData.copyBytes(to: &array, count:count * MemoryLayout<UInt8>.size)

    let characters = array.map { Character(UnicodeScalar($0)) }
    let result = String(Array(characters))
    print(array)
    print(result.utf8)

My output:

Ø=é|ðBô
tibdev78
  • 109
  • 1
  • 2
  • 8
  • What's the type of `characteristicData`? And what's the expected output? – Alexander Dec 12 '19 at 21:43
  • Characteristic from BLE device may vary depending on the device. What's the UUID of the characteristic? – OOPer Dec 12 '19 at 22:21
  • @Alexander-ReinstateMonica it's an array of Data type and i would like to read my values not about what my characters send me. – tibdev78 Dec 13 '19 at 13:01
  • @OOPer it's the UUID of my tile tracker, i'll post that tonight, i don't know by memory – tibdev78 Dec 13 '19 at 13:03
  • @OOPer the UUID is 9D410007-35D6-F4DD-BA60-E7BD8DC491C0 to read device – tibdev78 Dec 16 '19 at 00:00
  • Unfortunately, the UUID seems to be private (vendor specific) and I cannot find the data format of it on the web. If you cannot get data sheet of the device from the vendor, it is very hard to detect the actual data from the 8-byte. It may contain 4 16-bit integers, or 2 32-bit floats, or... Can you get some technical support from the vendor? – OOPer Dec 17 '19 at 11:23
  • Unfortunately no, cause tile tracker is a commercial product, and i think that your're right, it's a private UUID. I'm not going to ask them, can you send me your code for decode tile datas? xD. Else no vendor on that... – tibdev78 Dec 18 '19 at 22:32

0 Answers0