Pico Gpio Net Client
Client for interacting with the PGN daemon.
This is the class responsible for translating human-readable function names and variables to raw byte data, and transmitting that data back and forth over the socket.
To use this class, you must first call connect()
, and you should remember to close the client after you've finished using it.
While connected, you can issue commands to the PGN daemon by calling the functions within this class.
Example usage:
val serverName = PicoGpioNetClient(ip, port).use{ client ->
client.connect()
val apiVersion = client.getApiVersion()
if (apiVersion >= Command.CMD_GET_NAME.apiVersion)
client.getName()
else
"Unknown device name"
}
Content copied to clipboard
Parameters
ip
IP address of the Pico device running PGN which we want to connect to.
port
Port on which PGN is running. This is usually port 8080.
auto Flush
If true, flush all writes to the PGN daemon automatically.