mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-10 16:31:44 +00:00
Change driver API: up(ifp) -> poll(ifp, 1second)
Add misc extras required by Wi-Fi drivers (in progress)
This commit is contained in:
1 parent
8906b1ac0f
commit
065027843e
30 files changed
+359
-248
No files matched your search
+28
-7
@@ -11,21 +11,42 @@ struct mg_tcpip_driver {
|
||||
bool (*init)(struct mg_tcpip_if *); // Init driver
|
||||
size_t (*tx)(const void *, size_t, struct mg_tcpip_if *); // Transmit frame
|
||||
size_t (*rx)(void *buf, size_t len, struct mg_tcpip_if *); // Receive frame
|
||||
bool (*up)(struct mg_tcpip_if *); // Up/down status
|
||||
bool (*poll)(struct mg_tcpip_if *, bool); // Poll, return Up/down status
|
||||
};
|
||||
|
||||
typedef void (*mg_tcpip_event_handler_t)(struct mg_tcpip_if *ifp, int ev,
|
||||
void *ev_data);
|
||||
|
||||
enum {
|
||||
MG_TCPIP_EV_ST_CHG, // state change uint8_t * (&ifp->state)
|
||||
MG_TCPIP_EV_DHCP_DNS, // DHCP DNS assignment uint32_t *ipaddr
|
||||
MG_TCPIP_EV_DHCP_SNTP, // DHCP SNTP assignment uint32_t *ipaddr
|
||||
MG_TCPIP_EV_ARP, // Got ARP packet struct mg_str *
|
||||
MG_TCPIP_EV_TIMER_1S, // 1 second timer NULL
|
||||
MG_TCPIP_EV_USER // Starting ID for user events
|
||||
MG_TCPIP_EV_ST_CHG, // state change uint8_t * (&ifp->state)
|
||||
MG_TCPIP_EV_DHCP_DNS, // DHCP DNS assignment uint32_t *ipaddr
|
||||
MG_TCPIP_EV_DHCP_SNTP, // DHCP SNTP assignment uint32_t *ipaddr
|
||||
MG_TCPIP_EV_ARP, // Got ARP packet struct mg_str *
|
||||
MG_TCPIP_EV_TIMER_1S, // 1 second timer NULL
|
||||
MG_TCPIP_EV_WIFI_SCAN_RESULT, // Wi-Fi scan results struct mg_wifi_scan_bss_data *
|
||||
MG_TCPIP_EV_WIFI_SCAN_END, // Wi-Fi scan has finished NULL
|
||||
MG_TCPIP_EV_WIFI_CONNECT_ERR, // Wi-Fi connect has failed chip specific
|
||||
MG_TCPIP_EV_USER // Starting ID for user events
|
||||
};
|
||||
|
||||
struct mg_wifi_scan_bss_data {
|
||||
struct mg_str SSID;
|
||||
char *BSSID;
|
||||
int16_t RSSI;
|
||||
uint8_t security;
|
||||
#define MG_WIFI_SECURITY_OPEN 0
|
||||
#define MG_WIFI_SECURITY_WEP MG_BIT(0)
|
||||
#define MG_WIFI_SECURITY_WPA MG_BIT(1)
|
||||
#define MG_WIFI_SECURITY_WPA2 MG_BIT(2)
|
||||
#define MG_WIFI_SECURITY_WPA3 MG_BIT(3)
|
||||
uint8_t channel;
|
||||
unsigned band :2;
|
||||
#define MG_WIFI_BAND_2G 0
|
||||
#define MG_WIFI_BAND_5G 1
|
||||
unsigned has_n :1;
|
||||
};
|
||||
|
||||
|
||||
// Network interface
|
||||
struct mg_tcpip_if {
|
||||
uint8_t mac[6]; // MAC address. Must be set to a valid MAC
|
||||
|
||||
Reference in new issue
Block a user