File tree 4 files changed +25
-8
lines changed
4 files changed +25
-8
lines changed Original file line number Diff line number Diff line change 5
5
#include " lwipClient.h"
6
6
7
7
class EthernetClient : public lwipClient {
8
- public:
9
- EthernetClient () {}
10
- EthernetClient (struct tcp_struct *tcpClient) : lwipClient() {} // FIXME
8
+ public:
9
+ EthernetClient () {
10
+ this ->bindCNetIf (Ethernet);
11
+ }
12
+ EthernetClient (struct tcp_pcb *pcb) : lwipClient(pcb) {
13
+ this ->bindCNetIf (Ethernet);
14
+ }
11
15
};
12
16
13
17
#endif
Original file line number Diff line number Diff line change 6
6
7
7
class WiFiClient : public lwipClient {
8
8
public:
9
- WiFiClient () {}
10
- WiFiClient (struct tcp_struct *tcpClient) : lwipClient(tcpClient) {}
9
+ WiFiClient () {
10
+ this ->bindCNetIf (WiFi);
11
+ }
12
+ WiFiClient (struct tcp_pcb *pcb) : lwipClient(pcb) {
13
+ this ->bindCNetIf (WiFi);
14
+ }
11
15
};
12
16
13
17
#endif
Original file line number Diff line number Diff line change @@ -97,6 +97,7 @@ typedef enum {
97
97
#define INVALID_RESPONSE -4
98
98
99
99
class CLwipIf ;
100
+ class lwipClient ;
100
101
101
102
/* Base class implements DHCP, derived class will switch it on or off */
102
103
class CNetIf : public NetworkInterface {
@@ -238,7 +239,7 @@ class CWifiStation : public CNetIf {
238
239
239
240
virtual void task () override ;
240
241
241
- virtual int getMacAddress (uint8_t * mac) override ;
242
+ virtual int getMacAddress (uint8_t * mac) override {}
242
243
243
244
virtual const char * getSSID ();
244
245
virtual uint8_t * getBSSID (uint8_t * bssid);
@@ -277,7 +278,7 @@ class CWifiSoftAp : public CNetIf {
277
278
int startSoftAp (const char * ssid, const char * passphrase=nullptr , uint8_t channel=0 );
278
279
int stopSoftAp ();
279
280
280
- virtual int getMacAddress (uint8_t * mac) override ;
281
+ virtual int getMacAddress (uint8_t * mac) override {}
281
282
282
283
virtual const char * getSSID ();
283
284
virtual uint8_t * getBSSID (uint8_t * bssid);
@@ -357,3 +358,6 @@ class CLwipIf {
357
358
FspTimer timer;
358
359
#endif
359
360
};
361
+
362
+ extern CEth Ethernet;
363
+ extern CWifiStation WiFi;
Original file line number Diff line number Diff line change 3
3
#include < lwip/include/lwip/tcp.h>
4
4
#include < IPAddress.h>
5
5
#include < Print.h>
6
+ #include " CNetIf.h"
6
7
7
8
// TODO improve documentation
8
9
@@ -67,6 +68,10 @@ class lwipClient : public arduino::Client {
67
68
_timeout = timeout;
68
69
}
69
70
71
+ void bindCNetIf (CNetIf &n) {
72
+ tcp_bind_netif (this ->pcb , n.getNi ());
73
+ }
74
+
70
75
friend class lwipServer ;
71
76
72
77
using Print::write;
@@ -82,7 +87,7 @@ class lwipClient : public arduino::Client {
82
87
// TCP related info of the socket
83
88
_tcp_state_t state = TCP_NONE;
84
89
struct pbuf * pbuf_head = nullptr ;
85
- struct tcp_pcb * pcb = nullptr ;
90
+ struct tcp_pcb * pcb = nullptr ;
86
91
uint16_t pbuf_offset = 0 ;
87
92
88
93
uint16_t _timeout = 10000 ;
You can’t perform that action at this time.
0 commit comments