I’m developing Remote TV Control app for iOS with Swift, now I’m trying to add support for Hisense TVs working on VIDAA OS, I researched and understood that it is working with MQTT broker, I tried different packages to setup connection with TV, mainly CocoaMQTT package, but something went wrong, I used 36669 port to connect.
Would like to listen any best practices regarding that.
let clientID = "CocoaMQTT-" + String(ProcessInfo().processIdentifier)
let mqtt5 = CocoaMQTT5(clientID: clientID, host: "broker.emqx.io", port: 1883)
let connectProperties = MqttConnectProperties()
connectProperties.topicAliasMaximum = 0
connectProperties.sessionExpiryInterval = 0
connectProperties.receiveMaximum = 100
connectProperties.maximumPacketSize = 500
mqtt5.connectProperties = connectProperties
mqtt5.enableSSL = true
mqtt5.allowUntrustCACertificate = true
mqtt5.username = "hisenseservice"
mqtt5.password = "multimqttservice"
mqtt5.keepAlive = 60
mqtt5.delegate = self
mqtt5.connect()
I recieve this error:
The operation couldn’t be completed. (kCFStreamErrorDomainSSL error -9824.)
Maybe this approach is not correct to connect with Hisense TVs in Local Network. For example: For Samsung TVs I connected, with wss://<ip_address>:8002/ms.remote.control…
for LG TVs: wss://<ip_address>:3001/…
Now want to know the correct approach for Hisense TVs with VIDAA OS
UPDATE:
This is what CocoaMQTT logs in debug mode:
CocoaMQTT(info): Connected to 192.168.88.225 : 36669
CocoaMQTT(info): Enable backgrounding socket successfully
CocoaMQTT(debug): SEND: CONNECT(id: stic-master, username: hisenseservice, password: multimqttservice, keepAlive : 60, cleansess: true)
CocoaMQTT(debug): ==========================MQTT 5.0==========================
CocoaMQTT(debug): packetFixedHeaderType 16
CocoaMQTT(debug): fixedHeader [16]
CocoaMQTT(debug): remainingLen(len: len) [58]
CocoaMQTT(debug): variableHeader [0, 4, 77, 81, 84, 84, 5, 194, 0, 60, 0]
CocoaMQTT(debug): properties []
CocoaMQTT(debug): payload [0, 11, 115, 116, 105, 99, 45, 109, 97, 115, 116, 101, 114, 0, 14, 104, 105, 115, 101, 110, 115, 101, 115, 101, 114, 118, 105, 99, 101, 0, 16, 109, 117, 108, 116, 105, 109, 113, 116, 116, 115, 101, 114, 118, 105, 99, 101]
CocoaMQTT(debug): =============================================================
CocoaMQTT(debug): socket wrote data 0
nw_socket_handle_socket_event [C9:1] Socket SO_ERROR [54: Connection reset by peer]
nw_protocol_socket_reset_linger [C9:1] setsockopt SO_LINGER failed [22: Invalid argument]
CocoaMQTT(debug): socket disconnected
Optional(Error Domain=MGCDAsyncSocketErrorDomain Code=7 "Socket closed by remote peer" UserInfo={NSLocalizedDescription=Socket closed by remote peer})
client = CocoaMQTT5(clientID: "stic-master", host: ip, port: 36669)
client.username = "hisenseservice"
client.password = "multimqttservice"
client.enableSSL = false
client.allowUntrustCACertificate = true
client.backgroundOnSocket = true
client.autoReconnect = true
client.cleanSession = true
client.logLevel = .debug
client.didReceiveTrust = { mqtt5, trust, completion in
completion(true)
}
client.didReceiveMessage = { mqtt5, message, code, _ in
print(message)
}
client.didConnectAck = { mqtt5, reasonode, ack in
print(ack)
}
client.didDisconnect = { mqtt5, error in
print(error)
}
client.connect()
8