Merge pull request #3092 from cesanta/picofix

unbreak pico[2]W auto init
This commit is contained in:
Sergio R. Caprile 2025-04-07 16:00:33 -03:00 committed by GitHub
commit 578e52618d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 47 additions and 40 deletions

View File

@ -892,8 +892,8 @@ struct timeval {
#define MG_SET_MAC_ADDRESS(mac) #define MG_SET_MAC_ADDRESS(mac)
#endif #endif
#ifndef MG_SET_WIFI_CREDS #ifndef MG_SET_WIFI_CONFIG
#define MG_SET_WIFI_CREDS(ssid, pass) #define MG_SET_WIFI_CONFIG(data)
#endif #endif
#ifndef MG_ENABLE_TCPIP_PRINT_DEBUG_STATS #ifndef MG_ENABLE_TCPIP_PRINT_DEBUG_STATS
@ -2995,21 +2995,23 @@ struct mg_tcpip_driver_cyw_data {
bool apmode; // start in AP mode; 'false' starts connection to 'ssid' if not NULL bool apmode; // start in AP mode; 'false' starts connection to 'ssid' if not NULL
}; };
//#define MG_TCPIP_DRIVER_INIT(mgr) \ #if 0
// do { \ #define MG_TCPIP_DRIVER_INIT(mgr) \
// static struct mg_tcpip_driver_cyw_data driver_data_; \ do { \
// static struct mg_tcpip_if mif_; \ static struct mg_tcpip_driver_cyw_data driver_data_; \
// MG_SET_WIFI_CONFIG(&driver_data_); \ static struct mg_tcpip_if mif_; \
// mif_.ip = MG_TCPIP_IP; \ MG_SET_WIFI_CONFIG(&driver_data_); \
// mif_.mask = MG_TCPIP_MASK; \ mif_.ip = MG_TCPIP_IP; \
// mif_.gw = MG_TCPIP_GW; \ mif_.mask = MG_TCPIP_MASK; \
// mif_.driver = &mg_tcpip_driver_pico_w; \ mif_.gw = MG_TCPIP_GW; \
// mif_.driver_data = &driver_data_; \ mif_.driver = &mg_tcpip_driver_pico_w; \
// mif_.recv_queue.size = 8192; \ mif_.driver_data = &driver_data_; \
// mif_.mac[0] = 2; /* MAC read from OTP at driver init */ \ mif_.recv_queue.size = 8192; \
// mg_tcpip_init(mgr, &mif_); \ mif_.mac[0] = 2; /* MAC read from OTP at driver init */ \
// MG_INFO(("Driver: cyw, MAC: %M", mg_print_mac, mif_.mac)); \ mg_tcpip_init(mgr, &mif_); \
// } while (0) MG_INFO(("Driver: cyw, MAC: %M", mg_print_mac, mif_.mac)); \
} while (0)
#endif
#endif #endif

View File

@ -174,8 +174,8 @@
#define MG_SET_MAC_ADDRESS(mac) #define MG_SET_MAC_ADDRESS(mac)
#endif #endif
#ifndef MG_SET_WIFI_CREDS #ifndef MG_SET_WIFI_CONFIG
#define MG_SET_WIFI_CREDS(ssid, pass) #define MG_SET_WIFI_CONFIG(data)
#endif #endif
#ifndef MG_ENABLE_TCPIP_PRINT_DEBUG_STATS #ifndef MG_ENABLE_TCPIP_PRINT_DEBUG_STATS

View File

@ -32,20 +32,22 @@ struct mg_tcpip_driver_cyw_data {
bool apmode; // start in AP mode; 'false' starts connection to 'ssid' if not NULL bool apmode; // start in AP mode; 'false' starts connection to 'ssid' if not NULL
}; };
//#define MG_TCPIP_DRIVER_INIT(mgr) \ #if 0
// do { \ #define MG_TCPIP_DRIVER_INIT(mgr) \
// static struct mg_tcpip_driver_cyw_data driver_data_; \ do { \
// static struct mg_tcpip_if mif_; \ static struct mg_tcpip_driver_cyw_data driver_data_; \
// MG_SET_WIFI_CONFIG(&driver_data_); \ static struct mg_tcpip_if mif_; \
// mif_.ip = MG_TCPIP_IP; \ MG_SET_WIFI_CONFIG(&driver_data_); \
// mif_.mask = MG_TCPIP_MASK; \ mif_.ip = MG_TCPIP_IP; \
// mif_.gw = MG_TCPIP_GW; \ mif_.mask = MG_TCPIP_MASK; \
// mif_.driver = &mg_tcpip_driver_pico_w; \ mif_.gw = MG_TCPIP_GW; \
// mif_.driver_data = &driver_data_; \ mif_.driver = &mg_tcpip_driver_pico_w; \
// mif_.recv_queue.size = 8192; \ mif_.driver_data = &driver_data_; \
// mif_.mac[0] = 2; /* MAC read from OTP at driver init */ \ mif_.recv_queue.size = 8192; \
// mg_tcpip_init(mgr, &mif_); \ mif_.mac[0] = 2; /* MAC read from OTP at driver init */ \
// MG_INFO(("Driver: cyw, MAC: %M", mg_print_mac, mif_.mac)); \ mg_tcpip_init(mgr, &mif_); \
// } while (0) MG_INFO(("Driver: cyw, MAC: %M", mg_print_mac, mif_.mac)); \
} while (0)
#endif
#endif #endif

View File

@ -17,10 +17,13 @@
// MAC address is read from OTP by the driver // MAC address is read from OTP by the driver
// Set your Wi-Fi credentials // Set your Wi-Fi configuration
// Using a build-time constant: /* Using a build-time constant:
// #define MG_SET_WIFI_CREDS(ssid, pass) do { *ssid = "this"; *pass = "that"; } while (0) #define MG_SET_WIFI_CONFIG(data) do { \
// ((struct mg_tcpip_driver_pico_w_data *)data)->ssid = "this"; \
((struct mg_tcpip_driver_pico_w_data *)data)->pass = "that"; \
} while (0)
*/
// Using a custom function: // Using a custom function:
extern void main_setcreds(char **ssid, char **pass); extern void main_setconfig(void *data);
#define MG_SET_WIFI_CREDS(ssid, pass) main_setcreds(ssid, pass) #define MG_SET_WIFI_CONFIG(data) main_setconfig(data)