diff --git a/pico_w/wifi/freertos/http_client/CMakeLists.txt b/pico_w/wifi/freertos/http_client/CMakeLists.txt index c165e88bc..2b1d439e4 100644 --- a/pico_w/wifi/freertos/http_client/CMakeLists.txt +++ b/pico_w/wifi/freertos/http_client/CMakeLists.txt @@ -14,7 +14,7 @@ target_include_directories(picow_freertos_http_client_nosys PRIVATE target_link_libraries(picow_freertos_http_client_nosys pico_cyw43_arch_lwip_threadsafe_background pico_stdlib - pico_lwip_http_util + example_lwip_http_util FreeRTOS-Kernel-Heap4 # FreeRTOS kernel and dynamic heap ) pico_add_extra_outputs(picow_freertos_http_client_nosys) @@ -27,6 +27,7 @@ target_compile_definitions(picow_freertos_http_client_sys PRIVATE WIFI_PASSWORD=\"${WIFI_PASSWORD}\" NO_SYS=0 # don't want NO_SYS (generally this would be in your lwipopts.h) ALTCP_MBEDTLS_AUTHMODE=MBEDTLS_SSL_VERIFY_REQUIRED + CYW43_TASK_STACK_SIZE=2048 ) target_include_directories(picow_freertos_http_client_sys PRIVATE ${CMAKE_CURRENT_LIST_DIR} @@ -36,7 +37,7 @@ target_include_directories(picow_freertos_http_client_sys PRIVATE target_link_libraries(picow_freertos_http_client_sys pico_cyw43_arch_lwip_sys_freertos pico_stdlib - pico_lwip_http_util + example_lwip_http_util FreeRTOS-Kernel-Heap4 # FreeRTOS kernel and dynamic heap ) pico_add_extra_outputs(picow_freertos_http_client_sys) diff --git a/pico_w/wifi/freertos/http_client/picow_freertos_http_client.c b/pico_w/wifi/freertos/http_client/picow_freertos_http_client.c index ca4716720..bb4bd998a 100644 --- a/pico_w/wifi/freertos/http_client/picow_freertos_http_client.c +++ b/pico_w/wifi/freertos/http_client/picow_freertos_http_client.c @@ -6,20 +6,20 @@ #include "pico/cyw43_arch.h" #include "pico/stdlib.h" -#include "pico/http_client_util.h" #include "lwip/altcp_tls.h" #include "lwip/netif.h" #include "FreeRTOS.h" #include "task.h" +#include "example_http_client_util.h" #ifndef RUN_FREERTOS_ON_CORE #define RUN_FREERTOS_ON_CORE 0 #endif -#define TEST_TASK_PRIORITY ( tskIDLE_PRIORITY + 2UL ) -#define BLINK_TASK_PRIORITY ( tskIDLE_PRIORITY + 4UL ) +#define TEST_TASK_PRIORITY ( tskIDLE_PRIORITY + 2UL ) +#define TEST_TASK_STACK_SIZE 1024 // Using this url as we know the root cert won't change for a long time #define HOST "fw-download-alias1.raspberrypi.com" @@ -46,31 +46,11 @@ PC3wSPqJ1byJKA6D+ZyjKR1aORbiDQVEpDNWRKiQ5QapLg8wbcED0MrRKQIxAKUT\n\ v8TJkb/8jC/oBVTmczKlPMkciN+uiaZSXahgYKyYhvKTatCTZb+geSIhc0w/2w==\n\ -----END CERTIFICATE-----\n" -void blink_task(__unused void *params) { - bool on = false; - printf("blink_task starts\n"); - while (true) { -#if 0 && configNUM_CORES > 1 - static int last_core_id; - if (portGET_CORE_ID() != last_core_id) { - last_core_id = portGET_CORE_ID(); - printf("blinking now from core %d\n", last_core_id); - } -#endif - cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, on); - on = !on; - vTaskDelay(200); - } - vTaskDelete(NULL); -} - void main_task(__unused void *params) { if (cyw43_arch_init()) { printf("failed to initialise\n"); return; } - TaskHandle_t blinkHandle = NULL; - xTaskCreate(blink_task, "BlinkThread", configMINIMAL_STACK_SIZE, NULL, BLINK_TASK_PRIORITY, &blinkHandle); cyw43_arch_enable_sta_mode(); printf("Connecting to Wi-Fi...\n"); @@ -82,27 +62,26 @@ void main_task(__unused void *params) { } static const uint8_t cert_ok[] = TLS_ROOT_CERT_OK; - EXAMPLE_HTTP_REQUEST_T req = {0}; + static EXAMPLE_HTTP_REQUEST_T req = {0}; req.hostname = HOST; req.url = URL_REQUEST; req.headers_fn = http_client_header_print_fn; req.recv_fn = http_client_receive_print_fn; req.tls_config = altcp_tls_create_config_client(cert_ok, sizeof(cert_ok)); + int pass = http_client_request_sync(cyw43_arch_async_context(), &req); altcp_tls_free_config(req.tls_config); - if (pass != 0) { panic("test failed"); } - vTaskDelete(blinkHandle); cyw43_arch_deinit(); panic("Test passed"); } void vLaunch( void) { TaskHandle_t task; - xTaskCreate(main_task, "TestMainThread", 1024, NULL, TEST_TASK_PRIORITY, &task); + xTaskCreate(main_task, "TestMainThread", TEST_TASK_STACK_SIZE, NULL, TEST_TASK_PRIORITY, &task); #if NO_SYS && configUSE_CORE_AFFINITY && configNUM_CORES > 1 // we must bind the main task to one core (well at least while the init is called) diff --git a/pico_w/wifi/http_client/CMakeLists.txt b/pico_w/wifi/http_client/CMakeLists.txt index 8f7bd1fda..6577ef335 100644 --- a/pico_w/wifi/http_client/CMakeLists.txt +++ b/pico_w/wifi/http_client/CMakeLists.txt @@ -7,6 +7,9 @@ pico_mirrored_target_link_libraries(example_lwip_http_util INTERFACE pico_lwip_mbedtls pico_mbedtls ) +target_include_directories(example_lwip_http_util INTERFACE + ${CMAKE_CURRENT_LIST_DIR} + ) add_executable(picow_http_client picow_http_client.c