我的逻辑是:
代码:
全选init() {
....
rc = espconn_set_opt (conn, ESPCONN_COPY); // enable write buffer
...
}
espbuffsent (serverConnData *conn, const char *data, uint16 len) {
...
if (conn->readytosend)
{
LOG(\'S\');LOG(0);
rc = sendtxbuffer (conn);
}
else
{
LOG(\'N\');
}
}
sendtxbuffer (serverConnData *conn)
{
if (conn->txbufferlen != 0)
{
conn->readytosend = false;
result = espconn_send (conn->conn, (uint8_t*) conn->txbuffer, conn->txbufferlen);
if (result == ESPCONN_OK)
{
conn->txbufferlen = 0;
}
}
user_tcp_write_finish (void *arg)
{
LOG(\'F\');
serverConnData *conn = serverFindConnData (arg);
conn->readytosend = true;
LOG(\'s\');
if (conn->txbufferlen > 0)
{
sendtxbuffer (conn); // send possible new data in txbuffer
}
}