Fix unamalgamation for the rest of the drivers

This commit is contained in:
robert committed 2026-11-24 17:08:44 +02:00
1 parent 4f5997a8b4
commit 9f4e6a25bd
37 files changed
+162 -18

No files matched your search

+65 -6
View File
@@ -10050,7 +10050,7 @@ uint8_t mg_l2_ip6put(enum mg_l2type type, uint8_t *addr, uint8_t *opts);
#endif #endif
bool mg_l2_poll(struct mg_tcpip_if *ifp, bool expired_1000ms); 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 #if 0 && MG_ENABLE_PROFILE
const char *names[] = {"TCPIP_EV_STATE_CHANGE", "TCPIP_EV_DHCP_DNS", const char *names[] = {"TCPIP_EV_STATE_CHANGE", "TCPIP_EV_DHCP_DNS",
"TCPIP_EV_DHCP_SNTP", "TCPIP_EV_ARP", "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; 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 mg_multicast_add(struct mg_connection *c, char *ip) {
(void) ip; // ip4/6_mcastmac(mcast_mac, &ip); ipv6 param (void) ip; // ip4/6_mcastmac(mcast_mac, &ip); ipv6 param
// TODO(): actual IP -> MAC; check database, update // 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 #if MG_OTA == MG_OTA_CH32V307
// RM: https://www.wch-ic.com/downloads/CH32FV2x_V3xRM_PDF.html // RM: https://www.wch-ic.com/downloads/CH32FV2x_V3xRM_PDF.html
@@ -12820,6 +12821,8 @@ bool mg_ota_end(void) {
#endif #endif
#if MG_ARCH == MG_ARCH_ESP32 && MG_OTA == MG_OTA_ESP32 #if MG_ARCH == MG_ARCH_ESP32 && MG_OTA == MG_OTA_ESP32
static const esp_partition_t *s_ota_update_partition; 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 #if MG_OTA >= MG_OTA_RT1020 && MG_OTA <= MG_OTA_RT1180
static bool mg_imxrt_write(void *, const void *, size_t); 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 #if MG_OTA == MG_OTA_MCXN
// - Flash phrase: 16 bytes; smallest portion programmed in one operation. // - 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 #if MG_OTA == MG_OTA_MCXW71
// MCXW71SRM, section 11.2: ROM flash API, 8 KB sectors, 16-byte phrases, // 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 #if MG_OTA == MG_OTA_PICOSDK
// Both RP2040 and RP2350 have no flash, low-level flash access support in // 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 #if MG_OTA == MG_OTA_RW612
MG_IRAM static bool mg_frdm_write(void *, const void *, size_t); 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 #endif
#if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_ATCMD) && MG_ENABLE_DRIVER_ATCMD #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_ATCMD) && MG_ENABLE_DRIVER_ATCMD
#define MG_HDLC_FLAG 0x7e // HDLC frame delimiter #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 #endif
// https://arm-software.github.io/CMSIS_5/Driver/html/index.html // https://arm-software.github.io/CMSIS_5/Driver/html/index.html
#if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_CMSIS) && MG_ENABLE_DRIVER_CMSIS #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 <stddef.h>
#if MG_ENABLE_TCPIP && \ #if MG_ENABLE_TCPIP && \
((defined(MG_ENABLE_DRIVER_CYW) && MG_ENABLE_DRIVER_CYW) || \ ((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))
@@ -32158,8 +32173,10 @@ static void cyw_update_hash_table(void) {
// TODO(): read database, rebuild hash table // TODO(): read database, rebuild hash table
uint32_t val = 0; uint32_t val = 0;
val = 1; 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), 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); mg_delayms(50);
} }
@@ -32704,6 +32721,7 @@ bool mg_wifi_ap_stop(void) {
#if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_ESP32_802154) && \ #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_ESP32_802154) && \
MG_ENABLE_DRIVER_ESP32_802154 MG_ENABLE_DRIVER_ESP32_802154
@@ -32897,6 +32915,9 @@ struct mg_tcpip_driver mg_tcpip_driver_esp32_802154 = {
#endif #endif
#if MG_ENABLE_TCPIP && \ #if MG_ENABLE_TCPIP && \
(defined(MG_ENABLE_DRIVER_IMXRT10) && MG_ENABLE_DRIVER_IMXRT10) || \ (defined(MG_ENABLE_DRIVER_IMXRT10) && MG_ENABLE_DRIVER_IMXRT10) || \
(defined(MG_ENABLE_DRIVER_IMXRT11) && MG_ENABLE_DRIVER_IMXRT11) || \ (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) && \ #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_MCXW71) && \
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 #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_MG24) && MG_ENABLE_DRIVER_MG24
#include <rail.h> #include <rail.h>
@@ -33525,6 +33548,9 @@ struct mg_tcpip_driver mg_tcpip_driver_mg24 = {mgi_mg24_init, mgi_mg24_tx,
#endif #endif
#if defined(MG_ENABLE_TCPIP) && MG_ENABLE_TCPIP && \ #if defined(MG_ENABLE_TCPIP) && MG_ENABLE_TCPIP && \
defined(MG_ENABLE_DRIVER_NETC) && MG_ENABLE_DRIVER_NETC 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 #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_NRF52) && MG_ENABLE_DRIVER_NRF52
#include <nrf.h> #include <nrf.h>
@@ -34167,6 +34194,8 @@ struct mg_tcpip_driver mg_tcpip_driver_nrf52 = {mgi_nrf52_init, mgi_nrf52_tx,
#ifdef MG_ENABLE_LINES #ifdef MG_ENABLE_LINES
#line 1 "src/drivers/nxp_wifi.c" #line 1 "src/drivers/nxp_wifi.c"
#endif #endif
#if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_NXP_WIFI) && \ #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_NXP_WIFI) && \
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 #ifdef MG_ENABLE_LINES
#line 1 "src/drivers/pico-w.c" #line 1 "src/drivers/pico-w.c"
#endif #endif
#if MG_ENABLE_TCPIP && MG_ARCH == MG_ARCH_PICOSDK && \ #if MG_ENABLE_TCPIP && MG_ARCH == MG_ARCH_PICOSDK && \
defined(MG_ENABLE_DRIVER_PICO_W) && MG_ENABLE_DRIVER_PICO_W 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 struct mg_tcpip_if *s_ifp;
static uint32_t s_ip, s_mask; static uint32_t s_ip, s_mask;
static bool s_aplink = false, s_scanning = false; 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) { if (ifp->update_mac_hash_table) {
// first call to _poll() is after _init(), so this is safe // first call to _poll() is after _init(), so this is safe
cyw43_wifi_update_multicast_filter(&cyw43_state, (uint8_t *) mcast_addr, uint8_t mac[sizeof(mcast_addr)]; // copy from const uint8_t* to uint8_t*
true); memcpy(mac, mcast_addr, sizeof(mac));
cyw43_wifi_update_multicast_filter(&cyw43_state, mac, true);
ifp->update_mac_hash_table = false; ifp->update_mac_hash_table = false;
} }
if (!s1) return false; if (!s1) return false;
@@ -34662,6 +34695,9 @@ bool mg_wifi_ap_stop(void) {
#endif #endif
#if MG_ENABLE_TCPIP && \ #if MG_ENABLE_TCPIP && \
(defined(MG_ENABLE_DRIVER_RA6) && MG_ENABLE_DRIVER_RA6) || \ (defined(MG_ENABLE_DRIVER_RA6) && MG_ENABLE_DRIVER_RA6) || \
(defined(MG_ENABLE_DRIVER_RA8) && MG_ENABLE_DRIVER_RA8) (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 #endif
#if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_RW612) && MG_ENABLE_DRIVER_RW612 #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_RW612) && MG_ENABLE_DRIVER_RW612
struct ENET_Type { 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) && \ #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_RW612W) && \
MG_ENABLE_DRIVER_RW612W MG_ENABLE_DRIVER_RW612W
@@ -35634,6 +35674,9 @@ struct mg_tcpip_driver mg_tcpip_driver_rw612w = {
#endif #endif
#if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_SAME54) && \ #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_SAME54) && \
MG_ENABLE_DRIVER_SAME54 MG_ENABLE_DRIVER_SAME54
@@ -35888,6 +35931,8 @@ struct mg_tcpip_driver mg_tcpip_driver_same54 = {
#endif #endif
#if MG_ENABLE_TCPIP && \ #if MG_ENABLE_TCPIP && \
(defined(MG_ENABLE_DRIVER_CYW_SDIO) && MG_ENABLE_DRIVER_CYW_SDIO) (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) && \ #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_ST67W6) && \
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 struct mg_tcpip_if *s_ifp;
static uint32_t s_ip, s_mask; static uint32_t s_ip, s_mask;
static bool s_link = false, s_connecting = false; 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); 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) { static bool st67w6_init(uint8_t *mac) {
// struct mg_tcpip_driver_st67w6_data *d = (struct // struct mg_tcpip_driver_st67w6_data *d = (struct
@@ -37203,6 +37251,8 @@ struct mg_tcpip_driver mg_tcpip_driver_stm32h = {
#endif #endif
#if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_TM4C) && MG_ENABLE_DRIVER_TM4C #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_TM4C) && MG_ENABLE_DRIVER_TM4C
struct tm4c_emac { struct tm4c_emac {
volatile uint32_t EMACCFG, EMACFRAMEFLTR, EMACHASHTBLH, EMACHASHTBLL, 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 #endif
#if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_TMS570) && MG_ENABLE_DRIVER_TMS570 #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_TMS570) && MG_ENABLE_DRIVER_TMS570
struct tms570_emac_ctrl { struct tms570_emac_ctrl {
volatile uint32_t REVID, SOFTRESET, RESERVED1[1], INTCONTROL, C0RXTHRESHEN, 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 #endif
#if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_XMC) && MG_ENABLE_DRIVER_XMC #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_XMC) && MG_ENABLE_DRIVER_XMC
struct ETH_GLOBAL_TypeDef { struct ETH_GLOBAL_TypeDef {
@@ -38175,6 +38231,9 @@ struct mg_tcpip_driver mg_tcpip_driver_xmc = {mg_tcpip_driver_xmc_init,
#endif #endif
#if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_XMC7) && MG_ENABLE_DRIVER_XMC7 #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_XMC7) && MG_ENABLE_DRIVER_XMC7
struct ETH_Type { struct ETH_Type {
+14 -1
View File
@@ -93,6 +93,8 @@ extern "C" {
#if MG_ARCH == MG_ARCH_ARMCGT #if MG_ARCH == MG_ARCH_ARMCGT
#include <ctype.h> #include <ctype.h>
@@ -4842,11 +4844,14 @@ void mg_tcpip_free(struct mg_tcpip_if *);
// the queue is full. // the queue is full.
void mg_tcpip_qwrite(void *buf, size_t len, struct mg_tcpip_if *ifp); 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 // 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. // 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); 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 // Built-in hardware drivers. Assign one to mg_tcpip_if.driver before calling
// mg_tcpip_init(). See the matching driver header for configuration and // 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) && 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))
struct mg_tcpip_driver_cyw_firmware { struct mg_tcpip_driver_cyw_firmware {
const uint8_t *code_addr; const uint8_t *code_addr;
size_t code_len; 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 defined(MG_ENABLE_DRIVER_NXP_WIFI) && MG_ENABLE_DRIVER_NXP_WIFI
struct mg_tcpip_driver_nxp_wifi_data { struct mg_tcpip_driver_nxp_wifi_data {
struct mg_wifi_data wifi; 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/cyw43_arch.h" // keep this include
#include "pico/unique_id.h" // keep this include #include "pico/unique_id.h" // keep this include
struct mg_tcpip_driver_pico_w_data { struct mg_tcpip_driver_pico_w_data {
struct mg_wifi_data wifi; 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) && \ #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_ST67W6) && \
MG_ENABLE_DRIVER_ST67W6 MG_ENABLE_DRIVER_ST67W6
struct mg_tcpip_driver_st67w6_data { struct mg_tcpip_driver_st67w6_data {
struct mg_wifi_data wifi; struct mg_wifi_data wifi;
void *spi; void *spi;
+2
View File
@@ -49,6 +49,8 @@
#include "arch_armgcc.h" #include "arch_armgcc.h"
#include "arch_cube.h" #include "arch_cube.h"
#include "arch_esp32.h" #include "arch_esp32.h"
#include "arch_mcuxpresso.h"
#include "arch_picosdk.h"
#include "arch_rtx.h" #include "arch_rtx.h"
#include "arch_threadx.h" #include "arch_threadx.h"
#include "arch_unix.h" #include "arch_unix.h"
+2
View File
@@ -1,4 +1,6 @@
#include "net_builtin.h" #include "net_builtin.h"
#include "log.h"
#include "sntp.h"
#if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_ATCMD) && MG_ENABLE_DRIVER_ATCMD #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_ATCMD) && MG_ENABLE_DRIVER_ATCMD
+3 -1
View File
@@ -1,9 +1,11 @@
// https://arm-software.github.io/CMSIS_5/Driver/html/index.html // 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 #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_CMSIS) && MG_ENABLE_DRIVER_CMSIS
#include "cmsis.h" #include "cmsis.h"
#include "net_builtin.h" #include "log.h"
#include "queue.h" #include "queue.h"
extern ARM_DRIVER_ETH_MAC Driver_ETH_MAC0; extern ARM_DRIVER_ETH_MAC Driver_ETH_MAC0;
+7 -2
View File
@@ -1,5 +1,8 @@
#include "cyw.h" #include "net_builtin.h"
#include "net.h" #include "net.h"
#include "printf.h"
#include "util.h"
#include <stddef.h>
#if MG_ENABLE_TCPIP && \ #if MG_ENABLE_TCPIP && \
((defined(MG_ENABLE_DRIVER_CYW) && MG_ENABLE_DRIVER_CYW) || \ ((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 // TODO(): read database, rebuild hash table
uint32_t val = 0; uint32_t val = 0;
val = 1; 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), 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); mg_delayms(50);
} }
+2
View File
@@ -4,6 +4,8 @@
((defined(MG_ENABLE_DRIVER_CYW) && MG_ENABLE_DRIVER_CYW) || \ ((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))
#include "wifi.h"
struct mg_tcpip_driver_cyw_firmware { struct mg_tcpip_driver_cyw_firmware {
const uint8_t *code_addr; const uint8_t *code_addr;
size_t code_len; size_t code_len;
+1
View File
@@ -1,5 +1,6 @@
#include "l2_mesh.h" #include "l2_mesh.h"
#include "log.h" #include "log.h"
#include "util.h"
#include "net_builtin.h" #include "net_builtin.h"
#if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_ESP32_802154) && \ #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_ESP32_802154) && \
+3
View File
@@ -1,4 +1,7 @@
#include "net_builtin.h" #include "net_builtin.h"
#include "log.h"
#include "phy.h"
#include "util.h"
#if MG_ENABLE_TCPIP && \ #if MG_ENABLE_TCPIP && \
(defined(MG_ENABLE_DRIVER_IMXRT10) && MG_ENABLE_DRIVER_IMXRT10) || \ (defined(MG_ENABLE_DRIVER_IMXRT10) && MG_ENABLE_DRIVER_IMXRT10) || \
+1
View File
@@ -1,5 +1,6 @@
#include "l2_mesh.h" #include "l2_mesh.h"
#include "log.h" #include "log.h"
#include "util.h"
#include "net_builtin.h" #include "net_builtin.h"
#if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_MCXW71) && \ #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_MCXW71) && \
+1
View File
@@ -1,6 +1,7 @@
#include "net_builtin.h" #include "net_builtin.h"
#include "l2_mesh.h" #include "l2_mesh.h"
#include "log.h" #include "log.h"
#include "util.h"
#if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_MG24) && MG_ENABLE_DRIVER_MG24 #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_MG24) && MG_ENABLE_DRIVER_MG24
+3
View File
@@ -1,4 +1,7 @@
#include "net_builtin.h" #include "net_builtin.h"
#include "log.h"
#include "phy.h"
#include "util.h"
#if defined(MG_ENABLE_TCPIP) && MG_ENABLE_TCPIP && \ #if defined(MG_ENABLE_TCPIP) && MG_ENABLE_TCPIP && \
defined(MG_ENABLE_DRIVER_NETC) && MG_ENABLE_DRIVER_NETC defined(MG_ENABLE_DRIVER_NETC) && MG_ENABLE_DRIVER_NETC
+1
View File
@@ -1,6 +1,7 @@
#include "net_builtin.h" #include "net_builtin.h"
#include "l2_mesh.h" #include "l2_mesh.h"
#include "log.h" #include "log.h"
#include "util.h"
#if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_NRF52) && MG_ENABLE_DRIVER_NRF52 #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_NRF52) && MG_ENABLE_DRIVER_NRF52
#include <nrf.h> #include <nrf.h>
+2
View File
@@ -1,3 +1,5 @@
#include "net_builtin.h"
#if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_NXP_WIFI) && \ #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_NXP_WIFI) && \
MG_ENABLE_DRIVER_NXP_WIFI MG_ENABLE_DRIVER_NXP_WIFI
+2
View File
@@ -4,6 +4,8 @@
defined(MG_ENABLE_DRIVER_NXP_WIFI) && MG_ENABLE_DRIVER_NXP_WIFI defined(MG_ENABLE_DRIVER_NXP_WIFI) && MG_ENABLE_DRIVER_NXP_WIFI
#include "wifi.h"
struct mg_tcpip_driver_nxp_wifi_data { struct mg_tcpip_driver_nxp_wifi_data {
struct mg_wifi_data wifi; struct mg_wifi_data wifi;
}; };
+7 -3
View File
@@ -1,9 +1,12 @@
#include "net_builtin.h"
#if MG_ENABLE_TCPIP && MG_ARCH == MG_ARCH_PICOSDK && \ #if MG_ENABLE_TCPIP && MG_ARCH == MG_ARCH_PICOSDK && \
defined(MG_ENABLE_DRIVER_PICO_W) && MG_ENABLE_DRIVER_PICO_W defined(MG_ENABLE_DRIVER_PICO_W) && MG_ENABLE_DRIVER_PICO_W
#include "drivers/pico-w.h" #include "drivers/pico-w.h"
#include "net_builtin.h"
#include "pico/stdlib.h" #include "pico/stdlib.h"
#include "printf.h"
#include "util.h"
static struct mg_tcpip_if *s_ifp; static struct mg_tcpip_if *s_ifp;
static uint32_t s_ip, s_mask; 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) { if (ifp->update_mac_hash_table) {
// first call to _poll() is after _init(), so this is safe // first call to _poll() is after _init(), so this is safe
cyw43_wifi_update_multicast_filter(&cyw43_state, (uint8_t *) mcast_addr, uint8_t mac[sizeof(mcast_addr)]; // copy from const uint8_t* to uint8_t*
true); memcpy(mac, mcast_addr, sizeof(mac));
cyw43_wifi_update_multicast_filter(&cyw43_state, mac, true);
ifp->update_mac_hash_table = false; ifp->update_mac_hash_table = false;
} }
if (!s1) return false; if (!s1) return false;
+2
View File
@@ -7,6 +7,8 @@
#include "pico/cyw43_arch.h" // keep this include #include "pico/cyw43_arch.h" // keep this include
#include "pico/unique_id.h" // keep this include #include "pico/unique_id.h" // keep this include
#include "wifi.h"
struct mg_tcpip_driver_pico_w_data { struct mg_tcpip_driver_pico_w_data {
struct mg_wifi_data wifi; struct mg_wifi_data wifi;
}; };
+3
View File
@@ -1,4 +1,7 @@
#include "net_builtin.h" #include "net_builtin.h"
#include "log.h"
#include "phy.h"
#include "util.h"
#if MG_ENABLE_TCPIP && \ #if MG_ENABLE_TCPIP && \
(defined(MG_ENABLE_DRIVER_RA6) && MG_ENABLE_DRIVER_RA6) || \ (defined(MG_ENABLE_DRIVER_RA6) && MG_ENABLE_DRIVER_RA6) || \
+3
View File
@@ -1,4 +1,7 @@
#include "net_builtin.h" #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 #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_RW612) && MG_ENABLE_DRIVER_RW612
+1
View File
@@ -1,6 +1,7 @@
#include "net_builtin.h" #include "net_builtin.h"
#include "l2_mesh.h" #include "l2_mesh.h"
#include "log.h" #include "log.h"
#include "util.h"
#if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_RW612W) && \ #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_RW612W) && \
MG_ENABLE_DRIVER_RW612W MG_ENABLE_DRIVER_RW612W
+3
View File
@@ -1,4 +1,7 @@
#include "net_builtin.h" #include "net_builtin.h"
#include "log.h"
#include "phy.h"
#include "util.h"
#if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_SAME54) && \ #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_SAME54) && \
MG_ENABLE_DRIVER_SAME54 MG_ENABLE_DRIVER_SAME54
+2
View File
@@ -1,4 +1,6 @@
#include "log.h"
#include "sdio.h" #include "sdio.h"
#include "util.h"
#if MG_ENABLE_TCPIP && \ #if MG_ENABLE_TCPIP && \
(defined(MG_ENABLE_DRIVER_CYW_SDIO) && MG_ENABLE_DRIVER_CYW_SDIO) (defined(MG_ENABLE_DRIVER_CYW_SDIO) && MG_ENABLE_DRIVER_CYW_SDIO)
+5 -2
View File
@@ -1,9 +1,13 @@
#include "st67w6.h" #include "net_builtin.h"
#include "net.h" #include "net.h"
#include "printf.h"
#include "util.h"
#if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_ST67W6) && \ #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_ST67W6) && \
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 struct mg_tcpip_if *s_ifp;
static uint32_t s_ip, s_mask; static uint32_t s_ip, s_mask;
static bool s_link = false, s_connecting = false; 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); 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) { static bool st67w6_init(uint8_t *mac) {
// struct mg_tcpip_driver_st67w6_data *d = (struct // struct mg_tcpip_driver_st67w6_data *d = (struct
+2
View File
@@ -3,6 +3,8 @@
#if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_ST67W6) && \ #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_ST67W6) && \
MG_ENABLE_DRIVER_ST67W6 MG_ENABLE_DRIVER_ST67W6
#include "wifi.h"
struct mg_tcpip_driver_st67w6_data { struct mg_tcpip_driver_st67w6_data {
struct mg_wifi_data wifi; struct mg_wifi_data wifi;
void *spi; void *spi;
+2
View File
@@ -1,4 +1,6 @@
#include "net_builtin.h" #include "net_builtin.h"
#include "log.h"
#include "util.h"
#if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_TM4C) && MG_ENABLE_DRIVER_TM4C #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_TM4C) && MG_ENABLE_DRIVER_TM4C
struct tm4c_emac { struct tm4c_emac {
+3
View File
@@ -1,4 +1,7 @@
#include "net_builtin.h" #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 #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_TMS570) && MG_ENABLE_DRIVER_TMS570
struct tms570_emac_ctrl { struct tms570_emac_ctrl {
+3
View File
@@ -1,4 +1,7 @@
#include "net_builtin.h" #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 #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_XMC) && MG_ENABLE_DRIVER_XMC
+3
View File
@@ -1,4 +1,7 @@
#include "net_builtin.h" #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 #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_XMC7) && MG_ENABLE_DRIVER_XMC7
+2 -2
View File
@@ -242,7 +242,7 @@ uint8_t mg_l2_ip6put(enum mg_l2type type, uint8_t *addr, uint8_t *opts);
#endif #endif
bool mg_l2_poll(struct mg_tcpip_if *ifp, bool expired_1000ms); 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 #if 0 && MG_ENABLE_PROFILE
const char *names[] = {"TCPIP_EV_STATE_CHANGE", "TCPIP_EV_DHCP_DNS", const char *names[] = {"TCPIP_EV_STATE_CHANGE", "TCPIP_EV_DHCP_DNS",
"TCPIP_EV_DHCP_SNTP", "TCPIP_EV_ARP", "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; 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 mg_multicast_add(struct mg_connection *c, char *ip) {
(void) ip; // ip4/6_mcastmac(mcast_mac, &ip); ipv6 param (void) ip; // ip4/6_mcastmac(mcast_mac, &ip); ipv6 param
// TODO(): actual IP -> MAC; check database, update // TODO(): actual IP -> MAC; check database, update
+4 -1
View File
@@ -128,11 +128,14 @@ void mg_tcpip_free(struct mg_tcpip_if *);
// the queue is full. // the queue is full.
void mg_tcpip_qwrite(void *buf, size_t len, struct mg_tcpip_if *ifp); 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 // 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. // 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); 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 // Built-in hardware drivers. Assign one to mg_tcpip_if.driver before calling
// mg_tcpip_init(). See the matching driver header for configuration and // mg_tcpip_init(). See the matching driver header for configuration and
+1
View File
@@ -1,6 +1,7 @@
#include "flash.h" #include "flash.h"
#include "log.h" #include "log.h"
#include "ota.h" #include "ota.h"
#include "util.h"
#if MG_OTA == MG_OTA_CH32V307 #if MG_OTA == MG_OTA_CH32V307
// RM: https://www.wch-ic.com/downloads/CH32FV2x_V3xRM_PDF.html // RM: https://www.wch-ic.com/downloads/CH32FV2x_V3xRM_PDF.html
+2
View File
@@ -1,4 +1,6 @@
#include "arch.h" #include "arch.h"
#include "log.h"
#include "ota.h"
#if MG_ARCH == MG_ARCH_ESP32 && MG_OTA == MG_OTA_ESP32 #if MG_ARCH == MG_ARCH_ESP32 && MG_OTA == MG_OTA_ESP32
+1
View File
@@ -1,6 +1,7 @@
#include "flash.h" #include "flash.h"
#include "log.h" #include "log.h"
#include "ota.h" #include "ota.h"
#include "util.h"
#if MG_OTA >= MG_OTA_RT1020 && MG_OTA <= MG_OTA_RT1180 #if MG_OTA >= MG_OTA_RT1020 && MG_OTA <= MG_OTA_RT1180
+1
View File
@@ -1,6 +1,7 @@
#include "flash.h" #include "flash.h"
#include "log.h" #include "log.h"
#include "ota.h" #include "ota.h"
#include "util.h"
#if MG_OTA == MG_OTA_MCXN #if MG_OTA == MG_OTA_MCXN
+1
View File
@@ -1,6 +1,7 @@
#include "flash.h" #include "flash.h"
#include "log.h" #include "log.h"
#include "ota.h" #include "ota.h"
#include "util.h"
#if MG_OTA == MG_OTA_MCXW71 #if MG_OTA == MG_OTA_MCXW71
+1
View File
@@ -1,6 +1,7 @@
#include "flash.h" #include "flash.h"
#include "log.h" #include "log.h"
#include "ota.h" #include "ota.h"
#include "util.h"
#if MG_OTA == MG_OTA_PICOSDK #if MG_OTA == MG_OTA_PICOSDK
+1
View File
@@ -1,6 +1,7 @@
#include "flash.h" #include "flash.h"
#include "log.h" #include "log.h"
#include "ota.h" #include "ota.h"
#include "util.h"
#if MG_OTA == MG_OTA_RW612 #if MG_OTA == MG_OTA_RW612