File tree Expand file tree Collapse file tree 8 files changed +316
-232
lines changed Expand file tree Collapse file tree 8 files changed +316
-232
lines changed Original file line number Diff line number Diff line change 1
- #ifndef ARDUINO_LWIP_ETHERNET_CLIENT_H
2
- #define ARDUINO_LWIP_ETHERNET_CLIENT_H
3
-
1
+ #pragma once
4
2
5
3
#include " lwipClient.h"
6
4
7
5
class EthernetClient : public lwipClient {
8
6
public:
9
- EthernetClient () {
10
- this ->bindCNetIf (Ethernet);
11
- }
12
- EthernetClient (struct tcp_pcb *pcb) : lwipClient(pcb) {
13
- this ->bindCNetIf (Ethernet);
14
- }
15
- };
7
+ EthernetClient () {
8
+ }
9
+ EthernetClient (struct tcp_pcb *pcb, lwipServer *server)
10
+ : lwipClient(pcb, server) {
11
+ }
12
+ EthernetClient (lwipClient c)
13
+ : lwipClient(c) {
14
+ }
15
+
16
+ int connect (IPAddress ip, uint16_t port) {
17
+ auto res = lwipClient::connect (ip, port);
16
18
17
- #endif
19
+ this ->bindCNetIf (Ethernet);
20
+
21
+ return res;
22
+ }
23
+ };
Original file line number Diff line number Diff line change 1
- #ifndef ARDUINO_LWIP_ETHERNET_SERVER_H
2
- #define ARDUINO_LWIP_ETHERNET_SERVER_H
3
-
4
-
1
+ #pragma once
5
2
6
3
#include " lwipServer.h"
7
4
#include " EthernetClient.h"
8
5
9
- class EthernetServer : public lwipServer {
10
- public:
11
- EthernetServer () {}
12
- EthernetServer (uint16_t port) : lwipServer(port) {}
13
-
14
- EthernetClient available () {
15
- accept ();
6
+ class EthernetServer : public lwipServer {
7
+ public:
8
+ void begin () {
9
+ lwipServer::begin ();
10
+ this ->bindCNetIf (WiFi);
11
+ }
16
12
17
- for (int n = 0 ; n < MAX_CLIENT; n++) {
18
- if (_tcp_client[n] != NULL ) {
19
- if (_tcp_client[n]->pcb != NULL ) {
20
- EthernetClient client (_tcp_client[n]);
21
- uint8_t s = client.status ();
22
- if (s == TCP_ACCEPTED) {
23
- if (client.available ()) {
24
- return client;
25
- }
26
- }
27
- }
28
- }
29
- }
30
-
31
- struct tcp_struct *default_client = NULL ;
32
- return EthernetClient (default_client);
33
- }
13
+ EthernetClient available () {
14
+ return EthernetClient (lwipServer::available ());
15
+ }
34
16
};
35
-
36
- #endif
Original file line number Diff line number Diff line change 1
- #ifndef ARDUINO_LWIP_WIFI_CLIENT_H
2
- #define ARDUINO_LWIP_WIFI_CLIENT_H
3
-
1
+ #pragma once
4
2
5
3
#include " lwipClient.h"
6
4
7
- class WiFiClient : public lwipClient {
8
- public:
9
- WiFiClient () {
10
- this ->bindCNetIf (WiFi);
11
- }
12
- WiFiClient (struct tcp_pcb *pcb) : lwipClient(pcb) {
13
- this ->bindCNetIf (WiFi);
14
- }
15
- };
5
+ class WiFiClient : public lwipClient {
6
+ public:
7
+ WiFiClient () {
8
+ }
9
+ WiFiClient (struct tcp_pcb *pcb, lwipServer *server)
10
+ : lwipClient(pcb, server) {
11
+ }
12
+ WiFiClient (lwipClient c)
13
+ : lwipClient(c) {
14
+ }
16
15
17
- #endif
16
+ int connect (IPAddress ip, uint16_t port) {
17
+ auto res = lwipClient::connect (ip, port);
18
18
19
+ this ->bindCNetIf (WiFi);
20
+
21
+ return res;
22
+ }
23
+ };
Original file line number Diff line number Diff line change 1
- #ifndef ARDUINO_LWIP_WIFI_SERVER_H
2
- #define ARDUINO_LWIP_WIFI_SERVER_H
3
-
1
+ #pragma once
4
2
5
3
#include " lwipServer.h"
6
- #include " WiFiClient.h"
7
-
8
- class WiFiServer : public lwipServer {
9
- public:
10
- WiFiServer () {}
11
- WiFiServer (uint16_t port) : lwipServer(port) {}
4
+ #include " lwipClient.h"
12
5
13
- WiFiClient available () {
14
- accept ();
6
+ class WiFiServer : public lwipServer {
7
+ public:
8
+ void begin () {
9
+ lwipServer::begin ();
10
+ this ->bindCNetIf (WiFi);
11
+ }
15
12
16
- for (int n = 0 ; n < MAX_CLIENT; n++) {
17
- if (_tcp_client[n] != NULL ) {
18
- if (_tcp_client[n]->pcb != NULL ) {
19
- WiFiClient client (_tcp_client[n]);
20
- uint8_t s = client.status ();
21
- if (s == TCP_ACCEPTED) {
22
- if (client.available ()) {
23
- return client;
24
- }
25
- }
26
- }
27
- }
28
- }
29
-
30
- struct tcp_struct *default_client = NULL ;
31
- return WiFiClient (default_client);
32
- }
13
+ WiFiClient available () {
14
+ return WiFiClient (lwipServer::available ());
15
+ }
33
16
};
34
-
35
- #endif
You can’t perform that action at this time.
0 commit comments