mirror of
https://github.com/cesanta/mongoose.git
synced 2026-12-04 21:58:22 +00:00
add support for NXP Wifi in RW612, in an example
This commit is contained in:
1 parent
1f56776050
commit
81c166ad74
371 files changed
+321791
-2
No files matched your search
+97
-1
@@ -20196,7 +20196,8 @@ void mg_free(void *ptr) {
|
||||
|
||||
#if (!defined(MG_ENABLE_DRIVER_PICO_W) || !MG_ENABLE_DRIVER_PICO_W) && \
|
||||
(!defined(MG_ENABLE_DRIVER_CYW) || !MG_ENABLE_DRIVER_CYW) && \
|
||||
(!defined(MG_ENABLE_DRIVER_CYW_SDIO) || !MG_ENABLE_DRIVER_CYW_SDIO)
|
||||
(!defined(MG_ENABLE_DRIVER_CYW_SDIO) || !MG_ENABLE_DRIVER_CYW_SDIO) && \
|
||||
(!defined(MG_ENABLE_DRIVER_NXP_WIFI) || !MG_ENABLE_DRIVER_NXP_WIFI)
|
||||
|
||||
|
||||
bool mg_wifi_scan(void) {
|
||||
@@ -22297,6 +22298,101 @@ struct mg_tcpip_driver mg_tcpip_driver_imxrt = {mg_tcpip_driver_imxrt_init,
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef MG_ENABLE_LINES
|
||||
#line 1 "src/drivers/nxp_wifi.c"
|
||||
#endif
|
||||
#if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_NXP_WIFI) && \
|
||||
MG_ENABLE_DRIVER_NXP_WIFI
|
||||
|
||||
|
||||
|
||||
bool __attribute__((weak)) netif_init(struct mg_tcpip_if *ifp) {
|
||||
(void) ifp;
|
||||
MG_ERROR(("Please link wifi/net/port/ contents"));
|
||||
return false;
|
||||
}
|
||||
size_t __attribute__((weak))
|
||||
netif_tx(const void *bfr, size_t len, struct mg_tcpip_if *ifp) {
|
||||
(void) bfr;
|
||||
(void) len;
|
||||
netif_init(ifp);
|
||||
return 0;
|
||||
}
|
||||
bool __attribute__((weak)) netif_connect(struct mg_wifi_data *wifi) {
|
||||
(void) wifi;
|
||||
return netif_init(NULL);
|
||||
}
|
||||
bool __attribute__((weak))
|
||||
netif_poll(struct mg_tcpip_if *ifp, bool s1, mg_tcpip_event_handler_t evcb) {
|
||||
(void) ifp;
|
||||
(void) s1;
|
||||
(void) evcb;
|
||||
return false;
|
||||
}
|
||||
|
||||
static struct mg_tcpip_if *s_ifp;
|
||||
static uint32_t s_ip, s_mask;
|
||||
|
||||
static void wifi_cb(struct mg_tcpip_if *ifp, int ev, void *ev_data) {
|
||||
struct mg_wifi_data *wifi =
|
||||
&((struct mg_tcpip_driver_nxp_wifi_data *) ifp->driver_data)->wifi;
|
||||
if (wifi->apmode && ev == MG_TCPIP_EV_ST_CHG &&
|
||||
*(uint8_t *) ev_data == MG_TCPIP_STATE_UP) {
|
||||
MG_DEBUG(("Access Point started"));
|
||||
s_ip = ifp->ip, ifp->ip = wifi->apip;
|
||||
s_mask = ifp->mask, ifp->mask = wifi->apmask;
|
||||
ifp->enable_dhcp_client = false;
|
||||
ifp->enable_dhcp_server = true;
|
||||
}
|
||||
}
|
||||
|
||||
static bool nxp_wifi_init(struct mg_tcpip_if *ifp) {
|
||||
struct mg_wifi_data *wifi =
|
||||
&((struct mg_tcpip_driver_nxp_wifi_data *) ifp->driver_data)->wifi;
|
||||
s_ifp = ifp;
|
||||
s_ip = ifp->ip;
|
||||
s_mask = ifp->mask;
|
||||
ifp->pfn = wifi_cb;
|
||||
if (!netif_init(ifp)) return false;
|
||||
if (wifi->apmode) {
|
||||
return mg_wifi_ap_start(wifi);
|
||||
} else if (wifi->ssid != NULL && wifi->pass != NULL) {
|
||||
return mg_wifi_connect(wifi);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool nxp_wifi_poll(struct mg_tcpip_if *ifp, bool s1) {
|
||||
return netif_poll(ifp, s1, mg_tcpip_call);
|
||||
}
|
||||
|
||||
struct mg_tcpip_driver mg_tcpip_driver_nxp_wifi = {nxp_wifi_init, netif_tx,
|
||||
NULL, nxp_wifi_poll};
|
||||
|
||||
bool mg_wifi_connect(struct mg_wifi_data *wifi) {
|
||||
s_ifp->ip = s_ip;
|
||||
s_ifp->mask = s_mask;
|
||||
if (s_ifp->ip == 0) s_ifp->enable_dhcp_client = true;
|
||||
s_ifp->enable_dhcp_server = false;
|
||||
return netif_connect(wifi);
|
||||
}
|
||||
|
||||
bool __attribute__((weak)) mg_wifi_scan(void) {
|
||||
return netif_init(NULL);
|
||||
}
|
||||
bool __attribute__((weak)) mg_wifi_disconnect(void) {
|
||||
return netif_init(NULL);
|
||||
}
|
||||
bool __attribute__((weak)) mg_wifi_ap_start(struct mg_wifi_data *wifi) {
|
||||
(void) wifi;
|
||||
return netif_init(NULL);
|
||||
}
|
||||
bool __attribute__((weak)) mg_wifi_ap_stop(void) {
|
||||
return netif_init(NULL);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef MG_ENABLE_LINES
|
||||
#line 1 "src/drivers/phy.c"
|
||||
#endif
|
||||
|
||||
Reference in new issue
Block a user