This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Send a message to a telnet client without having receive a command first

The callback function netTELNETs_ProcessCommand processes and executes the command requested by the Telnet client. 

In my application, I have to send a list of message to answer to only one command request.

I've seen in  the documentation that the function netTELNETs_RequestMessage is used to pass unsolicited messages to the Telnet server. 

Is it possible to use this function to send several messages, and how can I use it ?

Thanks !

Thierry

  • It is possible to respond with a larger message, that does not fit into one response packet. The return value of the function netTELNETs_ProcessMessage informs the telnet server that the response is larger and needs more packets to send. The fourth parameter pvar can be used as a helper to process a large response message.

    uint32_t netTELNETs_ProcessCommand (const char *cmd, char *buf, uint32_t buf_len, uint32_t *pvar) {
      uint32_t len = 0;
     
      if (*pvar == 0) {
        // First call to this function, process command cmd
        // len = Copy initial part of the response into the buf
        // *pvar = 1;
        // Set request for another callback
        return (len | (1u << 31));
      } else {
        // A subsequent call to this function
        // len = Copy message fragment into the buf
        // *pvar++;
        if (!message_done) {
          // Set request for another callback
          return (len | (1u << 31));
        }
        // This is the last fragment of the message
        return (len);
      }
    }