Skip to content

Commit d4fe759

Browse files
committed
Fix http_client freertos examples
1 parent a77d881 commit d4fe759

File tree

3 files changed

+12
-29
lines changed

3 files changed

+12
-29
lines changed

pico_w/wifi/freertos/http_client/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ target_include_directories(picow_freertos_http_client_nosys PRIVATE
1414
target_link_libraries(picow_freertos_http_client_nosys
1515
pico_cyw43_arch_lwip_threadsafe_background
1616
pico_stdlib
17-
pico_lwip_http_util
17+
example_lwip_http_util
1818
FreeRTOS-Kernel-Heap4 # FreeRTOS kernel and dynamic heap
1919
)
2020
pico_add_extra_outputs(picow_freertos_http_client_nosys)
@@ -27,6 +27,7 @@ target_compile_definitions(picow_freertos_http_client_sys PRIVATE
2727
WIFI_PASSWORD=\"${WIFI_PASSWORD}\"
2828
NO_SYS=0 # don't want NO_SYS (generally this would be in your lwipopts.h)
2929
ALTCP_MBEDTLS_AUTHMODE=MBEDTLS_SSL_VERIFY_REQUIRED
30+
CYW43_TASK_STACK_SIZE=2048
3031
)
3132
target_include_directories(picow_freertos_http_client_sys PRIVATE
3233
${CMAKE_CURRENT_LIST_DIR}
@@ -36,7 +37,7 @@ target_include_directories(picow_freertos_http_client_sys PRIVATE
3637
target_link_libraries(picow_freertos_http_client_sys
3738
pico_cyw43_arch_lwip_sys_freertos
3839
pico_stdlib
39-
pico_lwip_http_util
40+
example_lwip_http_util
4041
FreeRTOS-Kernel-Heap4 # FreeRTOS kernel and dynamic heap
4142
)
4243
pico_add_extra_outputs(picow_freertos_http_client_sys)

pico_w/wifi/freertos/http_client/picow_freertos_http_client.c

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@
66

77
#include "pico/cyw43_arch.h"
88
#include "pico/stdlib.h"
9-
#include "pico/http_client_util.h"
109
#include "lwip/altcp_tls.h"
1110

1211
#include "lwip/netif.h"
1312

1413
#include "FreeRTOS.h"
1514
#include "task.h"
15+
#include "example_http_client_util.h"
1616

1717
#ifndef RUN_FREERTOS_ON_CORE
1818
#define RUN_FREERTOS_ON_CORE 0
1919
#endif
2020

21-
#define TEST_TASK_PRIORITY ( tskIDLE_PRIORITY + 2UL )
22-
#define BLINK_TASK_PRIORITY ( tskIDLE_PRIORITY + 4UL )
21+
#define TEST_TASK_PRIORITY ( tskIDLE_PRIORITY + 2UL )
22+
#define TEST_TASK_STACK_SIZE 1024
2323

2424
// Using this url as we know the root cert won't change for a long time
2525
#define HOST "fw-download-alias1.raspberrypi.com"
@@ -46,31 +46,11 @@ PC3wSPqJ1byJKA6D+ZyjKR1aORbiDQVEpDNWRKiQ5QapLg8wbcED0MrRKQIxAKUT\n\
4646
v8TJkb/8jC/oBVTmczKlPMkciN+uiaZSXahgYKyYhvKTatCTZb+geSIhc0w/2w==\n\
4747
-----END CERTIFICATE-----\n"
4848

49-
void blink_task(__unused void *params) {
50-
bool on = false;
51-
printf("blink_task starts\n");
52-
while (true) {
53-
#if 0 && configNUM_CORES > 1
54-
static int last_core_id;
55-
if (portGET_CORE_ID() != last_core_id) {
56-
last_core_id = portGET_CORE_ID();
57-
printf("blinking now from core %d\n", last_core_id);
58-
}
59-
#endif
60-
cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, on);
61-
on = !on;
62-
vTaskDelay(200);
63-
}
64-
vTaskDelete(NULL);
65-
}
66-
6749
void main_task(__unused void *params) {
6850
if (cyw43_arch_init()) {
6951
printf("failed to initialise\n");
7052
return;
7153
}
72-
TaskHandle_t blinkHandle = NULL;
73-
xTaskCreate(blink_task, "BlinkThread", configMINIMAL_STACK_SIZE, NULL, BLINK_TASK_PRIORITY, &blinkHandle);
7454

7555
cyw43_arch_enable_sta_mode();
7656
printf("Connecting to Wi-Fi...\n");
@@ -82,27 +62,26 @@ void main_task(__unused void *params) {
8262
}
8363

8464
static const uint8_t cert_ok[] = TLS_ROOT_CERT_OK;
85-
EXAMPLE_HTTP_REQUEST_T req = {0};
65+
static EXAMPLE_HTTP_REQUEST_T req = {0};
8666
req.hostname = HOST;
8767
req.url = URL_REQUEST;
8868
req.headers_fn = http_client_header_print_fn;
8969
req.recv_fn = http_client_receive_print_fn;
9070
req.tls_config = altcp_tls_create_config_client(cert_ok, sizeof(cert_ok));
71+
9172
int pass = http_client_request_sync(cyw43_arch_async_context(), &req);
9273
altcp_tls_free_config(req.tls_config);
93-
9474
if (pass != 0) {
9575
panic("test failed");
9676
}
9777

98-
vTaskDelete(blinkHandle);
9978
cyw43_arch_deinit();
10079
panic("Test passed");
10180
}
10281

10382
void vLaunch( void) {
10483
TaskHandle_t task;
105-
xTaskCreate(main_task, "TestMainThread", 1024, NULL, TEST_TASK_PRIORITY, &task);
84+
xTaskCreate(main_task, "TestMainThread", TEST_TASK_STACK_SIZE, NULL, TEST_TASK_PRIORITY, &task);
10685

10786
#if NO_SYS && configUSE_CORE_AFFINITY && configNUM_CORES > 1
10887
// we must bind the main task to one core (well at least while the init is called)

pico_w/wifi/http_client/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ pico_mirrored_target_link_libraries(example_lwip_http_util INTERFACE
77
pico_lwip_mbedtls
88
pico_mbedtls
99
)
10+
target_include_directories(example_lwip_http_util INTERFACE
11+
${CMAKE_CURRENT_LIST_DIR}
12+
)
1013

1114
add_executable(picow_http_client
1215
picow_http_client.c

0 commit comments

Comments
 (0)