-
Notifications
You must be signed in to change notification settings - Fork 2
/
w5500-lwIP.h
83 lines (63 loc) · 2.32 KB
/
w5500-lwIP.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#ifndef W5500LWIP_H
#define W5500LWIP_H
#include <lwip/netif.h>
#include <lwip/tcpip.h>
#include "w5500.h"
#ifdef ESP32
#include <SPI.h>
#define SPIparam(x...) x
#else
#define SPIparam(x...)
#endif
template< class T > class Wiznet5500lwIPQueue
{
public:
Wiznet5500lwIPQueue(int = 10);
~Wiznet5500lwIPQueue()
{
delete[] values;
}
bool enQueue(T);
T deQueue();
bool isEmpty();
bool isFull();
private:
SemaphoreHandle_t m;
int size;
T *values;
int front;
int back;
};
class Wiznet5500lwIP: public Wiznet5500 {
public:
Wiznet5500lwIP (int8_t cs=SS): Wiznet5500(cs)
{
}
// start with dhcp client
// default mac-address is inferred(+modified) from esp8266's STA one
//boolean begin (SPIparam(SPIClass& spi,) const uint8_t *macAddress = NULL, uint16_t mtu = 1500); MANU
//boolean begin (const uint8_t *macAddress = NULL, uint16_t mtu = 1500);
boolean begin (uint8_t *mac_address = NULL);
boolean begin (uint8_t *mac_address, IPAddress local_ip , IPAddress subnet , IPAddress gateway );
boolean begin (uint8_t *mac_address , IPAddress local_ip , IPAddress subnet , IPAddress gateway , IPAddress dns_server);
const netif* getNetIf () const { return &_netif; }
IPAddress localIP () const { return IPAddress(_netif.ip_addr.u_addr.ip4.addr); }
IPAddress subnetMask () const { return IPAddress(_netif.netmask.u_addr.ip4.addr); }
IPAddress gatewayIP () const { return IPAddress(_netif.gw.u_addr.ip4.addr); }
void lwiptcpip_callback();
err_t loop();
protected:
netif _netif;
uint16_t _mtu;
err_t start_with_dhclient ();
//err_t start_with_static_address (IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = (uint32_t)0x00000000, IPAddress dns2 = (uint32_t)0x00000000);
//err_t start_with_static_address (IPAddress local_ip, IPAddress gateway, IPAddress subnet);
err_t start_with_static_address ();
//bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = (uint32_t)0x00000000, IPAddress dns2 = (uint32_t)0x00000000);
err_t netif_init ();
static err_t netif_init_s (netif* netif);
static err_t linkoutput_s (netif *netif, struct pbuf *p);
tcpip_callback_msg *_callbackmsg;
Wiznet5500lwIPQueue<struct pbuf*> _pbufqueue;
};
#endif // W5500LWIP_H