Tests with ESP01 and AT commands
Quote from feri on February 26, 2026, 10:44 amI'm doing some tests with ESP01. I managed to zealize TCP connections with ESP01 client and I wanted to implement server mode.
I started a server with the following code:
void Esp01::StartServer(int port) { m_server = new QTcpServer(); bool no_err = QObject::connect(m_server, &QTcpServer::newConnection, [=](){ onNewConnection(); }); if (no_err) qDebug() << "CONNECT RIUSCITO"; if (m_server->listen(QHostAddress("127.0.0.1"), port)) { m_uartReply = m_OK; uartReply = true; if (m_debug) qDebug() << "ESP01 SERVER AT simulato - porta " << port; } else { if (m_debug) qDebug() << "Errore listen:" << m_server->errorString(); m_uartReply = m_ERROR; uartReply = true; } }The server is created and listens on the chosen port (tested with "telnet 127.0.0.1 8080")
but the "connect" doesn't work:
QObject::connect(m_server, &QTcpServer::newConnection, [=](){ onNewConnection(); });onNewConnection() it does not happen while:
QObject::connect( tcpSocket, &QTcpSocket::connected , [=](){ tcpConnected(id); }); QObject::connect( tcpSocket, &QTcpSocket::disconnected, [=](){ tcpDisconnected(id); }); QObject::connect( tcpSocket, &QTcpSocket::readyRead , [=](){ tcpReadyRead(id); });It works well, can you give me some advice?
Regards
I'm doing some tests with ESP01. I managed to zealize TCP connections with ESP01 client and I wanted to implement server mode.
I started a server with the following code:
void Esp01::StartServer(int port)
{
m_server = new QTcpServer();
bool no_err = QObject::connect(m_server, &QTcpServer::newConnection, [=](){ onNewConnection(); });
if (no_err) qDebug() << "CONNECT RIUSCITO";
if (m_server->listen(QHostAddress("127.0.0.1"), port)) {
m_uartReply = m_OK;
uartReply = true;
if (m_debug) qDebug() << "ESP01 SERVER AT simulato - porta " << port;
} else {
if (m_debug) qDebug() << "Errore listen:" << m_server->errorString();
m_uartReply = m_ERROR; uartReply = true;
}
}
The server is created and listens on the chosen port (tested with "telnet 127.0.0.1 8080")
but the "connect" doesn't work:
QObject::connect(m_server, &QTcpServer::newConnection, [=](){ onNewConnection(); });
onNewConnection() it does not happen while:
QObject::connect( tcpSocket, &QTcpSocket::connected , [=](){ tcpConnected(id); });
QObject::connect( tcpSocket, &QTcpSocket::disconnected, [=](){ tcpDisconnected(id); });
QObject::connect( tcpSocket, &QTcpSocket::readyRead , [=](){ tcpReadyRead(id); });
It works well, can you give me some advice?
Regards
