Statistics: Posted by ivanroberto — Thu Jan 22, 2015 10:11 pm
Statistics: Posted by ivanroberto — Thu Jan 22, 2015 8:13 pm
Statistics: Posted by Peter — Thu Jan 22, 2015 6:03 am
Code:
static bool _waitSentCB = false;
BOOL socketClientTX(uint8_t *Ptr, uint16_t len) {
BOOL retorno = false;
uint32_t timeOut;
struct espconn *pespconn = &Conn;
timeOut = system_get_time() + 2000000;
do{
if ((socketConnState >= TCP_CONNECTED) && !_waitSentCB) {
sint8 espsent_status = espconn_sent(pespconn, Ptr, len);
if (espsent_status == ESPCONN_OK) {
_waitSentCB = true; //Indica que o socket está ocupado enviando dados
socketConnState = TCP_SENT_DATA;
retorno = true;
#ifdef PLATFORM_DEBUG
ets_uart_printf("C > Data sent OK: %d bytes\r\n", len);
#endif
} else {
socketConnState = TCP_SENDING_DATA_ERROR;
#ifdef PLATFORM_DEBUG
ets_uart_printf("C > ### Error while sending data.\r\n");
#endif
}
break;
}
#ifdef PLATFORM_DEBUG
ets_uart_printf("C > Aguarda SentCB\r\n");
#endif
}while(timeOut > system_get_time());
return retorno;
}
static void ICACHE_FLASH_ATTR tcpclient_sent_cb(void *arg)
{
struct espconn *pespconn = arg;
_waitSentCB = false; //Indica que o socket foi liberado
#ifdef PLATFORM_DEBUG
ets_uart_printf("tcpclient_sent_cb\r\n");
#endif
}
Statistics: Posted by ivanroberto — Thu Jan 22, 2015 3:59 am