Need for a teamviewer to help start the function (swift)

Need for a teamviewer to help start the function (swift, Xcode 10) Urgently!

Russian speaker better!!!


/ * to transfer data, you need to get the connection characteristics and pass them to the writeWalue function

for this, I subscribed to receive characteristics using the function discoverCharacteristics (line 107)

announced function delegate func peripheral (_ peripheral: CBPeripheral, didDiscoverCharacteristicsFor service: CBService, error: Error?)

but control is not transferred to it, although I have prescribed that the controller should according to the protocol with the help of the line

peripheral.peripheral.delegate = ViewModelServices.sharedInstance as? CBPeripheralDelegate

Apparently this is the problem, most likely passing the wrong data to the delegate variable.



func peripheral(_ peripheral: CBPeripheral, didDiscoverCharacteristicsFor service: CBService, error: Error?) {

NSLog("func peripheral(_peripheral: CBPeripheral, didDiscoverCharacteristicsFor service: CBService, error: Error?)")

if let array = service.characteristics as [CBCharacteristic]! {

for charac in array {

NSLog("send command")

var dataDict = ["OpCode" : "0x012d001122334455667788990002"]

let data = NSKeyedArchiver.archivedData(withRootObject: dataDict)

peripheral.writeValue(data, for: charac, type: CBCharacteristicWriteType.withResponse)

}

Need for a teamviewer to help start the function (swift)
 
 
Q