Need help with BlueSocket connection

Hi,


I'm trying to use Aphid and Mosquitto (a IOT communication protocol and software Framework).

However, when I try to connect I'm getting:


Error: Error code: -9989(0x-2705), Operation now in progress
Error type: Error
Error type displaystyle: struct

I'm only connecting once though.
Here's my code in different places. Can anyone help?


I'm guessing that I need to create a thread and schedule the connection in the thread. However, I don't know how to do this. Can someone help me with this> Below is my code:


import UIKit

import Foundation

import SystemConfiguration

import AphidFramework

/ No multiple inheritance so I made Aphid an NSObject */

class UberCameraClient: /NSObject, */ Aphid, StreamDelegate, MQTTDelegate {


var inputStream: InputStream!

var outputStream: OutputStream!


let maxReadLength = 4096


weak var uberCameraDelegate: UberCameraClientDelegate?


func setupNetworkCommunication(_ inputDelegate: UberCameraClientDelegate) {

do {

try self.connect();

print("Made it past connect");


} catch let unknownError {

/

print("Error: \(unknownError)")

print("Error type: \(type(of: unknownError))")

if let dispStyle = Mirror(reflecting: unknownError).displayStyle {

print("Error type displaystyle: \(dispStyle)")

}

}

.

.

.

/*********************************************************************** MQTT implementation */

init(clientId: String) {

super.init(clientId: "Test", cleanSess: true, username: nil, password: nil,

host: "192.168.1.73", port: 1883);

super.delegate = self;

}

func didConnect() {

print("I connected!")

}

func didLoseConnection() {

print("connection lost")

}

func didCompleteDelivery(token: String) {

print(token)

}

func didReceiveMessage(topic: String, message: String) {

print(topic, message)

}

/*

This method is called when the connection to the server is lost.

throws: cause of the reason behind the loss of connection.

*/

func didLoseConnection(error: Error?) {

print("lost Connection");

}

}

Error: Error code: -9989(0x-2705), Operation now in progress

I don’t recognise that error. Is that coming back from an Apple API? If so, which one?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Hi,


I figured the problem out. There was a timeout of 0 set in the Aphid framework (on Github.) when calling a socket connect. I was also using the BlueSocket framework on Github. So it wasn't an apple API. Sorry, if I didn't ask the right place. If anyone asks you about this though, you could pass on that they may try increasing the timeout to something greater than 0.


John Byrne

Need help with BlueSocket connection
 
 
Q