From 9f4e6a25bdc40c5052a7cebe9c5c9969eb759d19 Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 24 Nov 2026 16:49:19 +0200 Subject: [PATCH] Fix unamalgamation for the rest of the drivers --- mongoose.c | 71 ++++++++++++++++++++++++++++++++++---- mongoose.h | 15 +++++++- src/arch.h | 2 ++ src/drivers/at_cmd.c | 2 ++ src/drivers/cmsis.c | 4 ++- src/drivers/cyw.c | 9 +++-- src/drivers/cyw.h | 2 ++ src/drivers/esp32_802154.c | 1 + src/drivers/imxrt.c | 3 ++ src/drivers/mcxw71.c | 1 + src/drivers/mg24.c | 1 + src/drivers/netc.c | 3 ++ src/drivers/nrf52.c | 1 + src/drivers/nxp_wifi.c | 2 ++ src/drivers/nxp_wifi.h | 2 ++ src/drivers/pico-w.c | 10 ++++-- src/drivers/pico-w.h | 2 ++ src/drivers/ra.c | 3 ++ src/drivers/rw612.c | 3 ++ src/drivers/rw612w.c | 1 + src/drivers/same54.c | 3 ++ src/drivers/sdio.c | 2 ++ src/drivers/st67w6.c | 7 ++-- src/drivers/st67w6.h | 2 ++ src/drivers/tm4c.c | 2 ++ src/drivers/tms570.c | 3 ++ src/drivers/xmc.c | 3 ++ src/drivers/xmc7.c | 3 ++ src/net_builtin.c | 4 +-- src/net_builtin.h | 5 ++- src/ota_ch32v307.c | 1 + src/ota_esp32.c | 2 ++ src/ota_imxrt.c | 1 + src/ota_mcxn.c | 1 + src/ota_mcxw71.c | 1 + src/ota_picosdk.c | 1 + src/ota_rw612.c | 1 + 37 files changed, 162 insertions(+), 18 deletions(-) diff --git a/mongoose.c b/mongoose.c index 08ddf035..6e41a8c0 100644 --- a/mongoose.c +++ b/mongoose.c @@ -10050,7 +10050,7 @@ uint8_t mg_l2_ip6put(enum mg_l2type type, uint8_t *addr, uint8_t *opts); #endif bool mg_l2_poll(struct mg_tcpip_if *ifp, bool expired_1000ms); -static void mg_tcpip_call(struct mg_tcpip_if *ifp, int ev, void *ev_data) { +void mg_tcpip_call(struct mg_tcpip_if *ifp, int ev, void *ev_data) { #if 0 && MG_ENABLE_PROFILE const char *names[] = {"TCPIP_EV_STATE_CHANGE", "TCPIP_EV_DHCP_DNS", "TCPIP_EV_DHCP_SNTP", "TCPIP_EV_ARP", @@ -12343,7 +12343,7 @@ bool mg_send(struct mg_connection *c, const void *buf, size_t len) { return res; } -uint8_t mcast_addr[6] = {0x01, 0x00, 0x5e, 0x00, 0x00, 0xfb}; +const uint8_t mcast_addr[6] = {0x01, 0x00, 0x5e, 0x00, 0x00, 0xfb}; void mg_multicast_add(struct mg_connection *c, char *ip) { (void) ip; // ip4/6_mcastmac(mcast_mac, &ip); ipv6 param // TODO(): actual IP -> MAC; check database, update @@ -12685,6 +12685,7 @@ void mg_ota_poll(struct mg_mgr *mgr) { + #if MG_OTA == MG_OTA_CH32V307 // RM: https://www.wch-ic.com/downloads/CH32FV2x_V3xRM_PDF.html @@ -12820,6 +12821,8 @@ bool mg_ota_end(void) { #endif + + #if MG_ARCH == MG_ARCH_ESP32 && MG_OTA == MG_OTA_ESP32 static const esp_partition_t *s_ota_update_partition; @@ -12882,6 +12885,7 @@ bool mg_ota_end(void) { + #if MG_OTA >= MG_OTA_RT1020 && MG_OTA <= MG_OTA_RT1180 static bool mg_imxrt_write(void *, const void *, size_t); @@ -13512,6 +13516,7 @@ struct mg_flash *mg_flash = &s_mg_flash_imxrt; + #if MG_OTA == MG_OTA_MCXN // - Flash phrase: 16 bytes; smallest portion programmed in one operation. @@ -13726,6 +13731,7 @@ struct mg_flash *mg_flash = &s_mg_flash_mcxn; + #if MG_OTA == MG_OTA_MCXW71 // MCXW71SRM, section 11.2: ROM flash API, 8 KB sectors, 16-byte phrases, @@ -13911,6 +13917,7 @@ bool mg_ota_end(void) { + #if MG_OTA == MG_OTA_PICOSDK // Both RP2040 and RP2350 have no flash, low-level flash access support in @@ -14094,6 +14101,7 @@ struct mg_flash *mg_flash = &s_mg_flash_picosdk; + #if MG_OTA == MG_OTA_RW612 MG_IRAM static bool mg_frdm_write(void *, const void *, size_t); @@ -30992,6 +31000,8 @@ size_t mg_ws_wrap(struct mg_connection *c, size_t len, int op) { #endif + + #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_ATCMD) && MG_ENABLE_DRIVER_ATCMD #define MG_HDLC_FLAG 0x7e // HDLC frame delimiter @@ -31151,6 +31161,8 @@ static bool byte_unstuff(struct mg_tcpip_driver_atcmd_data *dd, uint8_t *p) { #endif // https://arm-software.github.io/CMSIS_5/Driver/html/index.html + + #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_CMSIS) && MG_ENABLE_DRIVER_CMSIS @@ -31284,6 +31296,9 @@ static size_t cmsis_rx(void *buf, size_t buflen, struct mg_tcpip_if *ifp) { + +#include + #if MG_ENABLE_TCPIP && \ ((defined(MG_ENABLE_DRIVER_CYW) && MG_ENABLE_DRIVER_CYW) || \ (defined(MG_ENABLE_DRIVER_CYW_SDIO) && MG_ENABLE_DRIVER_CYW_SDIO)) @@ -32158,8 +32173,10 @@ static void cyw_update_hash_table(void) { // TODO(): read database, rebuild hash table uint32_t val = 0; val = 1; + uint8_t mac[sizeof(mcast_addr)]; // copy from const uint8_t* to uint8_t* + memcpy(mac, mcast_addr, sizeof(mac)); cyw_ioctl_iovar_set2_(0, "mcast_list", (uint8_t *) &val, sizeof(val), - (uint8_t *) mcast_addr, sizeof(mcast_addr)); + mac, sizeof(mac)); mg_delayms(50); } @@ -32704,6 +32721,7 @@ bool mg_wifi_ap_stop(void) { + #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_ESP32_802154) && \ MG_ENABLE_DRIVER_ESP32_802154 @@ -32897,6 +32915,9 @@ struct mg_tcpip_driver mg_tcpip_driver_esp32_802154 = { #endif + + + #if MG_ENABLE_TCPIP && \ (defined(MG_ENABLE_DRIVER_IMXRT10) && MG_ENABLE_DRIVER_IMXRT10) || \ (defined(MG_ENABLE_DRIVER_IMXRT11) && MG_ENABLE_DRIVER_IMXRT11) || \ @@ -33126,6 +33147,7 @@ struct mg_tcpip_driver mg_tcpip_driver_imxrt = {mg_tcpip_driver_imxrt_init, + #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_MCXW71) && \ MG_ENABLE_DRIVER_MCXW71 @@ -33352,6 +33374,7 @@ struct mg_tcpip_driver mg_tcpip_driver_mcxw71 = { + #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_MG24) && MG_ENABLE_DRIVER_MG24 #include @@ -33525,6 +33548,9 @@ struct mg_tcpip_driver mg_tcpip_driver_mg24 = {mgi_mg24_init, mgi_mg24_tx, #endif + + + #if defined(MG_ENABLE_TCPIP) && MG_ENABLE_TCPIP && \ defined(MG_ENABLE_DRIVER_NETC) && MG_ENABLE_DRIVER_NETC @@ -33999,6 +34025,7 @@ struct mg_tcpip_driver mg_tcpip_driver_netc = {mg_tcpip_driver_netc_init, + #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_NRF52) && MG_ENABLE_DRIVER_NRF52 #include @@ -34167,6 +34194,8 @@ struct mg_tcpip_driver mg_tcpip_driver_nrf52 = {mgi_nrf52_init, mgi_nrf52_tx, #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 @@ -34470,6 +34499,8 @@ bool mg_phy_up(struct mg_phy *phy, uint8_t phy_addr, bool *full_duplex, #ifdef MG_ENABLE_LINES #line 1 "src/drivers/pico-w.c" #endif + + #if MG_ENABLE_TCPIP && MG_ARCH == MG_ARCH_PICOSDK && \ defined(MG_ENABLE_DRIVER_PICO_W) && MG_ENABLE_DRIVER_PICO_W @@ -34477,6 +34508,7 @@ bool mg_phy_up(struct mg_phy *phy, uint8_t phy_addr, bool *full_duplex, + static struct mg_tcpip_if *s_ifp; static uint32_t s_ip, s_mask; static bool s_aplink = false, s_scanning = false; @@ -34540,8 +34572,9 @@ static bool mg_tcpip_driver_pico_w_poll(struct mg_tcpip_if *ifp, bool s1) { } if (ifp->update_mac_hash_table) { // first call to _poll() is after _init(), so this is safe - cyw43_wifi_update_multicast_filter(&cyw43_state, (uint8_t *) mcast_addr, - true); + uint8_t mac[sizeof(mcast_addr)]; // copy from const uint8_t* to uint8_t* + memcpy(mac, mcast_addr, sizeof(mac)); + cyw43_wifi_update_multicast_filter(&cyw43_state, mac, true); ifp->update_mac_hash_table = false; } if (!s1) return false; @@ -34662,6 +34695,9 @@ bool mg_wifi_ap_stop(void) { #endif + + + #if MG_ENABLE_TCPIP && \ (defined(MG_ENABLE_DRIVER_RA6) && MG_ENABLE_DRIVER_RA6) || \ (defined(MG_ENABLE_DRIVER_RA8) && MG_ENABLE_DRIVER_RA8) @@ -34929,6 +34965,9 @@ struct mg_tcpip_driver mg_tcpip_driver_ra = {mg_tcpip_driver_ra_init, #endif + + + #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_RW612) && MG_ENABLE_DRIVER_RW612 struct ENET_Type { @@ -35132,6 +35171,7 @@ struct mg_tcpip_driver mg_tcpip_driver_rw612 = {mg_tcpip_driver_rw612_init, + #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_RW612W) && \ MG_ENABLE_DRIVER_RW612W @@ -35634,6 +35674,9 @@ struct mg_tcpip_driver mg_tcpip_driver_rw612w = { #endif + + + #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_SAME54) && \ MG_ENABLE_DRIVER_SAME54 @@ -35888,6 +35931,8 @@ struct mg_tcpip_driver mg_tcpip_driver_same54 = { #endif + + #if MG_ENABLE_TCPIP && \ (defined(MG_ENABLE_DRIVER_CYW_SDIO) && MG_ENABLE_DRIVER_CYW_SDIO) @@ -36062,9 +36107,13 @@ bool mg_sdio_init(struct mg_tcpip_sdio *sdio) { + + #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_ST67W6) && \ MG_ENABLE_DRIVER_ST67W6 +bool mg_to_size_t(struct mg_str str, size_t *val); + static struct mg_tcpip_if *s_ifp; static uint32_t s_ip, s_mask; static bool s_link = false, s_connecting = false; @@ -36405,7 +36454,6 @@ static bool st67w6_at_cmd(char *cmd, size_t len) { } static bool st67w6_spi_init(void); -bool mg_to_size_t(struct mg_str str, size_t *val); static bool st67w6_init(uint8_t *mac) { // struct mg_tcpip_driver_st67w6_data *d = (struct @@ -37203,6 +37251,8 @@ struct mg_tcpip_driver mg_tcpip_driver_stm32h = { #endif + + #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_TM4C) && MG_ENABLE_DRIVER_TM4C struct tm4c_emac { volatile uint32_t EMACCFG, EMACFRAMEFLTR, EMACHASHTBLH, EMACHASHTBLL, @@ -37479,6 +37529,9 @@ struct mg_tcpip_driver mg_tcpip_driver_tm4c = {mg_tcpip_driver_tm4c_init, #endif + + + #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_TMS570) && MG_ENABLE_DRIVER_TMS570 struct tms570_emac_ctrl { volatile uint32_t REVID, SOFTRESET, RESERVED1[1], INTCONTROL, C0RXTHRESHEN, @@ -37933,6 +37986,9 @@ struct mg_tcpip_driver mg_tcpip_driver_w5500 = {w5500_init, w5500_tx, w5500_rx, #endif + + + #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_XMC) && MG_ENABLE_DRIVER_XMC struct ETH_GLOBAL_TypeDef { @@ -38175,6 +38231,9 @@ struct mg_tcpip_driver mg_tcpip_driver_xmc = {mg_tcpip_driver_xmc_init, #endif + + + #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_XMC7) && MG_ENABLE_DRIVER_XMC7 struct ETH_Type { diff --git a/mongoose.h b/mongoose.h index 77c0bcd2..adc5ad52 100644 --- a/mongoose.h +++ b/mongoose.h @@ -93,6 +93,8 @@ extern "C" { + + #if MG_ARCH == MG_ARCH_ARMCGT #include @@ -4842,11 +4844,14 @@ void mg_tcpip_free(struct mg_tcpip_if *); // the queue is full. void mg_tcpip_qwrite(void *buf, size_t len, struct mg_tcpip_if *ifp); +// Delivers an interface event to the protocol and user handlers +void mg_tcpip_call(struct mg_tcpip_if *ifp, int ev, void *ev_data); + // Sends a broadcast ARP who-has request for ip. mac may be NULL for a plain // broadcast, or a non-NULL hint to set the target MAC field in the request. void mg_tcpip_arp_request(struct mg_tcpip_if *ifp, uint32_t ip, uint8_t *mac); -extern uint8_t mcast_addr[6]; // Multicast MAC address programmed by drivers +extern const uint8_t mcast_addr[6]; // Multicast MAC address programmed by drivers // Built-in hardware drivers. Assign one to mg_tcpip_if.driver before calling // mg_tcpip_init(). See the matching driver header for configuration and @@ -5362,6 +5367,8 @@ extern struct mg_tcpip_driver mg_tcpip_driver_cmsis; ((defined(MG_ENABLE_DRIVER_CYW) && MG_ENABLE_DRIVER_CYW) || \ (defined(MG_ENABLE_DRIVER_CYW_SDIO) && MG_ENABLE_DRIVER_CYW_SDIO)) + + struct mg_tcpip_driver_cyw_firmware { const uint8_t *code_addr; size_t code_len; @@ -5652,6 +5659,8 @@ extern struct mg_tcpip_driver mg_tcpip_driver_nrf52; defined(MG_ENABLE_DRIVER_NXP_WIFI) && MG_ENABLE_DRIVER_NXP_WIFI + + struct mg_tcpip_driver_nxp_wifi_data { struct mg_wifi_data wifi; }; @@ -5711,6 +5720,8 @@ bool mg_phy_up(struct mg_phy *, uint8_t addr, bool *full_duplex, #include "pico/cyw43_arch.h" // keep this include #include "pico/unique_id.h" // keep this include + + struct mg_tcpip_driver_pico_w_data { struct mg_wifi_data wifi; }; @@ -5958,6 +5969,8 @@ bool mg_sdio_transfer(struct mg_tcpip_sdio *sdio, bool write, unsigned int f, #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_ST67W6) && \ MG_ENABLE_DRIVER_ST67W6 + + struct mg_tcpip_driver_st67w6_data { struct mg_wifi_data wifi; void *spi; diff --git a/src/arch.h b/src/arch.h index 75e280f7..1e163485 100644 --- a/src/arch.h +++ b/src/arch.h @@ -49,6 +49,8 @@ #include "arch_armgcc.h" #include "arch_cube.h" #include "arch_esp32.h" +#include "arch_mcuxpresso.h" +#include "arch_picosdk.h" #include "arch_rtx.h" #include "arch_threadx.h" #include "arch_unix.h" diff --git a/src/drivers/at_cmd.c b/src/drivers/at_cmd.c index 4cfc725b..90c765e1 100644 --- a/src/drivers/at_cmd.c +++ b/src/drivers/at_cmd.c @@ -1,4 +1,6 @@ #include "net_builtin.h" +#include "log.h" +#include "sntp.h" #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_ATCMD) && MG_ENABLE_DRIVER_ATCMD diff --git a/src/drivers/cmsis.c b/src/drivers/cmsis.c index ca8ead74..f8741732 100644 --- a/src/drivers/cmsis.c +++ b/src/drivers/cmsis.c @@ -1,9 +1,11 @@ // https://arm-software.github.io/CMSIS_5/Driver/html/index.html +#include "net_builtin.h" + #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_CMSIS) && MG_ENABLE_DRIVER_CMSIS #include "cmsis.h" -#include "net_builtin.h" +#include "log.h" #include "queue.h" extern ARM_DRIVER_ETH_MAC Driver_ETH_MAC0; diff --git a/src/drivers/cyw.c b/src/drivers/cyw.c index 1659d02d..7bcabcaa 100644 --- a/src/drivers/cyw.c +++ b/src/drivers/cyw.c @@ -1,5 +1,8 @@ -#include "cyw.h" +#include "net_builtin.h" #include "net.h" +#include "printf.h" +#include "util.h" +#include #if MG_ENABLE_TCPIP && \ ((defined(MG_ENABLE_DRIVER_CYW) && MG_ENABLE_DRIVER_CYW) || \ @@ -875,8 +878,10 @@ static void cyw_update_hash_table(void) { // TODO(): read database, rebuild hash table uint32_t val = 0; val = 1; + uint8_t mac[sizeof(mcast_addr)]; // copy from const uint8_t* to uint8_t* + memcpy(mac, mcast_addr, sizeof(mac)); cyw_ioctl_iovar_set2_(0, "mcast_list", (uint8_t *) &val, sizeof(val), - (uint8_t *) mcast_addr, sizeof(mcast_addr)); + mac, sizeof(mac)); mg_delayms(50); } diff --git a/src/drivers/cyw.h b/src/drivers/cyw.h index c0f3b71c..ba848062 100644 --- a/src/drivers/cyw.h +++ b/src/drivers/cyw.h @@ -4,6 +4,8 @@ ((defined(MG_ENABLE_DRIVER_CYW) && MG_ENABLE_DRIVER_CYW) || \ (defined(MG_ENABLE_DRIVER_CYW_SDIO) && MG_ENABLE_DRIVER_CYW_SDIO)) +#include "wifi.h" + struct mg_tcpip_driver_cyw_firmware { const uint8_t *code_addr; size_t code_len; diff --git a/src/drivers/esp32_802154.c b/src/drivers/esp32_802154.c index b7a7646a..79d89a91 100644 --- a/src/drivers/esp32_802154.c +++ b/src/drivers/esp32_802154.c @@ -1,5 +1,6 @@ #include "l2_mesh.h" #include "log.h" +#include "util.h" #include "net_builtin.h" #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_ESP32_802154) && \ diff --git a/src/drivers/imxrt.c b/src/drivers/imxrt.c index 2c58b6a8..952f7dfd 100644 --- a/src/drivers/imxrt.c +++ b/src/drivers/imxrt.c @@ -1,4 +1,7 @@ #include "net_builtin.h" +#include "log.h" +#include "phy.h" +#include "util.h" #if MG_ENABLE_TCPIP && \ (defined(MG_ENABLE_DRIVER_IMXRT10) && MG_ENABLE_DRIVER_IMXRT10) || \ diff --git a/src/drivers/mcxw71.c b/src/drivers/mcxw71.c index bcdc5f8f..cc116aa7 100644 --- a/src/drivers/mcxw71.c +++ b/src/drivers/mcxw71.c @@ -1,5 +1,6 @@ #include "l2_mesh.h" #include "log.h" +#include "util.h" #include "net_builtin.h" #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_MCXW71) && \ diff --git a/src/drivers/mg24.c b/src/drivers/mg24.c index 480f92ae..7090ebe5 100644 --- a/src/drivers/mg24.c +++ b/src/drivers/mg24.c @@ -1,6 +1,7 @@ #include "net_builtin.h" #include "l2_mesh.h" #include "log.h" +#include "util.h" #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_MG24) && MG_ENABLE_DRIVER_MG24 diff --git a/src/drivers/netc.c b/src/drivers/netc.c index eb981d2c..f89a6268 100644 --- a/src/drivers/netc.c +++ b/src/drivers/netc.c @@ -1,4 +1,7 @@ #include "net_builtin.h" +#include "log.h" +#include "phy.h" +#include "util.h" #if defined(MG_ENABLE_TCPIP) && MG_ENABLE_TCPIP && \ defined(MG_ENABLE_DRIVER_NETC) && MG_ENABLE_DRIVER_NETC diff --git a/src/drivers/nrf52.c b/src/drivers/nrf52.c index 08f4d71f..ef1bff65 100644 --- a/src/drivers/nrf52.c +++ b/src/drivers/nrf52.c @@ -1,6 +1,7 @@ #include "net_builtin.h" #include "l2_mesh.h" #include "log.h" +#include "util.h" #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_NRF52) && MG_ENABLE_DRIVER_NRF52 #include diff --git a/src/drivers/nxp_wifi.c b/src/drivers/nxp_wifi.c index f5bc2f3e..4be55cc9 100644 --- a/src/drivers/nxp_wifi.c +++ b/src/drivers/nxp_wifi.c @@ -1,3 +1,5 @@ +#include "net_builtin.h" + #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_NXP_WIFI) && \ MG_ENABLE_DRIVER_NXP_WIFI diff --git a/src/drivers/nxp_wifi.h b/src/drivers/nxp_wifi.h index d043d637..4c1a15c8 100644 --- a/src/drivers/nxp_wifi.h +++ b/src/drivers/nxp_wifi.h @@ -4,6 +4,8 @@ defined(MG_ENABLE_DRIVER_NXP_WIFI) && MG_ENABLE_DRIVER_NXP_WIFI +#include "wifi.h" + struct mg_tcpip_driver_nxp_wifi_data { struct mg_wifi_data wifi; }; diff --git a/src/drivers/pico-w.c b/src/drivers/pico-w.c index e0199b8f..8c933a63 100644 --- a/src/drivers/pico-w.c +++ b/src/drivers/pico-w.c @@ -1,9 +1,12 @@ +#include "net_builtin.h" + #if MG_ENABLE_TCPIP && MG_ARCH == MG_ARCH_PICOSDK && \ defined(MG_ENABLE_DRIVER_PICO_W) && MG_ENABLE_DRIVER_PICO_W #include "drivers/pico-w.h" -#include "net_builtin.h" #include "pico/stdlib.h" +#include "printf.h" +#include "util.h" static struct mg_tcpip_if *s_ifp; static uint32_t s_ip, s_mask; @@ -68,8 +71,9 @@ static bool mg_tcpip_driver_pico_w_poll(struct mg_tcpip_if *ifp, bool s1) { } if (ifp->update_mac_hash_table) { // first call to _poll() is after _init(), so this is safe - cyw43_wifi_update_multicast_filter(&cyw43_state, (uint8_t *) mcast_addr, - true); + uint8_t mac[sizeof(mcast_addr)]; // copy from const uint8_t* to uint8_t* + memcpy(mac, mcast_addr, sizeof(mac)); + cyw43_wifi_update_multicast_filter(&cyw43_state, mac, true); ifp->update_mac_hash_table = false; } if (!s1) return false; diff --git a/src/drivers/pico-w.h b/src/drivers/pico-w.h index 3a32112e..c9f3e1e9 100644 --- a/src/drivers/pico-w.h +++ b/src/drivers/pico-w.h @@ -7,6 +7,8 @@ #include "pico/cyw43_arch.h" // keep this include #include "pico/unique_id.h" // keep this include +#include "wifi.h" + struct mg_tcpip_driver_pico_w_data { struct mg_wifi_data wifi; }; diff --git a/src/drivers/ra.c b/src/drivers/ra.c index 8cacb5fe..4208067a 100644 --- a/src/drivers/ra.c +++ b/src/drivers/ra.c @@ -1,4 +1,7 @@ #include "net_builtin.h" +#include "log.h" +#include "phy.h" +#include "util.h" #if MG_ENABLE_TCPIP && \ (defined(MG_ENABLE_DRIVER_RA6) && MG_ENABLE_DRIVER_RA6) || \ diff --git a/src/drivers/rw612.c b/src/drivers/rw612.c index d132e2f7..6e129133 100644 --- a/src/drivers/rw612.c +++ b/src/drivers/rw612.c @@ -1,4 +1,7 @@ #include "net_builtin.h" +#include "log.h" +#include "phy.h" +#include "util.h" #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_RW612) && MG_ENABLE_DRIVER_RW612 diff --git a/src/drivers/rw612w.c b/src/drivers/rw612w.c index 101dbf03..e32e2450 100644 --- a/src/drivers/rw612w.c +++ b/src/drivers/rw612w.c @@ -1,6 +1,7 @@ #include "net_builtin.h" #include "l2_mesh.h" #include "log.h" +#include "util.h" #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_RW612W) && \ MG_ENABLE_DRIVER_RW612W diff --git a/src/drivers/same54.c b/src/drivers/same54.c index a40b20d0..68195135 100644 --- a/src/drivers/same54.c +++ b/src/drivers/same54.c @@ -1,4 +1,7 @@ #include "net_builtin.h" +#include "log.h" +#include "phy.h" +#include "util.h" #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_SAME54) && \ MG_ENABLE_DRIVER_SAME54 diff --git a/src/drivers/sdio.c b/src/drivers/sdio.c index 4a35475e..f6e1bff7 100644 --- a/src/drivers/sdio.c +++ b/src/drivers/sdio.c @@ -1,4 +1,6 @@ +#include "log.h" #include "sdio.h" +#include "util.h" #if MG_ENABLE_TCPIP && \ (defined(MG_ENABLE_DRIVER_CYW_SDIO) && MG_ENABLE_DRIVER_CYW_SDIO) diff --git a/src/drivers/st67w6.c b/src/drivers/st67w6.c index af576dff..3b2fae87 100644 --- a/src/drivers/st67w6.c +++ b/src/drivers/st67w6.c @@ -1,9 +1,13 @@ -#include "st67w6.h" +#include "net_builtin.h" #include "net.h" +#include "printf.h" +#include "util.h" #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_ST67W6) && \ MG_ENABLE_DRIVER_ST67W6 +bool mg_to_size_t(struct mg_str str, size_t *val); + static struct mg_tcpip_if *s_ifp; static uint32_t s_ip, s_mask; static bool s_link = false, s_connecting = false; @@ -344,7 +348,6 @@ static bool st67w6_at_cmd(char *cmd, size_t len) { } static bool st67w6_spi_init(void); -bool mg_to_size_t(struct mg_str str, size_t *val); static bool st67w6_init(uint8_t *mac) { // struct mg_tcpip_driver_st67w6_data *d = (struct diff --git a/src/drivers/st67w6.h b/src/drivers/st67w6.h index 8869a915..fbcb7f20 100644 --- a/src/drivers/st67w6.h +++ b/src/drivers/st67w6.h @@ -3,6 +3,8 @@ #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_ST67W6) && \ MG_ENABLE_DRIVER_ST67W6 +#include "wifi.h" + struct mg_tcpip_driver_st67w6_data { struct mg_wifi_data wifi; void *spi; diff --git a/src/drivers/tm4c.c b/src/drivers/tm4c.c index 31efafad..dfd64784 100644 --- a/src/drivers/tm4c.c +++ b/src/drivers/tm4c.c @@ -1,4 +1,6 @@ #include "net_builtin.h" +#include "log.h" +#include "util.h" #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_TM4C) && MG_ENABLE_DRIVER_TM4C struct tm4c_emac { diff --git a/src/drivers/tms570.c b/src/drivers/tms570.c index 5008ab1a..68b83842 100644 --- a/src/drivers/tms570.c +++ b/src/drivers/tms570.c @@ -1,4 +1,7 @@ #include "net_builtin.h" +#include "log.h" +#include "phy.h" +#include "util.h" #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_TMS570) && MG_ENABLE_DRIVER_TMS570 struct tms570_emac_ctrl { diff --git a/src/drivers/xmc.c b/src/drivers/xmc.c index 66c3ea99..4ea411d9 100644 --- a/src/drivers/xmc.c +++ b/src/drivers/xmc.c @@ -1,4 +1,7 @@ #include "net_builtin.h" +#include "log.h" +#include "phy.h" +#include "util.h" #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_XMC) && MG_ENABLE_DRIVER_XMC diff --git a/src/drivers/xmc7.c b/src/drivers/xmc7.c index 3dd1146f..76da6b3e 100644 --- a/src/drivers/xmc7.c +++ b/src/drivers/xmc7.c @@ -1,4 +1,7 @@ #include "net_builtin.h" +#include "log.h" +#include "phy.h" +#include "util.h" #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_XMC7) && MG_ENABLE_DRIVER_XMC7 diff --git a/src/net_builtin.c b/src/net_builtin.c index 4c24b286..9db296be 100644 --- a/src/net_builtin.c +++ b/src/net_builtin.c @@ -242,7 +242,7 @@ uint8_t mg_l2_ip6put(enum mg_l2type type, uint8_t *addr, uint8_t *opts); #endif bool mg_l2_poll(struct mg_tcpip_if *ifp, bool expired_1000ms); -static void mg_tcpip_call(struct mg_tcpip_if *ifp, int ev, void *ev_data) { +void mg_tcpip_call(struct mg_tcpip_if *ifp, int ev, void *ev_data) { #if 0 && MG_ENABLE_PROFILE const char *names[] = {"TCPIP_EV_STATE_CHANGE", "TCPIP_EV_DHCP_DNS", "TCPIP_EV_DHCP_SNTP", "TCPIP_EV_ARP", @@ -2535,7 +2535,7 @@ bool mg_send(struct mg_connection *c, const void *buf, size_t len) { return res; } -uint8_t mcast_addr[6] = {0x01, 0x00, 0x5e, 0x00, 0x00, 0xfb}; +const uint8_t mcast_addr[6] = {0x01, 0x00, 0x5e, 0x00, 0x00, 0xfb}; void mg_multicast_add(struct mg_connection *c, char *ip) { (void) ip; // ip4/6_mcastmac(mcast_mac, &ip); ipv6 param // TODO(): actual IP -> MAC; check database, update diff --git a/src/net_builtin.h b/src/net_builtin.h index 6fcb6c35..dc906e7d 100644 --- a/src/net_builtin.h +++ b/src/net_builtin.h @@ -128,11 +128,14 @@ void mg_tcpip_free(struct mg_tcpip_if *); // the queue is full. void mg_tcpip_qwrite(void *buf, size_t len, struct mg_tcpip_if *ifp); +// Delivers an interface event to the protocol and user handlers +void mg_tcpip_call(struct mg_tcpip_if *ifp, int ev, void *ev_data); + // Sends a broadcast ARP who-has request for ip. mac may be NULL for a plain // broadcast, or a non-NULL hint to set the target MAC field in the request. void mg_tcpip_arp_request(struct mg_tcpip_if *ifp, uint32_t ip, uint8_t *mac); -extern uint8_t mcast_addr[6]; // Multicast MAC address programmed by drivers +extern const uint8_t mcast_addr[6]; // Multicast MAC address programmed by drivers // Built-in hardware drivers. Assign one to mg_tcpip_if.driver before calling // mg_tcpip_init(). See the matching driver header for configuration and diff --git a/src/ota_ch32v307.c b/src/ota_ch32v307.c index 0093c680..894060c4 100644 --- a/src/ota_ch32v307.c +++ b/src/ota_ch32v307.c @@ -1,6 +1,7 @@ #include "flash.h" #include "log.h" #include "ota.h" +#include "util.h" #if MG_OTA == MG_OTA_CH32V307 // RM: https://www.wch-ic.com/downloads/CH32FV2x_V3xRM_PDF.html diff --git a/src/ota_esp32.c b/src/ota_esp32.c index d53d7bb0..69b4ce27 100644 --- a/src/ota_esp32.c +++ b/src/ota_esp32.c @@ -1,4 +1,6 @@ #include "arch.h" +#include "log.h" +#include "ota.h" #if MG_ARCH == MG_ARCH_ESP32 && MG_OTA == MG_OTA_ESP32 diff --git a/src/ota_imxrt.c b/src/ota_imxrt.c index fdf20ce0..c87cf8f1 100644 --- a/src/ota_imxrt.c +++ b/src/ota_imxrt.c @@ -1,6 +1,7 @@ #include "flash.h" #include "log.h" #include "ota.h" +#include "util.h" #if MG_OTA >= MG_OTA_RT1020 && MG_OTA <= MG_OTA_RT1180 diff --git a/src/ota_mcxn.c b/src/ota_mcxn.c index 110f2718..bfa56f92 100644 --- a/src/ota_mcxn.c +++ b/src/ota_mcxn.c @@ -1,6 +1,7 @@ #include "flash.h" #include "log.h" #include "ota.h" +#include "util.h" #if MG_OTA == MG_OTA_MCXN diff --git a/src/ota_mcxw71.c b/src/ota_mcxw71.c index 19eed354..0af99047 100644 --- a/src/ota_mcxw71.c +++ b/src/ota_mcxw71.c @@ -1,6 +1,7 @@ #include "flash.h" #include "log.h" #include "ota.h" +#include "util.h" #if MG_OTA == MG_OTA_MCXW71 diff --git a/src/ota_picosdk.c b/src/ota_picosdk.c index 816d80cb..5c58cbef 100644 --- a/src/ota_picosdk.c +++ b/src/ota_picosdk.c @@ -1,6 +1,7 @@ #include "flash.h" #include "log.h" #include "ota.h" +#include "util.h" #if MG_OTA == MG_OTA_PICOSDK diff --git a/src/ota_rw612.c b/src/ota_rw612.c index ef585b5c..920f3a05 100644 --- a/src/ota_rw612.c +++ b/src/ota_rw612.c @@ -1,6 +1,7 @@ #include "flash.h" #include "log.h" #include "ota.h" +#include "util.h" #if MG_OTA == MG_OTA_RW612