These are chat archives for SmingHub/Sming

27th
Nov 2018
frankdownunder
@frankdownunder
Nov 27 2018 02:39
Looks good
ip:192.168.100.103,mask:255.255.255.0,gw:192.168.100.1
Connecting to  mqtt://m12.cloudmqtt.com:15983/
Let's publish message now. Memory free=49448
Message with id 2 and QoS 1 was delivered successfully.Let's publish message now. Memory free=49392
Message with id 3 and QoS 1 was delivered successfully.Let's publish message now. Memory free=49392
slaff
@slaff
Nov 27 2018 08:25

I am struggling to send strings to arbitrary telnet session. writeString always returns -1.

@riban-bw Are you using the TelnetServer or you are trying to use the TcpClient as a TelnetClient?

riban-bw
@riban-bw
Nov 27 2018 08:27
@slaff I have created an instance of TelnetServer, disabled commands and try sending strings with writeString. A telnet client connects (sees the Sming message in the telnet client) but there is no further comms.
slaff
@slaff
Nov 27 2018 08:33
TcpConnection::writeString and TcpConnection::write skip all buffering and write directly to the TCP buffer. So if you are not familiar with LWIP and async operations it will be quite hard to have correct timing. What I mean is that you might send a command with writeString and then nanoseconds later try again to send another command. But the TCP buffer will get filled up and you can write to it only when it frees up some space. Best will be to use TcpConnection::write(IDataSourceStream* stream)
But again you have to know what you are doing. Async programming is a lot of fun :)
riban-bw
@riban-bw
Nov 27 2018 09:16
But why would no messages at all get to the client? I was hoping that the telnet library would give me the ability to send messages to a telnet session. :-(
slaff
@slaff
Nov 27 2018 09:41
if you filling up the TCP buffer then nothing can be stored in it.
Getting -1 usually means that the buffer is full.
Take a look at our network clients to see how things operate
You usually send something when on the onReadyToSendData is called.
riban-bw
@riban-bw
Nov 27 2018 13:35
I looked at the TelnetSe class and it doesn't seem to override onReadyToSendData so I don't know how it is supposed to work. I can create my own network logging class derived from TcpConnection class but thought TelnetServer should "just work".