Question about Telnet

I have managed to a code a simple driver that establishes a Telnet connection and sends and receives.

I found the Telnet documentation rather sparse but it seemed to be correct.

What was surprising was there was no command to send data.

Eventually I located a device in the HPM which used a Telnet connection and I found this bit of code which worked to send data:

def sendMsg(String msg) {
def hubCmd = sendHubCommand(new hubitat.device.HubAction("${msg}", Hubitat.device.Protocol.TELNET))

pauseExecution(500)

return hubCmd

}

But I have not found any documentation to explain the why and what of it all.

I know what "pauseExecution" does but I don't know why it is there.

And I basically know what the return does but, again, why is it there.

Thanks, Frederick

Take everything below with a grain of salt.

The actual telnetInterface is used to open the telnet connection. You then need a function (like you posted) to actually send data across the connection. Your return is to bring back the telnet response that will get parsed by the required parse function. The pause is to allow for the telnet connection to receive that response before moving on.

Thanks much.

At least I know what I found in the other users code is basically correct.

I still wonder why there isn't a simple built-in procedure for sending, something along the lines of "telnetSend(String msg)".

Not terribly important, it's just my insatiable curiosity working overtime.

Thanks again, Frederick

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.