mirror of
https://github.com/cesanta/mongoose.git
synced 2025-01-07 20:12:29 +08:00
Add auto init for Pico-W driver
This commit is contained in:
parent
0a4f322d49
commit
b7598cc354
22
mongoose.h
22
mongoose.h
@ -894,6 +894,10 @@ struct timeval {
|
|||||||
#define MG_SET_MAC_ADDRESS(mac)
|
#define MG_SET_MAC_ADDRESS(mac)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef MG_SET_WIFI_CREDS
|
||||||
|
#define MG_SET_WIFI_CREDS(ssid, pass)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef MG_ENABLE_TCPIP_PRINT_DEBUG_STATS
|
#ifndef MG_ENABLE_TCPIP_PRINT_DEBUG_STATS
|
||||||
#define MG_ENABLE_TCPIP_PRINT_DEBUG_STATS 0
|
#define MG_ENABLE_TCPIP_PRINT_DEBUG_STATS 0
|
||||||
#endif
|
#endif
|
||||||
@ -2947,6 +2951,7 @@ void mg_phy_init(struct mg_phy *, uint8_t addr, uint8_t config);
|
|||||||
bool mg_phy_up(struct mg_phy *, uint8_t addr, bool *full_duplex,
|
bool mg_phy_up(struct mg_phy *, uint8_t addr, bool *full_duplex,
|
||||||
uint8_t *speed);
|
uint8_t *speed);
|
||||||
|
|
||||||
|
|
||||||
#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
|
||||||
|
|
||||||
@ -2959,8 +2964,25 @@ struct mg_tcpip_driver_pico_w_data {
|
|||||||
char *pass;
|
char *pass;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define MG_TCPIP_DRIVER_INIT(mgr) \
|
||||||
|
do { \
|
||||||
|
static struct mg_tcpip_driver_pico_w_data driver_data_; \
|
||||||
|
static struct mg_tcpip_if mif_; \
|
||||||
|
MG_SET_WIFI_CREDS(&driver_data_.ssid, &driver_data_.pass); \
|
||||||
|
mif_.ip = MG_TCPIP_IP; \
|
||||||
|
mif_.mask = MG_TCPIP_MASK; \
|
||||||
|
mif_.gw = MG_TCPIP_GW; \
|
||||||
|
mif_.driver = &mg_tcpip_driver_pico_w; \
|
||||||
|
mif_.driver_data = &driver_data_; \
|
||||||
|
mif_.recv_queue.size = 8192; \
|
||||||
|
mif_.mac[0] = 2; /* MAC read from OTP at driver init */ \
|
||||||
|
mg_tcpip_init(mgr, &mif_); \
|
||||||
|
MG_INFO(("Driver: pico-w, MAC: %M", mg_print_mac, mif_.mac)); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
struct mg_tcpip_driver_ppp_data {
|
struct mg_tcpip_driver_ppp_data {
|
||||||
void *uart; // Opaque UART bus descriptor
|
void *uart; // Opaque UART bus descriptor
|
||||||
void (*reset)(void *); // Modem hardware reset
|
void (*reset)(void *); // Modem hardware reset
|
||||||
|
@ -174,6 +174,10 @@
|
|||||||
#define MG_SET_MAC_ADDRESS(mac)
|
#define MG_SET_MAC_ADDRESS(mac)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef MG_SET_WIFI_CREDS
|
||||||
|
#define MG_SET_WIFI_CREDS(ssid, pass)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef MG_ENABLE_TCPIP_PRINT_DEBUG_STATS
|
#ifndef MG_ENABLE_TCPIP_PRINT_DEBUG_STATS
|
||||||
#define MG_ENABLE_TCPIP_PRINT_DEBUG_STATS 0
|
#define MG_ENABLE_TCPIP_PRINT_DEBUG_STATS 0
|
||||||
#endif
|
#endif
|
||||||
|
@ -12,4 +12,20 @@ struct mg_tcpip_driver_pico_w_data {
|
|||||||
char *pass;
|
char *pass;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define MG_TCPIP_DRIVER_INIT(mgr) \
|
||||||
|
do { \
|
||||||
|
static struct mg_tcpip_driver_pico_w_data driver_data_; \
|
||||||
|
static struct mg_tcpip_if mif_; \
|
||||||
|
MG_SET_WIFI_CREDS(&driver_data_.ssid, &driver_data_.pass); \
|
||||||
|
mif_.ip = MG_TCPIP_IP; \
|
||||||
|
mif_.mask = MG_TCPIP_MASK; \
|
||||||
|
mif_.gw = MG_TCPIP_GW; \
|
||||||
|
mif_.driver = &mg_tcpip_driver_pico_w; \
|
||||||
|
mif_.driver_data = &driver_data_; \
|
||||||
|
mif_.recv_queue.size = 8192; \
|
||||||
|
mif_.mac[0] = 2; /* MAC read from OTP at driver init */ \
|
||||||
|
mg_tcpip_init(mgr, &mif_); \
|
||||||
|
MG_INFO(("Driver: pico-w, MAC: %M", mg_print_mac, mif_.mac)); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user