mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-20 19:41:58 +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
+27
-14
@@ -1,8 +1,8 @@
|
||||
#if MG_ENABLE_TCPIP && MG_ARCH == MG_ARCH_PICOSDK && \
|
||||
defined(MG_ENABLE_DRIVER_PICO_W) && MG_ENABLE_DRIVER_PICO_W
|
||||
|
||||
#include "net_builtin.h"
|
||||
#include "drivers/pico-w.h"
|
||||
#include "net_builtin.h"
|
||||
#include "pico/stdlib.h"
|
||||
|
||||
static struct mg_tcpip_if *s_ifp;
|
||||
@@ -13,12 +13,19 @@ static bool mg_tcpip_driver_pico_w_init(struct mg_tcpip_if *ifp) {
|
||||
s_ifp = ifp;
|
||||
if (cyw43_arch_init() != 0)
|
||||
return false; // initialize async_context and WiFi chip
|
||||
cyw43_arch_enable_sta_mode();
|
||||
// start connecting to network
|
||||
if (cyw43_arch_wifi_connect_bssid_async(d->ssid, NULL, d->pass,
|
||||
CYW43_AUTH_WPA2_AES_PSK) != 0)
|
||||
return false;
|
||||
cyw43_wifi_get_mac(&cyw43_state, CYW43_ITF_STA, ifp->mac);
|
||||
if (d->apmode && d->apssid != NULL){
|
||||
MG_DEBUG(("Starting AP '%s' (%u)", d->apssid, d->apchannel));
|
||||
cyw43_wifi_ap_set_channel(&cyw43_state, d->apchannel);
|
||||
cyw43_arch_enable_ap_mode(d->apssid, d->appass, CYW43_AUTH_WPA2_AES_PSK);
|
||||
cyw43_wifi_get_mac(&cyw43_state, CYW43_ITF_STA, ifp->mac);
|
||||
} else {
|
||||
cyw43_arch_enable_sta_mode();
|
||||
cyw43_wifi_get_mac(&cyw43_state, CYW43_ITF_AP, ifp->mac);
|
||||
if (d->ssid != NULL && d->pass != NULL) {
|
||||
MG_DEBUG(("Connecting to '%s'", d->ssid));
|
||||
return (cyw43_arch_wifi_connect_bssid_async(d->ssid, NULL, d->pass, CYW43_AUTH_WPA2_AES_PSK) == 0);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -30,17 +37,19 @@ static size_t mg_tcpip_driver_pico_w_tx(const void *buf, size_t len,
|
||||
: len;
|
||||
}
|
||||
|
||||
static bool mg_tcpip_driver_pico_w_up(struct mg_tcpip_if *ifp) {
|
||||
static bool mg_tcpip_driver_pico_w_poll(struct mg_tcpip_if *ifp, bool s1) {
|
||||
(void) ifp;
|
||||
return (cyw43_wifi_link_status(&cyw43_state, CYW43_ITF_STA) ==
|
||||
CYW43_LINK_JOIN);
|
||||
cyw43_arch_poll(); // not necessary, except when IRQs are disabled (OTA)
|
||||
return s1 ? (cyw43_wifi_link_status(&cyw43_state, CYW43_ITF_STA) ==
|
||||
CYW43_LINK_JOIN)
|
||||
: false;
|
||||
}
|
||||
|
||||
struct mg_tcpip_driver mg_tcpip_driver_pico_w = {
|
||||
mg_tcpip_driver_pico_w_init,
|
||||
mg_tcpip_driver_pico_w_tx,
|
||||
NULL,
|
||||
mg_tcpip_driver_pico_w_up,
|
||||
mg_tcpip_driver_pico_w_poll,
|
||||
};
|
||||
|
||||
// Called once per outstanding frame by async_context
|
||||
@@ -52,10 +61,14 @@ void cyw43_cb_process_ethernet(void *cb_data, int itf, size_t len,
|
||||
}
|
||||
|
||||
// Called by async_context
|
||||
void cyw43_cb_tcpip_set_link_up(cyw43_t *self, int itf) {}
|
||||
void cyw43_cb_tcpip_set_link_down(cyw43_t *self, int itf) {}
|
||||
void cyw43_cb_tcpip_set_link_up(cyw43_t *self, int itf) {
|
||||
}
|
||||
void cyw43_cb_tcpip_set_link_down(cyw43_t *self, int itf) {
|
||||
}
|
||||
|
||||
// there's life beyond lwIP
|
||||
void pbuf_copy_partial(void) {(void) 0;}
|
||||
void pbuf_copy_partial(void) {
|
||||
(void) 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user