diff --git a/drivers/wifi/siwx91x/Kconfig.siwx91x b/drivers/wifi/siwx91x/Kconfig.siwx91x index b7bf8a6d9faae..0f22558f9e923 100644 --- a/drivers/wifi/siwx91x/Kconfig.siwx91x +++ b/drivers/wifi/siwx91x/Kconfig.siwx91x @@ -71,6 +71,157 @@ config WIFI_SILABS_SIWX91X_LIMIT_PACKET_BUF_PER_STA would be buffered when the STA is in Power Save (PS) mode. This helps manage buffer usage and ensures efficient packet handling. +config WIFI_SILABS_SIWX91X_SNTP_CLIENT + bool "Offloaded implementation of SNTP client" + help + Enable this option to allow to use the SNTP (Simple Network Time + protocol) implementation provided by the Network Co-Processor present + on SiWx91x series. This implementation usually require less resources + than the Zephyr one. See also sl_sntp.h in Silabs HAL for more + information about the API. + +config WIFI_SILABS_SIWX91X_HTTP_CLIENT + bool "Offloaded implementation of HTTP client" + help + Enable this option to allow to use the HTTP (hypertext transfer + protocol) implementation provided by the Network Co-Processor present + on SiWx91x series. This implementation usually require less resources + than the Zephyr one. See also sl_http_client.h in Silabs HAL for more + information about the API. + +config WIFI_SILABS_SIWX91X_MQTT_CLIENT + bool "Offloaded implementation of MQTT client" + help + Enable this option to allow to use the MQTT(Message Queuing Telemetry + Transport) implementation provided by the Network Co-Processor present + on SiWx91x series. This implementation usually require less resources + than the Zephyr one. See also sl_mqtt_client.h in Silabs HAL for more + information about the API. + +config WIFI_SILABS_SIWX91X_PING + bool "Offloaded implementation of ICMP client" + help + Enable this option to allow to use the MQTT(Internet Control Message + Protocol) implementation provided by the Network Co-Processor present + on SiWx91x series. This implementation usually require less resources + than the Zephyr one. See also sl_net_ping.h in Silabs HAL for more + information about the API. + +config WIFI_SILABS_SIWX91X_WEBSOCKET_CLIENT + bool "Offloaded implementation of Websocket client" + help + Enable this option to allow to use the Websocket client implementation + provided by the Network Co-Processor present on SiWx91x series. This + implementation usually require less resources than the Zephyr one. + See also sl_websocket_client.h in Silabs HAL for more information + about the API. + +config WIFI_SILABS_SIWX91X_MDNS_RESPONDER + bool "Offloaded implementation of MDNS responder" + help + Enable this option to allow to use the MDNS(Multicast Domain Name + System) implementation provided by the Network Co-Processor present + on SiWx91x series. This implementation usually require less resources + than the Zephyr one. See also sl_mdns.h in Silabs HAL for more + information about the API. + +config WIFI_SILABS_SIWX91X_DNS_CLIENT + bool "Offloaded implementation of DNS client" + help + Enable this option to allow to use the DNS(Domain Name System) + implementation provided by the Network Co-Processor present on + SiWx91x series. This implementation usually require less + resources than the Zephyr one. See also sl_net_dns.h in Silabs + HAL for more information about the API. + +config WIFI_SILABS_SIWX91X_ENABLE_TLS + bool "Offloaded implementation of TLS" + help + Enable this option to allow to use the TLS(Transport layer Security) + implementation over the network provided by the Network Co-Processor + present on SiWx91x series. This implementation usually require less + resources than the Zephyr one. + +config WIFI_SILABS_SIWX91X_ENABLE_SINGLE_TLS_SOCKET + bool "Offloaded implementation of single TLS socket" + depends on WIFI_SILABS_SIWX91X_ENABLE_TLS + help + Enable this option to allow to use the single TLS socket + implementation over the network provided by the Network + Co-Processor present on SiWx91x series. + +config WIFI_SILABS_SIWX91X_ENABLE_THREE_SSL_SOCKETS + bool "Offloaded implementation of 3 SSL/TLS sockets" + help + Enable this option to support up to three SSL socket implementations + over the network, utilizing the Network Co-Processor available in + the SiWx91x series. + +config WIFI_SILABS_SIWX91X_SSL_HIGH_STREAMING + bool "Offloaded implementation for SSL/TLS high speed" + help + Enable this option to achieve high-throughput SSL/TLS streaming, + This implementation is provided by the Network Co-Processor present + on SiWx91x series. + +config WIFI_SILABS_SIWX91X_SSL_VERSIONS_SUPPORT + bool "Offloaded implementation of SSL/TLS multiple versions support" + help + Enable this option to allow the device to support multiple versions + of SSL/TLS over TCP, providing flexibility in handling different + SSL/TLS versions.This implementation is provided by the Network + Co-Processor present on SiWx91x series. + +config WIFI_SILABS_SIWX91X_ENABLE_SSL_16K_RECORD + bool "Offloaded implementation to support SSL 16K record" + help + Enable this option to support for 16K SSL record sizes, which improves + performance for SSL connections that use larger record sizes. This + implementation is provided by the Network Co-Processor present on + SiWx91x series. + +config WIFI_SILABS_SIWX91X_SSL_MEMORY_CLOUD + bool "Offloaded implementation for the SSL/TLS cloud connections" + help + Enable this option to allocate additional memory for SSL/TLS + connections, typically required for connections to cloud servers, + to avoid handshake failure.This implementation is provided by the + Network Co-Processor present on SiWx91x series. + +config WIFI_SILABS_SIWX91X_SOCKET_SELECT + bool "Offloaded implementation for socket select" + help + Enable this option for the configuration of socket select + implementation over the network provided by the Network + Co-Processor present on SiWx91x series. + +config WIFI_SILABS_SIWX91X_SOCKET_SELECT_COUNT + int "Offloaded implementation of select" + default 10 + range 1 10 + depends on WIFI_SILABS_SIWX91X_SOCKET_SELECT + help + Configure this option for the number of select operations the + device can handle, with a maximum value of 10. This implementation + is provided by the Network Co-Processor present on SiWx91x series. + +config WIFI_SILABS_SIWX91X_SOCKETS + bool "Offloaded implementation to configure sockets" + help + Enable this option to configure the number of sockets in SiWx91x. + over the network .This implementation is provided by the Network + Co-Processor present on SiWx91x series. + +config WIFI_SILABS_SIWX91X_TOTAL_SOCKETS + int "Offloaded implementation for maximum number of sockets" + default 10 + range 1 10 + depends on WIFI_SILABS_SIWX91X_SOCKETS + help + Configure this option for total number of sockets to use. A maximum + of 10 sockets are allowed to use. This implementation is provided + by the Network Co-Processor present on SiWx91x series. + config WIFI_SILABS_SIWX91X_ENABLE_ROAMING bool "WiFi roaming support" default y diff --git a/modules/hal_silabs/wiseconnect/CMakeLists.txt b/modules/hal_silabs/wiseconnect/CMakeLists.txt index 6ecadd1729ab7..f07b69857ef74 100644 --- a/modules/hal_silabs/wiseconnect/CMakeLists.txt +++ b/modules/hal_silabs/wiseconnect/CMakeLists.txt @@ -40,6 +40,7 @@ zephyr_include_directories( zephyr_library_sources( ${SISDK_DIR}/platform/common/src/sl_core_cortexm.c + ${SISDK_DIR}/platform/common/src/sl_slist.c ${WISECONNECT_DIR}/components/device/silabs/si91x/mcu/core/chip/src/rsi_deepsleep_soc.c ${WISECONNECT_DIR}/components/device/silabs/si91x/mcu/core/chip/src/system_si91x.c ${WISECONNECT_DIR}/components/device/silabs/si91x/mcu/drivers/peripheral_drivers/src/clock_update.c @@ -110,6 +111,60 @@ if(CONFIG_WIFI_SILABS_SIWX91X) ) endif() # CONFIG_WIFI_SILABS_SIWX91X +if(CONFIG_WIFI_SILABS_SIWX91X_NET_STACK_OFFLOAD) + zephyr_compile_definitions_ifdef(CONFIG_WIFI_SILABS_SIWX91X_SNTP_CLIENT + SLI_SI91X_INTERNAL_SNTP_CLIENT + ) + zephyr_include_directories_ifdef(CONFIG_WIFI_SILABS_SIWX91X_SNTP_CLIENT + ${WISECONNECT_DIR}/components/service/sntp/inc + ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/inc/sntp + ) + zephyr_library_sources_ifdef(CONFIG_WIFI_SILABS_SIWX91X_SNTP_CLIENT + ${WISECONNECT_DIR}/components/service/sntp/si91x/sl_sntp.c + ) + zephyr_compile_definitions_ifdef(CONFIG_WIFI_SILABS_SIWX91X_HTTP_CLIENT + SLI_SI91X_INTERNAL_HTTP_CLIENT + ) + zephyr_include_directories_ifdef(CONFIG_WIFI_SILABS_SIWX91X_HTTP_CLIENT + ${WISECONNECT_DIR}/components/service/http_client/inc + ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/inc/http_client/inc + ) + zephyr_library_sources_ifdef(CONFIG_WIFI_SILABS_SIWX91X_HTTP_CLIENT + ${WISECONNECT_DIR}/components/service/http_client/si91x_socket/sl_http_client.c + ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/src/sl_si91x_http_client_callback_framework.c + ) + zephyr_compile_definitions_ifdef(CONFIG_WIFI_SILABS_SIWX91X_MQTT_CLIENT + SLI_SI91X_EMBEDDED_MQTT_CLIENT + ) + zephyr_include_directories_ifdef(CONFIG_WIFI_SILABS_SIWX91X_MQTT_CLIENT + ${WISECONNECT_DIR}/components/service/mqtt/inc + ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/inc/mqtt/inc + ) + zephyr_library_sources_ifdef(CONFIG_WIFI_SILABS_SIWX91X_MQTT_CLIENT + ${WISECONNECT_DIR}/components/service/mqtt/si91x/sl_mqtt_client.c + ) + zephyr_include_directories_ifdef(CONFIG_WIFI_SILABS_SIWX91X_PING + ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/icmp + ) + zephyr_library_sources_ifdef(CONFIG_WIFI_SILABS_SIWX91X_PING + ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/icmp/sl_net_ping.c + ) + zephyr_include_directories_ifdef(CONFIG_WIFI_SILABS_SIWX91X_WEBSOCKET_CLIENT + ${WISECONNECT_DIR}/components/service/sl_websocket_client/inc + ) + zephyr_library_sources_ifdef(CONFIG_WIFI_SILABS_SIWX91X_WEBSOCKET_CLIENT + ${WISECONNECT_DIR}/components/service/sl_websocket_client/src/sl_websocket_client.c + ) + zephyr_include_directories_ifdef(CONFIG_WIFI_SILABS_SIWX91X_MDNS_RESPONDER + ${WISECONNECT_DIR}/components/service/mdns/inc + ) + zephyr_library_sources_ifdef(CONFIG_WIFI_SILABS_SIWX91X_MDNS_RESPONDER + ${WISECONNECT_DIR}/components/service/mdns/si91x/sl_mdns.c + ) + zephyr_library_sources_ifdef(CONFIG_WIFI_SILABS_SIWX91X_DNS_CLIENT + ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/sl_net/src/sl_net_si91x.c + ) +endif() # CONFIG_WIFI_SILABS_SIWX91X_NET_STACK_OFFLOAD if(CONFIG_BT_SILABS_SIWX91X) zephyr_compile_definitions( SLI_SI91X_ENABLE_BLE diff --git a/samples/boards/siwx91x/siwx91x_sample_app/CMakeLists.txt b/samples/boards/siwx91x/siwx91x_sample_app/CMakeLists.txt new file mode 100644 index 0000000000000..bb2798189c909 --- /dev/null +++ b/samples/boards/siwx91x/siwx91x_sample_app/CMakeLists.txt @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.20.0) + +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) +project(siwx91x_sample_app) + +target_sources(app PRIVATE src/main.c) diff --git a/samples/boards/siwx91x/siwx91x_sample_app/README.rst b/samples/boards/siwx91x/siwx91x_sample_app/README.rst new file mode 100644 index 0000000000000..f7d1ee3fa17e3 --- /dev/null +++ b/samples/boards/siwx91x/siwx91x_sample_app/README.rst @@ -0,0 +1,40 @@ +.. zephyr:code-sample:: siwx91x_sample_app + :name: siwx91x sample app + +Overview +******** + +A sample application that demonstrates the DNS client and ICMP functionality. +This program will get the IP address of the given hostname and the ICMP will +initiate a PING request to the address obtained from the DNS client. + +Requirements +************ + +* Windows PC (Remote PC). +* SiWx91x Wi-Fi Evaluation Kit(SoC). + +Configuration Parameters +************************ +The below confgurations are available in app_config.h file + +#define SSID "SiWx91x_AP" // Wi-Fi Network Name +#define PSK "12345678" // Wi-Fi Password +#define SECURITY_TYPE WIFI_SECURITY_TYPE_PSK // Wi-Fi Security Type: WIFI_SECURITY_TYPE_NONE/WIFI_SECURITY_TYPE_WPA_PSK/WIFI_SECURITY_TYPE_PSK +#define CHANNEL_NO WIFI_CHANNEL_ANY // Wi-Fi channel +#define HOSTNAME "www.zephyrproject.org" //Hostname to ping + +Building and Running +******************** + +* This sample can be found under :zephyr_file:`zephyr/samples/boards/siwx91x/siwx91x_sample_app` in the Zephyr tree. + +* Build:- west build -b siwx917_rb4338a samples/boards/siwx91x/siwx91x_sample_app/ -p + +* Flash:- west flash + +Test the Application +******************** +* Open any serial console to view logs. +* After program gets executed, SiWx91x EVK will be connected to an Access Point with configured **SSID** and **PSK** +* The device will start sending ping requests to the given hostname and the response can be seen in network_event_handler(). diff --git a/samples/boards/siwx91x/siwx91x_sample_app/prj.conf b/samples/boards/siwx91x/siwx91x_sample_app/prj.conf new file mode 100644 index 0000000000000..21ca9fae68d24 --- /dev/null +++ b/samples/boards/siwx91x/siwx91x_sample_app/prj.conf @@ -0,0 +1,10 @@ +CONFIG_WIFI=y +CONFIG_NETWORKING=y +CONFIG_WIFI_SILABS_SIWX91X_NET_STACK_OFFLOAD=y +CONFIG_NET_IPV4=y +CONFIG_NET_DHCPV4=y +CONFIG_NET_IPV6=n +CONFIG_NET_DHCPV6=n +CONFIG_MAIN_STACK_SIZE=2048 +CONFIG_WIFI_SILABS_SIWX91X_PING=y +CONFIG_WIFI_SILABS_SIWX91X_DNS_CLIENT=y diff --git a/samples/boards/siwx91x/siwx91x_sample_app/sample.yaml b/samples/boards/siwx91x/siwx91x_sample_app/sample.yaml new file mode 100644 index 0000000000000..11f7414eea9c1 --- /dev/null +++ b/samples/boards/siwx91x/siwx91x_sample_app/sample.yaml @@ -0,0 +1,11 @@ +sample: + name: siwx91x sample app + description: Demonstrates ICMP functionality +tests: + sample.boards.siwx91x.siwx91x_sample_app: + harness: Wi-Fi + platform_allow: + - siwx917_rb4338a + tags: Wi-Fi + integration_platforms: + - siwx917_rb4338a diff --git a/samples/boards/siwx91x/siwx91x_sample_app/src/app_config.h b/samples/boards/siwx91x/siwx91x_sample_app/src/app_config.h new file mode 100644 index 0000000000000..ac7c1610d6c9a --- /dev/null +++ b/samples/boards/siwx91x/siwx91x_sample_app/src/app_config.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2025 Silicon Laboratories Inc. + * SPDX-License-Identifier: Apache-2.0 + */ +#ifndef _CONFIG_H_ +#define _CONFIG_H_ + +/* Wi-Fi Network Name */ +#define SSID "SiWx91x_AP" +/* Wi-Fi Password */ +#define PSK "12345678" +/* Wi-Fi Security Type: + * WIFI_SECURITY_TYPE_NONE/WIFI_SECURITY_TYPE_WPA_PSK/WIFI_SECURITY_TYPE_PSK + */ +#define SECURITY_TYPE WIFI_SECURITY_TYPE_PSK +/* Wi-Fi channel */ +#define CHANNEL_NO WIFI_CHANNEL_ANY +#define STACK_SIZE 4096 +#define STATUS_OK 0 +#define STATUS_FAIL -1 +#define CMD_WAIT_TIME 180000 + +/* Hostname to ping */ +#define HOSTNAME "www.zephyrproject.org" +#define DNS_TIMEOUT (20 * MSEC_PER_SEC) +#define PING_PACKET_SIZE 64 +#define PING_PACKETS 30 + +static struct { + const struct shell *sh; + uint32_t scan_result; + + union { + struct { + uint8_t connecting: 1; + uint8_t disconnecting: 1; + uint8_t _unused: 6; + }; + uint8_t all; + }; +} context; + +#define WIFI_SHELL_MGMT_EVENTS (NET_EVENT_WIFI_CONNECT_RESULT) + +#endif /* _CONFIG_H_ */ diff --git a/samples/boards/siwx91x/siwx91x_sample_app/src/main.c b/samples/boards/siwx91x/siwx91x_sample_app/src/main.c new file mode 100644 index 0000000000000..6b02b9f72d38b --- /dev/null +++ b/samples/boards/siwx91x/siwx91x_sample_app/src/main.c @@ -0,0 +1,238 @@ +/* + * Copyright (c) 2012-2014 Wind River Systems, Inc. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include + +#include "sl_net_ip_types.h" +#include "sl_si91x_types.h" +#include "sl_net_si91x.h" +#include "sl_net_dns.h" +#ifdef CONFIG_WIFI_SILABS_SIWX91X_PING +#include "sl_net_ping.h" +#endif +#include "sl_net.h" +#include "app_config.h" + +volatile uint8_t state = 0; +static K_SEM_DEFINE(wlan_sem, 0, 1); +K_THREAD_STACK_DEFINE(wifi_stack, STACK_SIZE); + +typedef enum siwx91x_app_state_e { + SIWX91X_WIFI_CONNECT_STATE = 0, + SIWX91X_IP_CONFIG_STATE, + SIWX91X_PING_HOSTNAME_STATE +} siwx91x_app_state_t; + +void application_start(void); +static void wifi_mgmt_event_handler(struct net_mgmt_event_callback *cb, uint32_t mgmt_event, + struct net_if *iface); +static void handle_wifi_connect_result(struct net_mgmt_event_callback *cb); +static sl_status_t network_event_handler(sl_net_event_t event, sl_status_t status, void *data, + uint32_t data_length); + +static void dhcp_callback_handler(struct net_mgmt_event_callback *cb, uint32_t mgmt_event, + struct net_if *iface) +{ + uint8_t ipv4_addr[NET_IPV4_ADDR_LEN] = {0}; + uint8_t subnet[NET_IPV4_ADDR_LEN] = {0}; + uint8_t gateway[NET_IPV4_ADDR_LEN] = {0}; + int i = 0; + + if (mgmt_event != NET_EVENT_IPV4_ADDR_ADD) { + return; + } + + for (i = 0; i < ARRAY_SIZE(iface->config.ip.ipv4->unicast); i++) { + + if (iface->config.ip.ipv4->unicast[i].ipv4.addr_type != NET_ADDR_DHCP) { + continue; + } + + printf("Address[%d]: %s", net_if_get_by_iface(iface), + net_addr_ntop(AF_INET, + &iface->config.ip.ipv4->unicast[i].ipv4.address.in_addr, + ipv4_addr, sizeof(ipv4_addr))); + printf(" Subnet[%d]: %s", net_if_get_by_iface(iface), + net_addr_ntop(AF_INET, &iface->config.ip.ipv4->unicast[i].netmask, subnet, + sizeof(subnet))); + printf(" Router[%d]: %s", net_if_get_by_iface(iface), + net_addr_ntop(AF_INET, &iface->config.ip.ipv4->gw, gateway, + sizeof(gateway))); + + k_sem_give(&wlan_sem); + } +} + +void application_start(void) +{ + int32_t status = -1; + uint8_t ping_count = 0; + struct net_if *iface; + + printf("\r\nApplication started\r\n"); + state = SIWX91X_WIFI_CONNECT_STATE; + + while (1) { + switch (state) { + case SIWX91X_WIFI_CONNECT_STATE: { + struct wifi_connect_req_params cnx_params; + + iface = net_if_get_first_wifi(); + memset(&cnx_params, 0, sizeof(struct wifi_connect_req_params)); + context.connecting = true; + cnx_params.channel = CHANNEL_NO; + cnx_params.band = 0; + cnx_params.security = SECURITY_TYPE; + cnx_params.psk_length = strlen(PSK); + cnx_params.psk = PSK; + cnx_params.ssid_length = strlen(SSID); + cnx_params.ssid = SSID; + + status = net_mgmt(NET_REQUEST_WIFI_CONNECT, iface, &cnx_params, + sizeof(struct wifi_connect_req_params)); + if (status != STATUS_OK) { + printf("Connection request failed with error: %d\n", status); + context.connecting = false; + state = SIWX91X_WIFI_CONNECT_STATE; + break; + } + printf("Connection requested\n"); + + if (k_sem_take(&wlan_sem, K_MSEC(CMD_WAIT_TIME)) != STATUS_OK) { + printf("\r\nWi-Fi connect failed\r\n"); + state = SIWX91X_WIFI_CONNECT_STATE; + } + } break; + case SIWX91X_IP_CONFIG_STATE: { + if (k_sem_take(&wlan_sem, K_MSEC(CMD_WAIT_TIME)) != STATUS_OK) { + printf("\r\nIP config failed\r\n"); + state = SIWX91X_IP_CONFIG_STATE; + break; + } + state = SIWX91X_PING_HOSTNAME_STATE; + } break; + case SIWX91X_PING_HOSTNAME_STATE: { + sl_ip_address_t dns_ip = { 0 }; + + sli_net_register_event_handler(network_event_handler); + dns_ip.type = SL_IPV4; + status = sl_net_dns_resolve_hostname(HOSTNAME, DNS_TIMEOUT, + SL_NET_DNS_TYPE_IPV4, &dns_ip); + if (status != STATUS_OK) { + printf("\r\nDNS Query failed:0x%x\r\n", status); + break; + } + printf("\r\nDNS Query successful\r\n"); + printf("\r\nIP address = %d.%d.%d.%d\r\n", dns_ip.ip.v4.bytes[0], + dns_ip.ip.v4.bytes[1], dns_ip.ip.v4.bytes[2], dns_ip.ip.v4.bytes[3]); + while (ping_count < PING_PACKETS) { + status = sl_si91x_send_ping(dns_ip, PING_PACKET_SIZE); + if (status != SL_STATUS_IN_PROGRESS) { + printf("\r\nPing request failed with status 0x%X\r\n", + status); + return; + } + ping_count++; + k_sleep(K_MSEC(1000)); + } + return; + } break; + } + } +} + +static void wifi_mgmt_event_handler(struct net_mgmt_event_callback *cb, uint32_t mgmt_event, + struct net_if *iface) +{ + switch (mgmt_event) { + case NET_EVENT_WIFI_CONNECT_RESULT: + handle_wifi_connect_result(cb); + break; + case NET_EVENT_WIFI_DISCONNECT_RESULT: + break; + default: + break; + } +} + +static void handle_wifi_connect_result(struct net_mgmt_event_callback *cb) +{ + const struct wifi_status *status = (const struct wifi_status *)cb->info; + int st = status->status; + + if (st) { + if (st < 0) { + /* Errno values are negative, try to map to + * wifi status values. + */ + if (st == -ETIMEDOUT) { + st = WIFI_STATUS_CONN_TIMEOUT; + } + } + + printf("Connection request failed (%s/%d)\n", wifi_conn_status_txt(st), st); + state = SIWX91X_WIFI_CONNECT_STATE; + } else { + printf("Connected to Wi-Fi\n"); + state = SIWX91X_IP_CONFIG_STATE; + } + + context.connecting = false; + k_sem_give(&wlan_sem); +} + +static sl_status_t network_event_handler(sl_net_event_t event, sl_status_t status, void *data, + uint32_t data_length) +{ + UNUSED_PARAMETER(data_length); + switch (event) { + case SL_NET_PING_RESPONSE_EVENT: { + sl_si91x_ping_response_t *response = (sl_si91x_ping_response_t *)data; + + if (status != SL_STATUS_OK) { + printf("\r\nPing request failed!\r\n"); + return status; + } + printf("\n%u bytes received from %u.%u.%u.%u\n", response->ping_size, + response->ping_address.ipv4_address[0], + response->ping_address.ipv4_address[1], + response->ping_address.ipv4_address[2], + response->ping_address.ipv4_address[3]); + break; + } + default: + break; + } + + return SL_STATUS_OK; +} + +int main(void) +{ + struct net_mgmt_event_callback wifi_mgmt_cb; + struct net_mgmt_event_callback mgmt_cb; + struct k_thread wifi_task_handle; + + printf("siwx91x sample application for ICMP\r\n"); + net_mgmt_init_event_callback(&wifi_mgmt_cb, wifi_mgmt_event_handler, + (WIFI_SHELL_MGMT_EVENTS)); + net_mgmt_add_event_callback(&wifi_mgmt_cb); + net_mgmt_init_event_callback(&mgmt_cb, dhcp_callback_handler, NET_EVENT_IPV4_ADDR_ADD); + + net_mgmt_add_event_callback(&mgmt_cb); + + k_tid_t application_tid = k_thread_create(&wifi_task_handle, wifi_stack, STACK_SIZE, + (k_thread_entry_t)application_start, NULL, NULL, + NULL, K_PRIO_PREEMPT(10), 0, K_NO_WAIT); + + k_thread_start(application_tid); + k_thread_join(application_tid, K_FOREVER); + printf("\r\nApplication exit\r\n"); + return 0; +} diff --git a/soc/silabs/silabs_siwx91x/siwg917/nwp.c b/soc/silabs/silabs_siwx91x/siwg917/nwp.c index 8395925ebe90b..08911be2f40d0 100644 --- a/soc/silabs/silabs_siwx91x/siwg917/nwp.c +++ b/soc/silabs/silabs_siwx91x/siwg917/nwp.c @@ -127,6 +127,56 @@ static void siwx91x_configure_network_stack(sl_si91x_boot_configuration_t *boot_ } boot_config->tcp_ip_feature_bit_map |= SL_SI91X_TCP_IP_FEAT_ICMP; + if (IS_ENABLED(CONFIG_WIFI_SILABS_SIWX91X_SSL_HIGH_STREAMING)) { + boot_config->feature_bit_map |= SL_SI91X_FEAT_SSL_HIGH_STREAMING_BIT; + } + if (IS_ENABLED(CONFIG_WIFI_SILABS_SIWX91X_SNTP_CLIENT)) { + boot_config->tcp_ip_feature_bit_map |= SL_SI91X_TCP_IP_FEAT_SNTP_CLIENT; + } + if (IS_ENABLED(CONFIG_WIFI_SILABS_SIWX91X_HTTP_CLIENT)) { + boot_config->tcp_ip_feature_bit_map |= SL_SI91X_TCP_IP_FEAT_HTTP_CLIENT; + } + if (IS_ENABLED(CONFIG_WIFI_SILABS_SIWX91X_PING)) { + boot_config->tcp_ip_feature_bit_map |= SL_SI91X_TCP_IP_FEAT_ICMP; + } + if (IS_ENABLED(CONFIG_WIFI_SILABS_SIWX91X_MDNS_RESPONDER)) { + boot_config->tcp_ip_feature_bit_map |= SL_SI91X_TCP_IP_FEAT_MDNSD; + } + if (IS_ENABLED(CONFIG_WIFI_SILABS_SIWX91X_DNS_CLIENT)) { + boot_config->tcp_ip_feature_bit_map |= SL_SI91X_TCP_IP_FEAT_DNS_CLIENT; + } + if (IS_ENABLED(CONFIG_WIFI_SILABS_SIWX91X_ENABLE_TLS)) { + boot_config->tcp_ip_feature_bit_map |= SL_SI91X_TCP_IP_FEAT_SSL; + } + if (IS_ENABLED(CONFIG_WIFI_SILABS_SIWX91X_ENABLE_SINGLE_TLS_SOCKET)) { + boot_config->tcp_ip_feature_bit_map |= SL_SI91X_TCP_IP_FEAT_SINGLE_SSL_SOCKET; + } +#ifdef CONFIG_WIFI_SILABS_SIWX91X_SOCKETS + boot_config->tcp_ip_feature_bit_map |= + SL_SI91X_TCP_IP_TOTAL_SOCKETS(CONFIG_WIFI_SILABS_SIWX91X_TOTAL_SOCKETS); +#endif + if (IS_ENABLED(CONFIG_WIFI_SILABS_SIWX91X_MQTT_CLIENT)) { + boot_config->ext_tcp_ip_feature_bit_map |= SL_SI91X_EXT_EMB_MQTT_ENABLE; + } + if (IS_ENABLED(CONFIG_WIFI_SILABS_SIWX91X_ENABLE_THREE_SSL_SOCKETS)) { + boot_config->ext_tcp_ip_feature_bit_map |= + SL_SI91X_EXT_TCP_IP_FEAT_SSL_THREE_SOCKETS; + } + if (IS_ENABLED(CONFIG_WIFI_SILABS_SIWX91X_ENABLE_SSL_16K_RECORD)) { + boot_config->ext_tcp_ip_feature_bit_map |= SL_SI91X_EXT_TCP_IP_SSL_16K_RECORD; + } + if (IS_ENABLED(CONFIG_WIFI_SILABS_SIWX91X_SSL_MEMORY_CLOUD)) { + boot_config->ext_tcp_ip_feature_bit_map |= + SL_SI91X_EXT_TCP_IP_FEAT_SSL_MEMORY_CLOUD; + } +#ifdef CONFIG_WIFI_SILABS_SIWX91X_SOCKET_SELECT + boot_config->ext_tcp_ip_feature_bit_map |= + SL_SI91X_EXT_TCP_IP_TOTAL_SELECTS(CONFIG_WIFI_SILABS_SIWX91X_SOCKET_SELECT_COUNT); +#endif + if (IS_ENABLED(CONFIG_WIFI_SILABS_SIWX91X_SSL_VERSIONS_SUPPORT)) { + boot_config->ext_custom_feature_bit_map |= + SL_SI91X_EXT_FEAT_SSL_VERSIONS_SUPPORT; + } boot_config->ext_tcp_ip_feature_bit_map |= SL_SI91X_EXT_TCP_IP_WINDOW_SCALING; boot_config->ext_tcp_ip_feature_bit_map |= SL_SI91X_EXT_TCP_IP_TOTAL_SELECTS(10); diff --git a/west.yml b/west.yml index 702bc9b784e32..10b64ea9c628f 100644 --- a/west.yml +++ b/west.yml @@ -235,7 +235,7 @@ manifest: groups: - hal - name: hal_silabs - revision: a0095a7ac356a04e12188bb563e6207594f8e6b2 + revision: pull/100/head path: modules/hal/silabs groups: - hal