I am trying read the array data sent by Peripheral and parse it into Swift array form.
Peripheral Device is sending data for Example: Array[1 To 15] Numbers.(For full scale purpose this integer values range between 1000 to 2000). but for now i am trying to make it work with 1 to 15 Integer values. I was able to get the result in string format in encoded format. My Question is how can i get array 1 to 15 from Characteristic.value from didUpdateValueFor Method in swift.
Here is the code snippet for reference.
func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) {
if characteristic == rxCharacteristic {
count += 1
let data = characteristic.value
print("Count: \(count), data: \(data! as NSData)")
}
}
In X-Code console Printed result is:
Count: 2, data: <00000100 02>
Count: 3, data: <00030004 00050006 00070008 0009000a 000b000c>
Count: 4, data: <000d00>
Count: 5, data: <0e000f00>