Code to send data to a nordic BLE in a button action

Hii,

I have downloaded a source code from https://github.com/NordicSemiconductor/IOS-nRF-Toolbox and added to my project to connect with nordic UART . But I cant acess the function to send a value to BLE in another class that I have created in the project.


func send(aText: String) {

guard self.uartRXCharacteristic != nil else {

log(withLevel: .warningLogLevel, andMessage: "UART RX Characteristic not found")

return

}

/

/

var type = CBCharacteristicWriteType.withoutResponse

if (self.uartRXCharacteristic!.properties.rawValue & CBCharacteristicProperties.write.rawValue) > 0 {

type = CBCharacteristicWriteType.withResponse

}

/

/

/

/

let longWriteSupported = false

/

let textData = aText.data(using: String.Encoding.utf8)!

textData.withUnsafeBytes { (u8Ptr: UnsafePointer<CChar>) in

var buffer = UnsafeMutableRawPointer(mutating: UnsafeRawPointer(u8Ptr))

var len = textData.count

while(len != 0){

var part : String

if len > MTU && (type == CBCharacteristicWriteType.withoutResponse || longWriteSupported == false) {

/

/

var builder = NSMutableString(bytes: buffer, length: MTU, encoding: String.Encoding.utf8.rawValue)

if builder != nil {

/

buffer = buffer + MTU

len = len - MTU

} else {

/

builder = NSMutableString(bytes: buffer, length: (MTU - 1), encoding: String.Encoding.utf8.rawValue)

buffer = buffer + (MTU - 1)

len = len - (MTU - 1)

}

part = String(describing: builder!)

} else {

let builder = NSMutableString(bytes: buffer, length: len, encoding: String.Encoding.utf8.rawValue)

part = String(describing: builder!)

len = 0

}

send(text: part, withType: type)

}

}

}

I'm using Swift 4

Code to send data to a nordic BLE in a button action
 
 
Q