From 2507272357d814c938b1d7ead17ef6f250e7d67b Mon Sep 17 00:00:00 2001 From: Peter Harper <77111776+peterharperuk@users.noreply.github.com> Date: Tue, 3 Sep 2024 16:52:05 +0100 Subject: [PATCH] Fix compile issues with LWIP_SINGLE_NETIF (#515) Fixes #514 --- pico_w/bt/picow_bt_example_common.c | 2 +- pico_w/bt/standalone/server_with_wifi.c | 2 +- pico_w/wifi/freertos/httpd/pico_freertos_httpd.c | 2 +- pico_w/wifi/freertos/iperf/picow_freertos_iperf.c | 2 +- pico_w/wifi/httpd/pico_httpd.c | 2 +- pico_w/wifi/iperf/picow_iperf.c | 2 +- pico_w/wifi/lwipopts_examples_common.h | 1 + pico_w/wifi/tcp_server/picow_tcp_server.c | 2 +- 8 files changed, 8 insertions(+), 7 deletions(-) diff --git a/pico_w/bt/picow_bt_example_common.c b/pico_w/bt/picow_bt_example_common.c index 7d93520b1..cd20ceec4 100644 --- a/pico_w/bt/picow_bt_example_common.c +++ b/pico_w/bt/picow_bt_example_common.c @@ -97,7 +97,7 @@ void picow_bt_example_main(void) { } else { printf("Connected in %lus.\n", (to_ms_since_boot(get_absolute_time()) - start_ms) / 1000); } - printf("\nReady, running iperf server at %s\n", ip4addr_ntoa(netif_ip4_addr(netif_list))); + printf("\nReady, running iperf server at %s\n", ip4addr_ntoa(netif_ip4_addr(netif_default))); lwiperf_start_tcp_server_default(&iperf_report, NULL); #endif } diff --git a/pico_w/bt/standalone/server_with_wifi.c b/pico_w/bt/standalone/server_with_wifi.c index af17e6f05..014051068 100644 --- a/pico_w/bt/standalone/server_with_wifi.c +++ b/pico_w/bt/standalone/server_with_wifi.c @@ -100,7 +100,7 @@ int main() { // setup iperf cyw43_arch_lwip_begin(); - printf("\nReady, running iperf server at %s\n", ip4addr_ntoa(netif_ip4_addr(netif_list))); + printf("\nReady, running iperf server at %s\n", ip4addr_ntoa(netif_ip4_addr(netif_default))); lwiperf_start_tcp_server_default(&iperf_report, NULL); cyw43_arch_lwip_end(); diff --git a/pico_w/wifi/freertos/httpd/pico_freertos_httpd.c b/pico_w/wifi/freertos/httpd/pico_freertos_httpd.c index 0a262e5de..207be5d7f 100644 --- a/pico_w/wifi/freertos/httpd/pico_freertos_httpd.c +++ b/pico_w/wifi/freertos/httpd/pico_freertos_httpd.c @@ -158,7 +158,7 @@ void main_task(__unused void *params) { #endif #endif - printf("\nReady, running httpd at %s\n", ip4addr_ntoa(netif_ip4_addr(netif_list))); + printf("\nReady, running httpd at %s\n", ip4addr_ntoa(netif_ip4_addr(netif_default))); httpd_init(); http_set_cgi_handlers(cgi_handlers, LWIP_ARRAYSIZE(cgi_handlers)); diff --git a/pico_w/wifi/freertos/iperf/picow_freertos_iperf.c b/pico_w/wifi/freertos/iperf/picow_freertos_iperf.c index 148f6035a..1e8fb6489 100644 --- a/pico_w/wifi/freertos/iperf/picow_freertos_iperf.c +++ b/pico_w/wifi/freertos/iperf/picow_freertos_iperf.c @@ -79,7 +79,7 @@ void main_task(__unused void *params) { ip4_addr_set_u32(&clientaddr, ipaddr_addr(xstr(IPERF_SERVER_IP))); assert(lwiperf_start_tcp_client_default(&clientaddr, &iperf_report, NULL) != NULL); #else - printf("\nReady, running iperf server at %s\n", ip4addr_ntoa(netif_ip4_addr(netif_list))); + printf("\nReady, running iperf server at %s\n", ip4addr_ntoa(netif_ip4_addr(netif_default))); lwiperf_start_tcp_server_default(&iperf_report, NULL); #endif cyw43_arch_lwip_end(); diff --git a/pico_w/wifi/httpd/pico_httpd.c b/pico_w/wifi/httpd/pico_httpd.c index e469c88f0..87e9f85e9 100644 --- a/pico_w/wifi/httpd/pico_httpd.c +++ b/pico_w/wifi/httpd/pico_httpd.c @@ -203,7 +203,7 @@ int main() { } else { printf("Connected.\n"); } - printf("\nReady, running httpd at %s\n", ip4addr_ntoa(netif_ip4_addr(netif_list))); + printf("\nReady, running httpd at %s\n", ip4addr_ntoa(netif_ip4_addr(netif_default))); // start http server wifi_connected_time = get_absolute_time(); diff --git a/pico_w/wifi/iperf/picow_iperf.c b/pico_w/wifi/iperf/picow_iperf.c index 927e5c7b2..e676591c9 100644 --- a/pico_w/wifi/iperf/picow_iperf.c +++ b/pico_w/wifi/iperf/picow_iperf.c @@ -72,7 +72,7 @@ int main() { ip4_addr_set_u32(&clientaddr, ipaddr_addr(xstr(IPERF_SERVER_IP))); assert(lwiperf_start_tcp_client_default(&clientaddr, &iperf_report, NULL) != NULL); #else - printf("\nReady, running iperf server at %s\n", ip4addr_ntoa(netif_ip4_addr(netif_list))); + printf("\nReady, running iperf server at %s\n", ip4addr_ntoa(netif_ip4_addr(netif_default))); lwiperf_start_tcp_server_default(&iperf_report, NULL); #endif cyw43_arch_lwip_end(); diff --git a/pico_w/wifi/lwipopts_examples_common.h b/pico_w/wifi/lwipopts_examples_common.h index 217cb1357..a857a1fe5 100644 --- a/pico_w/wifi/lwipopts_examples_common.h +++ b/pico_w/wifi/lwipopts_examples_common.h @@ -51,6 +51,7 @@ #define LWIP_NETIF_TX_SINGLE_PBUF 1 #define DHCP_DOES_ARP_CHECK 0 #define LWIP_DHCP_DOES_ACD_CHECK 0 +#define LWIP_SINGLE_NETIF 1 #ifndef NDEBUG #define LWIP_DEBUG 1 diff --git a/pico_w/wifi/tcp_server/picow_tcp_server.c b/pico_w/wifi/tcp_server/picow_tcp_server.c index f9b500eb4..2d5be709e 100644 --- a/pico_w/wifi/tcp_server/picow_tcp_server.c +++ b/pico_w/wifi/tcp_server/picow_tcp_server.c @@ -187,7 +187,7 @@ static err_t tcp_server_accept(void *arg, struct tcp_pcb *client_pcb, err_t err) static bool tcp_server_open(void *arg) { TCP_SERVER_T *state = (TCP_SERVER_T*)arg; - DEBUG_printf("Starting server at %s on port %u\n", ip4addr_ntoa(netif_ip4_addr(netif_list)), TCP_PORT); + DEBUG_printf("Starting server at %s on port %u\n", ip4addr_ntoa(netif_ip4_addr(netif_default)), TCP_PORT); struct tcp_pcb *pcb = tcp_new_ip_type(IPADDR_TYPE_ANY); if (!pcb) {