I am trying to send data to a ble, but my device only accepts byte arrays. How do I convert data to byte array and send it in Swift 3?
print("hex value is",hexRepresentation)
print("pairing code",pairingcode)
var aaa = calcchecksum(data:"4A6BF961585C3F86DCEB562CEC51A4CE")
if let auxData = (hexRepresentation+"4A6BF961585C3F86DCEB562CEC51A4CE"+aaa).data(using: .utf8), let lChar = self.mainCharacteristic {
let bytearraydata = [UInt8](auxData) as Data?
aPeripheral.writeValue(bytearraydata, for: lChar, type: .withResponse
}