I want to control my HM-11 BLE module from phone. My code works when I want to send string to the BLE module. But now I need to send AT commands and I'm lost. Here is part of the code:
@IBAction func sendButton(_ sender: AnyObject) {
//writeValue("AT") Its work, but send string
let mydata = "AT"
//let bytes : [UInt8] = [ 0x41, 0x54 ]
//let data = Data(bytes:bytes)
let directAttay : [UInt8] = Array(mydata.utf8)
writeValue(directAttay)
}
I tried many options but allways get error, cannot.
If I try to send the data
(in this code part up commented out) I get this:
ViewController.swift:36:20: Cannot convert value of type 'Data' to expected argument type 'String'
When I try to send directArray
, I get this error:
ViewController.swift:36:20: Cannot convert value of type '[UInt8]' to expected argument type 'String'