File tree Expand file tree Collapse file tree 4 files changed +25
-8
lines changed Expand file tree Collapse file tree 4 files changed +25
-8
lines changed Original file line number Diff line number Diff line change 55#include " lwipClient.h"
66
77class 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+ }
1115};
1216
1317#endif
Original file line number Diff line number Diff line change 66
77class WiFiClient : public lwipClient {
88 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+ }
1115};
1216
1317#endif
Original file line number Diff line number Diff line change @@ -97,6 +97,7 @@ typedef enum {
9797#define INVALID_RESPONSE -4
9898
9999class CLwipIf ;
100+ class lwipClient ;
100101
101102/* Base class implements DHCP, derived class will switch it on or off */
102103class CNetIf : public NetworkInterface {
@@ -238,7 +239,7 @@ class CWifiStation : public CNetIf {
238239
239240 virtual void task () override ;
240241
241- virtual int getMacAddress (uint8_t * mac) override ;
242+ virtual int getMacAddress (uint8_t * mac) override {}
242243
243244 virtual const char * getSSID ();
244245 virtual uint8_t * getBSSID (uint8_t * bssid);
@@ -277,7 +278,7 @@ class CWifiSoftAp : public CNetIf {
277278 int startSoftAp (const char * ssid, const char * passphrase=nullptr , uint8_t channel=0 );
278279 int stopSoftAp ();
279280
280- virtual int getMacAddress (uint8_t * mac) override ;
281+ virtual int getMacAddress (uint8_t * mac) override {}
281282
282283 virtual const char * getSSID ();
283284 virtual uint8_t * getBSSID (uint8_t * bssid);
@@ -357,3 +358,6 @@ class CLwipIf {
357358 FspTimer timer;
358359#endif
359360};
361+
362+ extern CEth Ethernet;
363+ extern CWifiStation WiFi;
Original file line number Diff line number Diff line change 33#include < lwip/include/lwip/tcp.h>
44#include < IPAddress.h>
55#include < Print.h>
6+ #include " CNetIf.h"
67
78// TODO improve documentation
89
@@ -67,6 +68,10 @@ class lwipClient : public arduino::Client {
6768 _timeout = timeout;
6869 }
6970
71+ void bindCNetIf (CNetIf &n) {
72+ tcp_bind_netif (this ->pcb , n.getNi ());
73+ }
74+
7075 friend class lwipServer ;
7176
7277 using Print::write;
@@ -82,7 +87,7 @@ class lwipClient : public arduino::Client {
8287 // TCP related info of the socket
8388 _tcp_state_t state = TCP_NONE;
8489 struct pbuf * pbuf_head = nullptr ;
85- struct tcp_pcb * pcb = nullptr ;
90+ struct tcp_pcb * pcb = nullptr ;
8691 uint16_t pbuf_offset = 0 ;
8792
8893 uint16_t _timeout = 10000 ;
You can’t perform that action at this time.
0 commit comments