Change driver API: up(ifp) -> poll(ifp, 1second)

Add misc extras required by Wi-Fi drivers (in progress)
This commit is contained in:
Sergio R. Caprile committed 2025-03-07 14:14:16 -03:00
1 parent 8906b1ac0f
commit 065027843e
30 files changed
+359 -248

No files matched your search

@@ -320,7 +320,8 @@ static void rx_irq(void) {
s_rxno = rxno;
}
static bool mg_tcpip_driver_rp2040_rmii_up(struct mg_tcpip_if *ifp) {
static bool mg_tcpip_driver_rp2040_rmii_poll(struct mg_tcpip_if *ifp, bool s1) {
if (!s1) return false;
struct mg_tcpip_driver_rp2040_rmii_data *d =
(struct mg_tcpip_driver_rp2040_rmii_data *) ifp->driver_data;
uint32_t bsr =
@@ -332,5 +333,5 @@ struct mg_tcpip_driver mg_tcpip_driver_rp2040_rmii = {
mg_tcpip_driver_rp2040_rmii_init,
mg_tcpip_driver_rp2040_rmii_tx,
NULL,
mg_tcpip_driver_rp2040_rmii_up,
mg_tcpip_driver_rp2040_rmii_poll,
};
@@ -39,9 +39,10 @@ static size_t usb_tx(const void *buf, size_t len, struct mg_tcpip_if *ifp) {
return len;
}
static bool usb_up(struct mg_tcpip_if *ifp) {
static bool usb_poll(struct mg_tcpip_if *ifp, bool s1) {
(void) ifp;
return tud_inited() && tud_ready() && tud_connected();
tud_task();
return s1 ? tud_inited() && tud_ready() && tud_connected() : false;
}
static void fn(struct mg_connection *c, int ev, void *ev_data, void *fn_dta) {
@@ -57,7 +58,7 @@ int main(void) {
mg_mgr_init(&mgr); // and attach it to the interface
mg_timer_add(&mgr, 500, MG_TIMER_REPEAT, blink_cb, &mgr);
struct mg_tcpip_driver driver = {.tx = usb_tx, .up = usb_up};
struct mg_tcpip_driver driver = {.tx = usb_tx, .poll = usb_poll};
struct mg_tcpip_if mif = {.mac = {2, 0, 1, 2, 3, 0x77},
.ip = mg_htonl(MG_U32(192, 168, 3, 1)),
.mask = mg_htonl(MG_U32(255, 255, 255, 0)),
@@ -74,7 +75,6 @@ int main(void) {
MG_INFO(("Starting event loop"));
for (;;) {
mg_mgr_poll(&mgr, 0);
tud_task();
}
return 0;
+4 -4
View File
@@ -52,9 +52,10 @@ static size_t usb_tx(const void *buf, size_t len, struct mg_tcpip_if *ifp) {
return len;
}
static bool usb_up(struct mg_tcpip_if *ifp) {
static bool usb_poll(struct mg_tcpip_if *ifp, bool s1) {
(void) ifp;
return tud_inited() && tud_ready() && tud_connected();
tud_task();
return s1 ? tud_inited() && tud_ready() && tud_connected() : false;
}
static void fn(struct mg_connection *c, int ev, void *ev_data, void *fn_dta) {
@@ -69,7 +70,7 @@ int main(void) {
struct mg_mgr mgr; // Initialise Mongoose event manager
mg_mgr_init(&mgr); // and attach it to the interface
struct mg_tcpip_driver driver = {.tx = usb_tx, .up = usb_up};
struct mg_tcpip_driver driver = {.tx = usb_tx, .poll = usb_poll};
struct mg_tcpip_if mif = {.mac = {2, 0, 1, 2, 3, 0x77},
.ip = mg_htonl(MG_U32(192, 168, 3, 1)),
.mask = mg_htonl(MG_U32(255, 255, 255, 0)),
@@ -87,7 +88,6 @@ int main(void) {
MG_INFO(("Starting event loop"));
for (;;) {
mg_mgr_poll(&mgr, 0);
tud_task();
}
return 0;