Arm Mbed and Pelion Device Management support forum

Telnet on TCPSocket with Nucleo F767ZI and Arduino 4 Relays Shield

Dear all,
I hope you can help me with the following problem:

My task: I want to switch on and off a led-light source using an Arduino 4 Relays Shield (this is what a I currently have in my toolbox) which is mounted on top of a Nucleo F767ZI. I want to control one of the relays remotely by connecting to the Nucleo via telnet (TCP connection).

Done so far:
I have reused the standard mbed example and added the required control commands, see here:

The Problem:
After uploading the compiled code (compiled with online compiler) to the Nucleo I can connect to the board via telnet on port 4001 once (command: telnet 4001). As long as this first connection is in use and not interrupted everything works fine. I can switch the light on and off as often I want. But after I have disconnected via the typical telnet quit (Ctrl+Alt Gr+9, then quit), I cannot reconnect to the device. The device is not available any longer. If I reset the board via the reset button, I can connect to the board again. To circumvent this problem I added the quit command “QUI” to the code that resets the board via NVIC_SystemRestart(); , see here:

    if(!strcmp (befehl, "QUI"))
    {
        srv.close();
        NVIC_SystemReset();  
    } else;

Can you give me some hint what I have to change in my code so that I do not need to perform a system reset after the termination of the telnet connection?

Thanks a lot in advance and best regards.

Hi there,

you close the server at the end of loop, and its open method is before loop, so it can not be reopened again. Just do not close the server, just because of an error and close the connected client instead. I think/hope that will solve this.

BR, Jan