6
6
7
7
#include "pico/cyw43_arch.h"
8
8
#include "pico/stdlib.h"
9
- #include "pico/http_client_util.h"
10
9
#include "lwip/altcp_tls.h"
11
10
12
11
#include "lwip/netif.h"
13
12
14
13
#include "FreeRTOS.h"
15
14
#include "task.h"
15
+ #include "example_http_client_util.h"
16
16
17
17
#ifndef RUN_FREERTOS_ON_CORE
18
18
#define RUN_FREERTOS_ON_CORE 0
19
19
#endif
20
20
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
23
23
24
24
// Using this url as we know the root cert won't change for a long time
25
25
#define HOST "fw-download-alias1.raspberrypi.com"
@@ -46,31 +46,11 @@ PC3wSPqJ1byJKA6D+ZyjKR1aORbiDQVEpDNWRKiQ5QapLg8wbcED0MrRKQIxAKUT\n\
46
46
v8TJkb/8jC/oBVTmczKlPMkciN+uiaZSXahgYKyYhvKTatCTZb+geSIhc0w/2w==\n\
47
47
-----END CERTIFICATE-----\n"
48
48
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
-
67
49
void main_task (__unused void * params ) {
68
50
if (cyw43_arch_init ()) {
69
51
printf ("failed to initialise\n" );
70
52
return ;
71
53
}
72
- TaskHandle_t blinkHandle = NULL ;
73
- xTaskCreate (blink_task , "BlinkThread" , configMINIMAL_STACK_SIZE , NULL , BLINK_TASK_PRIORITY , & blinkHandle );
74
54
75
55
cyw43_arch_enable_sta_mode ();
76
56
printf ("Connecting to Wi-Fi...\n" );
@@ -82,27 +62,26 @@ void main_task(__unused void *params) {
82
62
}
83
63
84
64
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 };
86
66
req .hostname = HOST ;
87
67
req .url = URL_REQUEST ;
88
68
req .headers_fn = http_client_header_print_fn ;
89
69
req .recv_fn = http_client_receive_print_fn ;
90
70
req .tls_config = altcp_tls_create_config_client (cert_ok , sizeof (cert_ok ));
71
+
91
72
int pass = http_client_request_sync (cyw43_arch_async_context (), & req );
92
73
altcp_tls_free_config (req .tls_config );
93
-
94
74
if (pass != 0 ) {
95
75
panic ("test failed" );
96
76
}
97
77
98
- vTaskDelete (blinkHandle );
99
78
cyw43_arch_deinit ();
100
79
panic ("Test passed" );
101
80
}
102
81
103
82
void vLaunch ( void ) {
104
83
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 );
106
85
107
86
#if NO_SYS && configUSE_CORE_AFFINITY && configNUM_CORES > 1
108
87
// we must bind the main task to one core (well at least while the init is called)
0 commit comments