mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +03:00
WiFiClient cleanup
This commit is contained in:
parent
4944a8fb5f
commit
ccfbd9c969
@ -126,7 +126,7 @@ int ICACHE_FLASH_ATTR WiFiClient::connect(IPAddress ip, uint16_t port)
|
|||||||
int8_t ICACHE_FLASH_ATTR WiFiClient::_connected(void* pcb, int8_t err)
|
int8_t ICACHE_FLASH_ATTR WiFiClient::_connected(void* pcb, int8_t err)
|
||||||
{
|
{
|
||||||
tcp_pcb* tpcb = reinterpret_cast<tcp_pcb*>(pcb);
|
tcp_pcb* tpcb = reinterpret_cast<tcp_pcb*>(pcb);
|
||||||
_client = new ClientContext(tpcb, 1024, 0, 0);
|
_client = new ClientContext(tpcb, 0, 0);
|
||||||
_client->ref();
|
_client->ref();
|
||||||
esp_schedule();
|
esp_schedule();
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
@ -134,7 +134,7 @@ int8_t ICACHE_FLASH_ATTR WiFiClient::_connected(void* pcb, int8_t err)
|
|||||||
|
|
||||||
void ICACHE_FLASH_ATTR WiFiClient::_err(int8_t err)
|
void ICACHE_FLASH_ATTR WiFiClient::_err(int8_t err)
|
||||||
{
|
{
|
||||||
DEBUGV("WC:err\r\n");
|
DEBUGV(":err\r\n");
|
||||||
esp_schedule();
|
esp_schedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +81,6 @@ WiFiClient WiFiServer::available(byte* status)
|
|||||||
{
|
{
|
||||||
WiFiClient result(_unclaimed);
|
WiFiClient result(_unclaimed);
|
||||||
_unclaimed = _unclaimed->next();
|
_unclaimed = _unclaimed->next();
|
||||||
// printf("WiFiServer::available\r\n");
|
|
||||||
DEBUGV("WS:av\r\n");
|
DEBUGV("WS:av\r\n");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -123,7 +122,7 @@ T* slist_append_tail(T* head, T* item)
|
|||||||
int8_t WiFiServer::_accept(tcp_pcb* apcb, int8_t err)
|
int8_t WiFiServer::_accept(tcp_pcb* apcb, int8_t err)
|
||||||
{
|
{
|
||||||
DEBUGV("WS:ac\r\n");
|
DEBUGV("WS:ac\r\n");
|
||||||
ClientContext* client = new ClientContext(apcb, _rx_buffer_size, &WiFiServer::_s_discard, this);
|
ClientContext* client = new ClientContext(apcb, &WiFiServer::_s_discard, this);
|
||||||
_unclaimed = slist_append_tail(_unclaimed, client);
|
_unclaimed = slist_append_tail(_unclaimed, client);
|
||||||
tcp_accepted(_pcb);
|
tcp_accepted(_pcb);
|
||||||
// printf("WiFiServer::_accept\r\n");
|
// printf("WiFiServer::_accept\r\n");
|
||||||
@ -132,7 +131,7 @@ int8_t WiFiServer::_accept(tcp_pcb* apcb, int8_t err)
|
|||||||
|
|
||||||
void WiFiServer::_discard(ClientContext* client)
|
void WiFiServer::_discard(ClientContext* client)
|
||||||
{
|
{
|
||||||
_discarded = slist_append_tail(_discarded, client);
|
// _discarded = slist_append_tail(_discarded, client);
|
||||||
DEBUGV("WS:dis\r\n");
|
DEBUGV("WS:dis\r\n");
|
||||||
// printf("WiFiServer::_discard\r\n");
|
// printf("WiFiServer::_discard\r\n");
|
||||||
}
|
}
|
||||||
|
@ -33,10 +33,9 @@ extern "C" void esp_schedule();
|
|||||||
class ClientContext
|
class ClientContext
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ClientContext(tcp_pcb* pcb, size_t rx_buffer_size,
|
ClientContext(tcp_pcb* pcb,
|
||||||
discard_cb_t discard_cb, void* discard_cb_arg)
|
discard_cb_t discard_cb, void* discard_cb_arg)
|
||||||
: _pcb(pcb)
|
: _pcb(pcb)
|
||||||
// , _rx_buf(rx_buffer_size)
|
|
||||||
, _rx_buf(0)
|
, _rx_buf(0)
|
||||||
, _rx_buf_offset(0)
|
, _rx_buf_offset(0)
|
||||||
, _discard_cb(discard_cb)
|
, _discard_cb(discard_cb)
|
||||||
@ -50,7 +49,6 @@ public:
|
|||||||
tcp_recv(pcb, &_s_recv);
|
tcp_recv(pcb, &_s_recv);
|
||||||
tcp_sent(pcb, &_s_sent);
|
tcp_sent(pcb, &_s_sent);
|
||||||
tcp_err(pcb, &_s_error);
|
tcp_err(pcb, &_s_error);
|
||||||
// tcp_poll(pcb, &_s_poll, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
~ClientContext()
|
~ClientContext()
|
||||||
@ -297,12 +295,15 @@ private:
|
|||||||
private:
|
private:
|
||||||
ClientContext* _next;
|
ClientContext* _next;
|
||||||
int _refcnt;
|
int _refcnt;
|
||||||
|
|
||||||
tcp_pcb* _pcb;
|
tcp_pcb* _pcb;
|
||||||
|
|
||||||
pbuf* _rx_buf;
|
pbuf* _rx_buf;
|
||||||
size_t _rx_buf_offset;
|
size_t _rx_buf_offset;
|
||||||
// cbuf _rx_buf;
|
|
||||||
discard_cb_t _discard_cb;
|
discard_cb_t _discard_cb;
|
||||||
void* _discard_cb_arg;
|
void* _discard_cb_arg;
|
||||||
|
|
||||||
size_t _size_sent;
|
size_t _size_sent;
|
||||||
bool _send_waiting;
|
bool _send_waiting;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user