SuperTinyKernel™ RTOS 1.08.x
Lightweight, high-performance, deterministic, bare-metal C++ RTOS for resource-constrained embedded systems. MIT Open Source License.
Loading...
Searching...
No Matches
httpd_tls/example.cpp
/*
* Copyright (c) 2022 Raspberry Pi (Trading) Ltd.
* Copyright (c) 2022-2026 Neutron Code Limited <stk@neutroncode.com> (STK threading adaptation)
*
* SPDX-License-Identifier: BSD-3-Clause
*
* ---------------------------------------------------------------------------
* Pico W lwIP httpd + mDNS example, ported to STK
* ---------------------------------------------------------------------------
*
* A direct port of Raspberry Pi's original single-superloop example onto STK
* threading. It follows the same split used in example-blinky.cpp: one-time
* hardware bring-up runs directly in RunExample(), and everything ongoing
* (Wi-Fi connect, server setup, and the polling loop) runs inside a task's
* Run().
*
* Exception to that split: cyw43_arch_init() is called from inside the
* task's Run(), not from RunExample() alongside the rest of one-time
* bring-up. cyw43_arch_init() builds (or reuses) an async_context_stk,
* whose locking/ownership checks - async_context_stk_lock_check(),
* async_context_stk_execute_sync() - call stk::GetTid() to identify the
* calling task. stk::GetTid() only means something once it's called from a
* real, running STK task, i.e. after kernel.Start(). RunExample() runs
* before that, so cyw43_arch_init() can't live there. sys_arch_set_kernel()
* and cyw43_arch_stk_preinit() have no such restriction - they only stash
* pointers - so those still run from RunExample() as usual.
*
* Threading model: this targets cyw43_arch_stk's task-based background
* model, the STK analogue of upstream's FREERTOS backend, rather than
* POLL or THREADSAFE_BACKGROUND. cyw43_arch_stk.cpp hard-errors under
* NO_SYS=1, so this port only ever runs under NO_SYS=0: cyw43_arch_init()
* spins up async_context_stk's own worker task to drive the driver, and -
* since CYW43_LWIP is set - also spawns lwIP's tcpip thread via
* tcpip_init()/sys_thread_new(), sharing its core lock with the async
* context through sys_arch's LWIP_STK_CUSTOM_CORE_LOCKING hook (see
* lwip_stk.cpp/.h). This task itself never polls the driver; it just needs
* to stay alive after setup.
*
* Efficiency: WifiHttpdTask blocks on s_ControlFlags.Wait() rather than
* spinning, so it only runs when there's actually something to do (an LED
* request, a connect/init/shutdown request). The same holds one level down:
* async_context_stk's worker task and lwIP's tcpip thread are themselves
* STK tasks that block on their own queues/semaphores when idle, rather than
* polling the cyw43 driver or the network stack in a loop. With every task
* in the system blocked on an event rather than busy-waiting, the STK
* scheduler has nothing runnable and puts the CPU to sleep (WFI, or a
* tickless idle that also skips the periodic tick - see KERNEL_TICKLESS /
* STK_TICKLESS_IDLE below) until an interrupt - Wi-Fi/lwIP activity, a POST
* request, a timer - wakes something up. None of that requires any explicit
* power-management code in this file: it falls out of every task in the
* chain (this one, the driver's worker, lwIP's tcpip thread) using
* event-driven waits instead of polling.
* ---------------------------------------------------------------------------
*/
#include <assert.h>
#include <stk.h>
#include <sync/stk_sync.h>
#include <time/stk_time.h>
#include "example.h"
#include "pico/stdlib.h"
#include "pico/cyw43_arch.h"
#include "hardware/structs/rosc.h"
#include "lwip/ip4_addr.h"
#include "lwip/apps/mdns.h"
#include "lwip/apps/mdns_priv.h"
#include "lwip/init.h"
#include "lwip/apps/httpd.h"
#include "lwip/altcp_tls.h"
// Certificates generated by generate_certs_h.py to DER format, to use .crt/,key contents directly
// #define MBEDTLS_PEM_PARSE_C in mbedtls_config.h.
#include "example_certs.h"
// mbedTLS
#include "psa/crypto.h"
#include "mbedtls/platform.h"
// STK
#include "arch/sys_arch.h" // lwIP
#include "pico/cyw43_arch_stk.h" // Pico SDK
#include "threading_alt.h" // mbedTLS
// The driver work plus httpd/mDNS buffers make this a heavier task than a
// typical blinky-style one, so the stack is sized generously.
enum { TASK_STACK_SIZE = 4096 };
#define STR_HELPER(x) #x
#define STR(x) STR_HELPER(x)
void httpd_init(void);
const char WIFI_SSID[] = ENV_WIFI_SSID;
const char WIFI_PASSWORD[] = ENV_WIFI_PASSWORD;
// Tag names are capped by LWIP_HTTPD_MAX_TAG_NAME_LEN - keep entries within it.
static const char *SSI_TAGS[] =
{
"status",
"welcome",
"uptime",
"ledstate",
"ledinv",
"table",
};
#if LWIP_HTTPD_SUPPORT_POST
#define LED_STATE_BUFSIZE 4
static const uint32_t FLAG_LED_UPDATE = (1U << 0); // A POST handler requested a GPIO write.
static const uint32_t FLAG_CONNECT_WIFI = (1U << 1); // Wi-Fi should (re)connect.
static const uint32_t FLAG_INIT_NET = (1U << 2); // The network stack should (re)initialize.
static const uint32_t FLAG_SHUTDOWN_NET = (1U << 3); // The network stack should shut down.
static void *s_CurrentConnection;
static absolute_time_t s_ConnectedTime;
static bool s_LedOn = false;
static altcp_tls_config *s_TlsConfig = NULL;
stk::sync::EventFlags s_ControlFlags;
static void RequestLedUpdate() { s_ControlFlags.Set(FLAG_LED_UPDATE); } // ISR-safe - callable from lwIP callback context.
static void RequestConnectWiFi() { s_ControlFlags.Set(FLAG_CONNECT_WIFI); }
static void RequestInitNetwork() { s_ControlFlags.Set(FLAG_INIT_NET); }
static void RequestShutdownNetwork() { s_ControlFlags.Set(FLAG_SHUTDOWN_NET); }
#if LWIP_MDNS_RESPONDER
static void srv_txt(struct mdns_service *service, void *txt_userdata)
{
err_t res;
LWIP_UNUSED_ARG(txt_userdata);
res = mdns_resp_add_service_txtitem(service, "path=/", 6);
LWIP_ERROR("mdns add service txt failed\n", (res == ERR_OK), return);
}
#endif
// Writes a substring of the MAC address's ASCII hex representation
// (e.g. "112233445566") into dest_in, starting at character index chr_off
// and taking chr_len characters - e.g. chr_off=8, chr_len=4 returns "5566".
// Returns the number of characters written.
static size_t get_mac_ascii(int idx, size_t chr_off, size_t chr_len, char *dest_in)
{
static const char hexchr[] = "0123456789ABCDEF";
uint8_t mac[6];
char *dest = dest_in;
assert(chr_off + chr_len <= (2 * sizeof(mac)));
cyw43_hal_get_mac(idx, mac);
for (; chr_len && (chr_off >> 1) < sizeof(mac); ++chr_off, --chr_len)
{
*dest++ = hexchr[mac[chr_off >> 1] >> (4 * (1 - (chr_off & 1))) & 0xf];
}
return dest - dest_in;
}
static const char *cgi_handler_test(int iIndex, int iNumParams, char *pcParam[], char *pcValue[])
{
STK_UNUSED(iIndex);
STK_UNUSED(pcValue);
if (iNumParams > 0)
{
if (strcmp(pcParam[0], "test") == 0)
{
return "/test.shtml";
}
}
return "/index.shtml";
}
static const char *cgi_handler_restart(int iIndex, int iNumParams, char *pcParam[], char *pcValue[])
{
//RequestShutdownNetwork(); // Disabled: network shutdown doesn't work reliably with lwIP.
return "/index.shtml";
}
static const tCGI CGI_HANDLERS[] =
{
{ "/", cgi_handler_test },
{ "/index.shtml", cgi_handler_test },
{ "/restart", cgi_handler_restart },
};
// pcInsert is capped at LWIP_HTTPD_MAX_TAG_INSERT_LEN; use LWIP_HTTPD_SSI_MULTIPART
// (see the "table" tag below) to stream larger amounts of data across multiple calls.
u16_t ssi_example_ssi_handler(int iIndex, char *pcInsert, int iInsertLen
, uint16_t current_tag_part, uint16_t *next_tag_part
#endif
)
{
size_t printed;
switch (iIndex)
{
case 0: // "status"
{
printed = snprintf(pcInsert, iInsertLen, "Pass");
break;
}
case 1: // "welcome"
{
printed = snprintf(pcInsert, iInsertLen, "Hello from Pico");
break;
}
case 2: // "uptime"
{
uint64_t uptime_s = absolute_time_diff_us(s_ConnectedTime, get_absolute_time()) / 1e6;
printed = snprintf(pcInsert, iInsertLen, "%d", (int)uptime_s);
break;
}
case 3: // "ledstate"
{
printed = snprintf(pcInsert, iInsertLen, "%s", s_LedOn ? "ON" : "OFF");
break;
}
case 4: // "ledinv"
{
printed = snprintf(pcInsert, iInsertLen, "%s", s_LedOn ? "OFF" : "ON");
break;
}
#if LWIP_HTTPD_SSI_MULTIPART
case 5: /* "table" */
{
printed = snprintf(pcInsert, iInsertLen, "<tr><td>This is table row number %d</td></tr>", current_tag_part + 1);
// Advance next_tag_part to request another call for the next row; leaving it
// unchanged (once we hit 9) tells lwIP this tag is fully sent.
if (current_tag_part < 9)
{
*next_tag_part = current_tag_part + 1;
}
break;
}
#endif
default: // unknown tag
{
printed = 0;
break;
}
}
return (u16_t)printed;
}
err_t httpd_post_begin(void *connection, const char *uri, const char *http_request,
u16_t http_request_len, int content_len, char *response_uri,
u16_t response_uri_len, u8_t *post_auto_wnd)
{
STK_UNUSED(http_request);
STK_UNUSED(http_request_len);
STK_UNUSED(content_len);
if (memcmp(uri, "/led.cgi", 8) == 0 && s_CurrentConnection != connection)
{
s_CurrentConnection = connection;
snprintf(response_uri, response_uri_len, "/ledfail.shtml");
*post_auto_wnd = 1;
return ERR_OK;
}
return ERR_VAL;
}
// Finds param_name in the POST body pbuf chain and copies its value into
// value_buf (NUL-terminated). Returns value_buf on success, NULL if the
// parameter is missing or its value doesn't fit in value_buf_len.
char *httpd_param_value(struct pbuf *p, const char *param_name, char *value_buf, size_t value_buf_len)
{
size_t param_len = strlen(param_name);
u16_t param_pos = pbuf_memfind(p, param_name, param_len, 0);
if (param_pos != 0xFFFF)
{
u16_t param_value_pos = param_pos + param_len;
u16_t param_value_len = 0;
u16_t tmp = pbuf_memfind(p, "&", 1, param_value_pos);
if (tmp != 0xFFFF)
{
param_value_len = tmp - param_value_pos;
}
else
{
param_value_len = p->tot_len - param_value_pos;
}
if (param_value_len > 0 && param_value_len < value_buf_len)
{
char *result = (char *)pbuf_get_contiguous(p, value_buf, value_buf_len, param_value_len, param_value_pos);
if (result)
{
result[param_value_len] = 0;
return result;
}
}
}
return NULL;
}
err_t httpd_post_receive_data(void *connection, struct pbuf *p)
{
err_t ret = ERR_VAL;
LWIP_ASSERT("NULL pbuf", p != NULL);
if (s_CurrentConnection == connection)
{
char buf[LED_STATE_BUFSIZE];
char *val = httpd_param_value(p, "led_state=", buf, sizeof(buf));
if (val)
{
s_LedOn = (strcmp(val, "ON") == 0) ? true : false;
RequestLedUpdate();
ret = ERR_OK;
}
}
pbuf_free(p);
return ret;
}
void httpd_post_finished(void *connection, char *response_uri, u16_t response_uri_len)
{
snprintf(response_uri, response_uri_len, "/ledfail.shtml");
if (s_CurrentConnection == connection)
{
snprintf(response_uri, response_uri_len, "/ledpass.shtml");
}
s_CurrentConnection = NULL;
}
#endif
static bool InitNetwork()
{
// Must run from inside the task, not from RunExample() before kernel.Start() -
// see the file header for why (cyw43_arch_init()'s async_context_stk needs a
// running STK task to call stk::GetTid() from).
if (cyw43_arch_init())
{
printf("failed to initialise\n");
return false;
}
// Initialize PSA Crypto engine (Required for Mbed TLS 4)
psa_status_t status = psa_crypto_init();
if (status != PSA_SUCCESS)
{
printf("failed to initialise PSA crypto: %d\n", (int)status);
cyw43_arch_deinit();
return false;
}
cyw43_arch_enable_sta_mode();
return true;
}
static void ShutdownNetwork()
{
#if LWIP_MDNS_RESPONDER
mdns_resp_remove_netif(&cyw43_state.netif[CYW43_ITF_STA]);
udp_remove(get_mdns_pcb());
// KNOWN ISSUE: this doesn't decrement netif_client_id in netif.c, so a later
// mdns_resp_add_netif() will assert in netif_alloc_client_data_id() on reinit.
#endif
cyw43_arch_disable_sta_mode();
cyw43_arch_deinit();
}
static void InitServer()
{
char hostname[sizeof(CYW43_HOST_NAME) + 4];
memcpy(&hostname[0], CYW43_HOST_NAME, sizeof(CYW43_HOST_NAME) - 1);
get_mac_ascii(CYW43_HAL_MAC_WLAN0, 8, 4, &hostname[sizeof(CYW43_HOST_NAME) - 1]);
hostname[sizeof(hostname) - 1] = '\0';
netif_set_hostname(&cyw43_state.netif[CYW43_ITF_STA], hostname);
#if LWIP_MDNS_RESPONDER
// Set up the mDNS responder.
cyw43_arch_lwip_begin();
mdns_resp_init();
printf("mdns host name %s.local\n", hostname);
#if LWIP_VERSION_MAJOR >= 2 && LWIP_VERSION_MINOR >= 2
mdns_resp_add_netif(&cyw43_state.netif[CYW43_ITF_STA], hostname);
mdns_resp_add_service(&cyw43_state.netif[CYW43_ITF_STA], "pico_httpd", "_http", DNSSD_PROTO_TCP, 80, srv_txt, NULL);
#else
mdns_resp_add_netif(&cyw43_state.netif[CYW43_ITF_STA], hostname, 60);
mdns_resp_add_service(&cyw43_state.netif[CYW43_ITF_STA], "pico_httpd", "_http", DNSSD_PROTO_TCP, 80, 60, srv_txt, NULL);
#endif
cyw43_arch_lwip_end();
#endif
// Set up the HTTP server. CGI/SSI handlers are global state shared by
// both the plain-HTTP and HTTPS listeners below, so only need setting once.
cyw43_arch_lwip_begin();
http_set_cgi_handlers(CGI_HANDLERS, LWIP_ARRAYSIZE(CGI_HANDLERS));
http_set_ssi_handler(ssi_example_ssi_handler, SSI_TAGS, LWIP_ARRAYSIZE(SSI_TAGS));
// Set up HTTPS on top of the same httpd instance. Uses a self-signed
// cert (see certs_der.h / generate_cert.sh) - browsers will show a
// "not private" warning on first visit since it's not CA-signed; that's
// expected for a self-generated cert and can be bypassed/accepted or
// the cert can be installed as trusted on the client.
s_TlsConfig = altcp_tls_create_config_server_privkey_cert(
s_TlsKey, sizeof(s_TlsKey),
NULL, 0, /* private key is not password-protected */
s_TlsCert, sizeof(s_TlsCert));
if (s_TlsConfig == NULL)
{
printf("Failed to create TLS config - HTTPS disabled, HTTP still available\n");
}
else
{
httpd_inits(s_TlsConfig);
printf("HTTPS server listening on port %d\n", HTTPD_SERVER_PORT_HTTPS);
}
cyw43_arch_lwip_end();
}
static bool ConnectWiFi()
{
printf("Connecting to WiFi...\n");
if (cyw43_arch_wifi_connect_timeout_ms(WIFI_SSID, WIFI_PASSWORD, CYW43_AUTH_WPA2_AES_PSK, 30000))
{
printf("failed to connect.\n");
return false;
}
else
{
printf("Connected.\n");
}
printf("\nReady, running httpd at %s\n", ip4addr_ntoa(netif_ip4_addr(netif_list)));
// Record the connect time for the "uptime" SSI tag.
s_ConnectedTime = get_absolute_time();
return true;
}
// Owns Wi-Fi connect and httpd/mDNS server setup, driven by control-flag events
// rather than the original's while(true) superloop. It doesn't drive the cyw43
// driver itself - async_context_stk's own worker task (spun up inside
// cyw43_arch_init()) does that - so this task's loop just needs to stay alive
// and react to flags after setup.
class WifiHttpdTask : public stk::Task<TASK_STACK_SIZE, stk::ACCESS_PRIVILEGED>
{
private:
void Run() override
{
bool running = true;
while (running)
{
const uint32_t raised = s_ControlFlags.Wait(FLAG_CONNECT_WIFI | FLAG_LED_UPDATE | FLAG_INIT_NET | FLAG_SHUTDOWN_NET, stk::sync::EventFlags::OPT_WAIT_ANY, stk::WAIT_INFINITE);
{
continue;
}
if (raised & FLAG_LED_UPDATE)
{
cyw43_arch_lwip_begin();
cyw43_gpio_set(&cyw43_state, 0, s_LedOn);
cyw43_arch_lwip_end();
}
if (raised & FLAG_CONNECT_WIFI)
{
if (!ConnectWiFi())
{
RequestConnectWiFi();
}
}
if (raised & FLAG_INIT_NET)
{
if (InitNetwork())
{
RequestConnectWiFi();
}
else
{
RequestInitNetwork();
}
}
if (raised & FLAG_SHUTDOWN_NET)
{
RequestInitNetwork();
}
}
}
};
void RunExample()
{
using namespace stk;
// Bring up stdio for logging.
stdio_init_all();
// Enable dynamic task registration and inter-task sync, plus tickless idle
// where the platform supports it.
static constexpr uint8_t KernelMode = KERNEL_DYNAMIC | KERNEL_SYNC | (STK_TICKLESS_IDLE ? KERNEL_TICKLESS : 0);
// Task budget: WifiHttpdTask + TimerHost + async_context_stk's worker tasks +
// lwIP's own sys_thread_new()-spawned tcpip thread (sized by
// LWIP_STK_THREAD_POOL_SIZE). Note: LWIP_STK_NETCONN_SEM_MAX_THREADS is NOT a
// task count - it sizes sys_arch's TId-keyed side-table for
// LWIP_NETCONN_SEM_PER_THREAD and has no bearing on kernel.AddTask() capacity.
static constexpr size_t tasks_count = 1U + stk::time::TimerHost::TASK_COUNT + ASYNC_CONTEXT_STK_TASKS + LWIP_STK_THREAD_POOL_SIZE;
// Allocate the scheduling kernel with priority-based scheduling (sched::SwitchStrategyFP32).
static stk::time::TimerHost timer_host;
static WifiHttpdTask task;
kernel.Initialize();
timer_host.Initialize(&kernel, stk::ACCESS_USER);
// Register the task with the kernel.
kernel.AddTask(&task);
// init mbedTLS threading
stk_mbedtls_threading_init();
// Wire the kernel into lwIP's sys_arch port - must happen before lwip_init().
sys_arch_set_kernel(&kernel);
// Wire the kernel and timer host into the cyw43 port - must happen before cyw43_arch_init().
cyw43_arch_stk_preinit(&kernel, &timer_host);
// Kick off network init once the task starts running; safe to request before kernel.Start().
RequestInitNetwork();
// Start the scheduler - this runs the registered task and blocks here permanently.
kernel.Start();
// Unreachable: kernel.Start() never returns.
STK_ASSERT(false);
}
// mbedTLS specific:
extern "C" int __mbedtls_platform_get_entropy(psa_driver_get_entropy_flags_t flags, size_t *estimate_bits,
unsigned char *output, size_t output_size)
{
/* We don't implement any special flags */
if (flags != 0)
{
return PSA_ERROR_NOT_SUPPORTED;
}
if (output == NULL || estimate_bits == NULL)
{
return PSA_ERROR_INVALID_ARGUMENT;
}
/* Sample physical noise bits from ROSC */
for (size_t i = 0; i < output_size; i++)
{
uint8_t random_byte = 0;
for (int b = 0; b < 8; b++)
{
random_byte = (random_byte << 1) | (rosc_hw->randombit & 1);
}
output[i] = random_byte;
}
/* Set the estimated entropy bits gathered (8 bits per byte) */
*estimate_bits = 8 * output_size;
return 0; // Success
}
#ifdef DEBUG
extern "C" const char *mbedtls_ssl_states_str(mbedtls_ssl_states state)
{
switch (state)
{
case MBEDTLS_SSL_HELLO_REQUEST: return "HELLO_REQUEST";
case MBEDTLS_SSL_CLIENT_HELLO: return "CLIENT_HELLO";
case MBEDTLS_SSL_SERVER_HELLO: return "SERVER_HELLO";
case MBEDTLS_SSL_SERVER_CERTIFICATE: return "SERVER_CERTIFICATE";
case MBEDTLS_SSL_SERVER_KEY_EXCHANGE: return "SERVER_KEY_EXCHANGE";
case MBEDTLS_SSL_CERTIFICATE_REQUEST: return "CERTIFICATE_REQUEST";
case MBEDTLS_SSL_SERVER_HELLO_DONE: return "SERVER_HELLO_DONE";
case MBEDTLS_SSL_CLIENT_CERTIFICATE: return "CLIENT_CERTIFICATE";
case MBEDTLS_SSL_CLIENT_KEY_EXCHANGE: return "CLIENT_KEY_EXCHANGE";
case MBEDTLS_SSL_CERTIFICATE_VERIFY: return "CERTIFICATE_VERIFY";
case MBEDTLS_SSL_CLIENT_CHANGE_CIPHER_SPEC: return "CLIENT_CHANGE_CIPHER_SPEC";
case MBEDTLS_SSL_CLIENT_FINISHED: return "CLIENT_FINISHED";
case MBEDTLS_SSL_SERVER_CHANGE_CIPHER_SPEC: return "SERVER_CHANGE_CIPHER_SPEC";
case MBEDTLS_SSL_SERVER_FINISHED: return "SERVER_FINISHED";
case MBEDTLS_SSL_FLUSH_BUFFERS: return "FLUSH_BUFFERS";
case MBEDTLS_SSL_HANDSHAKE_WRAPUP: return "HANDSHAKE_WRAPUP";
case MBEDTLS_SSL_HANDSHAKE_OVER: return "HANDSHAKE_OVER";
default: return "UNKNOWN_STATE";
}
}
extern "C" const char *mbedtls_ssl_named_group_to_str(uint16_t group_id)
{
switch (group_id)
{
case MBEDTLS_SSL_IANA_TLS_GROUP_SECP256R1: return "secp256r1";
case MBEDTLS_SSL_IANA_TLS_GROUP_SECP384R1: return "secp384r1";
case MBEDTLS_SSL_IANA_TLS_GROUP_SECP521R1: return "secp521r1";
case MBEDTLS_SSL_IANA_TLS_GROUP_X25519: return "x25519";
case MBEDTLS_SSL_IANA_TLS_GROUP_X448: return "x448";
case MBEDTLS_SSL_IANA_TLS_GROUP_FFDHE2048: return "ffdhe2048";
case MBEDTLS_SSL_IANA_TLS_GROUP_FFDHE3072: return "ffdhe3072";
default: return "UNKNOWN_GROUP";
}
}
extern "C" const char *mbedtls_ssl_sig_alg_to_str(uint16_t sig_alg)
{
switch (sig_alg)
{
/* RSA PKCS#1 v1.5 */
case MBEDTLS_TLS1_3_SIG_RSA_PKCS1_SHA256: return "rsa_pkcs1_sha256";
case MBEDTLS_TLS1_3_SIG_RSA_PKCS1_SHA384: return "rsa_pkcs1_sha384";
case MBEDTLS_TLS1_3_SIG_RSA_PKCS1_SHA512: return "rsa_pkcs1_sha512";
/* ECDSA */
case MBEDTLS_TLS1_3_SIG_ECDSA_SECP256R1_SHA256: return "ecdsa_secp256r1_sha256";
case MBEDTLS_TLS1_3_SIG_ECDSA_SECP384R1_SHA384: return "ecdsa_secp384r1_sha384";
case MBEDTLS_TLS1_3_SIG_ECDSA_SECP521R1_SHA512: return "ecdsa_secp521r1_sha512";
/* RSA-PSS */
case MBEDTLS_TLS1_3_SIG_RSA_PSS_RSAE_SHA256: return "rsa_pss_rsae_sha256";
case MBEDTLS_TLS1_3_SIG_RSA_PSS_RSAE_SHA384: return "rsa_pss_rsae_sha384";
case MBEDTLS_TLS1_3_SIG_RSA_PSS_RSAE_SHA512: return "rsa_pss_rsae_sha512";
/* EdDSA */
case MBEDTLS_TLS1_3_SIG_ED25519: return "ed25519";
case MBEDTLS_TLS1_3_SIG_ED448: return "ed448";
default: return "unknown_sig_alg";
}
}
#endif
const unsigned char s_TlsCert[]
const unsigned char s_TlsKey[]
#define LWIP_HTTPD_SSI_MULTIPART
Definition lwipopts.h:23
Top-level STK include. Provides the Kernel class template and all built-in task-switching strategies.
#define STK_UNUSED(X)
Explicitly marks a variable as unused to suppress compiler warnings.
Definition stk_defs.h:715
#define STK_ASSERT(e)
Runtime assertion. Halts execution if the expression e evaluates to false.
Definition stk_defs.h:532
Collection of synchronization primitives (stk::sync namespace).
Collection of time-related primitives (stk::time namespace).
Namespace of STK package.
@ ACCESS_USER
Unprivileged access mode (access to some hardware is restricted, see CPU manual for details)....
Definition stk_common.h:37
static constexpr Timeout WAIT_INFINITE
Timeout value: block indefinitely until the synchronization object is signaled.
Definition stk_common.h:274
@ KERNEL_TICKLESS
Tickless mode. To use this mode STK_TICKLESS_IDLE must be defined to 1 in stk_config....
Definition stk_common.h:51
@ KERNEL_SYNC
Synchronization support (see Event).
Definition stk_common.h:50
@ KERNEL_DYNAMIC
Tasks can be added or removed and therefore exit when done.
Definition stk_common.h:48
EventFlagsT< uint32_t > EventFlags
Default event flags group with a 32-bit flags word (31 usable flags, bit 31 reserved).
Concrete implementation of IKernel.
Definition stk.h:102
void Start() override
Start the scheduler. This call does not return until all tasks have exited (KERNEL_DYNAMIC mode) or i...
Definition stk.h:1999
EAddResult AddTask(ITask *user_task) override
Register task for a soft real-time (SRT) scheduling.
Definition stk.h:1465
void Initialize(uint32_t resolution_us=PERIODICITY_DEFAULT) override
Initialize kernel.
Definition stk.h:1425
Partial implementation of the user task.
Definition stk_helper.h:98
T Set(T flags)
Set one or more flags.
static constexpr uint32_t OPT_WAIT_ANY
T Wait(T flags, uint32_t options=OPT_WAIT_ANY, Timeout timeout_ticks=WAIT_INFINITE)
Wait for one or more flags to be set.
static bool IsError(uint32_t result)
Software timer multiplexer that manages multiple Timer instances on top of a small fixed set of kerne...
EAddResult Initialize(IKernel *kernel, EAccessMode mode, const Config &cfg=Config())
Initialize timer host instance.
@ TASK_COUNT
total number of tasks serving this instance
void Run() override
Entry point of the user task.
static const char * SSI_TAGS[]
static bool ConnectWiFi()
static void InitServer()
static void ShutdownNetwork()
const char WIFI_PASSWORD[]
void httpd_init(void)
static bool InitNetwork()
const char WIFI_SSID[]
static bool ConnectWiFi()
static void InitServer()
int __mbedtls_platform_get_entropy(psa_driver_get_entropy_flags_t flags, size_t *estimate_bits, unsigned char *output, size_t output_size)
static void ShutdownNetwork()
static bool InitNetwork()
#define TASK_STACK_SIZE