20 #include <zephyr/kernel.h>
21 #include <zephyr/net/socket.h>
26 #include <zephyr/net/net_if.h>
27 #include <zephyr/posix/sys/ioctl.h>
32struct net_if* rf24_netif_get_iface(
void);
39RF24Client* RF24Client::g_rf24client_instance =
nullptr;
40int RF24Client::_socket;
41uint32_t RF24Client::serverConnectionTimeout;
42uint8_t RF24Client::peekBuffer[64];
47 #define UIP_TCP_PHYH_LEN UIP_LLH_LEN + UIP_IPTCPH_LEN
48uip_userdata_t RF24Client::all_data[UIP_CONNS];
54 #if !defined ETHERNET_USING_LWIP_ARDUINO
56 #include "lwip/tcpip.h"
57 #include "lwip/timeouts.h"
59 #include "lwip/include/lwip/tcp.h"
60 #include "lwip/include/lwip/tcpip.h"
66char* RF24Client::incomingData[2];
67uint16_t RF24Client::dataSize[2];
68struct tcp_pcb* RF24Client::myPcb;
69uint32_t RF24Client::clientConnectionTimeout;
70uint32_t RF24Client::serverConnectionTimeout;
71uint32_t RF24Client::simpleCounter;
73int32_t RF24Client::accepts;
82 if (state !=
nullptr) {
83 state->serverTimer = millis();
84 state->clientTimer = millis();
87 if (state->dataSentSize >= len) {
88 state->dataSentSize -= len;
91 state->dataSentSize = 0;
94 if (state->dataSentSize == 0) {
95 state->waiting_for_ack =
false;
98 state->waiting_for_ack =
true;
100 state->result = ERR_OK;
108err_t RF24Client::blocking_write(
struct tcp_pcb* fpcb, ConnectState* fstate,
const char* data,
size_t len)
111 if (fpcb ==
nullptr) {
116 if (!fstate->connected) {
121 const uint32_t timeoutStart = millis();
123 if (len > tcp_sndbuf(fpcb)) {
124 #if defined RF24ETHERNET_CORE_REQUIRES_LOCKING
126 ETHERNET_APPLY_LOCK();
130 #if defined RF24ETHERNET_CORE_REQUIRES_LOCKING
132 ETHERNET_REMOVE_LOCK();
135 fstate->waiting_for_ack =
true;
138 while (len > tcp_sndbuf(fpcb)) {
140 if (millis() - timeoutStart > serverConnectionTimeout) {
146 #if defined RF24ETHERNET_CORE_REQUIRES_LOCKING
148 ETHERNET_APPLY_LOCK();
152 err_t err = ERR_CLSD;
153 if (fpcb !=
nullptr) {
154 err = tcp_write(fpcb, data, len, TCP_WRITE_FLAG_COPY);
160 #if defined RF24ETHERNET_CORE_REQUIRES_LOCKING
162 ETHERNET_REMOVE_LOCK();
168 #if defined RF24ETHERNET_CORE_REQUIRES_LOCKING
170 ETHERNET_REMOVE_LOCK();
174 const uint32_t timerStart = millis();
175 while (fstate !=
nullptr && fstate->waiting_for_ack) {
176 if (!fstate->connected) {
179 if (millis() - timerStart > 5000) {
180 if (fstate !=
nullptr) {
197 if (state !=
nullptr) {
199 state->connected =
false;
200 state->waiting_for_ack =
false;
201 state->dataSentSize = 0;
202 dataSize[state->stateActiveID] = 0;
217 if (state !=
nullptr) {
218 state->serverTimer = millis();
222 if (state !=
nullptr) {
223 state->connected =
false;
225 if (tpcb !=
nullptr) {
226 if (tcp_close(tpcb) != ERR_OK) {
241 if (err != ERR_OK || state ==
nullptr) {
252 uint32_t timeout = millis();
253 while (q !=
nullptr) {
254 if (millis() - timeout > 3000) {
257 const uint8_t* data =
static_cast<const uint8_t*
>(q->payload);
259 memcpy(&incomingData[
id][dataSize[
id]], data, q->len);
260 dataSize[id] += q->len;
268 if (tpcb !=
nullptr) {
269 tcp_recved(tpcb, p->tot_len);
286 if (state !=
nullptr) {
287 state->connected =
false;
289 if (tpcb !=
nullptr) {
290 if (tcp_close(tpcb) != ERR_OK) {
305 if (err != ERR_OK || state ==
nullptr) {
312 if (state !=
nullptr) {
313 state->clientTimer = millis();
318 uint32_t timeout = millis();
319 while (q !=
nullptr) {
320 if (millis() - timeout > 3000) {
323 const uint8_t* data =
static_cast<const uint8_t*
>(q->payload);
325 memcpy(&incomingData[
id][dataSize[
id]], data, q->len);
326 dataSize[id] += q->len;
334 if (tpcb !=
nullptr) {
335 tcp_recved(tpcb, p->tot_len);
353err_t RF24Client::clientTimeouts(
void* arg,
struct tcp_pcb* tpcb)
358 if (state !=
nullptr) {
359 if (millis() - state->clientTimer > state->cConnectionTimeout) {
360 if (tpcb->state == ESTABLISHED || tpcb->state == SYN_SENT || tpcb->state == SYN_RCVD) {
362 err_t err = tcp_close(tpcb);
364 state->connected =
false;
373err_t RF24Client::serverTimeouts(
void* arg,
struct tcp_pcb* tpcb)
378 if (state !=
nullptr && tpcb !=
nullptr) {
381 state->result = ERR_OK;
383 if (millis() - state->serverTimer > state->sConnectionTimeout) {
387 state->result = tcp_close(tpcb);
388 state->closeTimer = millis();
390 state->connected =
false;
391 if (state->result != ERR_OK) {
392 tcp_arg(tpcb,
nullptr);
395 tcp_arg(myPcb,
nullptr);
400 return state->result;
404 return state->result;
411err_t RF24Client::closed_port(
void* arg,
struct tcp_pcb* tpcb)
416 if (state !=
nullptr) {
420 if (myPcb ==
nullptr) {
421 if (state !=
nullptr && tpcb !=
nullptr) {
423 if ((tpcb->state == ESTABLISHED || tpcb->state == SYN_SENT || tpcb->state == SYN_RCVD)) {
424 if (state->backlogWasAccepted ==
false) {
426 state->backlogWasAccepted =
true;
427 state->connectTimestamp = millis();
428 state->connected =
true;
433 tcp_backlog_accepted(tpcb);
441 if (tpcb !=
nullptr) {
442 if (state !=
nullptr) {
443 if (millis() - state->connectTimestamp > state->sConnectionTimeout) {
445 if ((tpcb->state == ESTABLISHED || tpcb->state == SYN_SENT || tpcb->state == SYN_RCVD)) {
449 if (state->backlogWasAccepted ==
false) {
451 tcp_backlog_accepted(tpcb);
452 state->backlogWasAccepted =
true;
456 state->result = tcp_close(tpcb);
457 state->connected =
false;
458 if (state->result == ERR_OK) {
459 state->closeTimer = millis();
467 return state->result;
478err_t RF24Client::accept(
void* arg,
struct tcp_pcb* tpcb, err_t err)
482 if (tpcb ==
nullptr) {
483 IF_RF24ETHERNET_DEBUG_CLIENT(Serial.print(
"Server: Accepted conn, but no tpcb from: "); Serial.println(ip4addr_ntoa(ip_2_ip4(&tpcb->remote_ip))););
487 if (tpcb !=
nullptr) {
492 if (myPcb !=
nullptr) {
494 IF_RF24ETHERNET_DEBUG_CLIENT(Serial.print(
"Server: Accept w/already connected: Accepted_Conns - Delayed_Conns == "); Serial.println(accepts););
495 tcp_backlog_delayed(tpcb);
497 tcp_poll(tpcb, closed_port, 5);
499 gState[actState]->connected =
false;
500 gState[actState]->backlogWasAccepted =
false;
504 tcp_poll(tpcb, serverTimeouts, 8);
507 gState[actState]->connected =
true;
508 gState[actState]->backlogWasAccepted =
true;
511 dataSize[actState] = 0;
514 gState[actState]->stateActiveID = actState;
515 gState[actState]->identifier = simpleCounter;
516 gState[actState]->sConnectionTimeout = serverConnectionTimeout;
517 gState[actState]->connectTimestamp = millis();
518 gState[actState]->serverTimer = millis();
519 gState[actState]->dataSentSize = 0;
530err_t RF24Client::closeConn(
void* arg,
struct tcp_pcb* tpcb)
533 if (tpcb !=
nullptr) {
544err_t RF24Client::on_connected(
void* arg,
struct tcp_pcb* tpcb, err_t err)
550 if (state !=
nullptr) {
561 state->cConnectionTimeout = clientConnectionTimeout;
562 state->clientTimer = millis();
565 state->connected =
true;
568 state->connected =
false;
589 g_rf24client_instance =
this;
610 return (data && (data->packets_in != 0 || (data->state & UIP_CLIENT_CONNECTED))) ? 1 : 0;
625 if (connectionEstablished) {
626 struct zsock_pollfd pfd {};
628 pfd.events = ZSOCK_POLLIN;
630 int rc = zsock_poll(&pfd, 1, 0);
635 if (pfd.revents & (ZSOCK_POLLHUP | ZSOCK_POLLERR | ZSOCK_POLLNVAL)) {
636 connectionEstablished =
false;
638 zsock_close(_socket);
643 if (pfd.revents & ZSOCK_POLLIN) {
645 int n = zsock_recv(_socket, &dummy, 1, ZSOCK_MSG_PEEK | ZSOCK_MSG_DONTWAIT);
647 connectionEstablished =
false;
649 zsock_close(_socket);
660 struct zsock_pollfd pfd {};
662 pfd.events = ZSOCK_POLLOUT;
664 int rc = zsock_poll(&pfd, 1, 0);
675 if (pfd.revents & (ZSOCK_POLLERR | ZSOCK_POLLHUP)) {
677 zsock_close(_socket);
683 if (pfd.revents & ZSOCK_POLLOUT) {
686 socklen_t len =
sizeof(error);
688 int ret = zsock_getsockopt(_socket, SOL_SOCKET, SO_ERROR, &error, &len);
689 if (ret < 0 || error != 0) {
691 zsock_close(_socket);
698 connectionEstablished =
true;
703 zsock_close(_socket);
717 #if UIP_ACTIVE_OPEN > 0
725 struct uip_conn* conn = uip_connect(&ipaddr, htons(port));
729 #if UIP_CONNECTION_TIMEOUT > 0
730 uint32_t timeout = millis();
733 while ((conn->tcpstateflags & UIP_TS_MASK) != UIP_CLOSED)
737 if ((conn->tcpstateflags & UIP_TS_MASK) == UIP_ESTABLISHED)
739 data = (uip_userdata_t*)conn->appstate;
740 IF_RF24ETHERNET_DEBUG_CLIENT(Serial.print(millis()); Serial.print(F(
" connected, state: ")); Serial.print(data->state); Serial.print(F(
", first packet in: ")); Serial.println(data->packets_in););
744 #if UIP_CONNECTION_TIMEOUT > 0
747 conn->tcpstateflags = UIP_CLOSED;
759 if (myPcb !=
nullptr) {
764 #if defined RF24ETHERNET_CORE_REQUIRES_LOCKING
766 ETHERNET_APPLY_LOCK();
770 if (myPcb ==
nullptr) {
775 #if defined RF24ETHERNET_CORE_REQUIRES_LOCKING
777 ETHERNET_REMOVE_LOCK();
797 IP_ADDR4(&myIp, ip[0], ip[1], ip[2], ip[3]);
799 err = tcp_connect(myPcb, &myIp, port, on_connected);
802 #if defined RF24ETHERNET_CORE_REQUIRES_LOCKING
804 ETHERNET_REMOVE_LOCK();
812 #if defined RF24ETHERNET_CORE_REQUIRES_LOCKING
814 ETHERNET_REMOVE_LOCK();
818 const uint32_t timeoutStart = millis();
824 if (clientConnectionTimeout > 0) {
835 int sock = zsock_socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
841 int flags = zsock_fcntl(sock, F_GETFL, 0);
847 zsock_fcntl(sock, F_SETFL, flags | O_NONBLOCK);
849 struct sockaddr_in addr = {};
850 addr.sin_family = AF_INET;
851 addr.sin_port = htons(port);
854 snprintf(ipstr,
sizeof(ipstr),
"%u.%u.%u.%u", ip[0], ip[1], ip[2], ip[3]);
855 if (net_addr_pton(AF_INET, ipstr, &addr.sin_addr) < 0) {
860 int rc = zsock_connect(sock, (
const struct sockaddr*)&addr,
sizeof(addr));
869 if (errno != EINPROGRESS) {
876 int64_t start_time = k_uptime_get();
879 while (k_uptime_get() - start_time < 5000) {
884 struct zsock_pollfd pfd = {
886 .events = ZSOCK_POLLOUT,
890 rc = zsock_poll(&pfd, 1, 0);
897 if (rc > 0 && (pfd.revents & (ZSOCK_POLLOUT | ZSOCK_POLLERR | ZSOCK_POLLHUP))) {
899 socklen_t slen =
sizeof(soerr);
900 if (zsock_getsockopt(sock, SOL_SOCKET, SO_ERROR, &soerr, &slen) < 0) {
908 zsock_fcntl(sock, F_SETFL, flags & ~O_NONBLOCK);
916 zsock_fcntl(sock, F_SETFL, flags & ~O_NONBLOCK);
927 zsock_fcntl(sock, F_SETFL, flags & ~O_NONBLOCK);
940void dnsCallback(
const char* name,
const ip_addr_t* ipaddr,
void* callback_arg)
953 IPAddress remote_addr;
955 dns.
begin(RF24EthernetClass::_dnsServerAddress);
960 #if defined(ETH_DEBUG_L1) || defined(RF24ETHERNET_DEBUG_DNS)
961 Serial.println(F(
"*UIP Got DNS*"));
963 return connect(remote_addr, port);
965#elif RF24ETHERNET_USE_UDP
968 IPAddress remote_addr;
970 dns.
begin(RF24EthernetClass::_dnsServerAddress);
975 #if defined(ETH_DEBUG_L1) || defined(RF24ETHERNET_DEBUG_DNS)
976 Serial.println(F(
"*lwIP Got DNS*"));
978 return connect(remote_addr, port);
989#if defined(ETH_DEBUG_L1) || defined(RF24ETHERNET_DEBUG_DNS)
990 Serial.println(F(
"* DNS fail*"));
1001 if (data && data->state)
1006 data->packets_in = 0;
1009 if (data->state & UIP_CLIENT_REMOTECLOSED)
1015 data->state |= UIP_CLIENT_CLOSE;
1033 zsock_close(_socket);
1043void RF24Client::_stop()
1045 tcp_pcb* pcb = myPcb;
1048 if (pcb !=
nullptr) {
1049 #if defined RF24ETHERNET_CORE_REQUIRES_LOCKING
1051 ETHERNET_APPLY_LOCK();
1054 if (pcb->state != CLOSED) {
1056 tcp_recv(pcb, NULL);
1057 tcp_sent(pcb, NULL);
1060 err_t err = tcp_close(pcb);
1061 if (err != ERR_OK) {
1065 #if defined RF24ETHERNET_CORE_REQUIRES_LOCKING
1067 ETHERNET_REMOVE_LOCK();
1083 return data && rhs.data && (data == rhs.data);
1094RF24Client::operator bool()
1098 return data && (!(data->state & UIP_CLIENT_REMOTECLOSED) || data->packets_in != 0);
1111 return _write(data, &c, 1);
1118 return _write(data, buf, size);
1123size_t RF24Client::_write(uip_userdata_t* u,
const uint8_t* buf,
size_t size)
1125size_t RF24Client::_write(uint8_t* data,
const uint8_t* buf,
size_t size)
1132 size_t total_written = 0;
1133 size_t payloadSize = rf24_min(size, UIP_TCP_MSS);
1134 uint32_t start = millis();
1140 if (millis() - start > 5000)
1145 return total_written;
1148 if (u && !(u->state & (UIP_CLIENT_CLOSE | UIP_CLIENT_REMOTECLOSED)) && (u->state & UIP_CLIENT_CONNECTED))
1150 if (u->out_pos + payloadSize > UIP_TCP_MSS || u->hold)
1157 Serial.print(millis());
1158 Serial.print(F(
" UIPClient.write: writePacket("));
1159 Serial.print(u->packets_out);
1160 Serial.print(F(
") pos: "));
1161 Serial.print(u->out_pos);
1162 Serial.print(F(
", buf["));
1163 Serial.print(size - total_written);
1164 Serial.print(F(
"]: '"));
1165 Serial.write((uint8_t*)buf + total_written, payloadSize);
1166 Serial.println(F(
"'")););
1168 memcpy(u->myData + u->out_pos, buf + total_written, payloadSize);
1170 u->out_pos += payloadSize;
1171 total_written += payloadSize;
1173 if (total_written < size)
1175 size_t remain = size - total_written;
1176 payloadSize = rf24_min(remain, UIP_TCP_MSS);
1190 bool initialActiveState = activeState;
1191 size_t chunk = MAX_PAYLOAD_SIZE - 14;
1192 size_t position = 0;
1194 gState[initialActiveState]->waiting_for_ack =
false;
1195 uint32_t timeout = millis();
1196 while (size > chunk) {
1197 if (millis() - timeout > 3000) {
1200 if (myPcb ==
nullptr)
1203 gState[initialActiveState]->dataSentSize += chunk;
1204 err_t write_err = blocking_write(myPcb, gState[initialActiveState],
reinterpret_cast<const char*
>(&buf[position]), chunk);
1206 if (write_err != ERR_OK) {
1207 gState[initialActiveState]->result = write_err;
1208 gState[initialActiveState]->connected =
false;
1217 if (myPcb ==
nullptr)
1220 gState[initialActiveState]->dataSentSize += chunk;
1221 err_t write_err = blocking_write(myPcb, gState[initialActiveState],
reinterpret_cast<const char*
>(&buf[position]), size);
1223 if (write_err != ERR_OK) {
1224 gState[initialActiveState]->result = write_err;
1225 gState[initialActiveState]->connected =
false;
1230 return position + size;
1233 RF24Client* self = RF24Client::g_rf24client_instance;
1234 if (!self || !buf || size == 0)
1237 if (self->_socket < 0) {
1238 self->_lastError = ENOTCONN;
1243 while (total < size) {
1245 ssize_t n = zsock_send(self->_socket, buf + total, size - total, 0);
1255 self->_lastError = err;
1258 if (err == EAGAIN || err == EWOULDBLOCK)
1284 uip_userdata_t* u = (uip_userdata_t*)uip_conn->appstate;
1287 if (!u && uip_connected())
1291 u = (uip_userdata_t*)EthernetClient::_allocateData();
1295 uip_conn->appstate = u;
1304 #if UIP_CONNECTION_TIMEOUT > 0
1305 if (u && u->connectTimeout > 0) {
1306 if (millis() - u->connectTimer > u->connectTimeout) {
1307 u->state |= UIP_CLIENT_CLOSE;
1308 u->connectTimer = millis();
1319 IF_RF24ETHERNET_DEBUG_CLIENT(Serial.println(); Serial.print(millis()); Serial.print(F(
" UIPClient uip_newdata, uip_len:")); Serial.println(uip_len););
1320 #if UIP_CONNECTION_TIMEOUT > 0
1321 u->connectTimer = millis();
1323 u->hold = (u->out_pos = (u->windowOpened = (u->packets_out =
false)));
1325 if (uip_len && !(u->state & (UIP_CLIENT_CLOSE | UIP_CLIENT_REMOTECLOSED)))
1328 u->state &= ~UIP_CLIENT_RESTART;
1329 u->windowOpened =
false;
1330 u->restartTime = millis();
1332 uint16_t writePos = u->in_pos + u->dataCnt;
1333 uint16_t incomingLen = uip_datalen();
1337 memcpy(&u->myData[writePos], uip_appdata, incomingLen);
1338 u->dataCnt += incomingLen;
1344 Serial.println(F(
"UIPClient RX overflow, closing connection")););
1345 u->state |= UIP_CLIENT_CLOSE;
1353 if (uip_closed() || uip_timedout() || uip_aborted())
1361 ((uip_userdata_closed_t*)u)->lport = uip_conn->lport;
1362 u->state |= UIP_CLIENT_REMOTECLOSED;
1372 uip_conn->appstate = NULL;
1380 u->state &= ~UIP_CLIENT_RESTART;
1381 u->hold = (u->out_pos = (u->windowOpened = (u->packets_out =
false)));
1382 u->restartTime = millis();
1383 #if UIP_CONNECTION_TIMEOUT > 0
1384 u->connectTimer = millis();
1389 if (uip_poll() || uip_rexmit())
1394 uip_len = u->out_pos;
1395 uip_send(u->myData, u->out_pos);
1401 if (u->packets_out != 0 && !u->hold)
1403 uip_len = u->out_pos;
1404 uip_send(u->myData, u->out_pos);
1412 if (!(u->state & (UIP_CLIENT_CLOSE | UIP_CLIENT_REMOTECLOSED)))
1415 if (u->windowOpened ==
true && u->state & UIP_CLIENT_RESTART && millis() - u->restartTime > u->restartInterval)
1417 u->restartTime = millis();
1418 #if defined RF24ETHERNET_DEBUG_CLIENT || defined ETH_DEBUG_L1
1420 Serial.print(millis());
1421 #if UIP_CONNECTION_TIMEOUT > 0
1422 Serial.print(F(
" UIPClient Re-Open TCP Window, time remaining before abort: "));
1426 u->restartInterval += 500;
1427 u->restartInterval = rf24_min(u->restartInterval, 7000);
1434 if (u->state & UIP_CLIENT_CLOSE)
1438 if (u->packets_out == 0)
1441 uip_conn->appstate = NULL;
1453 if (u->state & UIP_CLIENT_RESTART && !u->windowOpened)
1455 if (!(u->state & (UIP_CLIENT_CLOSE | UIP_CLIENT_REMOTECLOSED)))
1458 #if defined ETH_DEBUG_L1
1460 Serial.print(millis());
1461 Serial.println(F(
" UIPClient Re-Open TCP Window"));
1463 u->windowOpened =
true;
1465 u->restartTime = millis();
1473uip_userdata_t* RF24Client::_allocateData()
1475 for (uint8_t sock = 0; sock < UIP_CONNS; sock++)
1477 uip_userdata_t* data = &RF24Client::all_data[sock];
1480 data->state = sock | UIP_CLIENT_CONNECTED;
1481 data->packets_in = 0;
1482 data->packets_out = 0;
1487 data->restartTime = millis();
1488 data->restartInterval = 5000;
1489 #if (UIP_CONNECTION_TIMEOUT > 0)
1490 data->connectTimer = millis();
1502 uint32_t start = millis();
1505 if (millis() - start > timeout)
1522 return _available(data);
1525 return _available(data);
1532int RF24Client::_available(uip_userdata_t* u)
1534int RF24Client::_available(uint8_t* data)
1543 return dataSize[activeState];
1546 RF24Client* self = RF24Client::g_rf24client_instance;
1547 if (!self || self->_socket < 0)
1551 struct zsock_pollfd pfd
1554 pfd.fd = self->_socket;
1555 pfd.events = ZSOCK_POLLIN;
1556 int pr = zsock_poll(&pfd, 1, 0);
1565 int n = zsock_recv(self->_socket, peekBuffer,
sizeof(peekBuffer),
1566 ZSOCK_MSG_PEEK | ZSOCK_MSG_DONTWAIT);
1572 if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR)
1586 if (!data->packets_in)
1592 data->state |= UIP_CLIENT_CLOSE;
1597 size = rf24_min(data->dataCnt, size);
1598 memcpy(buf, &data->myData[data->in_pos], size);
1599 data->dataCnt -= size;
1601 data->in_pos += size;
1605 data->packets_in = 0;
1608 if (uip_stopped(&uip_conns[data->state & UIP_CLIENT_SOCKETS]) && !(data->state & (UIP_CLIENT_CLOSE | UIP_CLIENT_REMOTECLOSED)))
1610 data->state |= UIP_CLIENT_RESTART;
1611 data->restartTime = 0;
1613 IF_ETH_DEBUG_L2(Serial.print(F(
"UIPClient set restart ")); Serial.println(data->state & UIP_CLIENT_SOCKETS); Serial.println(F(
"**")); Serial.println(data->state, BIN); Serial.println(F(
"**")); Serial.println(UIP_CLIENT_SOCKETS, BIN); Serial.println(F(
"**")););
1617 IF_ETH_DEBUG_L2(Serial.print(F(
"UIPClient stop?????? ")); Serial.println(data->state & UIP_CLIENT_SOCKETS); Serial.println(F(
"**")); Serial.println(data->state, BIN); Serial.println(F(
"**")); Serial.println(UIP_CLIENT_SOCKETS, BIN); Serial.println(F(
"**")););
1620 if (data->packets_in == 0)
1622 if (data->state & UIP_CLIENT_REMOTECLOSED)
1645 memcpy(&buf[0], &incomingData[
activeState][0], size);
1654 if (!buf || size == 0)
1657 _lastError = ENOTCONN;
1661 int n = zsock_recv(_socket, buf, size, ZSOCK_MSG_DONTWAIT);
1679 if (err == EAGAIN || err == EWOULDBLOCK || err == EINTR) {
1685 if (err == EBADF || err == ENOTSOCK) {
1698 if (
read(&c, 1) < 0)
1710 return data->myData[data->in_pos];
1728 data->packets_in = 0;
void dnsCallback(const char *name, const ip_addr_t *ipaddr, void *callback_arg)
#define INCOMING_DATA_SIZE
#define uip_ip_addr(addr, ip)
RF24EthernetClass RF24Ethernet
void begin(const IPAddress &aDNSServer)
int getHostByName(const char *aHostname, IPAddress &aResult)
virtual bool operator==(const EthernetClient &)
int connect(IPAddress ip, uint16_t port)
static void error_callback(void *arg, err_t err)
static err_t srecv_callback(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err)
int waitAvailable(uint32_t timeout=750)
static ConnectState * gState[2]
static err_t recv_callback(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err)
static err_t sent_callback(void *arg, struct tcp_pcb *tpcb, uint16_t len)
static bool connectionActive
#define IF_ETH_DEBUG_L2(x)
#define IF_RF24ETHERNET_DEBUG_CLIENT(x)
#define IF_ETH_DEBUG_L1(x)
#define UIP_CONNECTION_TIMEOUT
Optional: Uncomment to disable
#define OUTPUT_BUFFER_SIZE
#define UIP_WINDOW_REOPEN_DELAY
Optional: Used with UIP_CONNECTION_TIMEOUT
volatile bool stateActiveID
uint16_t u16_t
16 bit datatype
void serialip_appcall(void)