Hello INDI Coders,
I am still new to INDI. I am trying a little SWIFT app to
directly communicate with an INDI server running on a Raspberry Pi.
I like to use SWIFT on macOS / iPadOS taking advantage of the still relatively new Network Framework (introduced in 2018). Apple introduced this framework to get rid of sockets and to make communication easier. While this might be debatable, I just like to know how this would work in SWIFT.
How would I send a command to an INDI server? What data format does it have to be? What is the syntax? Is there a quick and easy tutorial? I used setprop and getprop successfully from the command line in a terminal window. I do not want to import c-code or use those functions in SWIFT.
To give you a extremely basic example, I can easily connect to an INDI server on my local network with the following few code lines:
import Cocoa
import Foundation
import Network
let IPscope: NWEndpoint.Host = NWEndpoint.Host("192.168.68.70")
let indiPort: NWEndpoint.Port = NWEndpoint.Port(rawValue: 7624)!
let connection = NWConnection(host: IPscope, port: indiPort, using: .tcp)
connection.stateUpdateHandler = { (newState) in
switch(newState) {
case .ready:
print("Network ready")
case .waiting(let error):
print("Network waiting .... , error: \(error.localizedDescription)")
case .failed(let error):
print("Network connection failed :-( .... , error: \(error.localizedDescription)")
default:
break
}
}
connection.start(queue: .main)
This code seems to work.
Now how do I receive or send (i.e. change) properties?
Any help is highly appreciated.