HomeiOS Developmentios - Methods to authenticate with Sony Bravia TV IP Management with...

ios – Methods to authenticate with Sony Bravia TV IP Management with pin code?


Usually, to authenticate with Sony Bravia TV, I exploit pre-shared key and it really works. However I see some apps can use pin code to authenticate and the pin code is displayed on the display of TV. How can I do this for my iOS app? Once I request to TV the pin code simply displayed about 1 second and it disappeared instantly. I additionally used socket to speak with the TV however I do not know tips on how to confirm. That is my code:

let ipAddress = "192.168.1.94"
let port: Int32 = 80
let path = "/sony/accessControl"
let requestBody: String = """
{
"id": 1001,
"technique": "actRegister",
"params": [
{
"clientid": "iRule:1",
"nickname": "Tran Nghia Pro"
},
[
{
"clientid": "iRule:1",
"value": "no",
"nickname": "Tran Nghia Pro",
"function": "WOL"
}
]
],
"model": "1.0"
}
""" 
let request = """
POST (path) HTTP/1.1r
Host: (ipAddress)r
Content material-Sort: utility/jsonr
Content material-Size: (requestBody.depend)r
r
(requestBody)
"""
let consumer = TCPClient(tackle: ipAddress, port: port)
swap consumer.join(timeout: 5) {
case .success:
// Ship the POST request
swap consumer.ship(string: request) {
case .success:
// Learn the response
if let knowledge = consumer.learn(1024) {
if let responseString = String(bytes: knowledge, encoding: .utf8) {
print("Response: (responseString)")
} else {
print("Invalid response knowledge")
}
} else {
print("No knowledge obtained")
}
// Shut the connection
consumer.shut()
case .failure(let error):
print("Error sending request: (error.localizedDescription)")
}
case .failure(let error):
print("Error connecting to server: (error.localizedDescription)")
}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments