From 1695372beb9c53e4e6d7594f17b407c316dca97e Mon Sep 17 00:00:00 2001 From: sharad-patil24 <100128124+sharad-patil24@users.noreply.github.com> Date: Thu, 13 Apr 2023 19:03:56 +0530 Subject: [PATCH] [Silabs] : Cleanup and applying coding guideline on Silabs code (#25977) * 917 SoC cleanup and some modifications * removing some files which were not used * Refactor : Applying Coding guideline of Silabs src/platform * some fixes for 917 SoC * Restyler changes * Restyler changes * code standard changes in rs911x folder * Review comment solved * Restyled by clang-format * Build issue solved --------- Co-authored-by: Chirag Bansal Co-authored-by: Restyled.io --- examples/platform/silabs/SiWx917/BUILD.gn | 1 - .../silabs/SiWx917/SiWx917/hal/rsi_hal.h | 105 ------- .../platform/silabs/SiWx917/SiWx917/rsi_if.c | 135 ++++----- .../platform/silabs/SiWx917/SiWx917/wfx_rsi.h | 42 ++- .../silabs/SiWx917/SiWx917/wfx_rsi_host.c | 70 ++--- .../silabs/SiWx917/SiWx917/wfx_rsidev.c | 272 ------------------ .../silabs/efr32/rs911x/hal/efx_spi.c | 12 +- .../silabs/efr32/rs911x/hal/rsi_hal.h | 41 ++- .../efr32/rs911x/hal/rsi_hal_mcu_interrupt.c | 11 +- .../platform/silabs/efr32/rs911x/rsi_if.c | 122 ++++---- .../platform/silabs/efr32/rs911x/wfx_rsi.h | 43 ++- .../silabs/efr32/rs911x/wfx_rsi_host.c | 71 ++--- .../platform/silabs/efr32/rs911x/wfx_rsidev.c | 272 ------------------ .../silabs/SiWx917/BLEManagerImpl.cpp | 79 ++--- .../silabs/SiWx917/bluetooth/rsi_ble_config.h | 208 ++++++-------- .../SiWx917/bluetooth/wfx_sl_ble_init.c | 61 ++-- .../SiWx917/bluetooth/wfx_sl_ble_init.h | 71 +++-- .../silabs/SiWx917/wifi/dhcp_client.cpp | 2 +- .../silabs/SiWx917/wifi/dhcp_client.h | 12 +- .../silabs/SiWx917/wifi/wfx_host_events.h | 169 +++++------ src/platform/silabs/SiWx917/wifi/wfx_msgs.h | 22 -- .../silabs/SiWx917/wifi/wifi_config.h | 28 +- .../silabs/efr32/rs911x/BLEManagerImpl.cpp | 53 ++-- .../silabs/efr32/rs911x/rsi_ble_config.h | 3 +- .../silabs/efr32/rs911x/wfx_sl_ble_init.c | 18 +- src/platform/silabs/efr32/wifi/dhcp_client.h | 12 +- src/platform/silabs/efr32/wifi/wifi_config.h | 24 +- third_party/silabs/SiWx917_sdk.gni | 1 + 28 files changed, 544 insertions(+), 1416 deletions(-) delete mode 100644 examples/platform/silabs/SiWx917/SiWx917/hal/rsi_hal.h delete mode 100644 examples/platform/silabs/SiWx917/SiWx917/wfx_rsidev.c delete mode 100644 examples/platform/silabs/efr32/rs911x/wfx_rsidev.c diff --git a/examples/platform/silabs/SiWx917/BUILD.gn b/examples/platform/silabs/SiWx917/BUILD.gn index 32435f1d58b494..79a71b0fe49462 100644 --- a/examples/platform/silabs/SiWx917/BUILD.gn +++ b/examples/platform/silabs/SiWx917/BUILD.gn @@ -231,7 +231,6 @@ source_set("siwx917-common") { ".", "SiWx917/", "${wifi_sdk_dir}", - "${wifi_sdk_dir}/hal", ] sources = [ diff --git a/examples/platform/silabs/SiWx917/SiWx917/hal/rsi_hal.h b/examples/platform/silabs/SiWx917/SiWx917/hal/rsi_hal.h deleted file mode 100644 index 8e4e6e25952583..00000000000000 --- a/examples/platform/silabs/SiWx917/SiWx917/hal/rsi_hal.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _HAL_RSI_HAL_H_ -#define _HAL_RSI_HAL_H_ -#include "rsi_board_configuration.h" - -#define RSI_HAL_NO_COM_PORT /* This will be done by the project */ - -/* Should be enums */ -#define RSI_HAL_RESET_PIN 0 -#define RSI_HAL_MODULE_INTERRUPT 1 -#define RSI_HAL_SLEEP_CONFIRM_PIN 2 -#define RSI_HAL_WAKEUP_INDICATION_PIN 3 -#define RSI_HAL_MODULE_INTERRUPT_PIN 4 - -//! Timer related macros -//! Macro to configure timer type in single shot -#define RSI_HAL_TIMER_TYPE_SINGLE_SHOT 0 - -// Macro to configure timer type in periodic -#define RSI_HAL_TIMER_TYPE_PERIODIC 1 - -// Macro to configure timer in micro seconds mode -#define RSI_HAL_TIMER_MODE_MICRO 0 - -// Macro to configure timer in milli seconds mode -#define RSI_HAL_TIMER_MODE_MILLI 1 - -//! GPIO Pins related Macros -//! Macro to configure GPIO in output mode -#define RSI_HAL_GPIO_OUTPUT_MODE 1 - -// Macro to configure GPIO in input mode -#define RSI_HAL_GPIO_INPUT_MODE 0 - -// Macro to drive low value on GPIO -#define RSI_HAL_GPIO_LOW 0 - -// Macro to drive high value on GPIO -#define RSI_HAL_GPIO_HIGH 1 - -/****************************************************** - * * Function Declarations - * ******************************************************/ - -void rsi_hal_board_init(void); -void rsi_switch_to_high_clk_freq(void); -void rsi_hal_intr_config(void (*rsi_interrupt_handler)(void)); -void rsi_hal_intr_mask(void); -void rsi_hal_intr_unmask(void); -void rsi_hal_intr_clear(void); -uint8_t rsi_hal_intr_pin_status(void); -void rsi_hal_config_gpio(uint8_t gpio_number, uint8_t mode, uint8_t value); -void rsi_hal_set_gpio(uint8_t gpio_number); -uint8_t rsi_hal_get_gpio(uint8_t gpio_number); -void rsi_hal_clear_gpio(uint8_t gpio_number); -int16_t rsi_spi_transfer(uint8_t * tx_buff, uint8_t * rx_buff, uint16_t transfer_length, uint8_t mode); -int16_t rsi_uart_send(uint8_t * ptrBuf, uint16_t bufLen); -int16_t rsi_uart_recv(uint8_t * ptrBuf, uint16_t bufLen); -int16_t rsi_com_port_send(uint8_t * ptrBuf, uint16_t bufLen); -int16_t rsi_com_port_receive(uint8_t * ptrBuf, uint16_t bufLen); -uint32_t rsi_get_random_number(void); -int32_t rsi_timer_start(uint8_t timer_node, uint8_t mode, uint8_t type, uint32_t duration, void (*rsi_timer_expiry_handler)(void)); -int32_t rsi_timer_stop(uint8_t timer_node); -uint32_t rsi_timer_read(uint8_t timer_node); -void rsi_delay_us(uint32_t delay_us); -void rsi_delay_ms(uint32_t delay_ms); -uint32_t rsi_hal_gettickcount(void); -void SysTick_Handler(void); - -void rsi_interrupt_handler(void); -void ABRD(void); - -void Error_Handler(void); - -/* RTC Related API's */ -uint32_t rsi_rtc_get_time(void); -int32_t rsi_rtc_set_time(uint32_t time); -/* End - RTC Related API's */ - -#ifdef LOGGING_STATS -void rsi_hal_log_stats_intr_config(void (*rsi_give_wakeup_indication)()); -#endif /* LOGGING_STATS */ -#ifdef RSI_WITH_OS -void rsi_os_delay_ms(uint32_t delay_ms); -void PORTD_IRQHandler(void); - -#endif /* RSI_WITH_OS */ - -#endif diff --git a/examples/platform/silabs/SiWx917/SiWx917/rsi_if.c b/examples/platform/silabs/SiWx917/SiWx917/rsi_if.c index 3ad6bad62a4b89..5461e4ad524387 100644 --- a/examples/platform/silabs/SiWx917/SiWx917/rsi_if.c +++ b/examples/platform/silabs/SiWx917/SiWx917/rsi_if.c @@ -30,6 +30,7 @@ #include "rsi_driver.h" #include "rsi_wlan_non_rom.h" +#include "rsi_bootup_config.h" #include "rsi_common_apis.h" #include "rsi_data_types.h" #include "rsi_error.h" @@ -39,15 +40,10 @@ #include "rsi_wlan.h" #include "rsi_wlan_apis.h" #include "rsi_wlan_config.h" -//#include "rsi_wlan_non_rom.h" -#include "rsi_bootup_config.h" #include "dhcp_client.h" #include "wfx_rsi.h" -#define VAL(str) #str -#define TOSTRING(str) VAL(str) - /* Rsi driver Task will use as its stack */ StackType_t driverRsiTaskStack[WFX_RSI_WLAN_TASK_SZ] = { 0 }; @@ -74,7 +70,7 @@ extern rsi_semaphore_handle_t sl_rs_ble_init_sem; * This file implements the interface to the RSI SAPIs */ static uint8_t wfx_rsi_drv_buf[WFX_RSI_BUF_SZ]; -wfx_wifi_scan_ext_t * temp_reset; +static wfx_wifi_scan_ext_t * temp_reset; /****************************************************************** * @fn int32_t wfx_rsi_get_ap_info(wfx_wifi_scan_result_t *ap) @@ -114,7 +110,7 @@ int32_t wfx_rsi_get_ap_ext(wfx_wifi_scan_ext_t * extra_info) status = rsi_wlan_get(RSI_WLAN_EXT_STATS, buff, sizeof(buff)); if (status != RSI_SUCCESS) { - WFX_RSI_LOG("\r\n Failed, Error Code : 0x%lX\r\n", status); + SILABS_LOG("Failed, Error Code : 0x%lX", status); } else { @@ -145,7 +141,7 @@ int32_t wfx_rsi_reset_count() status = rsi_wlan_get(RSI_WLAN_EXT_STATS, buff, sizeof(buff)); if (status != RSI_SUCCESS) { - WFX_RSI_LOG("\r\n Failed, Error Code : 0x%lX\r\n", status); + SILABS_LOG("Failed, Error Code : 0x%lX", status); } else { @@ -187,14 +183,14 @@ int32_t wfx_rsi_disconnect() *********************************************************************/ static void wfx_rsi_join_cb(uint16_t status, const uint8_t * buf, const uint16_t len) { - WFX_RSI_LOG("%s: status: %02x", __func__, status); + SILABS_LOG("%s: status: %02x", __func__, status); wfx_rsi.dev_state &= ~WFX_RSI_ST_STA_CONNECTING; if (status != RSI_SUCCESS) { /* * We should enable retry.. (Need config variable for this) */ - WFX_RSI_LOG("%s: failed. retry: %d", __func__, wfx_rsi.join_retries); + SILABS_LOG("%s: failed. retry: %d", __func__, wfx_rsi.join_retries); wfx_retry_interval_handler(is_wifi_disconnection_event, wfx_rsi.join_retries++); if (is_wifi_disconnection_event || wfx_rsi.join_retries <= WFX_RSI_CONFIG_MAX_JOIN) xEventGroupSetBits(wfx_rsi.events, WFX_EVT_STA_START_JOIN); @@ -204,7 +200,7 @@ static void wfx_rsi_join_cb(uint16_t status, const uint8_t * buf, const uint16_t /* * Join was complete - Do the DHCP */ - WFX_RSI_LOG("%s: join completed.", __func__); + SILABS_LOG("%s: join completed.", __func__); xEventGroupSetBits(wfx_rsi.events, WFX_EVT_STA_CONN); wfx_rsi.join_retries = 0; retryInterval = WLAN_MIN_RETRY_TIMER_MS; @@ -225,7 +221,7 @@ static void wfx_rsi_join_cb(uint16_t status, const uint8_t * buf, const uint16_t *********************************************************************/ static void wfx_rsi_join_fail_cb(uint16_t status, uint8_t * buf, uint32_t len) { - WFX_RSI_LOG("%s: error: failed status: %02x", __func__, status); + SILABS_LOG("%s: error: failed status: %02x", __func__, status); wfx_rsi.join_retries += 1; wfx_rsi.dev_state &= ~(WFX_RSI_ST_STA_CONNECTING | WFX_RSI_ST_STA_CONNECTED); is_wifi_disconnection_event = true; @@ -244,7 +240,6 @@ static void wfx_rsi_join_fail_cb(uint16_t status, uint8_t * buf, uint32_t len) *****************************************************************************************/ static void wfx_rsi_wlan_pkt_cb(uint16_t status, uint8_t * buf, uint32_t len) { - // WFX_RSI_LOG("%s: status=%d, len=%d", __func__, status, len); if (status != RSI_SUCCESS) { return; @@ -265,7 +260,7 @@ static int32_t wfx_rsi_init(void) int32_t status; uint8_t buf[RSI_RESPONSE_HOLD_BUFF_SIZE]; - WFX_RSI_LOG("%s: start wireless drv task", __func__); + SILABS_LOG("%s: start wireless drv task", __func__); /* * Create the driver task */ @@ -273,82 +268,69 @@ static int32_t wfx_rsi_init(void) WLAN_TASK_PRIORITY, driverRsiTaskStack, &driverRsiTaskBuffer); if (NULL == wfx_rsi.drv_task) { - WFX_RSI_LOG("%s: error: rsi_wireless_driver_task failed", __func__); + SILABS_LOG("%s: error: rsi_wireless_driver_task failed", __func__); return RSI_ERROR_INVALID_PARAM; } /* Initialize WiSeConnect or Module features. */ - WFX_RSI_LOG("%s: rsi_wireless_init", __func__); + SILABS_LOG("%s: rsi_wireless_init", __func__); if ((status = rsi_wireless_init(OPER_MODE_0, RSI_OPERMODE_WLAN_BLE)) != RSI_SUCCESS) { - WFX_RSI_LOG("%s: error: rsi_wireless_init failed with status: %02x", __func__, status); + SILABS_LOG("%s: error: rsi_wireless_init failed with status: %02x", __func__, status); return status; } - WFX_RSI_LOG("%s: get FW version..", __func__); + SILABS_LOG("%s: get FW version..", __func__); /* * Get the MAC and other info to let the user know about it. */ if (rsi_wlan_get(RSI_FW_VERSION, buf, sizeof(buf)) != RSI_SUCCESS) { - WFX_RSI_LOG("%s: error: rsi_wlan_get(RSI_FW_VERSION) failed with status: %02x", __func__, status); + SILABS_LOG("%s: error: rsi_wlan_get(RSI_FW_VERSION) failed with status: %02x", __func__, status); return status; } buf[sizeof(buf) - 1] = 0; - WFX_RSI_LOG("%s: RSI firmware version: %s", __func__, buf); + SILABS_LOG("%s: RSI firmware version: %s", __func__, buf); //! Send feature frame if ((status = rsi_send_feature_frame()) != RSI_SUCCESS) { - WFX_RSI_LOG("%s: error: rsi_send_feature_frame failed with status: %02x", __func__, status); + SILABS_LOG("%s: error: rsi_send_feature_frame failed with status: %02x", __func__, status); return status; } - WFX_RSI_LOG("%s: sent rsi_send_feature_frame", __func__); + SILABS_LOG("%s: sent rsi_send_feature_frame", __func__); /* initializes wlan radio parameters and WLAN supplicant parameters. */ (void) rsi_wlan_radio_init(); /* Required so we can get MAC address */ if ((status = rsi_wlan_get(RSI_MAC_ADDRESS, &wfx_rsi.sta_mac.octet[0], RESP_BUFF_SIZE)) != RSI_SUCCESS) { - WFX_RSI_LOG("%s: error: rsi_wlan_get failed with status: %02x", __func__, status); + SILABS_LOG("%s: error: rsi_wlan_get failed with status: %02x", __func__, status); return status; } - WFX_RSI_LOG("%s: WLAN: MAC %02x:%02x:%02x %02x:%02x:%02x", __func__, wfx_rsi.sta_mac.octet[0], wfx_rsi.sta_mac.octet[1], - wfx_rsi.sta_mac.octet[2], wfx_rsi.sta_mac.octet[3], wfx_rsi.sta_mac.octet[4], wfx_rsi.sta_mac.octet[5]); + SILABS_LOG("%s: WLAN: MAC %02x:%02x:%02x %02x:%02x:%02x", __func__, wfx_rsi.sta_mac.octet[0], wfx_rsi.sta_mac.octet[1], + wfx_rsi.sta_mac.octet[2], wfx_rsi.sta_mac.octet[3], wfx_rsi.sta_mac.octet[4], wfx_rsi.sta_mac.octet[5]); wfx_rsi.events = xEventGroupCreateStatic(&rsiDriverEventGroup); /* * Register callbacks - We are only interested in the connectivity CBs */ if ((status = rsi_wlan_register_callbacks(RSI_JOIN_FAIL_CB, wfx_rsi_join_fail_cb)) != RSI_SUCCESS) { - WFX_RSI_LOG("%s: RSI callback register join failed with status: %02x", __func__, status); + SILABS_LOG("%s: RSI callback register join failed with status: %02x", __func__, status); return status; } if ((status = rsi_wlan_register_callbacks(RSI_WLAN_DATA_RECEIVE_NOTIFY_CB, wfx_rsi_wlan_pkt_cb)) != RSI_SUCCESS) { - WFX_RSI_LOG("%s: RSI callback register data-notify failed with status: %02x", __func__, status); + SILABS_LOG("%s: RSI callback register data-notify failed with status: %02x", __func__, status); return status; } wfx_rsi.dev_state |= WFX_RSI_ST_DEV_READY; rsi_semaphore_post(&sl_rs_ble_init_sem); - WFX_RSI_LOG("%s: RSI: OK", __func__); + SILABS_LOG("%s: RSI: OK", __func__); return RSI_SUCCESS; } -/************************************************************************************* - * @fn void wfx_show_err(char *msg) - * @brief - * driver shows error message - * @param[in] msg - * @return - * None - *****************************************************************************************/ -void wfx_show_err(char * msg) -{ - WFX_RSI_LOG("%s: message: %d", __func__, msg); -} - /*************************************************************************************** * @fn static void wfx_rsi_save_ap_info() * @brief @@ -364,7 +346,8 @@ static void wfx_rsi_save_ap_info() status = rsi_wlan_scan_with_bitmap_options((int8_t *) &wfx_rsi.sec.ssid[0], AP_CHANNEL_NO_0, &rsp, sizeof(rsp), SCAN_BITMAP_OPTN_1); - if (status) + + if (status == RSI_SUCCESS) { /* * Scan is done - failed @@ -374,7 +357,7 @@ static void wfx_rsi_save_ap_info() #else /* !WIFI_ENABLE_SECURITY_WPA3 */ wfx_rsi.sec.security = WFX_SEC_WPA2; #endif /* WIFI_ENABLE_SECURITY_WPA3 */ - WFX_RSI_LOG("%s: warn: failed with status: %02x", status); + SILABS_LOG("%s: warn: failed with status: %02x", status); return; } else @@ -383,6 +366,7 @@ static void wfx_rsi_save_ap_info() wfx_rsi.ap_chan = rsp.scan_info->rf_channel; memcpy(&wfx_rsi.ap_mac.octet[0], &rsp.scan_info->bssid[0], BSSID_MAX_STR_LEN); } + switch (rsp.scan_info->security_mode) { case SME_OPEN: @@ -407,8 +391,8 @@ static void wfx_rsi_save_ap_info() wfx_rsi.sec.security = WFX_SEC_UNSPECIFIED; break; } - WFX_RSI_LOG("%s: WLAN: connecting to %s==%s, sec=%d, status=%02x", __func__, &wfx_rsi.sec.ssid[0], &wfx_rsi.sec.passkey[0], - wfx_rsi.sec.security, status); + SILABS_LOG("%s: WLAN: connecting to %s==%s, sec=%d, status=%02x", __func__, &wfx_rsi.sec.ssid[0], &wfx_rsi.sec.passkey[0], + wfx_rsi.sec.security, status); } /******************************************************************************************** @@ -425,7 +409,7 @@ static void wfx_rsi_do_join(void) if (wfx_rsi.dev_state & (WFX_RSI_ST_STA_CONNECTING | WFX_RSI_ST_STA_CONNECTED)) { - WFX_RSI_LOG("%s: not joining - already in progress", __func__); + SILABS_LOG("%s: not joining - already in progress", __func__); } else { @@ -445,12 +429,12 @@ static void wfx_rsi_do_join(void) connect_security_mode = RSI_OPEN; break; default: - WFX_RSI_LOG("%s: error: unknown security type."); + SILABS_LOG("%s: error: unknown security type."); return; } - WFX_RSI_LOG("%s: WLAN: connecting to %s==%s, sec=%d", __func__, &wfx_rsi.sec.ssid[0], &wfx_rsi.sec.passkey[0], - wfx_rsi.sec.security); + SILABS_LOG("%s: WLAN: connecting to %s==%s, sec=%d", __func__, &wfx_rsi.sec.ssid[0], &wfx_rsi.sec.passkey[0], + wfx_rsi.sec.security); /* * Join the network */ @@ -461,7 +445,7 @@ static void wfx_rsi_do_join(void) if ((status = rsi_wlan_register_callbacks(RSI_JOIN_FAIL_CB, wfx_rsi_join_fail_cb)) != RSI_SUCCESS) { - WFX_RSI_LOG("%s: RSI callback register join failed with status: %02x", __func__, status); + SILABS_LOG("%s: RSI callback register join failed with status: %02x", __func__, status); } /* Try to connect Wifi with given Credentials @@ -477,20 +461,19 @@ static void wfx_rsi_do_join(void) { wfx_rsi.dev_state &= ~WFX_RSI_ST_STA_CONNECTING; - WFX_RSI_LOG("%s: rsi_wlan_connect_async failed with status: %02x on try %d", __func__, status, - wfx_rsi.join_retries); + SILABS_LOG("%s: rsi_wlan_connect_async failed with status: %02x on try %d", __func__, status, wfx_rsi.join_retries); wfx_retry_interval_handler(is_wifi_disconnection_event, wfx_rsi.join_retries); wfx_rsi.join_retries++; } else { - WFX_RSI_LOG("%s: starting JOIN to %s after %d tries\n", __func__, (char *) &wfx_rsi.sec.ssid[0], - wfx_rsi.join_retries); + SILABS_LOG("%s: starting JOIN to %s after %d tries\n", __func__, (char *) &wfx_rsi.sec.ssid[0], + wfx_rsi.join_retries); break; // exit while loop } } - WFX_RSI_LOG("Returning the do join"); + SILABS_LOG("Returning the do join"); } } @@ -515,7 +498,7 @@ void wfx_rsi_task(void * arg) uint32_t rsi_status = wfx_rsi_init(); if (rsi_status != RSI_SUCCESS) { - WFX_RSI_LOG("%s: error: wfx_rsi_init with status: %02x", __func__, rsi_status); + SILABS_LOG("%s: error: wfx_rsi_init with status: %02x", __func__, rsi_status); return; } wfx_lwip_start(); @@ -523,7 +506,7 @@ void wfx_rsi_task(void * arg) sta_netif = wfx_get_netif(SL_WFX_STA_INTERFACE); wfx_started_notify(); - WFX_RSI_LOG("%s: starting event wait", __func__); + SILABS_LOG("%s: starting event wait", __func__); for (;;) { /* @@ -546,7 +529,7 @@ void wfx_rsi_task(void * arg) if (flags) { - WFX_RSI_LOG("%s: wait event encountered: %x", __func__, flags); + SILABS_LOG("%s: wait event encountered: %x", __func__, flags); } /* * Let's handle DHCP polling here @@ -601,7 +584,7 @@ void wfx_rsi_task(void * arg) /* * Initiate the Join command (assuming we have been provisioned) */ - WFX_RSI_LOG("%s: starting LwIP STA", __func__); + SILABS_LOG("%s: starting LwIP STA", __func__); wfx_rsi.dev_state |= WFX_RSI_ST_STA_CONNECTED; hasNotifiedWifiConnectivity = false; #if (CHIP_DEVICE_CONFIG_ENABLE_IPV4) @@ -618,7 +601,7 @@ void wfx_rsi_task(void * arg) { wfx_rsi.dev_state &= ~(WFX_RSI_ST_STA_READY | WFX_RSI_ST_STA_CONNECTING | WFX_RSI_ST_STA_CONNECTED | WFX_RSI_ST_STA_DHCP_DONE); - WFX_RSI_LOG("%s: disconnect notify", __func__); + SILABS_LOG("%s: disconnect notify", __func__); /* TODO: Implement disconnect notify */ wfx_lwip_set_sta_link_down(); // Internally dhcpclient_poll(netif) -> // wfx_ip_changed_notify(0) for IPV4 @@ -635,7 +618,7 @@ void wfx_rsi_task(void * arg) { if (!(wfx_rsi.dev_state & WFX_RSI_ST_SCANSTARTED)) { - WFX_RSI_LOG("%s: start SSID scan", __func__); + SILABS_LOG("%s: start SSID scan", __func__); int x; wfx_wifi_scan_result_t ap; rsi_scan_info_t * scan; @@ -643,7 +626,7 @@ void wfx_rsi_task(void * arg) uint8_t bgscan_results[BG_SCAN_RES_SIZE] = { 0 }; status = rsi_wlan_bgscan_profile(1, (rsi_rsp_scan_t *) bgscan_results, BG_SCAN_RES_SIZE); - WFX_RSI_LOG("%s: status: %02x size = %d", __func__, status, BG_SCAN_RES_SIZE); + SILABS_LOG("%s: status: %02x size = %d", __func__, status, BG_SCAN_RES_SIZE); rsi_rsp_scan_t * rsp = (rsi_rsp_scan_t *) bgscan_results; if (status) { @@ -658,11 +641,11 @@ void wfx_rsi_task(void * arg) strcpy(&ap.ssid[0], (char *) &scan->ssid[0]); if (wfx_rsi.scan_ssid) { - WFX_RSI_LOG("Inside scan_ssid"); - WFX_RSI_LOG("SCAN SSID: %s , ap scan: %s", wfx_rsi.scan_ssid, ap.ssid); + SILABS_LOG("Inside scan_ssid"); + SILABS_LOG("SCAN SSID: %s , ap scan: %s", wfx_rsi.scan_ssid, ap.ssid); if (strcmp(wfx_rsi.scan_ssid, ap.ssid) == CMP_SUCCESS) { - WFX_RSI_LOG("Inside ap details"); + SILABS_LOG("Inside ap details"); ap.security = scan->security_mode; ap.rssi = (-1) * scan->rssi_val; memcpy(&ap.bssid[0], &scan->bssid[0], BSSID_MAX_STR_LEN); @@ -671,7 +654,7 @@ void wfx_rsi_task(void * arg) } else { - WFX_RSI_LOG("Inside else"); + SILABS_LOG("Inside else"); ap.security = scan->security_mode; ap.rssi = (-1) * scan->rssi_val; memcpy(&ap.bssid[0], &scan->bssid[0], BSSID_MAX_STR_LEN); @@ -721,8 +704,8 @@ void wfx_dhcp_got_ipv4(uint32_t ip) wfx_rsi.ip4_addr[1] = (ip >> 8) & HEX_VALUE_FF; wfx_rsi.ip4_addr[2] = (ip >> 16) & HEX_VALUE_FF; wfx_rsi.ip4_addr[3] = (ip >> 24) & HEX_VALUE_FF; - WFX_RSI_LOG("%s: DHCP OK: IP=%d.%d.%d.%d", __func__, wfx_rsi.ip4_addr[0], wfx_rsi.ip4_addr[1], wfx_rsi.ip4_addr[2], - wfx_rsi.ip4_addr[3]); + SILABS_LOG("%s: DHCP OK: IP=%d.%d.%d.%d", __func__, wfx_rsi.ip4_addr[0], wfx_rsi.ip4_addr[1], wfx_rsi.ip4_addr[2], + wfx_rsi.ip4_addr[3]); wfx_rsi.dev_state |= WFX_RSI_ST_STA_DHCP_DONE; /* Notify the Connectivity Manager - via the app */ wfx_ip_changed_notify(IP_STATUS_SUCCESS); @@ -821,20 +804,20 @@ int32_t wfx_rsi_init_platform() { int32_t status; /*init task - RS911x*/ - WFX_RSI_LOG("RSI_INIT"); - WFX_RSI_LOG("%s: starting(HEAP_SZ = %d)", __func__, SL_HEAP_SIZE); + SILABS_LOG("RSI_INIT"); + SILABS_LOG("%s: starting(HEAP_SZ = %d)", __func__, SL_HEAP_SIZE); //! Driver initialization status = rsi_driver_init(wfx_rsi_drv_buf, WFX_RSI_BUF_SZ); if ((status < RSI_DRIVER_STATUS) || (status > WFX_RSI_BUF_SZ)) { - WFX_RSI_LOG("%s: error: RSI drv init failed with status: %02x", __func__, status); + SILABS_LOG("%s: error: RSI drv init failed with status: %02x", __func__, status); } - WFX_RSI_LOG("%s: rsi_device_init", __func__); + SILABS_LOG("%s: rsi_device_init", __func__); /* ! Redpine module intialisation */ if ((status = rsi_device_init(LOAD_NWP_FW)) != RSI_SUCCESS) { - WFX_RSI_LOG("%s: error: rsi_device_init failed with status: %02x", __func__, status); + SILABS_LOG("%s: error: rsi_device_init failed with status: %02x", __func__, status); return status; } @@ -858,12 +841,12 @@ void wfx_retry_interval_handler(bool is_wifi_disconnection_event, uint16_t retry */ if (retryJoin < MAX_JOIN_RETRIES_COUNT) { - WFX_RSI_LOG("%s: Next attempt after %d Seconds", __func__, CONVERT_MS_TO_SEC(WLAN_RETRY_TIMER_MS)); + SILABS_LOG("%s: Next attempt after %d Seconds", __func__, CONVERT_MS_TO_SEC(WLAN_RETRY_TIMER_MS)); vTaskDelay(pdMS_TO_TICKS(WLAN_RETRY_TIMER_MS)); } else { - WFX_RSI_LOG("Connect failed after max %d tries", retryJoin); + SILABS_LOG("Connect failed after max %d tries", retryJoin); } } else @@ -877,7 +860,7 @@ void wfx_retry_interval_handler(bool is_wifi_disconnection_event, uint16_t retry { retryInterval = WLAN_MAX_RETRY_TIMER_MS; } - WFX_RSI_LOG("%s: Next attempt after %d Seconds", __func__, CONVERT_MS_TO_SEC(retryInterval)); + SILABS_LOG("%s: Next attempt after %d Seconds", __func__, CONVERT_MS_TO_SEC(retryInterval)); vTaskDelay(pdMS_TO_TICKS(retryInterval)); retryInterval += retryInterval; } diff --git a/examples/platform/silabs/SiWx917/SiWx917/wfx_rsi.h b/examples/platform/silabs/SiWx917/SiWx917/wfx_rsi.h index 4309e97ccc04d5..1a586931be5f18 100644 --- a/examples/platform/silabs/SiWx917/SiWx917/wfx_rsi.h +++ b/examples/platform/silabs/SiWx917/SiWx917/wfx_rsi.h @@ -24,33 +24,32 @@ #define WFX_RSI_WLAN_TASK_SZ (1024 + 512 + 256 + 1024 + 512) /* Unknown how big this should be */ #define WFX_RSI_TASK_SZ (1024 + 1024 + 1024) /* Stack for the WFX/RSI task */ #define WFX_RSI_BUF_SZ (1024 * 15) /* May need tweak */ -#define WFX_RSI_CONFIG_MAX_JOIN 5 /* Max join retries */ -#define WFX_RSI_NUM_TIMERS 2 /* Number of RSI timers to alloc */ +#define WFX_RSI_CONFIG_MAX_JOIN (5) /* Max join retries */ /* * Various events fielded by the wfx_rsi task * Make sure that we only use 8 bits (otherwise freeRTOS - may need some changes) */ -#define WFX_EVT_STA_CONN 0x01 -#define WFX_EVT_STA_DISCONN 0x02 -#define WFX_EVT_AP_START 0x04 -#define WFX_EVT_AP_STOP 0x08 -#define WFX_EVT_SCAN 0x10 /* This is used as scan result and start */ -#define WFX_EVT_STA_START_JOIN 0x20 -#define WFX_EVT_STA_DO_DHCP 0x40 -#define WFX_EVT_STA_DHCP_DONE 0x80 +#define WFX_EVT_STA_CONN (0x01) +#define WFX_EVT_STA_DISCONN (0x02) +#define WFX_EVT_AP_START (0x04) +#define WFX_EVT_AP_STOP (0x08) +#define WFX_EVT_SCAN (0x10) /* This is used as scan result and start */ +#define WFX_EVT_STA_START_JOIN (0x20) +#define WFX_EVT_STA_DO_DHCP (0x40) +#define WFX_EVT_STA_DHCP_DONE (0x80) -#define WFX_RSI_ST_DEV_READY 0x01 -#define WFX_RSI_ST_AP_READY 0x02 -#define WFX_RSI_ST_STA_PROVISIONED 0x04 -#define WFX_RSI_ST_STA_CONNECTING 0x08 -#define WFX_RSI_ST_STA_CONNECTED 0x10 -#define WFX_RSI_ST_STA_DHCP_DONE 0x40 /* Requested to do DHCP after conn */ -#define WFX_RSI_ST_STA_MODE 0x80 /* Enable Station Mode */ -#define WFX_RSI_ST_AP_MODE 0x100 /* Enable AP Mode */ +#define WFX_RSI_ST_DEV_READY (0x01) +#define WFX_RSI_ST_AP_READY (0x02) +#define WFX_RSI_ST_STA_PROVISIONED (0x04) +#define WFX_RSI_ST_STA_CONNECTING (0x08) +#define WFX_RSI_ST_STA_CONNECTED (0x10) +#define WFX_RSI_ST_STA_DHCP_DONE (0x40) /* Requested to do DHCP after conn */ +#define WFX_RSI_ST_STA_MODE (0x80) /* Enable Station Mode */ +#define WFX_RSI_ST_AP_MODE (0x100) /* Enable AP Mode */ #define WFX_RSI_ST_STA_READY (WFX_RSI_ST_STA_CONNECTED | WFX_RSI_ST_STA_DHCP_DONE) -#define WFX_RSI_ST_STARTED 0x200 /* RSI task started */ -#define WFX_RSI_ST_SCANSTARTED 0x400 /* Scan Started */ +#define WFX_RSI_ST_STARTED (0x200) /* RSI task started */ +#define WFX_RSI_ST_SCANSTARTED (0x400) /* Scan Started */ struct wfx_rsi { @@ -75,7 +74,6 @@ struct wfx_rsi uint16_t join_retries; uint8_t ip4_addr[4]; /* Not sure if this is enough */ }; -#define RSI_SCAN_RESP_SZ 54 extern struct wfx_rsi wfx_rsi; #ifdef __cplusplus @@ -91,7 +89,7 @@ int32_t wfx_rsi_get_ap_info(wfx_wifi_scan_result_t * ap); int32_t wfx_rsi_get_ap_ext(wfx_wifi_scan_ext_t * extra_info); int32_t wfx_rsi_reset_count(); int32_t wfx_rsi_disconnect(); -#define WFX_RSI_LOG(...) efr32Log(__VA_ARGS__); +#define SILABS_LOG(...) efr32Log(__VA_ARGS__); #ifdef __cplusplus } diff --git a/examples/platform/silabs/SiWx917/SiWx917/wfx_rsi_host.c b/examples/platform/silabs/SiWx917/SiWx917/wfx_rsi_host.c index f44b6e9b8f7ff0..b731aef85660a9 100644 --- a/examples/platform/silabs/SiWx917/SiWx917/wfx_rsi_host.c +++ b/examples/platform/silabs/SiWx917/SiWx917/wfx_rsi_host.c @@ -48,11 +48,11 @@ sl_status_t wfx_wifi_start(void) { if (wfx_rsi.dev_state & WFX_RSI_ST_STARTED) { - WFX_RSI_LOG("%s: already started.", __func__); + SILABS_LOG("%s: already started.", __func__); return SL_STATUS_OK; } wfx_rsi.dev_state |= WFX_RSI_ST_STARTED; - WFX_RSI_LOG("%s: starting..", __func__); + SILABS_LOG("%s: starting..", __func__); /* * Create the Wifi driver task */ @@ -61,7 +61,7 @@ sl_status_t wfx_wifi_start(void) if (NULL == wfx_rsi.wlan_task) { - WFX_RSI_LOG("%s: error: failed to create task.", __func__); + SILABS_LOG("%s: error: failed to create task.", __func__); return SL_STATUS_FAIL; } return SL_STATUS_OK; @@ -95,33 +95,11 @@ bool wfx_is_sta_mode_enabled(void) { bool mode; mode = !!(wfx_rsi.dev_state & WFX_RSI_ST_STA_MODE); - // WFX_RSI_LOG("%s: %d", __func__, (mode ? "yes" : "no")); return mode; } /********************************************************************* - * @fn sl_wfx_state_t wfx_get_wifi_state(void) - * @brief - * get the wifi state - * @param[in] None - * @return return SL_WFX_NOT_INIT if successful, - * SL_WFX_started otherwise - ***********************************************************************/ -sl_wfx_state_t wfx_get_wifi_state(void) -{ - if (wfx_rsi.dev_state & WFX_RSI_ST_STA_DHCP_DONE) - { - return SL_WFX_STA_INTERFACE_CONNECTED; - } - if (wfx_rsi.dev_state & WFX_RSI_ST_DEV_READY) - { - return SL_WFX_STARTED; - } - return SL_WFX_NOT_INIT; -} - -/********************************************************************* - * @fn sl_wfx_state_t wfx_get_wifi_state(void) + * @fn void wfx_get_wifi_mac_addr(sl_wfx_interface_t interface, sl_wfx_mac_address_t *addr) * @brief * get the wifi mac address * @param[in] Interface: @@ -139,8 +117,8 @@ void wfx_get_wifi_mac_addr(sl_wfx_interface_t interface, sl_wfx_mac_address_t * mac = &wfx_rsi.sta_mac; #endif *addr = *mac; - WFX_RSI_LOG("%s: %02x:%02x:%02x:%02x:%02x:%02x", __func__, mac->octet[0], mac->octet[1], mac->octet[2], mac->octet[3], - mac->octet[4], mac->octet[5]); + SILABS_LOG("%s: %02x:%02x:%02x:%02x:%02x:%02x", __func__, mac->octet[0], mac->octet[1], mac->octet[2], mac->octet[3], + mac->octet[4], mac->octet[5]); } /********************************************************************* @@ -153,7 +131,7 @@ void wfx_get_wifi_mac_addr(sl_wfx_interface_t interface, sl_wfx_mac_address_t * ***********************************************************************/ void wfx_set_wifi_provision(wfx_wifi_provision_t * cfg) { - WFX_RSI_LOG("%s: SSID: %s", __func__, &wfx_rsi.sec.ssid[0]); + SILABS_LOG("%s: SSID: %s", __func__, &wfx_rsi.sec.ssid[0]); wfx_rsi.sec = *cfg; wfx_rsi.dev_state |= WFX_RSI_ST_STA_PROVISIONED; @@ -180,20 +158,6 @@ bool wfx_get_wifi_provision(wfx_wifi_provision_t * wifiConfig) return false; } -/********************************************************************* - * @fn bool wfx_is_sta_provisioned(void) - * @brief - * Driver is STA provisioned - * @param[in] None - * @return None - ***********************************************************************/ -bool wfx_is_sta_provisioned(void) -{ - bool status = (wfx_rsi.dev_state & WFX_RSI_ST_STA_PROVISIONED) ? true : false; - WFX_RSI_LOG("%s: status: SSID -> %s: %s", __func__, &wfx_rsi.sec.ssid[0], (status ? "provisioned" : "not provisioned")); - return status; -} - /********************************************************************* * @fn void wfx_clear_wifi_provision(void) * @brief @@ -205,7 +169,7 @@ void wfx_clear_wifi_provision(void) { memset(&wfx_rsi.sec, 0, sizeof(wfx_rsi.sec)); wfx_rsi.dev_state &= ~WFX_RSI_ST_STA_PROVISIONED; - WFX_RSI_LOG("%s: completed.", __func__); + SILABS_LOG("%s: completed.", __func__); } /************************************************************************* @@ -220,12 +184,12 @@ sl_status_t wfx_connect_to_ap(void) { if (wfx_rsi.dev_state & WFX_RSI_ST_STA_PROVISIONED) { - WFX_RSI_LOG("%s: connecting to access point -> SSID: %s, PSK:%s", __func__, &wfx_rsi.sec.ssid[0], &wfx_rsi.sec.passkey[0]); + SILABS_LOG("%s: connecting to access point -> SSID: %s, PSK:%s", __func__, &wfx_rsi.sec.ssid[0], &wfx_rsi.sec.passkey[0]); xEventGroupSetBits(wfx_rsi.events, WFX_EVT_STA_START_JOIN); } else { - WFX_RSI_LOG("%s: error: access point not provisioned", __func__); + SILABS_LOG("%s: error: access point not provisioned", __func__); return SL_STATUS_INVALID_CONFIGURATION; } return SL_STATUS_OK; @@ -244,7 +208,7 @@ void wfx_setup_ip6_link_local(sl_wfx_interface_t whichif) * TODO: Implement IPV6 setup, currently in wfx_rsi_task() * This is hooked with MATTER code. */ - WFX_RSI_LOG("%s: warning: not implemented.", __func__); + SILABS_LOG("%s: warning: not implemented.", __func__); } /********************************************************************* @@ -259,7 +223,7 @@ bool wfx_is_sta_connected(void) { bool status; status = (wfx_rsi.dev_state & WFX_RSI_ST_STA_CONNECTED) ? true : false; - WFX_RSI_LOG("%s: status: %s", __func__, (status ? "connected" : "not connected")); + SILABS_LOG("%s: status: %s", __func__, (status ? "connected" : "not connected")); return status; } @@ -288,11 +252,11 @@ wifi_mode_t wfx_get_wifi_mode() ***********************************************************************/ sl_status_t wfx_sta_discon(void) { - WFX_RSI_LOG("%s: started.", __func__); + SILABS_LOG("%s: started.", __func__); int32_t status; status = wfx_rsi_disconnect(); wfx_rsi.dev_state &= ~WFX_RSI_ST_STA_CONNECTED; - WFX_RSI_LOG("%s: completed.", __func__); + SILABS_LOG("%s: completed.", __func__); return status; } #if CHIP_DEVICE_CONFIG_ENABLE_IPV4 @@ -315,7 +279,7 @@ bool wfx_have_ipv4_addr(sl_wfx_interface_t which_if) { status = false; /* TODO */ } - WFX_RSI_LOG("%s: status: %d", __func__, status); + SILABS_LOG("%s: status: %d", __func__, status); return status; } #endif /* CHIP_DEVICE_CONFIG_ENABLE_IPV4 */ @@ -339,7 +303,7 @@ bool wfx_have_ipv6_addr(sl_wfx_interface_t which_if) { status = false; /* TODO */ } - WFX_RSI_LOG("%s: status: %d", __func__, status); + SILABS_LOG("%s: status: %d", __func__, status); return status; } @@ -436,6 +400,6 @@ bool wfx_start_scan(char * ssid, void (*callback)(wfx_wifi_scan_result_t *)) void wfx_cancel_scan(void) { /* Not possible */ - WFX_RSI_LOG("%s: cannot cancel scan", __func__); + SILABS_LOG("%s: cannot cancel scan", __func__); } #endif /* SL_WFX_CONFIG_SCAN */ diff --git a/examples/platform/silabs/SiWx917/SiWx917/wfx_rsidev.c b/examples/platform/silabs/SiWx917/SiWx917/wfx_rsidev.c deleted file mode 100644 index d7a464151cac53..00000000000000 --- a/examples/platform/silabs/SiWx917/SiWx917/wfx_rsidev.c +++ /dev/null @@ -1,272 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifdef _WFX_NOT_USED_USING_HAL_INSTEAD_ -#include -#include -#include - -#include "em_bus.h" -#include "em_cmu.h" -#include "em_gpio.h" -#include "em_ldma.h" -#include "em_usart.h" -#include "gpiointerrupt.h" - -/* Need Lwip stuff before rsi is included */ -#include "wfx_host_events.h" - -#include "FreeRTOS.h" -#include "event_groups.h" -#include "rsi_common_apis.h" -#include "rsi_data_types.h" -#include "rsi_error.h" -#include "rsi_nwk.h" -#include "rsi_socket.h" -#include "rsi_utils.h" -#include "rsi_wlan.h" -#include "rsi_wlan_apis.h" -#include "rsi_wlan_config.h" -#include "task.h" - -#include "wfx_host_pinout.h" -#include "wfx_rsi.h" - -/* The following stuff comes from hal/rsi_hal_mcu_interrupt.c */ -static void (*rsi_intr_cb)(void); -/********************************************************************* - * @fn void rsi_hal_intr_config(void (*rsi_interrupt_handler)(void)) - * @brief - * get the hal intr configuration - * @param[in] rsi_interrupt_handler: - * @return - * None - ***********************************************************************/ -void rsi_hal_intr_config(void (*rsi_interrupt_handler)(void)) -{ - rsi_intr_cb = rsi_interrupt_handler; -} - -/*********************************************************************** - * @fn static void wfx_spi_wakeup_irq_callback(uint8_t irqNumber) - * @brief - * end of stuff from hal/rsi_hal_mcu_interrupt.c - * @param[in] irqNumber: - * @return None - * **********************************************************************/ -static void wfx_spi_wakeup_irq_callback(uint8_t irqNumber) -{ - BaseType_t bus_task_woken; - uint32_t interrupt_mask; - - if (irqNumber != SL_WFX_HOST_PINOUT_SPI_IRQ) - return; - // Get and clear all pending GPIO interrupts - interrupt_mask = GPIO_IntGet(); - GPIO_IntClear(interrupt_mask); - if (rsi_intr_cb) - (*rsi_intr_cb)(); -} - -/*********************************************************************** - * @fn static void wfx_host_gpio_init(void) - * @brief - * function called when host gpio intialization - * @param[in] None - * @return None - * **********************************************************************/ -static void wfx_host_gpio_init(void) -{ - // Enable GPIO clock. - CMU_ClockEnable(cmuClock_GPIO, true); - - // Configure WF200 reset pin. - GPIO_PinModeSet(SL_WFX_HOST_PINOUT_RESET_PORT, SL_WFX_HOST_PINOUT_RESET_PIN, gpioModePushPull, PINOUT_CLEAR); - // Configure WF200 WUP pin. - GPIO_PinModeSet(SL_WFX_HOST_PINOUT_WUP_PORT, SL_WFX_HOST_PINOUT_WUP_PIN, gpioModePushPull, PINOUT_CLEAR); - - // GPIO used as IRQ. - GPIO_PinModeSet(SL_WFX_HOST_PINOUT_SPI_WIRQ_PORT, SL_WFX_HOST_PINOUT_SPI_WIRQ_PIN, gpioModeInputPull, PINOUT_CLEAR); - CMU_OscillatorEnable(cmuOsc_LFXO, true, true); - - // Set up interrupt based callback function - trigger on both edges. - GPIOINT_Init(); - GPIO_ExtIntConfig(SL_WFX_HOST_PINOUT_SPI_WIRQ_PORT, SL_WFX_HOST_PINOUT_SPI_WIRQ_PIN, SL_WFX_HOST_PINOUT_SPI_IRQ, true, false, - true); - GPIOINT_CallbackRegister(SL_WFX_HOST_PINOUT_SPI_IRQ, wfx_spi_wakeup_irq_callback); - - // Change GPIO interrupt priority (FreeRTOS asserts unless this is done here!) - NVIC_SetPriority(GPIO_EVEN_IRQn, WFX_GPIO_NVIC_PRIORITY); - NVIC_SetPriority(GPIO_ODD_IRQn, WFX_GPIO_NVIC_PRIORITY); -} - -#define USART SL_WFX_HOST_PINOUT_SPI_PERIPHERAL - -/*********************************************************************** - * @fn static int sl_wfx_host_spi_set_config(void *usart) - * @brief - * set the configuration of spi - * @param[in] usart: - * @return returns 0 if successful, - * -1 otherwise - * **********************************************************************/ -static int sl_wfx_host_spi_set_config(void * usart) -{ - int ret = -1; - - if (0) - { -#if defined(USART0) - } - else if (usart == USART0) - { - usart_clock = cmuClock_USART0; - usart_tx_signal = dmadrvPeripheralSignal_USART0_TXBL; - usart_rx_signal = dmadrvPeripheralSignal_USART0_RXDATAV; - ret = 0; -#endif -#if defined(USART1) - } - else if (usart == USART1) - { - usart_clock = cmuClock_USART1; - usart_tx_signal = dmadrvPeripheralSignal_USART1_TXBL; - usart_rx_signal = dmadrvPeripheralSignal_USART1_RXDATAV; - ret = 0; -#endif -#if defined(USART2) - } - else if (usart == USART2) - { - usart_clock = cmuClock_USART2; - usart_tx_signal = dmadrvPeripheralSignal_USART2_TXBL; - usart_rx_signal = dmadrvPeripheralSignal_USART2_RXDATAV; - ret = 0; -#endif -#if defined(USART3) - } - else if (usart == USART3) - { - usart_clock = cmuClock_USART3; - usart_tx_signal = dmadrvPeripheralSignal_USART3_TXBL; - usart_rx_signal = dmadrvPeripheralSignal_USART3_RXDATAV; - ret = 0; -#endif -#if defined(USART4) - } - else if (usart == USART4) - { - usart_clock = cmuClock_USART4; - usart_tx_signal = dmadrvPeripheralSignal_USART4_TXBL; - usart_rx_signal = dmadrvPeripheralSignal_USART4_RXDATAV; - ret = 0; -#endif -#if defined(USART5) - } - else if (usart == USART5) - { - usart_clock = cmuClock_USART5; - usart_tx_signal = dmadrvPeripheralSignal_USART5_TXBL; - usart_rx_signal = dmadrvPeripheralSignal_USART5_RXDATAV; - ret = 0; -#endif -#if defined(USARTRF0) - } - else if (usart == USARTRF0) - { - usart_clock = cmuClock_USARTRF0; - usart_tx_signal = dmadrvPeripheralSignal_USARTRF0_TXBL; - usart_rx_signal = dmadrvPeripheralSignal_USARTRF0_RXDATAV; - ret = 0; -#endif -#if defined(USARTRF1) - } - else if (usart == USARTRF1) - { - usart_clock = cmuClock_USARTRF1; - usart_tx_signal = dmadrvPeripheralSignal_USARTRF1_TXBL; - usart_rx_signal = dmadrvPeripheralSignal_USARTRF1_RXDATAV; - ret = 0; -#endif - } - - return ret; -} - -/**************************************************************************** - * @fn sl_status_t sl_wfx_host_init_bus(void) - * @brief - * Initialize SPI peripheral - * @param[in] None - * @return returns SL_STATUS_OK if successful, - * SL_STATUS_FAIL otherwise - *****************************************************************************/ -sl_status_t sl_wfx_host_init_bus(void) -{ - int res; - - // Initialize and enable the USART - USART_InitSync_TypeDef usartInit = USART_INITSYNC_DEFAULT; - - res = sl_wfx_host_spi_set_config(USART); - if (res != SPI_CONFIG_SUCESS) - { - return SL_STATUS_FAIL; - } - - spi_enabled = true; - dummy_tx_data = 0; - usartInit.baudrate = 36000000u; - usartInit.msbf = true; - CMU_ClockEnable(cmuClock_HFPER, true); - CMU_ClockEnable(cmuClock_GPIO, true); - CMU_ClockEnable(usart_clock, true); - USART_InitSync(USART, &usartInit); - USART->CTRL |= (1u << _USART_CTRL_SMSDELAY_SHIFT); - USART->ROUTELOC0 = - (USART->ROUTELOC0 & ~(_USART_ROUTELOC0_TXLOC_MASK | _USART_ROUTELOC0_RXLOC_MASK | _USART_ROUTELOC0_CLKLOC_MASK)) | - (SL_WFX_HOST_PINOUT_SPI_TX_LOC << _USART_ROUTELOC0_TXLOC_SHIFT) | - (SL_WFX_HOST_PINOUT_SPI_RX_LOC << _USART_ROUTELOC0_RXLOC_SHIFT) | - (SL_WFX_HOST_PINOUT_SPI_CLK_LOC << _USART_ROUTELOC0_CLKLOC_SHIFT); - - USART->ROUTEPEN = USART_ROUTEPEN_TXPEN | USART_ROUTEPEN_RXPEN | USART_ROUTEPEN_CLKPEN; - GPIO_DriveStrengthSet(SL_WFX_HOST_PINOUT_SPI_CLK_PORT, gpioDriveStrengthStrongAlternateStrong); - GPIO_PinModeSet(SL_WFX_HOST_PINOUT_SPI_TX_PORT, SL_WFX_HOST_PINOUT_SPI_TX_PIN, gpioModePushPull, PINOUT_CLEAR); - GPIO_PinModeSet(SL_WFX_HOST_PINOUT_SPI_RX_PORT, SL_WFX_HOST_PINOUT_SPI_RX_PIN, gpioModeInput, PINOUT_CLEAR); - GPIO_PinModeSet(SL_WFX_HOST_PINOUT_SPI_CLK_PORT, SL_WFX_HOST_PINOUT_SPI_CLK_PIN, gpioModePushPull, PINOUT_CLEAR); - - DMADRV_Init(); - DMADRV_AllocateChannel(&tx_dma_channel, NULL); - DMADRV_AllocateChannel(&rx_dma_channel, NULL); - GPIO_PinModeSet(SL_WFX_HOST_PINOUT_SPI_CS_PORT, SL_WFX_HOST_PINOUT_SPI_CS_PIN, gpioModePushPull, PINOUT_SET); - USART->CMD = USART_CMD_CLEARRX | USART_CMD_CLEARTX; - - return SL_STATUS_OK; -} - -/*********************************************************************** - * @fn void wfx_rsidev_init(void) - * @brief - * function called when driver rsidev intialization - * @param[in] None - * @return None - * **********************************************************************/ -void wfx_rsidev_init(void) -{ - wfx_host_gpio_init(); -} -#endif /* _NOT_USED */ diff --git a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c index 7dfe39963733ce..02ae9b2cba9b17 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c +++ b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c @@ -140,13 +140,13 @@ void rsi_hal_board_init(void) xSemaphoreGive(spiTransferLock); /* GPIO INIT of MG12 & MG24 : Reset, Wakeup, Interrupt */ - WFX_RSI_LOG("RSI_HAL: init GPIO"); + SILABS_LOG("RSI_HAL: init GPIO"); sl_wfx_host_gpio_init(); /* Reset of Wifi chip */ - WFX_RSI_LOG("RSI_HAL: Reset Wifi"); + SILABS_LOG("RSI_HAL: Reset Wifi"); sl_wfx_host_reset_chip(); - WFX_RSI_LOG("RSI_HAL: Init done"); + SILABS_LOG("RSI_HAL: Init done"); } /***************************************************************************** @@ -223,8 +223,8 @@ int16_t rsi_spi_transfer(uint8_t * tx_buf, uint8_t * rx_buf, uint16_t xlen, uint int itemsTransferred = 0; int itemsRemaining = 0; SPIDRV_GetTransferStatus(SPI_HANDLE, &itemsTransferred, &itemsRemaining); - WFX_RSI_LOG("SPI transfert timed out %d/%d (rx%x rx%x)", itemsTransferred, itemsRemaining, (uint32_t) tx_buf, - (uint32_t) rx_buf); + SILABS_LOG("SPI transfert timed out %d/%d (rx%x rx%x)", itemsTransferred, itemsRemaining, (uint32_t) tx_buf, + (uint32_t) rx_buf); SPIDRV_AbortTransfer(SPI_HANDLE); rsiError = RSI_ERROR_SPI_TIMEOUT; @@ -232,7 +232,7 @@ int16_t rsi_spi_transfer(uint8_t * tx_buf, uint8_t * rx_buf, uint16_t xlen, uint } else { - WFX_RSI_LOG("SPI transfert failed with err:%x (tx%x rx%x)", spiError, (uint32_t) tx_buf, (uint32_t) rx_buf); + SILABS_LOG("SPI transfert failed with err:%x (tx%x rx%x)", spiError, (uint32_t) tx_buf, (uint32_t) rx_buf); rsiError = RSI_ERROR_SPI_FAIL; spiInitiatorTaskHandle = NULL; // SPI operation failed. No notification to received. } diff --git a/examples/platform/silabs/efr32/rs911x/hal/rsi_hal.h b/examples/platform/silabs/efr32/rs911x/hal/rsi_hal.h index d6a85e28331600..c39622be3198cb 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/rsi_hal.h +++ b/examples/platform/silabs/efr32/rs911x/hal/rsi_hal.h @@ -22,44 +22,44 @@ #define RSI_HAL_NO_COM_PORT /* This will be done by the project */ /* Should be enums */ -#define RSI_HAL_RESET_PIN 0 -#define RSI_HAL_MODULE_INTERRUPT 1 -#define RSI_HAL_SLEEP_CONFIRM_PIN 2 -#define RSI_HAL_WAKEUP_INDICATION_PIN 3 -#define RSI_HAL_MODULE_INTERRUPT_PIN 4 -#define RSI_HAL_LP_SLEEP_CONFIRM_PIN 6 +#define RSI_HAL_RESET_PIN (0) +#define RSI_HAL_MODULE_INTERRUPT (1) +#define RSI_HAL_SLEEP_CONFIRM_PIN (2) +#define RSI_HAL_WAKEUP_INDICATION_PIN (3) +#define RSI_HAL_MODULE_INTERRUPT_PIN (4) +#define RSI_HAL_LP_SLEEP_CONFIRM_PIN (6) //! Timer related macros //! Macro to configure timer type in single shot -#define RSI_HAL_TIMER_TYPE_SINGLE_SHOT 0 +#define RSI_HAL_TIMER_TYPE_SINGLE_SHOT (0) // Macro to configure timer type in periodic -#define RSI_HAL_TIMER_TYPE_PERIODIC 1 +#define RSI_HAL_TIMER_TYPE_PERIODIC (1) // Macro to configure timer in micro seconds mode -#define RSI_HAL_TIMER_MODE_MICRO 0 +#define RSI_HAL_TIMER_MODE_MICRO (0) // Macro to configure timer in milli seconds mode -#define RSI_HAL_TIMER_MODE_MILLI 1 +#define RSI_HAL_TIMER_MODE_MILLI (1) //! GPIO Pins related Macros //! Macro to configure GPIO in output mode -#define RSI_HAL_GPIO_OUTPUT_MODE 1 +#define RSI_HAL_GPIO_OUTPUT_MODE (1) // Macro to configure GPIO in input mode -#define RSI_HAL_GPIO_INPUT_MODE 0 +#define RSI_HAL_GPIO_INPUT_MODE (0) // Macro to drive low value on GPIO -#define RSI_HAL_GPIO_LOW 0 +#define RSI_HAL_GPIO_LOW (0) // Macro to drive high value on GPIO -#define RSI_HAL_GPIO_HIGH 1 +#define RSI_HAL_GPIO_HIGH (1) // Macro to drive LDMA channel number -#define RSI_LDMA_TRANSFER_CHANNEL_NUM 3 +#define RSI_LDMA_TRANSFER_CHANNEL_NUM (3) // Macro to drive semaphore block minimun timer in milli seconds -#define RSI_SEM_BLOCK_MIN_TIMER_VALUE_MS 50 +#define RSI_SEM_BLOCK_MIN_TIMER_VALUE_MS (50) /****************************************************** * * Function Declarations @@ -77,11 +77,6 @@ void rsi_hal_set_gpio(uint8_t gpio_number); uint8_t rsi_hal_get_gpio(uint8_t gpio_number); void rsi_hal_clear_gpio(uint8_t gpio_number); int16_t rsi_spi_transfer(uint8_t * tx_buff, uint8_t * rx_buff, uint16_t transfer_length, uint8_t mode); -int16_t rsi_uart_send(uint8_t * ptrBuf, uint16_t bufLen); -int16_t rsi_uart_recv(uint8_t * ptrBuf, uint16_t bufLen); -int16_t rsi_com_port_send(uint8_t * ptrBuf, uint16_t bufLen); -int16_t rsi_com_port_receive(uint8_t * ptrBuf, uint16_t bufLen); -uint32_t rsi_get_random_number(void); int32_t rsi_timer_start(uint8_t timer_node, uint8_t mode, uint8_t type, uint32_t duration, void (*rsi_timer_expiry_handler)(void)); int32_t rsi_timer_stop(uint8_t timer_node); uint32_t rsi_timer_read(uint8_t timer_node); @@ -89,11 +84,7 @@ void rsi_delay_us(uint32_t delay_us); void rsi_delay_ms(uint32_t delay_ms); uint32_t rsi_hal_gettickcount(void); void SysTick_Handler(void); - void rsi_interrupt_handler(void); -void ABRD(void); - -void Error_Handler(void); /* RTC Related API's */ uint32_t rsi_rtc_get_time(void); diff --git a/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_interrupt.c b/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_interrupt.c index 40e4189635d71c..cb802e32948839 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_interrupt.c +++ b/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_interrupt.c @@ -50,13 +50,9 @@ uint8_t current_pin_set, prev_pin_set; /* ARGSUSED */ void rsi_gpio_irq_cb(uint8_t irqnum) { - - // WFX_RSI_LOG ("RSI: Got Int=%d", irqnum) if (irqnum != SL_WFX_HOST_PINOUT_SPI_IRQ) return; GPIO_IntClear(1 << SL_WFX_HOST_PINOUT_SPI_IRQ); - - // WFX_RSI_LOG ("Got SPI intr, cb=%x", (uint32_t)call_back); if (call_back != NULL) (*call_back)(); } @@ -74,7 +70,7 @@ void rsi_gpio_irq_cb(uint8_t irqnum) void rsi_hal_intr_config(void (*rsi_interrupt_handler)(void)) { call_back = rsi_interrupt_handler; - WFX_RSI_LOG("RSI:Set SPI intr CB to=%x", (uint32_t) call_back); + SILABS_LOG("RSI:Set SPI intr CB to=%x", (uint32_t) call_back); } /*===================================================*/ @@ -92,7 +88,7 @@ void rsi_hal_log_stats_intr_config(void (*rsi_give_wakeup_indication)()) { gpio_callback = rsi_give_wakeup_indication; } -#endif +#endif /* LOGGING_STATS */ /*===================================================*/ /** @@ -105,8 +101,6 @@ void rsi_hal_log_stats_intr_config(void (*rsi_give_wakeup_indication)()) */ void rsi_hal_intr_mask(void) { - // WFX_RSI_LOG ("RSI:Disable IRQ"); - // NVIC_DisableIRQ(GPIO_ODD_IRQn); GPIO_IntDisable(1 << SL_WFX_HOST_PINOUT_SPI_IRQ); } @@ -125,7 +119,6 @@ void rsi_hal_intr_unmask(void) NVIC_EnableIRQ(GPIO_ODD_IRQn); NVIC_EnableIRQ(GPIO_EVEN_IRQn); GPIO_IntEnable(1 << SL_WFX_HOST_PINOUT_SPI_IRQ); - // WFX_RSI_LOG ("RSI:Enable IRQ (mask=%x)", GPIO_IntGetEnabled ()); } /*===================================================*/ diff --git a/examples/platform/silabs/efr32/rs911x/rsi_if.c b/examples/platform/silabs/efr32/rs911x/rsi_if.c index e76ab4386a8007..2f7c6651f20df2 100644 --- a/examples/platform/silabs/efr32/rs911x/rsi_if.c +++ b/examples/platform/silabs/efr32/rs911x/rsi_if.c @@ -36,17 +36,16 @@ #include "rsi_driver.h" #include "rsi_wlan_non_rom.h" +#include "rsi_bootup_config.h" #include "rsi_common_apis.h" #include "rsi_data_types.h" +#include "rsi_error.h" #include "rsi_nwk.h" #include "rsi_socket.h" #include "rsi_utils.h" #include "rsi_wlan.h" #include "rsi_wlan_apis.h" #include "rsi_wlan_config.h" -//#include "rsi_wlan_non_rom.h" -#include "rsi_bootup_config.h" -#include "rsi_error.h" #include "dhcp_client.h" #include "wfx_host_events.h" @@ -81,7 +80,7 @@ extern rsi_semaphore_handle_t sl_rs_ble_init_sem; * This file implements the interface to the RSI SAPIs */ static uint8_t wfx_rsi_drv_buf[WFX_RSI_BUF_SZ]; -wfx_wifi_scan_ext_t * temp_reset; +static wfx_wifi_scan_ext_t * temp_reset; /****************************************************************** * @fn int32_t wfx_rsi_get_ap_info(wfx_wifi_scan_result_t *ap) @@ -121,7 +120,7 @@ int32_t wfx_rsi_get_ap_ext(wfx_wifi_scan_ext_t * extra_info) status = rsi_wlan_get(RSI_WLAN_EXT_STATS, buff, sizeof(buff)); if (status != RSI_SUCCESS) { - WFX_RSI_LOG("\r\n Failed, Error Code : 0x%lX\r\n", status); + SILABS_LOG("Failed, Error Code : 0x%lX", status); } else { @@ -152,7 +151,7 @@ int32_t wfx_rsi_reset_count() status = rsi_wlan_get(RSI_WLAN_EXT_STATS, buff, sizeof(buff)); if (status != RSI_SUCCESS) { - WFX_RSI_LOG("\r\n Failed, Error Code : 0x%lX\r\n", status); + SILABS_LOG("Failed, Error Code : 0x%lX", status); } else { @@ -196,10 +195,10 @@ void wfx_rsi_power_save() int32_t status = rsi_wlan_power_save_profile(RSI_SLEEP_MODE_2, RSI_MAX_PSP); if (status != RSI_SUCCESS) { - WFX_RSI_LOG("Powersave Config Failed, Error Code : 0x%lX", status); + SILABS_LOG("Powersave Config Failed, Error Code : 0x%lX", status); return; } - WFX_RSI_LOG("Powersave Config Success"); + SILABS_LOG("Powersave Config Success"); } /****************************************************************** * @fn wfx_rsi_join_cb(uint16_t status, const uint8_t *buf, const uint16_t len) @@ -213,7 +212,7 @@ void wfx_rsi_power_save() *********************************************************************/ static void wfx_rsi_join_cb(uint16_t status, const uint8_t * buf, const uint16_t len) { - WFX_RSI_LOG("%s: status: %02x", __func__, status); + SILABS_LOG("%s: status: %02x", __func__, status); wfx_rsi.dev_state &= ~WFX_RSI_ST_STA_CONNECTING; temp_reset = (wfx_wifi_scan_ext_t *) malloc(sizeof(wfx_wifi_scan_ext_t)); memset(temp_reset, 0, sizeof(wfx_wifi_scan_ext_t)); @@ -222,7 +221,7 @@ static void wfx_rsi_join_cb(uint16_t status, const uint8_t * buf, const uint16_t /* * We should enable retry.. (Need config variable for this) */ - WFX_RSI_LOG("%s: failed. retry: %d", __func__, wfx_rsi.join_retries); + SILABS_LOG("%s: failed. retry: %d", __func__, wfx_rsi.join_retries); wfx_retry_interval_handler(is_wifi_disconnection_event, wfx_rsi.join_retries++); if (is_wifi_disconnection_event || wfx_rsi.join_retries <= WFX_RSI_CONFIG_MAX_JOIN) xEventGroupSetBits(wfx_rsi.events, WFX_EVT_STA_START_JOIN); @@ -232,7 +231,7 @@ static void wfx_rsi_join_cb(uint16_t status, const uint8_t * buf, const uint16_t /* * Join was complete - Do the DHCP */ - WFX_RSI_LOG("%s: join completed.", __func__); + SILABS_LOG("%s: join completed.", __func__); xEventGroupSetBits(wfx_rsi.events, WFX_EVT_STA_CONN); wfx_rsi.join_retries = 0; retryInterval = WLAN_MIN_RETRY_TIMER_MS; @@ -251,7 +250,7 @@ static void wfx_rsi_join_cb(uint16_t status, const uint8_t * buf, const uint16_t *********************************************************************/ static void wfx_rsi_join_fail_cb(uint16_t status, uint8_t * buf, uint32_t len) { - WFX_RSI_LOG("%s: error: failed status: %02x", __func__, status); + SILABS_LOG("%s: error: failed status: %02x", __func__, status); wfx_rsi.join_retries += 1; wfx_rsi.dev_state &= ~(WFX_RSI_ST_STA_CONNECTING | WFX_RSI_ST_STA_CONNECTED); is_wifi_disconnection_event = true; @@ -269,7 +268,6 @@ static void wfx_rsi_join_fail_cb(uint16_t status, uint8_t * buf, uint32_t len) *****************************************************************************************/ static void wfx_rsi_wlan_pkt_cb(uint16_t status, uint8_t * buf, uint32_t len) { - // WFX_RSI_LOG("%s: status=%d, len=%d", __func__, status, len); if (status != RSI_SUCCESS) { return; @@ -291,23 +289,23 @@ static int32_t wfx_rsi_init(void) uint8_t buf[RSI_RESPONSE_HOLD_BUFF_SIZE]; extern void rsi_hal_board_init(void); - WFX_RSI_LOG("%s: starting(HEAP_SZ = %d)", __func__, SL_HEAP_SIZE); + SILABS_LOG("%s: starting(HEAP_SZ = %d)", __func__, SL_HEAP_SIZE); //! Driver initialization status = rsi_driver_init(wfx_rsi_drv_buf, WFX_RSI_BUF_SZ); if ((status < RSI_DRIVER_STATUS) || (status > WFX_RSI_BUF_SZ)) { - WFX_RSI_LOG("%s: error: RSI Driver initialization failed with status: %02x", __func__, status); + SILABS_LOG("%s: error: RSI Driver initialization failed with status: %02x", __func__, status); return status; } - WFX_RSI_LOG("%s: rsi_device_init", __func__); + SILABS_LOG("%s: rsi_device_init", __func__); /* ! Redpine module intialisation */ if ((status = rsi_device_init(LOAD_NWP_FW)) != RSI_SUCCESS) { - WFX_RSI_LOG("%s: error: rsi_device_init failed with status: %02x", __func__, status); + SILABS_LOG("%s: error: rsi_device_init failed with status: %02x", __func__, status); return status; } - WFX_RSI_LOG("%s: start wireless drv task", __func__); + SILABS_LOG("%s: start wireless drv task", __func__); /* * Create the driver task */ @@ -315,7 +313,7 @@ static int32_t wfx_rsi_init(void) WLAN_TASK_PRIORITY, driverRsiTaskStack, &driverRsiTaskBuffer); if (NULL == wfx_rsi.drv_task) { - WFX_RSI_LOG("%s: error: rsi_wireless_driver_task failed", __func__); + SILABS_LOG("%s: error: rsi_wireless_driver_task failed", __func__); return RSI_ERROR_INVALID_PARAM; } @@ -326,53 +324,53 @@ static int32_t wfx_rsi_init(void) if ((status = rsi_wireless_init(OPER_MODE_0, COEX_MODE_0)) != RSI_SUCCESS) { #endif - WFX_RSI_LOG("%s: error: Initialize WiSeConnect failed with status: %02x", __func__, status); + SILABS_LOG("%s: error: Initialize WiSeConnect failed with status: %02x", __func__, status); return status; } - WFX_RSI_LOG("%s: get FW version..", __func__); + SILABS_LOG("%s: get FW version..", __func__); /* * Get the MAC and other info to let the user know about it. */ if (rsi_wlan_get(RSI_FW_VERSION, buf, sizeof(buf)) != RSI_SUCCESS) { - WFX_RSI_LOG("%s: error: rsi_wlan_get(RSI_FW_VERSION) failed with status: %02x", __func__, status); + SILABS_LOG("%s: error: rsi_wlan_get(RSI_FW_VERSION) failed with status: %02x", __func__, status); return status; } buf[sizeof(buf) - 1] = 0; - WFX_RSI_LOG("%s: RSI firmware version: %s", __func__, buf); + SILABS_LOG("%s: RSI firmware version: %s", __func__, buf); //! Send feature frame if ((status = rsi_send_feature_frame()) != RSI_SUCCESS) { - WFX_RSI_LOG("%s: error: rsi_send_feature_frame failed with status: %02x", __func__, status); + SILABS_LOG("%s: error: rsi_send_feature_frame failed with status: %02x", __func__, status); return status; } - WFX_RSI_LOG("%s: sent rsi_send_feature_frame", __func__); + SILABS_LOG("%s: sent rsi_send_feature_frame", __func__); /* initializes wlan radio parameters and WLAN supplicant parameters. */ (void) rsi_wlan_radio_init(); /* Required so we can get MAC address */ if ((status = rsi_wlan_get(RSI_MAC_ADDRESS, &wfx_rsi.sta_mac.octet[0], RESP_BUFF_SIZE)) != RSI_SUCCESS) { - WFX_RSI_LOG("%s: error: rsi_wlan_get failed with status: %02x", __func__, status); + SILABS_LOG("%s: error: rsi_wlan_get failed with status: %02x", __func__, status); return status; } - WFX_RSI_LOG("%s: WLAN: MAC %02x:%02x:%02x %02x:%02x:%02x", __func__, wfx_rsi.sta_mac.octet[0], wfx_rsi.sta_mac.octet[1], - wfx_rsi.sta_mac.octet[2], wfx_rsi.sta_mac.octet[3], wfx_rsi.sta_mac.octet[4], wfx_rsi.sta_mac.octet[5]); + SILABS_LOG("%s: WLAN: MAC %02x:%02x:%02x %02x:%02x:%02x", __func__, wfx_rsi.sta_mac.octet[0], wfx_rsi.sta_mac.octet[1], + wfx_rsi.sta_mac.octet[2], wfx_rsi.sta_mac.octet[3], wfx_rsi.sta_mac.octet[4], wfx_rsi.sta_mac.octet[5]); wfx_rsi.events = xEventGroupCreateStatic(&rsiDriverEventGroup); /* * Register callbacks - We are only interested in the connectivity CBs */ if ((status = rsi_wlan_register_callbacks(RSI_JOIN_FAIL_CB, wfx_rsi_join_fail_cb)) != RSI_SUCCESS) { - WFX_RSI_LOG("%s: RSI callback register join failed with status: %02x", __func__, status); + SILABS_LOG("%s: RSI callback register join failed with status: %02x", __func__, status); return status; } if ((status = rsi_wlan_register_callbacks(RSI_WLAN_DATA_RECEIVE_NOTIFY_CB, wfx_rsi_wlan_pkt_cb)) != RSI_SUCCESS) { - WFX_RSI_LOG("%s: RSI callback register data-notify failed with status: %02x", __func__, status); + SILABS_LOG("%s: RSI callback register data-notify failed with status: %02x", __func__, status); return status; } @@ -381,23 +379,10 @@ static int32_t wfx_rsi_init(void) #endif wfx_rsi.dev_state |= WFX_RSI_ST_DEV_READY; - WFX_RSI_LOG("%s: RSI: OK", __func__); + SILABS_LOG("%s: RSI: OK", __func__); return RSI_SUCCESS; } -/************************************************************************************* - * @fn void wfx_show_err(char *msg) - * @brief - * driver shows error message - * @param[in] msg - * @return - * None - *****************************************************************************************/ -void wfx_show_err(char * msg) -{ - WFX_RSI_LOG("%s: message: %d", __func__, msg); -} - /*************************************************************************************** * @fn static void wfx_rsi_save_ap_info() * @brief @@ -423,7 +408,7 @@ static void wfx_rsi_save_ap_info() // translation #else /* !WIFI_ENABLE_SECURITY_WPA3 */ wfx_rsi.sec.security = WFX_SEC_WPA2; #endif /* WIFI_ENABLE_SECURITY_WPA3 */ - WFX_RSI_LOG("%s: warn: failed with status: %02x", status); + SILABS_LOG("%s: warn: failed with status: %02x", status); return; } else @@ -458,8 +443,8 @@ static void wfx_rsi_save_ap_info() // translation break; } - WFX_RSI_LOG("%s: WLAN: connecting to %s==%s, sec=%d, status=%02x", __func__, &wfx_rsi.sec.ssid[0], &wfx_rsi.sec.passkey[0], - wfx_rsi.sec.security, status); + SILABS_LOG("%s: WLAN: connecting to %s==%s, sec=%d, status=%02x", __func__, &wfx_rsi.sec.ssid[0], &wfx_rsi.sec.passkey[0], + wfx_rsi.sec.security, status); } /******************************************************************************************** @@ -476,7 +461,7 @@ static void wfx_rsi_do_join(void) if (wfx_rsi.dev_state & (WFX_RSI_ST_STA_CONNECTING | WFX_RSI_ST_STA_CONNECTED)) { - WFX_RSI_LOG("%s: not joining - already in progress", __func__); + SILABS_LOG("%s: not joining - already in progress", __func__); } else { @@ -497,12 +482,12 @@ static void wfx_rsi_do_join(void) connect_security_mode = RSI_OPEN; break; default: - WFX_RSI_LOG("%s: error: unknown security type."); + SILABS_LOG("%s: error: unknown security type."); return; } - WFX_RSI_LOG("%s: WLAN: connecting to %s==%s, sec=%d", __func__, &wfx_rsi.sec.ssid[0], &wfx_rsi.sec.passkey[0], - wfx_rsi.sec.security); + SILABS_LOG("%s: WLAN: connecting to %s==%s, sec=%d", __func__, &wfx_rsi.sec.ssid[0], &wfx_rsi.sec.passkey[0], + wfx_rsi.sec.security); /* * Join the network @@ -514,7 +499,7 @@ static void wfx_rsi_do_join(void) if ((status = rsi_wlan_register_callbacks(RSI_JOIN_FAIL_CB, wfx_rsi_join_fail_cb)) != RSI_SUCCESS) { - WFX_RSI_LOG("%s: RSI callback register join failed with status: %02x", __func__, status); + SILABS_LOG("%s: RSI callback register join failed with status: %02x", __func__, status); } /* Try to connect Wifi with given Credentials @@ -530,16 +515,15 @@ static void wfx_rsi_do_join(void) { wfx_rsi.dev_state &= ~WFX_RSI_ST_STA_CONNECTING; - WFX_RSI_LOG("%s: rsi_wlan_connect_async failed with status: %02x on try %d", __func__, status, - wfx_rsi.join_retries); + SILABS_LOG("%s: rsi_wlan_connect_async failed with status: %02x on try %d", __func__, status, wfx_rsi.join_retries); wfx_retry_interval_handler(is_wifi_disconnection_event, wfx_rsi.join_retries); wfx_rsi.join_retries++; } else { - WFX_RSI_LOG("%s: starting JOIN to %s after %d tries\n", __func__, (char *) &wfx_rsi.sec.ssid[0], - wfx_rsi.join_retries); + SILABS_LOG("%s: starting JOIN to %s after %d tries\n", __func__, (char *) &wfx_rsi.sec.ssid[0], + wfx_rsi.join_retries); break; // exit while loop } } @@ -566,7 +550,7 @@ void wfx_rsi_task(void * arg) uint32_t rsi_status = wfx_rsi_init(); if (rsi_status != RSI_SUCCESS) { - WFX_RSI_LOG("%s: error: wfx_rsi_init with status: %02x", __func__, rsi_status); + SILABS_LOG("%s: error: wfx_rsi_init with status: %02x", __func__, rsi_status); return; } wfx_lwip_start(); @@ -574,7 +558,7 @@ void wfx_rsi_task(void * arg) sta_netif = wfx_get_netif(SL_WFX_STA_INTERFACE); wfx_started_notify(); - WFX_RSI_LOG("%s: starting event wait", __func__); + SILABS_LOG("%s: starting event wait", __func__); for (;;) { /* @@ -597,7 +581,7 @@ void wfx_rsi_task(void * arg) if (flags) { - WFX_RSI_LOG("%s: wait event encountered: %x", __func__, flags); + SILABS_LOG("%s: wait event encountered: %x", __func__, flags); } /* * Let's handle DHCP polling here @@ -666,7 +650,7 @@ void wfx_rsi_task(void * arg) /* * Initiate the Join command (assuming we have been provisioned) */ - WFX_RSI_LOG("%s: starting LwIP STA", __func__); + SILABS_LOG("%s: starting LwIP STA", __func__); wfx_rsi.dev_state |= WFX_RSI_ST_STA_CONNECTED; hasNotifiedWifiConnectivity = false; #if (CHIP_DEVICE_CONFIG_ENABLE_IPV4) @@ -683,7 +667,7 @@ void wfx_rsi_task(void * arg) { wfx_rsi.dev_state &= ~(WFX_RSI_ST_STA_READY | WFX_RSI_ST_STA_CONNECTING | WFX_RSI_ST_STA_CONNECTED | WFX_RSI_ST_STA_DHCP_DONE); - WFX_RSI_LOG("%s: disconnect notify", __func__); + SILABS_LOG("%s: disconnect notify", __func__); /* TODO: Implement disconnect notify */ wfx_lwip_set_sta_link_down(); // Internally dhcpclient_poll(netif) -> // wfx_ip_changed_notify(0) for IPV4 @@ -700,7 +684,7 @@ void wfx_rsi_task(void * arg) { if (!(wfx_rsi.dev_state & WFX_RSI_ST_SCANSTARTED)) { - WFX_RSI_LOG("%s: start SSID scan", __func__); + SILABS_LOG("%s: start SSID scan", __func__); int x; wfx_wifi_scan_result_t ap; rsi_scan_info_t * scan; @@ -708,7 +692,7 @@ void wfx_rsi_task(void * arg) uint8_t bgscan_results[BG_SCAN_RES_SIZE] = { 0 }; status = rsi_wlan_bgscan_profile(1, (rsi_rsp_scan_t *) bgscan_results, BG_SCAN_RES_SIZE); - WFX_RSI_LOG("%s: status: %02x size = %d", __func__, status, BG_SCAN_RES_SIZE); + SILABS_LOG("%s: status: %02x size = %d", __func__, status, BG_SCAN_RES_SIZE); rsi_rsp_scan_t * rsp = (rsi_rsp_scan_t *) bgscan_results; if (status) { @@ -723,11 +707,11 @@ void wfx_rsi_task(void * arg) strcpy(&ap.ssid[0], (char *) &scan->ssid[0]); if (wfx_rsi.scan_ssid) { - WFX_RSI_LOG("Inside scan_ssid"); - WFX_RSI_LOG("SCAN SSID: %s , ap scan: %s", wfx_rsi.scan_ssid, ap.ssid); + SILABS_LOG("Inside scan_ssid"); + SILABS_LOG("SCAN SSID: %s , ap scan: %s", wfx_rsi.scan_ssid, ap.ssid); if (strcmp(wfx_rsi.scan_ssid, ap.ssid) == CMP_SUCCESS) { - WFX_RSI_LOG("Inside ap details"); + SILABS_LOG("Inside ap details"); ap.security = scan->security_mode; ap.rssi = (-1) * scan->rssi_val; memcpy(&ap.bssid[0], &scan->bssid[0], BSSID_MAX_STR_LEN); @@ -736,7 +720,7 @@ void wfx_rsi_task(void * arg) } else { - WFX_RSI_LOG("Inside else"); + SILABS_LOG("Inside else"); ap.security = scan->security_mode; ap.rssi = (-1) * scan->rssi_val; ap.chan = scan->rf_channel; @@ -787,8 +771,8 @@ void wfx_dhcp_got_ipv4(uint32_t ip) wfx_rsi.ip4_addr[1] = (ip >> 8) & HEX_VALUE_FF; wfx_rsi.ip4_addr[2] = (ip >> 16) & HEX_VALUE_FF; wfx_rsi.ip4_addr[3] = (ip >> 24) & HEX_VALUE_FF; - WFX_RSI_LOG("%s: DHCP OK: IP=%d.%d.%d.%d", __func__, wfx_rsi.ip4_addr[0], wfx_rsi.ip4_addr[1], wfx_rsi.ip4_addr[2], - wfx_rsi.ip4_addr[3]); + SILABS_LOG("%s: DHCP OK: IP=%d.%d.%d.%d", __func__, wfx_rsi.ip4_addr[0], wfx_rsi.ip4_addr[1], wfx_rsi.ip4_addr[2], + wfx_rsi.ip4_addr[3]); /* Notify the Connectivity Manager - via the app */ wfx_rsi.dev_state |= WFX_RSI_ST_STA_DHCP_DONE; wfx_ip_changed_notify(IP_STATUS_SUCCESS); diff --git a/examples/platform/silabs/efr32/rs911x/wfx_rsi.h b/examples/platform/silabs/efr32/rs911x/wfx_rsi.h index 7cbcd9f63e407e..846644f2ba7f55 100644 --- a/examples/platform/silabs/efr32/rs911x/wfx_rsi.h +++ b/examples/platform/silabs/efr32/rs911x/wfx_rsi.h @@ -24,33 +24,33 @@ #define WFX_RSI_WLAN_TASK_SZ (1024 + 512 + 256) /* Unknown how big this should be */ #define WFX_RSI_TASK_SZ (1024 + 1024) /* Stack for the WFX/RSI task */ #define WFX_RSI_BUF_SZ (1024 * 10) /* May need tweak */ -#define WFX_RSI_CONFIG_MAX_JOIN 5 /* Max join retries */ -#define WFX_RSI_NUM_TIMERS 2 /* Number of RSI timers to alloc */ +#define WFX_RSI_CONFIG_MAX_JOIN (5) /* Max join retries */ +#define WFX_RSI_NUM_TIMERS (2) /* Number of RSI timers to alloc */ /* * Various events fielded by the wfx_rsi task * Make sure that we only use 8 bits (otherwise freeRTOS - may need some changes) */ -#define WFX_EVT_STA_CONN 0x01 -#define WFX_EVT_STA_DISCONN 0x02 -#define WFX_EVT_AP_START 0x04 -#define WFX_EVT_AP_STOP 0x08 -#define WFX_EVT_SCAN 0x10 /* This is used as scan result and start */ -#define WFX_EVT_STA_START_JOIN 0x20 -#define WFX_EVT_STA_DO_DHCP 0x40 -#define WFX_EVT_STA_DHCP_DONE 0x80 +#define WFX_EVT_STA_CONN (0x01) +#define WFX_EVT_STA_DISCONN (0x02) +#define WFX_EVT_AP_START (0x04) +#define WFX_EVT_AP_STOP (0x08) +#define WFX_EVT_SCAN (0x10) /* This is used as scan result and start */ +#define WFX_EVT_STA_START_JOIN (0x20) +#define WFX_EVT_STA_DO_DHCP (0x40) +#define WFX_EVT_STA_DHCP_DONE (0x80) -#define WFX_RSI_ST_DEV_READY 0x01 -#define WFX_RSI_ST_AP_READY 0x02 -#define WFX_RSI_ST_STA_PROVISIONED 0x04 -#define WFX_RSI_ST_STA_CONNECTING 0x08 -#define WFX_RSI_ST_STA_CONNECTED 0x10 -#define WFX_RSI_ST_STA_DHCP_DONE 0x40 /* Requested to do DHCP after conn */ -#define WFX_RSI_ST_STA_MODE 0x80 /* Enable Station Mode */ -#define WFX_RSI_ST_AP_MODE 0x100 /* Enable AP Mode */ +#define WFX_RSI_ST_DEV_READY (0x01) +#define WFX_RSI_ST_AP_READY (0x02) +#define WFX_RSI_ST_STA_PROVISIONED (0x04) +#define WFX_RSI_ST_STA_CONNECTING (0x08) +#define WFX_RSI_ST_STA_CONNECTED (0x10) +#define WFX_RSI_ST_STA_DHCP_DONE (0x40) /* Requested to do DHCP after conn */ +#define WFX_RSI_ST_STA_MODE (0x80) /* Enable Station Mode */ +#define WFX_RSI_ST_AP_MODE (0x100) /* Enable AP Mode */ #define WFX_RSI_ST_STA_READY (WFX_RSI_ST_STA_CONNECTED | WFX_RSI_ST_STA_DHCP_DONE) -#define WFX_RSI_ST_STARTED 0x200 /* RSI task started */ -#define WFX_RSI_ST_SCANSTARTED 0x400 /* Scan Started */ +#define WFX_RSI_ST_STARTED (0x200) /* RSI task started */ +#define WFX_RSI_ST_SCANSTARTED (0x400) /* Scan Started */ struct wfx_rsi { @@ -76,7 +76,6 @@ struct wfx_rsi uint16_t join_retries; uint8_t ip4_addr[4]; /* Not sure if this is enough */ }; -#define RSI_SCAN_RESP_SZ 54 extern struct wfx_rsi wfx_rsi; #ifdef __cplusplus @@ -92,7 +91,7 @@ int32_t wfx_rsi_get_ap_info(wfx_wifi_scan_result_t * ap); int32_t wfx_rsi_get_ap_ext(wfx_wifi_scan_ext_t * extra_info); int32_t wfx_rsi_reset_count(); int32_t wfx_rsi_disconnect(); -#define WFX_RSI_LOG(...) efr32Log(__VA_ARGS__); +#define SILABS_LOG(...) efr32Log(__VA_ARGS__); #ifdef __cplusplus } diff --git a/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c b/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c index a55e0aeb5cab2e..9f89a678dfce0a 100644 --- a/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c +++ b/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c @@ -52,11 +52,11 @@ sl_status_t wfx_wifi_start(void) { if (wfx_rsi.dev_state & WFX_RSI_ST_STARTED) { - WFX_RSI_LOG("%s: already started.", __func__); + SILABS_LOG("%s: already started.", __func__); return SL_STATUS_OK; } wfx_rsi.dev_state |= WFX_RSI_ST_STARTED; - WFX_RSI_LOG("%s: starting..", __func__); + SILABS_LOG("%s: starting..", __func__); /* * Create the Wifi driver task */ @@ -65,7 +65,7 @@ sl_status_t wfx_wifi_start(void) if (NULL == wfx_rsi.wlan_task) { - WFX_RSI_LOG("%s: error: failed to create task.", __func__); + SILABS_LOG("%s: error: failed to create task.", __func__); return SL_STATUS_FAIL; } return SL_STATUS_OK; @@ -94,33 +94,12 @@ bool wfx_is_sta_mode_enabled(void) { bool mode; mode = !!(wfx_rsi.dev_state & WFX_RSI_ST_STA_MODE); - // WFX_RSI_LOG("%s: %d", __func__, (mode ? "yes" : "no")); + // SILABS_LOG("%s: %d", __func__, (mode ? "yes" : "no")); return mode; } /********************************************************************* - * @fn sl_wfx_state_t wfx_get_wifi_state(void) - * @brief - * get the wifi state - * @param[in] None - * @return return SL_WFX_NOT_INIT if successful, - * SL_WFX_started otherwise - ***********************************************************************/ -sl_wfx_state_t wfx_get_wifi_state(void) -{ - if (wfx_rsi.dev_state & WFX_RSI_ST_STA_DHCP_DONE) - { - return SL_WFX_STA_INTERFACE_CONNECTED; - } - if (wfx_rsi.dev_state & WFX_RSI_ST_DEV_READY) - { - return SL_WFX_STARTED; - } - return SL_WFX_NOT_INIT; -} - -/********************************************************************* - * @fn sl_wfx_state_t wfx_get_wifi_state(void) + * @fn wfx_get_wifi_mac_addr(sl_wfx_interface_t interface, sl_wfx_mac_address_t * addr) * @brief * get the wifi mac address * @param[in] Interface: @@ -138,8 +117,8 @@ void wfx_get_wifi_mac_addr(sl_wfx_interface_t interface, sl_wfx_mac_address_t * mac = &wfx_rsi.sta_mac; #endif *addr = *mac; - WFX_RSI_LOG("%s: %02x:%02x:%02x:%02x:%02x:%02x", __func__, mac->octet[0], mac->octet[1], mac->octet[2], mac->octet[3], - mac->octet[4], mac->octet[5]); + SILABS_LOG("%s: %02x:%02x:%02x:%02x:%02x:%02x", __func__, mac->octet[0], mac->octet[1], mac->octet[2], mac->octet[3], + mac->octet[4], mac->octet[5]); } /********************************************************************* @@ -152,7 +131,7 @@ void wfx_get_wifi_mac_addr(sl_wfx_interface_t interface, sl_wfx_mac_address_t * ***********************************************************************/ void wfx_set_wifi_provision(wfx_wifi_provision_t * cfg) { - WFX_RSI_LOG("%s: SSID: %s", __func__, &wfx_rsi.sec.ssid[0]); + SILABS_LOG("%s: SSID: %s", __func__, &wfx_rsi.sec.ssid[0]); wfx_rsi.sec = *cfg; wfx_rsi.dev_state |= WFX_RSI_ST_STA_PROVISIONED; @@ -179,20 +158,6 @@ bool wfx_get_wifi_provision(wfx_wifi_provision_t * wifiConfig) return false; } -/********************************************************************* - * @fn bool wfx_is_sta_provisioned(void) - * @brief - * Driver is STA provisioned - * @param[in] None - * @return None - ***********************************************************************/ -bool wfx_is_sta_provisioned(void) -{ - bool status = (wfx_rsi.dev_state & WFX_RSI_ST_STA_PROVISIONED) ? true : false; - WFX_RSI_LOG("%s: status: SSID -> %s: %s", __func__, &wfx_rsi.sec.ssid[0], (status ? "provisioned" : "not provisioned")); - return status; -} - /********************************************************************* * @fn void wfx_clear_wifi_provision(void) * @brief @@ -204,7 +169,7 @@ void wfx_clear_wifi_provision(void) { memset(&wfx_rsi.sec, 0, sizeof(wfx_rsi.sec)); wfx_rsi.dev_state &= ~WFX_RSI_ST_STA_PROVISIONED; - WFX_RSI_LOG("%s: completed.", __func__); + SILABS_LOG("%s: completed.", __func__); } /************************************************************************* @@ -219,12 +184,12 @@ sl_status_t wfx_connect_to_ap(void) { if (wfx_rsi.dev_state & WFX_RSI_ST_STA_PROVISIONED) { - WFX_RSI_LOG("%s: connecting to access point -> SSID: %s, PSK:%s", __func__, &wfx_rsi.sec.ssid[0], &wfx_rsi.sec.passkey[0]); + SILABS_LOG("%s: connecting to access point -> SSID: %s, PSK:%s", __func__, &wfx_rsi.sec.ssid[0], &wfx_rsi.sec.passkey[0]); xEventGroupSetBits(wfx_rsi.events, WFX_EVT_STA_START_JOIN); } else { - WFX_RSI_LOG("%s: error: access point not provisioned", __func__); + SILABS_LOG("%s: error: access point not provisioned", __func__); return SL_STATUS_INVALID_CONFIGURATION; } return SL_STATUS_OK; @@ -243,7 +208,7 @@ void wfx_setup_ip6_link_local(sl_wfx_interface_t whichif) * TODO: Implement IPV6 setup, currently in wfx_rsi_task() * This is hooked with MATTER code. */ - WFX_RSI_LOG("%s: warning: not implemented.", __func__); + SILABS_LOG("%s: warning: not implemented.", __func__); } /********************************************************************* @@ -258,7 +223,7 @@ bool wfx_is_sta_connected(void) { bool status; status = (wfx_rsi.dev_state & WFX_RSI_ST_STA_CONNECTED) ? true : false; - WFX_RSI_LOG("%s: status: %s", __func__, (status ? "connected" : "not connected")); + SILABS_LOG("%s: status: %s", __func__, (status ? "connected" : "not connected")); return status; } @@ -287,11 +252,11 @@ wifi_mode_t wfx_get_wifi_mode() ***********************************************************************/ sl_status_t wfx_sta_discon(void) { - WFX_RSI_LOG("%s: started.", __func__); + SILABS_LOG("%s: started.", __func__); int32_t status; status = wfx_rsi_disconnect(); wfx_rsi.dev_state &= ~WFX_RSI_ST_STA_CONNECTED; - WFX_RSI_LOG("%s: completed.", __func__); + SILABS_LOG("%s: completed.", __func__); return status; } #if CHIP_DEVICE_CONFIG_ENABLE_IPV4 @@ -314,7 +279,7 @@ bool wfx_have_ipv4_addr(sl_wfx_interface_t which_if) { status = false; /* TODO */ } - WFX_RSI_LOG("%s: status: %d", __func__, status); + SILABS_LOG("%s: status: %d", __func__, status); return status; } #endif /* CHIP_DEVICE_CONFIG_ENABLE_IPV4 */ @@ -338,7 +303,7 @@ bool wfx_have_ipv6_addr(sl_wfx_interface_t which_if) { status = false; /* TODO */ } - WFX_RSI_LOG("%s: status: %d", __func__, status); + SILABS_LOG("%s: status: %d", __func__, status); return status; } @@ -435,6 +400,6 @@ bool wfx_start_scan(char * ssid, void (*callback)(wfx_wifi_scan_result_t *)) void wfx_cancel_scan(void) { /* Not possible */ - WFX_RSI_LOG("%s: cannot cancel scan", __func__); + SILABS_LOG("%s: cannot cancel scan", __func__); } #endif /* SL_WFX_CONFIG_SCAN */ diff --git a/examples/platform/silabs/efr32/rs911x/wfx_rsidev.c b/examples/platform/silabs/efr32/rs911x/wfx_rsidev.c deleted file mode 100644 index 2e1b40d41260d5..00000000000000 --- a/examples/platform/silabs/efr32/rs911x/wfx_rsidev.c +++ /dev/null @@ -1,272 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifdef _WFX_NOT_USED_USING_HAL_INSTEAD_ -#include -#include -#include - -#include "em_bus.h" -#include "em_cmu.h" -#include "em_gpio.h" -#include "em_ldma.h" -#include "em_usart.h" -#include "gpiointerrupt.h" - -/* Need Lwip stuff before rsi is included */ -#include "wfx_host_events.h" - -#include "FreeRTOS.h" -#include "event_groups.h" -#include "rsi_common_apis.h" -#include "rsi_data_types.h" -#include "rsi_error.h" -#include "rsi_nwk.h" -#include "rsi_socket.h" -#include "rsi_utils.h" -#include "rsi_wlan.h" -#include "rsi_wlan_apis.h" -#include "rsi_wlan_config.h" -#include "task.h" - -#include "wfx_host_pinout.h" -#include "wfx_rsi.h" - -/* The following stuff comes from hal/rsi_hal_mcu_interrupt.c */ -static void (*rsi_intr_cb)(void); -/********************************************************************* - * @fn void rsi_hal_intr_config(void (*rsi_interrupt_handler)(void)) - * @brief - * get the hal intr configuration - * @param[in] rsi_interrupt_handler: - * @return - * None - ***********************************************************************/ -void rsi_hal_intr_config(void (*rsi_interrupt_handler)(void)) -{ - rsi_intr_cb = rsi_interrupt_handler; -} - -/*********************************************************************** - * @fn static void wfx_spi_wakeup_irq_callback(uint8_t irqNumber) - * @brief - * end of stuff from hal/rsi_hal_mcu_interrupt.c - * @param[in] irqNumber: - * @return None - * **********************************************************************/ -static void wfx_spi_wakeup_irq_callback(uint8_t irqNumber) -{ - BaseType_t bus_task_woken; - uint32_t interrupt_mask; - - if (irqNumber != SL_WFX_HOST_PINOUT_SPI_IRQ) - return; - // Get and clear all pending GPIO interrupts - interrupt_mask = GPIO_IntGet(); - GPIO_IntClear(interrupt_mask); - if (rsi_intr_cb) - (*rsi_intr_cb)(); -} - -/*********************************************************************** - * @fn static void wfx_host_gpio_init(void) - * @brief - * function called when host gpio intialization - * @param[in] None - * @return None - * **********************************************************************/ -static void wfx_host_gpio_init(void) -{ - // Enable GPIO clock. - CMU_ClockEnable(cmuClock_GPIO, true); - - // Configure WF200 reset pin. - GPIO_PinModeSet(SL_WFX_HOST_PINOUT_RESET_PORT, SL_WFX_HOST_PINOUT_RESET_PIN, gpioModePushPull, PINOUT_CLEAR); - // Configure WF200 WUP pin. - GPIO_PinModeSet(SL_WFX_HOST_PINOUT_WUP_PORT, SL_WFX_HOST_PINOUT_WUP_PIN, gpioModePushPull, PINOUT_CLEAR); - - // GPIO used as IRQ. - GPIO_PinModeSet(SL_WFX_HOST_PINOUT_SPI_WIRQ_PORT, SL_WFX_HOST_PINOUT_SPI_WIRQ_PIN, gpioModeInputPull, PINOUT_CLEAR); - CMU_OscillatorEnable(cmuOsc_LFXO, true, true); - - // Set up interrupt based callback function - trigger on both edges. - GPIOINT_Init(); - GPIO_ExtIntConfig(SL_WFX_HOST_PINOUT_SPI_WIRQ_PORT, SL_WFX_HOST_PINOUT_SPI_WIRQ_PIN, SL_WFX_HOST_PINOUT_SPI_IRQ, true, false, - true); - GPIOINT_CallbackRegister(SL_WFX_HOST_PINOUT_SPI_IRQ, wfx_spi_wakeup_irq_callback); - - // Change GPIO interrupt priority (FreeRTOS asserts unless this is done here!) - NVIC_SetPriority(GPIO_EVEN_IRQn, WFX_GPIO_NVIC_PRIORITY); - NVIC_SetPriority(GPIO_ODD_IRQn, WFX_GPIO_NVIC_PRIORITY); -} - -#define USART SL_WFX_HOST_PINOUT_SPI_PERIPHERAL - -/*********************************************************************** - * @fn static int sl_wfx_host_spi_set_config(void *usart) - * @brief - * set the configuration of spi - * @param[in] usart: - * @return returns 0 if sucessful, - * -1 otherwise - * **********************************************************************/ -static int sl_wfx_host_spi_set_config(void * usart) -{ - int ret = -1; - - if (0) - { -#if defined(USART0) - } - else if (usart == USART0) - { - usart_clock = cmuClock_USART0; - usart_tx_signal = dmadrvPeripheralSignal_USART0_TXBL; - usart_rx_signal = dmadrvPeripheralSignal_USART0_RXDATAV; - ret = 0; -#endif -#if defined(USART1) - } - else if (usart == USART1) - { - usart_clock = cmuClock_USART1; - usart_tx_signal = dmadrvPeripheralSignal_USART1_TXBL; - usart_rx_signal = dmadrvPeripheralSignal_USART1_RXDATAV; - ret = 0; -#endif -#if defined(USART2) - } - else if (usart == USART2) - { - usart_clock = cmuClock_USART2; - usart_tx_signal = dmadrvPeripheralSignal_USART2_TXBL; - usart_rx_signal = dmadrvPeripheralSignal_USART2_RXDATAV; - ret = 0; -#endif -#if defined(USART3) - } - else if (usart == USART3) - { - usart_clock = cmuClock_USART3; - usart_tx_signal = dmadrvPeripheralSignal_USART3_TXBL; - usart_rx_signal = dmadrvPeripheralSignal_USART3_RXDATAV; - ret = 0; -#endif -#if defined(USART4) - } - else if (usart == USART4) - { - usart_clock = cmuClock_USART4; - usart_tx_signal = dmadrvPeripheralSignal_USART4_TXBL; - usart_rx_signal = dmadrvPeripheralSignal_USART4_RXDATAV; - ret = 0; -#endif -#if defined(USART5) - } - else if (usart == USART5) - { - usart_clock = cmuClock_USART5; - usart_tx_signal = dmadrvPeripheralSignal_USART5_TXBL; - usart_rx_signal = dmadrvPeripheralSignal_USART5_RXDATAV; - ret = 0; -#endif -#if defined(USARTRF0) - } - else if (usart == USARTRF0) - { - usart_clock = cmuClock_USARTRF0; - usart_tx_signal = dmadrvPeripheralSignal_USARTRF0_TXBL; - usart_rx_signal = dmadrvPeripheralSignal_USARTRF0_RXDATAV; - ret = 0; -#endif -#if defined(USARTRF1) - } - else if (usart == USARTRF1) - { - usart_clock = cmuClock_USARTRF1; - usart_tx_signal = dmadrvPeripheralSignal_USARTRF1_TXBL; - usart_rx_signal = dmadrvPeripheralSignal_USARTRF1_RXDATAV; - ret = 0; -#endif - } - - return ret; -} - -/**************************************************************************** - * @fn sl_status_t sl_wfx_host_init_bus(void) - * @brief - * Initialize SPI peripheral - * @param[in] None - * @return returns SL_STATUS_OK if successful, - * SL_STATUS_FAIL otherwise - *****************************************************************************/ -sl_status_t sl_wfx_host_init_bus(void) -{ - int res; - - // Initialize and enable the USART - USART_InitSync_TypeDef usartInit = USART_INITSYNC_DEFAULT; - - res = sl_wfx_host_spi_set_config(USART); - if (res != SPI_CONFIG_SUCESS) - { - return SL_STATUS_FAIL; - } - - spi_enabled = true; - dummy_tx_data = 0; - usartInit.baudrate = 36000000u; - usartInit.msbf = true; - CMU_ClockEnable(cmuClock_HFPER, true); - CMU_ClockEnable(cmuClock_GPIO, true); - CMU_ClockEnable(usart_clock, true); - USART_InitSync(USART, &usartInit); - USART->CTRL |= (1u << _USART_CTRL_SMSDELAY_SHIFT); - USART->ROUTELOC0 = - (USART->ROUTELOC0 & ~(_USART_ROUTELOC0_TXLOC_MASK | _USART_ROUTELOC0_RXLOC_MASK | _USART_ROUTELOC0_CLKLOC_MASK)) | - (SL_WFX_HOST_PINOUT_SPI_TX_LOC << _USART_ROUTELOC0_TXLOC_SHIFT) | - (SL_WFX_HOST_PINOUT_SPI_RX_LOC << _USART_ROUTELOC0_RXLOC_SHIFT) | - (SL_WFX_HOST_PINOUT_SPI_CLK_LOC << _USART_ROUTELOC0_CLKLOC_SHIFT); - - USART->ROUTEPEN = USART_ROUTEPEN_TXPEN | USART_ROUTEPEN_RXPEN | USART_ROUTEPEN_CLKPEN; - GPIO_DriveStrengthSet(SL_WFX_HOST_PINOUT_SPI_CLK_PORT, gpioDriveStrengthStrongAlternateStrong); - GPIO_PinModeSet(SL_WFX_HOST_PINOUT_SPI_TX_PORT, SL_WFX_HOST_PINOUT_SPI_TX_PIN, gpioModePushPull, PINOUT_CLEAR); - GPIO_PinModeSet(SL_WFX_HOST_PINOUT_SPI_RX_PORT, SL_WFX_HOST_PINOUT_SPI_RX_PIN, gpioModeInput, PINOUT_CLEAR); - GPIO_PinModeSet(SL_WFX_HOST_PINOUT_SPI_CLK_PORT, SL_WFX_HOST_PINOUT_SPI_CLK_PIN, gpioModePushPull, PINOUT_CLEAR); - - DMADRV_Init(); - DMADRV_AllocateChannel(&tx_dma_channel, NULL); - DMADRV_AllocateChannel(&rx_dma_channel, NULL); - GPIO_PinModeSet(SL_WFX_HOST_PINOUT_SPI_CS_PORT, SL_WFX_HOST_PINOUT_SPI_CS_PIN, gpioModePushPull, PINOUT_SET); - USART->CMD = USART_CMD_CLEARRX | USART_CMD_CLEARTX; - - return SL_STATUS_OK; -} - -/*********************************************************************** - * @fn void wfx_rsidev_init(void) - * @brief - * function called when driver rsidev intialization - * @param[in] None - * @return None - * **********************************************************************/ -void wfx_rsidev_init(void) -{ - wfx_host_gpio_init(); -} -#endif /* _NOT_USED */ diff --git a/src/platform/silabs/SiWx917/BLEManagerImpl.cpp b/src/platform/silabs/SiWx917/BLEManagerImpl.cpp index cd8ba47acf628e..04bf47f85400d0 100644 --- a/src/platform/silabs/SiWx917/BLEManagerImpl.cpp +++ b/src/platform/silabs/SiWx917/BLEManagerImpl.cpp @@ -70,7 +70,7 @@ using namespace ::chip::Ble; void sl_ble_init() { - WFX_RSI_LOG("%s starting", __func__); + ChipLogProgress(DeviceLayer, "%s starting", __func__); // registering the GAP callback functions rsi_ble_gap_register_callbacks(NULL, NULL, rsi_ble_on_disconnect_event, NULL, NULL, NULL, rsi_ble_on_enhance_conn_status_event, @@ -81,7 +81,7 @@ void sl_ble_init() rsi_ble_on_mtu_event, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, rsi_ble_on_event_indication_confirmation, NULL); rsi_semaphore_create(&sl_ble_event_sem, 0); - WFX_RSI_LOG("registering rsi_ble_add_service"); + ChipLogProgress(DeviceLayer, "registering rsi_ble_add_service"); // Exchange of GATT info with BLE stack rsi_ble_add_matter_service(); @@ -89,20 +89,21 @@ void sl_ble_init() // initializing the application events map rsi_ble_app_init_events(); - WFX_RSI_LOG("StartAdvertising"); + ChipLogProgress(DeviceLayer, "StartAdvertising"); chip::DeviceLayer::Internal::BLEManagerImpl().StartAdvertising(); // TODO:: Called on after init of module - WFX_RSI_LOG("%s Ended", __func__); + ChipLogProgress(DeviceLayer, "%s Ended", __func__); } void sl_ble_event_handling_task(void) { int32_t event_id; - WFX_RSI_LOG("%s starting", __func__); + ChipLogProgress(DeviceLayer, "%s starting", __func__); rsi_semaphore_create(&sl_rs_ble_init_sem, 0); //! This semaphore is waiting for wifi module initialization. rsi_semaphore_wait(&sl_rs_ble_init_sem, 0); + // Initialize BLE and starts BLE Advertisement sl_ble_init(); // Application event map @@ -120,7 +121,7 @@ void sl_ble_event_handling_task(void) case RSI_BLE_CONN_EVENT: { rsi_ble_app_clear_event(RSI_BLE_CONN_EVENT); chip::DeviceLayer::Internal::BLEMgrImpl().HandleConnectEvent(); - WFX_RSI_LOG("%s Module got connected", __func__); + ChipLogProgress(DeviceLayer, "%s Module got connected", __func__); // Requests the connection parameters change with the remote device rsi_ble_conn_params_update(event_msg.resp_enh_conn.dev_addr, BLE_MIN_CONNECTION_INTERVAL_MS, BLE_MAX_CONNECTION_INTERVAL_MS, BLE_SLAVE_LATENCY_MS, BLE_TIMEOUT_MS); @@ -128,7 +129,7 @@ void sl_ble_event_handling_task(void) break; case RSI_BLE_DISCONN_EVENT: { // event invokes when disconnection was completed - WFX_RSI_LOG("%s Module got Disconnected", __func__); + ChipLogProgress(DeviceLayer, "%s Module got Disconnected", __func__); chip::DeviceLayer::Internal::BLEMgrImpl().HandleConnectionCloseEvent(event_msg.reason); // clear the served event rsi_ble_app_clear_event(RSI_BLE_DISCONN_EVENT); @@ -136,7 +137,7 @@ void sl_ble_event_handling_task(void) break; case RSI_BLE_MTU_EVENT: { // event invokes when write/notification events received - WFX_RSI_LOG("%s RSI_BLE_MTU_EVENT", __func__); + ChipLogProgress(DeviceLayer, "%s RSI_BLE_MTU_EVENT", __func__); chip::DeviceLayer::Internal::BLEMgrImpl().UpdateMtu(event_msg.rsi_ble_mtu); // clear the served event rsi_ble_app_clear_event(RSI_BLE_MTU_EVENT); @@ -144,28 +145,28 @@ void sl_ble_event_handling_task(void) break; case RSI_BLE_GATT_WRITE_EVENT: { // event invokes when write/notification events received - WFX_RSI_LOG("%s RSI_BLE_GATT_WRITE_EVENT", __func__); + ChipLogProgress(DeviceLayer, "%s RSI_BLE_GATT_WRITE_EVENT", __func__); chip::DeviceLayer::Internal::BLEMgrImpl().HandleWriteEvent(event_msg.rsi_ble_write); // clear the served event rsi_ble_app_clear_event(RSI_BLE_GATT_WRITE_EVENT); } break; case RSI_BLE_GATT_INDICATION_CONFIRMATION: { - WFX_RSI_LOG("%s indication confirmation", __func__); + ChipLogProgress(DeviceLayer, "%s indication confirmation", __func__); chip::DeviceLayer::Internal::BLEMgrImpl().HandleTxConfirmationEvent(1); rsi_ble_app_clear_event(RSI_BLE_GATT_INDICATION_CONFIRMATION); } break; case RSI_BLE_RESP_ATT_VALUE: { - WFX_RSI_LOG("RSI_BLE : RESP_ATT confirmation"); + ChipLogProgress(DeviceLayer, "RSI_BLE : RESP_ATT confirmation"); } default: break; } } - WFX_RSI_LOG("%s Ended", __func__); + ChipLogProgress(DeviceLayer, "%s Ended", __func__); } namespace chip { @@ -174,19 +175,19 @@ namespace Internal { namespace { -#define CHIP_ADV_DATA_TYPE_FLAGS 0x01 -#define CHIP_ADV_DATA_TYPE_UUID 0x03 -#define CHIP_ADV_DATA_TYPE_NAME 0x09 -#define CHIP_ADV_DATA_TYPE_SERVICE_DATA 0x16 +#define CHIP_ADV_DATA_TYPE_FLAGS (0x01) +#define CHIP_ADV_DATA_TYPE_UUID (0x03) +#define CHIP_ADV_DATA_TYPE_NAME (0x09) +#define CHIP_ADV_DATA_TYPE_SERVICE_DATA (0x16) -#define CHIP_ADV_DATA_FLAGS 0x06 +#define CHIP_ADV_DATA_FLAGS (0x06) -#define CHIP_ADV_DATA 0 -#define CHIP_ADV_SCAN_RESPONSE_DATA 1 -#define CHIP_ADV_SHORT_UUID_LEN 2 +#define CHIP_ADV_DATA (0) +#define CHIP_ADV_SCAN_RESPONSE_DATA (1) +#define CHIP_ADV_SHORT_UUID_LEN (2) -#define MAX_RESPONSE_DATA_LEN 31 -#define MAX_ADV_DATA_LEN 31 +#define MAX_RESPONSE_DATA_LEN (31) +#define MAX_ADV_DATA_LEN (31) // Timer Frequency used. #define TIMER_CLK_FREQ ((uint32_t) 32768) @@ -212,7 +213,7 @@ namespace { #define BLE_CONFIG_MIN_CE_LENGTH (0) // Leave to min value #define BLE_CONFIG_MAX_CE_LENGTH (0xFFFF) // Leave to max value -#define BLE_DEFAULT_TIMER_PERIOD 1 +#define BLE_DEFAULT_TIMER_PERIOD_MS (1) TimerHandle_t sbleAdvTimeoutTimer; // FreeRTOS sw timer. @@ -238,7 +239,7 @@ CHIP_ERROR BLEManagerImpl::_Init() if (wfx_rsi.ble_task == NULL) { - WFX_RSI_LOG("%s: error: failed to create ble task.", __func__); + ChipLogProgress(DeviceLayer, "%s: error: failed to create ble task.", __func__); } // Initialize the CHIP BleLayer. @@ -250,11 +251,11 @@ CHIP_ERROR BLEManagerImpl::_Init() mServiceMode = ConnectivityManager::kCHIPoBLEServiceMode_Enabled; // Create FreeRTOS sw timer for BLE timeouts and interval change. - sbleAdvTimeoutTimer = xTimerCreate("BleAdvTimer", // Just a text name, not used by the RTOS kernel - pdMS_TO_TICKS(BLE_DEFAULT_TIMER_PERIOD), // == default timer period - false, // no timer reload (==one-shot) - (void *) this, // init timer id = ble obj context - BleAdvTimeoutHandler // timer callback handler + sbleAdvTimeoutTimer = xTimerCreate("BleAdvTimer", // Just a text name, not used by the RTOS kernel + pdMS_TO_TICKS(BLE_DEFAULT_TIMER_PERIOD_MS), // == default timer period + false, // no timer reload (==one-shot) + (void *) this, // init timer id = ble obj context + BleAdvTimeoutHandler // timer callback handler ); mFlags.ClearAll().Set(Flags::kAdvertisingEnabled, CHIP_DEVICE_CONFIG_CHIPOBLE_ENABLE_ADVERTISING_AUTOSTART); @@ -434,12 +435,12 @@ bool BLEManagerImpl::SendIndication(BLE_CONNECTION_OBJECT conId, const ChipBleUU PacketBufferHandle data) { int32_t status = 0; - WFX_RSI_LOG("In send indication"); + ChipLogProgress(DeviceLayer, "In send indication"); status = rsi_ble_indicate_value(event_msg.resp_enh_conn.dev_addr, event_msg.rsi_ble_measurement_hndl, (data->DataLength()), data->Start()); if (status != RSI_SUCCESS) { - WFX_RSI_LOG("indication %d failed with error code %lx ", status); + ChipLogProgress(DeviceLayer, "indication failed with error code %lx ", status); return false; } @@ -469,7 +470,7 @@ bool BLEManagerImpl::SendReadResponse(BLE_CONNECTION_OBJECT conId, BLE_READ_REQU void BLEManagerImpl::NotifyChipConnectionClosed(BLE_CONNECTION_OBJECT conId) { - // Nothing to do + // Nothing to do : Placeholder } CHIP_ERROR BLEManagerImpl::MapBLEError(int bleErr) @@ -493,12 +494,11 @@ CHIP_ERROR BLEManagerImpl::MapBLEError(int bleErr) void BLEManagerImpl::DriveBLEState(void) { - ChipLogProgress(DeviceLayer, "DriveBLEState starting"); CHIP_ERROR err = CHIP_NO_ERROR; - // Check if BLE stack is initialized - // VerifyOrExit(mFlags.Has(Flags::kEFRBLEStackInitialized), /* */); + // Check if BLE stack is initialized ( TODO ) + // VerifyOrExit(mFlags.Has(Flags::kEFRBLEStackInitialized),); ChipLogProgress(DeviceLayer, "Start advertising if needed..."); // Start advertising if needed... @@ -754,11 +754,12 @@ void BLEManagerImpl::HandleWriteEvent(rsi_ble_event_write_t evt) ChipLogProgress(DeviceLayer, "Char Write Req, packet type %d", evt.pkt_type); // uint8_t attribute = (uint8_t) event_msg.rsi_ble_measurement_hndl; - WFX_RSI_LOG("event_msg.rsi_ble_gatt_server_client_config_hndl = %d", event_msg.rsi_ble_gatt_server_client_config_hndl); + ChipLogProgress(DeviceLayer, "event_msg.rsi_ble_gatt_server_client_config_hndl = %d", + event_msg.rsi_ble_gatt_server_client_config_hndl); if (evt.handle[0] == (uint8_t) event_msg.rsi_ble_gatt_server_client_config_hndl) // TODO:: compare the handle exactly { - WFX_RSI_LOG("Inside HandleTXCharCCCDWrite "); + ChipLogProgress(DeviceLayer, "Inside HandleTXCharCCCDWrite "); HandleTXCharCCCDWrite(&evt); } else @@ -935,10 +936,10 @@ CHIP_ERROR BLEManagerImpl::EncodeAdditionalDataTlv() return err; } -// TODO:: Need the +// TODO:: Need to do the correct implementation void BLEManagerImpl::HandleC3ReadRequest(void) { - + // TODO // if (ret != SL_STATUS_OK) // { // ChipLogDetail(DeviceLayer, "Failed to send read response, err:%ld", ret); diff --git a/src/platform/silabs/SiWx917/bluetooth/rsi_ble_config.h b/src/platform/silabs/SiWx917/bluetooth/rsi_ble_config.h index 078a050f470cc6..7b257895fd1d84 100644 --- a/src/platform/silabs/SiWx917/bluetooth/rsi_ble_config.h +++ b/src/platform/silabs/SiWx917/bluetooth/rsi_ble_config.h @@ -24,76 +24,76 @@ * * Macros * ******************************************************/ //! application event list -#define RSI_BLE_CONN_EVENT 0x01 -#define RSI_BLE_DISCONN_EVENT 0x02 -#define RSI_BLE_GATT_WRITE_EVENT 0x03 -#define RSI_BLE_MTU_EVENT 0x04 -#define RSI_BLE_GATT_INDICATION_CONFIRMATION 0x05 -#define RSI_BLE_RESP_ATT_VALUE 0x06 -#define RSI_SSID 0x0D -#define RSI_SECTYPE 0x0E -#define RSI_BLE_WLAN_DISCONN_NOTIFY 0x0F -#define RSI_WLAN_ALREADY 0x10 -#define RSI_WLAN_NOT_ALREADY 0x11 -#define RSI_BLE_WLAN_TIMEOUT_NOTIFY 0x12 -#define RSI_BLE_WLAN_JOIN_STATUS 0x15 -#define RSI_APP_FW_VERSION 0x13 -#define RSI_BLE_WLAN_DISCONNECT_STATUS 0x14 - -#define RSI_REM_DEV_ADDR_LEN 18 -#define RSI_REM_DEV_NAME_LEN 31 +#define RSI_BLE_CONN_EVENT (0x01) +#define RSI_BLE_DISCONN_EVENT (0x02) +#define RSI_BLE_GATT_WRITE_EVENT (0x03) +#define RSI_BLE_MTU_EVENT (0x04) +#define RSI_BLE_GATT_INDICATION_CONFIRMATION (0x05) +#define RSI_BLE_RESP_ATT_VALUE (0x06) +#define RSI_SSID (0x0D) +#define RSI_SECTYPE (0x0E) +#define RSI_BLE_WLAN_DISCONN_NOTIFY (0x0F) +#define RSI_WLAN_ALREADY (0x10) +#define RSI_WLAN_NOT_ALREADY (0x11) +#define RSI_BLE_WLAN_TIMEOUT_NOTIFY (0x12) +#define RSI_BLE_WLAN_JOIN_STATUS (0x15) +#define RSI_APP_FW_VERSION (0x13) +#define RSI_BLE_WLAN_DISCONNECT_STATUS (0x14) + +#define RSI_REM_DEV_ADDR_LEN (18) +#define RSI_REM_DEV_NAME_LEN (31) #define RSI_BLE_DEV_NAME "CCP_DEVICE" #define RSI_BLE_SET_RAND_ADDR "00:23:A7:12:34:56" -#define CLEAR_WHITELIST 0x00 -#define ADD_DEVICE_TO_WHITELIST 0x01 -#define DELETE_DEVICE_FROM_WHITELIST 0x02 +#define CLEAR_WHITELIST (0x00) +#define ADD_DEVICE_TO_WHITELIST (0x01) +#define DELETE_DEVICE_FROM_WHITELIST (0x02) -#define ALL_PHYS 0x00 +#define ALL_PHYS (0x00) -#define RSI_BLE_DEV_ADDR_RESOLUTION_ENABLE 0 +#define RSI_BLE_DEV_ADDR_RESOLUTION_ENABLE (0) -#define RSI_OPERMODE_WLAN_BLE 13 +#define RSI_OPERMODE_WLAN_BLE (13) /***********************************************************************************************************************************************/ //! Characteristic Presenatation Format Fields /***********************************************************************************************************************************************/ -#define RSI_BLE_UINT8_FORMAT 0x04 -#define RSI_BLE_EXPONENT 0x00 -#define RSI_BLE_PERCENTAGE_UNITS_UUID 0x27AD -#define RSI_BLE_NAME_SPACE 0x01 -#define RSI_BLE_DESCRIPTION 0x010B +#define RSI_BLE_UINT8_FORMAT (0x04) +#define RSI_BLE_EXPONENT (0x00) +#define RSI_BLE_PERCENTAGE_UNITS_UUID (0x27AD) +#define RSI_BLE_NAME_SPACE (0x01) +#define RSI_BLE_DESCRIPTION (0x010B) //! BLE characteristic custom service uuid -#define RSI_BLE_CUSTOM_SERVICE_UUID 0xFFF6 -#define RSI_BLE_CUSTOM_LEVEL_UUID 0x1FF1 +#define RSI_BLE_CUSTOM_SERVICE_UUID (0xFFF6) +#define RSI_BLE_CUSTOM_LEVEL_UUID (0x1FF1) #ifdef RSI_M4_INTERFACE -#define RSI_BLE_MAX_NBR_ATT_REC 20 -#define RSI_BLE_MAX_NBR_SLAVES 1 -#define RSI_BLE_NUM_CONN_EVENTS 2 +#define RSI_BLE_MAX_NBR_ATT_REC (20) +#define RSI_BLE_MAX_NBR_SLAVES (1) +#define RSI_BLE_NUM_CONN_EVENTS (2) #else -#define RSI_BLE_MAX_NBR_ATT_REC 80 -#define RSI_BLE_MAX_NBR_SLAVES 3 -#define RSI_BLE_NUM_CONN_EVENTS 20 +#define RSI_BLE_MAX_NBR_ATT_REC (80) +#define RSI_BLE_MAX_NBR_SLAVES (3) +#define RSI_BLE_NUM_CONN_EVENTS (20) #endif -#define RSI_BLE_MAX_NBR_ATT_SERV 10 +#define RSI_BLE_MAX_NBR_ATT_SERV (10) -#define RSI_BLE_MAX_NBR_MASTERS 1 -#define RSI_BLE_GATT_ASYNC_ENABLE 1 -#define RSI_BLE_GATT_INIT 0 +#define RSI_BLE_MAX_NBR_MASTERS (1) +#define RSI_BLE_GATT_ASYNC_ENABLE (1) +#define RSI_BLE_GATT_INIT (0) -#define RSI_BLE_START_SCAN 0x01 -#define RSI_BLE_STOP_SCAN 0x00 +#define RSI_BLE_START_SCAN (0x01) +#define RSI_BLE_STOP_SCAN (0x00) #define RSI_BLE_SCAN_TYPE SCAN_TYPE_ACTIVE #define RSI_BLE_SCAN_FILTER_TYPE SCAN_FILTER_TYPE_ALL /* Number of BLE GATT RECORD SIZE IN (n*16 BYTES), eg:(0x40*16)=1024 bytes */ -#define RSI_BLE_NUM_REC_BYTES 0x40 +#define RSI_BLE_NUM_REC_BYTES (0x40) -#define RSI_BLE_INDICATE_CONFIRMATION_FROM_HOST 0 +#define RSI_BLE_INDICATE_CONFIRMATION_FROM_HOST (0) /*=======================================================================*/ //! Advertising command parameters @@ -105,25 +105,25 @@ #define RSI_BLE_ADV_DIR_ADDR "00:15:83:6A:64:17" //! Reduced the BLE adv interval time to match with EFR BLE -#define RSI_BLE_ADV_INT_MIN 0x20 -#define RSI_BLE_ADV_INT_MAX 0x20 +#define RSI_BLE_ADV_INT_MIN (0x20) +#define RSI_BLE_ADV_INT_MAX (0x20) -#define RSI_BLE_ADV_CHANNEL_MAP 0x07 +#define RSI_BLE_ADV_CHANNEL_MAP (0x07) //! Advertise status //! Start the advertising process -#define RSI_BLE_START_ADV 0x01 +#define RSI_BLE_START_ADV (0x01) //! Stop the advertising process -#define RSI_BLE_STOP_ADV 0x00 +#define RSI_BLE_STOP_ADV (0x00) //! BLE Tx Power Index On Air -#define RSI_BLE_PWR_INX 30 +#define RSI_BLE_PWR_INX (30) //! BLE Active H/w Pwr Features -#define BLE_DISABLE_DUTY_CYCLING 0 -#define BLE_DUTY_CYCLING 1 -#define BLR_DUTY_CYCLING 2 -#define BLE_4X_PWR_SAVE_MODE 4 +#define BLE_DISABLE_DUTY_CYCLING (0) +#define BLE_DUTY_CYCLING (1) +#define BLR_DUTY_CYCLING (2) +#define BLE_4X_PWR_SAVE_MODE (4) #define RSI_BLE_PWR_SAVE_OPTIONS BLE_DISABLE_DUTY_CYCLING //! Advertise types @@ -131,61 +131,61 @@ /* Advertising will be visible(discoverable) to all the devices. * Scanning/Connection is also accepted from all devices * */ -#define UNDIR_CONN 0x80 +#define UNDIR_CONN (0x80) /* Advertising will be visible(discoverable) to the particular device * mentioned in RSI_BLE_ADV_DIR_ADDR only. * Scanning and Connection will be accepted from that device only. * */ -#define DIR_CONN 0x81 +#define DIR_CONN (0x81) /* Advertising will be visible(discoverable) to all the devices. * Scanning will be accepted from all the devices. * Connection will be not be accepted from any device. * */ -#define UNDIR_SCAN 0x82 +#define UNDIR_SCAN (0x82) /* Advertising will be visible(discoverable) to all the devices. * Scanning and Connection will not be accepted from any device * */ -#define UNDIR_NON_CONN 0x83 +#define UNDIR_NON_CONN (0x83) /* Advertising will be visible(discoverable) to the particular device * mentioned in RSI_BLE_ADV_DIR_ADDR only. * Scanning and Connection will be accepted from that device only. * */ -#define DIR_CONN_LOW_DUTY_CYCLE 0x84 +#define DIR_CONN_LOW_DUTY_CYCLE (0x84) //! Advertising flags -#define LE_LIMITED_DISCOVERABLE 0x01 -#define LE_GENERAL_DISCOVERABLE 0x02 -#define LE_BR_EDR_NOT_SUPPORTED 0x04 +#define LE_LIMITED_DISCOVERABLE (0x01) +#define LE_GENERAL_DISCOVERABLE (0x02) +#define LE_BR_EDR_NOT_SUPPORTED (0x04) //! Advertise filters -#define ALLOW_SCAN_REQ_ANY_CONN_REQ_ANY 0x00 -#define ALLOW_SCAN_REQ_WHITE_LIST_CONN_REQ_ANY 0x01 -#define ALLOW_SCAN_REQ_ANY_CONN_REQ_WHITE_LIST 0x02 -#define ALLOW_SCAN_REQ_WHITE_LIST_CONN_REQ_WHITE_LIST 0x03 +#define ALLOW_SCAN_REQ_ANY_CONN_REQ_ANY (0x00) +#define ALLOW_SCAN_REQ_WHITE_LIST_CONN_REQ_ANY (0x01) +#define ALLOW_SCAN_REQ_ANY_CONN_REQ_WHITE_LIST (0x02) +#define ALLOW_SCAN_REQ_WHITE_LIST_CONN_REQ_WHITE_LIST (0x03) //! Address types -#define LE_PUBLIC_ADDRESS 0x00 -#define LE_RANDOM_ADDRESS 0x01 -#define LE_RESOLVABLE_PUBLIC_ADDRESS 0x02 -#define LE_RESOLVABLE_RANDOM_ADDRESS 0x03 +#define LE_PUBLIC_ADDRESS (0x00) +#define LE_RANDOM_ADDRESS (0x01) +#define LE_RESOLVABLE_PUBLIC_ADDRESS (0x02) +#define LE_RESOLVABLE_RANDOM_ADDRESS (0x03) /*=======================================================================*/ /*=======================================================================*/ //! Connection parameters /*=======================================================================*/ -#define LE_SCAN_INTERVAL 0x0100 -#define LE_SCAN_WINDOW 0x0050 +#define LE_SCAN_INTERVAL (0x0100) +#define LE_SCAN_WINDOW (0x0050) -#define CONNECTION_INTERVAL_MIN 0x00A0 -#define CONNECTION_INTERVAL_MAX 0x00A0 +#define CONNECTION_INTERVAL_MIN (0x00A0) +#define CONNECTION_INTERVAL_MAX (0x00A0) -#define CONNECTION_LATENCY 0x0000 -#define SUPERVISION_TIMEOUT 0x07D0 // 2000 +#define CONNECTION_LATENCY (0x0000) +#define SUPERVISION_TIMEOUT (0x07D0) // 2000 /*=======================================================================*/ @@ -197,56 +197,36 @@ #define SL_WFX_BLE_SCAN_FILTER_TYPE SCAN_FILTER_TYPE_ALL //! Scan status -#define SL_WFX_BLE_START_SCAN 0x01 -#define SL_WFX_BLE_STOP_SCAN 0x00 +#define SL_WFX_BLE_START_SCAN (0x01) +#define SL_WFX_BLE_STOP_SCAN (0x00) //! Scan types -#define SCAN_TYPE_ACTIVE 0x01 -#define SCAN_TYPE_PASSIVE 0x00 +#define SCAN_TYPE_ACTIVE (0x01) +#define SCAN_TYPE_PASSIVE (0x00) //! Scan filters -#define SCAN_FILTER_TYPE_ALL 0x00 -#define SCAN_FILTER_TYPE_ONLY_WHITE_LIST 0x01 +#define SCAN_FILTER_TYPE_ALL (0x00) +#define SCAN_FILTER_TYPE_ONLY_WHITE_LIST (0x01) -#define SL_WFX_SEL_INTERNAL_ANTENNA 0x00 -#define SL_WFX_SEL_EXTERNAL_ANTENNA 0x01 +#define SL_WFX_SEL_INTERNAL_ANTENNA (0x00) +#define SL_WFX_SEL_EXTERNAL_ANTENNA (0x01) -#define SL_WFX_BT_CTRL_REMOTE_USER_TERMINATED 0x4E13 -#define SL_WFX_BT_CTRL_REMOTE_DEVICE_TERMINATED_CONNECTION_DUE_TO_LOW_RESOURCES 0x4E14 -#define SL_WFX_BT_CTRL_REMOTE_POWERING_OFF 0x4E15 -#define SL_WFX_BT_CTRL_TERMINATED_MIC_FAILURE 0x4E3D -#define SL_WFX_BT_FAILED_TO_ESTABLISH_CONN 0x4E3E -#define SL_WFX_BT_INVALID_RANGE 0x4E60 +#define SL_WFX_BT_CTRL_REMOTE_USER_TERMINATED (0x4E13) +#define SL_WFX_BT_CTRL_REMOTE_DEVICE_TERMINATED_CONNECTION_DUE_TO_LOW_RESOURCES (0x4E14) +#define SL_WFX_BT_CTRL_REMOTE_POWERING_OFF (0x4E15) +#define SL_WFX_BT_CTRL_TERMINATED_MIC_FAILURE (0x4E3D) +#define SL_WFX_BT_FAILED_TO_ESTABLISH_CONN (0x4E3E) +#define SL_WFX_BT_INVALID_RANGE (0x4E60) /***********************************************************************************************************************************************/ //! RS9116 Firmware Configurations /***********************************************************************************************************************************************/ - -/*=======================================================================*/ -//! Opermode command parameters -/*=======================================================================*/ -/* -#define RSI_FEATURE_BIT_MAP \ - (FEAT_ULP_GPIO_BASED_HANDSHAKE | FEAT_DEV_TO_HOST_ULP_GPIO_1) //! To set wlan feature select bit map -#define RSI_TCP_IP_BYPASS RSI_DISABLE //! TCP IP BYPASS feature check -#define RSI_TCP_IP_FEATURE_BIT_MAP \ - (TCP_IP_FEAT_DHCPV4_CLIENT) //! TCP/IP feature select bitmap for selecting TCP/IP features -#define RSI_EXT_TCPIP_FEATURE_BITMAP 0 - -#define RSI_CUSTOM_FEATURE_BIT_MAP FEAT_CUSTOM_FEAT_EXTENTION_VALID //! To set custom feature select bit map - -#define RSI_EXT_CUSTOM_FEATURE_BIT_MAP (EXT_FEAT_LOW_POWER_MODE | EXT_FEAT_XTAL_CLK_ENABLE | EXT_FEAT_384K_MODE) - -#define RSI_BT_FEATURE_BITMAP (BT_RF_TYPE | ENABLE_BLE_PROTOCOL) -*/ /*=======================================================================*/ //! Power save command parameters /*=======================================================================*/ -//! set handshake type of power mode -//#define RSI_HAND_SHAKE_TYPE GPIO_BASED -#define BLE_ATT_REC_SIZE 500 -#define NO_OF_VAL_ATT 5 //! Attribute value count +#define BLE_ATT_REC_SIZE (500) +#define NO_OF_VAL_ATT (5) //! Attribute value count /***********************************************************************************************************************************************/ //! user defined structure @@ -268,4 +248,4 @@ typedef struct rsi_ble_s rsi_ble_att_list_t att_rec_list[NO_OF_VAL_ATT]; } rsi_ble_t; -#endif \ No newline at end of file +#endif diff --git a/src/platform/silabs/SiWx917/bluetooth/wfx_sl_ble_init.c b/src/platform/silabs/SiWx917/bluetooth/wfx_sl_ble_init.c index c816f81d686caf..579ed35a48e6f2 100644 --- a/src/platform/silabs/SiWx917/bluetooth/wfx_sl_ble_init.c +++ b/src/platform/silabs/SiWx917/bluetooth/wfx_sl_ble_init.c @@ -1,38 +1,23 @@ -/******************************************************************************* - * @file wfx_sl_ble_init.c - * @brief - ******************************************************************************* - * # License - * Copyright 2021 Silicon Laboratories Inc. www.silabs.com - ******************************************************************************* +/* * - * The licensor of this software is Silicon Laboratories Inc. Your use of this - * software is governed by the terms of Silicon Labs Master Software License - * Agreement (MSLA) available at - * www.silabs.com/about-us/legal/master-software-license-agreement. This - * software is distributed to you in Source Code format and is governed by the - * sections of the MSLA applicable to Source Code. + * Copyright (c) 2022 Project CHIP Authors * - ******************************************************************************/ -/************************************************************************* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ - -/*================================================================================ -* @brief : This file contains example application for Wlan Station BLE -* Provisioning -* @section Description : -* This application explains how to get the WLAN connection functionality using -* BLE provisioning. -* Silicon Labs Module starts advertising and with BLE Provisioning the Access Point -* details are fetched. -* Silicon Labs device is configured as a WiFi station and connects to an Access Point. -=================================================================================*/ - #include "wfx_sl_ble_init.h" #include "rsi_ble_config.h" -// application defines +// Global Variables rsi_ble_event_conn_status_t conn_event_to_app; rsi_ble_t att_list; sl_wfx_msg_t event_msg; @@ -53,7 +38,7 @@ const uint8_t ShortUUID_CHIPoBLEService[] = { 0xF6, 0xFF }; */ void rsi_ble_app_init_events() { - WFX_RSI_LOG("%s: starting", __func__); + SILABS_LOG("%s: starting", __func__); event_msg.ble_app_event_map = 0; event_msg.ble_app_event_mask = 0xFFFFFFFF; event_msg.ble_app_event_mask = event_msg.ble_app_event_mask; // To suppress warning while compiling @@ -71,7 +56,7 @@ void rsi_ble_app_init_events() */ void rsi_ble_app_clear_event(uint32_t event_num) { - WFX_RSI_LOG("%s: starting", __func__); + SILABS_LOG("%s: starting", __func__); event_msg.event_num = event_num; event_msg.ble_app_event_map &= ~BIT(event_num); return; @@ -88,7 +73,7 @@ void rsi_ble_app_clear_event(uint32_t event_num) */ void rsi_ble_on_mtu_event(rsi_ble_event_mtu_t * rsi_ble_mtu) { - WFX_RSI_LOG("%s: starting", __func__); + SILABS_LOG("%s: starting", __func__); memcpy(&event_msg.rsi_ble_mtu, rsi_ble_mtu, sizeof(rsi_ble_event_mtu_t)); rsi_ble_app_set_event(RSI_BLE_MTU_EVENT); } @@ -105,7 +90,7 @@ void rsi_ble_on_mtu_event(rsi_ble_event_mtu_t * rsi_ble_mtu) */ void rsi_ble_on_gatt_write_event(uint16_t event_id, rsi_ble_event_write_t * rsi_ble_write) { - WFX_RSI_LOG("%s: starting", __func__); + SILABS_LOG("%s: starting", __func__); event_msg.event_id = event_id; memcpy(&event_msg.rsi_ble_write, rsi_ble_write, sizeof(rsi_ble_event_write_t)); rsi_ble_app_set_event(RSI_BLE_GATT_WRITE_EVENT); @@ -122,7 +107,7 @@ void rsi_ble_on_gatt_write_event(uint16_t event_id, rsi_ble_event_write_t * rsi_ */ void rsi_ble_on_enhance_conn_status_event(rsi_ble_event_enhance_conn_status_t * resp_enh_conn) { - WFX_RSI_LOG("%s: starting", __func__); + SILABS_LOG("%s: starting", __func__); event_msg.connectionHandle = 1; event_msg.bondingHandle = 255; memcpy(event_msg.resp_enh_conn.dev_addr, resp_enh_conn->dev_addr, RSI_DEV_ADDR_LEN); @@ -141,7 +126,7 @@ void rsi_ble_on_enhance_conn_status_event(rsi_ble_event_enhance_conn_status_t * */ void rsi_ble_on_disconnect_event(rsi_ble_event_disconnect_t * resp_disconnect, uint16_t reason) { - WFX_RSI_LOG("%s: starting", __func__); + SILABS_LOG("%s: starting", __func__); event_msg.reason = reason; rsi_ble_app_set_event(RSI_BLE_DISCONN_EVENT); } @@ -157,7 +142,7 @@ void rsi_ble_on_disconnect_event(rsi_ble_event_disconnect_t * resp_disconnect, u */ void rsi_ble_on_event_indication_confirmation(uint16_t resp_status, rsi_ble_set_att_resp_t * rsi_ble_event_set_att_rsp) { - WFX_RSI_LOG("%s: starting", __func__); + SILABS_LOG("%s: starting", __func__); event_msg.resp_status = resp_status; memcpy(&event_msg.rsi_ble_event_set_att_rsp, rsi_ble_event_set_att_rsp, sizeof(rsi_ble_set_att_resp_t)); rsi_ble_app_set_event(RSI_BLE_GATT_INDICATION_CONFIRMATION); @@ -200,7 +185,7 @@ int32_t rsi_ble_app_get_event(void) */ void rsi_ble_app_set_event(uint32_t event_num) { - WFX_RSI_LOG("%s: starting", __func__); + SILABS_LOG("%s: starting", __func__); event_msg.ble_app_event_map |= BIT(event_num); rsi_semaphore_post(&sl_ble_event_sem); return; @@ -316,7 +301,9 @@ void rsi_ble_add_char_val_att(void * serv_handler, uint16_t handle, uuid_t att_t new_att.property = val_prop; if (data != NULL) + { memcpy(new_att.data, data, RSI_MIN(sizeof(new_att.data), data_len)); + } //! preparing the attribute value new_att.data_len = data_len; @@ -420,4 +407,4 @@ uint32_t rsi_ble_add_matter_service(void) memset(&data, 0, sizeof(data)); return 0; -} \ No newline at end of file +} diff --git a/src/platform/silabs/SiWx917/bluetooth/wfx_sl_ble_init.h b/src/platform/silabs/SiWx917/bluetooth/wfx_sl_ble_init.h index e52e1553de540d..02f835d62ad6e0 100644 --- a/src/platform/silabs/SiWx917/bluetooth/wfx_sl_ble_init.h +++ b/src/platform/silabs/SiWx917/bluetooth/wfx_sl_ble_init.h @@ -1,30 +1,23 @@ -/******************************************************************************* - * @file wfx_sl_ble_init.h - * @brief - ******************************************************************************* - * # License - * Copyright 2021 Silicon Laboratories Inc. www.silabs.com - ******************************************************************************* +/* * - * The licensor of this software is Silicon Laboratories Inc. Your use of this - * software is governed by the terms of Silicon Labs Master Software License - * Agreement (MSLA) available at - * www.silabs.com/about-us/legal/master-software-license-agreement. This - * software is distributed to you in Source Code format and is governed by the - * sections of the MSLA applicable to Source Code. + * Copyright (c) 2022 Project CHIP Authors * - ******************************************************************************/ -/************************************************************************* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ -/** - * Include files - * */ - #ifndef WFX_SL_BLE_INIT #define WFX_SL_BLE_INIT -#define RSI_BLE_ENABLE 1 +#define RSI_BLE_ENABLE (1) // BLE include file to refer BLE APIs #include "FreeRTOS.h" @@ -74,38 +67,38 @@ typedef struct sl_wfx_msg_s } sl_wfx_msg_t; -#define ATT_REC_IN_HOST 0 +#define ATT_REC_IN_HOST (0) -#define RSI_BT_CTRL_REMOTE_USER_TERMINATED 0x4E13 -#define RSI_BT_CTRL_REMOTE_DEVICE_TERMINATED_CONNECTION_DUE_TO_LOW_RESOURCES 0x4E14 -#define RSI_BT_CTRL_REMOTE_POWERING_OFF 0x4E15 -#define RSI_BT_CTRL_TERMINATED_MIC_FAILURE 0x4E3D -#define RSI_BT_FAILED_TO_ESTABLISH_CONN 0x4E3E -#define RSI_BT_INVALID_RANGE 0x4E60 +#define RSI_BT_CTRL_REMOTE_USER_TERMINATED (0x4E13) +#define RSI_BT_CTRL_REMOTE_DEVICE_TERMINATED_CONNECTION_DUE_TO_LOW_RESOURCES (0x4E14) +#define RSI_BT_CTRL_REMOTE_POWERING_OFF (0x4E15) +#define RSI_BT_CTRL_TERMINATED_MIC_FAILURE (0x4E3D) +#define RSI_BT_FAILED_TO_ESTABLISH_CONN (0x4E3E) +#define RSI_BT_INVALID_RANGE (0x4E60) -#define RSI_BLE_MATTER_CUSTOM_SERVICE_UUID 0 -#define RSI_BLE_MATTER_CUSTOM_SERVICE_SIZE 2 -#define RSI_BLE_MATTER_CUSTOM_SERVICE_VALUE_16 0xFFF6 -#define RSI_BLE_MATTER_CUSTOM_SERVICE_DATA 0x00 +#define RSI_BLE_MATTER_CUSTOM_SERVICE_UUID (0) +#define RSI_BLE_MATTER_CUSTOM_SERVICE_SIZE (2) +#define RSI_BLE_MATTER_CUSTOM_SERVICE_VALUE_16 (0xFFF6) +#define RSI_BLE_MATTER_CUSTOM_SERVICE_DATA (0x00) -#define RSI_BLE_CUSTOM_CHARACTERISTIC_RX_SIZE 16 +#define RSI_BLE_CUSTOM_CHARACTERISTIC_RX_SIZE (16) #define RSI_BLE_CUSTOM_CHARACTERISTIC_RX_RESERVED 0x00, 0x00, 0x00 #define RSI_BLE_CUSTOM_CHARACTERISTIC_RX_VALUE_128_DATA_1 0x18EE2EF5 #define RSI_BLE_CUSTOM_CHARACTERISTIC_RX_VALUE_128_DATA_2 0x263D #define RSI_BLE_CUSTOM_CHARACTERISTIC_RX_VALUE_128_DATA_3 0x4559 #define RSI_BLE_CUSTOM_CHARACTERISTIC_RX_VALUE_128_DATA_4 0x9F, 0x95, 0x9C, 0x4F, 0x11, 0x9D, 0x9F, 0x42 -#define RSI_BLE_CHARACTERISTIC_RX_ATTRIBUTE_HANDLE_LOCATION 1 -#define RSI_BLE_CHARACTERISTIC_RX_VALUE_HANDLE_LOCATION 2 +#define RSI_BLE_CHARACTERISTIC_RX_ATTRIBUTE_HANDLE_LOCATION (1) +#define RSI_BLE_CHARACTERISTIC_RX_VALUE_HANDLE_LOCATION (2) -#define RSI_BLE_CUSTOM_CHARACTERISTIC_TX_SIZE 16 +#define RSI_BLE_CUSTOM_CHARACTERISTIC_TX_SIZE (16) #define RSI_BLE_CUSTOM_CHARACTERISTIC_TX_RESERVED 0x00, 0x00, 0x00 #define RSI_BLE_CUSTOM_CHARACTERISTIC_TX_VALUE_128_DATA_1 0x18EE2EF5 #define RSI_BLE_CUSTOM_CHARACTERISTIC_TX_VALUE_128_DATA_2 0x263D #define RSI_BLE_CUSTOM_CHARACTERISTIC_TX_VALUE_128_DATA_3 0x4559 #define RSI_BLE_CUSTOM_CHARACTERISTIC_TX_VALUE_128_DATA_4 0x9F, 0x95, 0x9C, 0x4F, 0x12, 0x9D, 0x9F, 0x42 -#define RSI_BLE_CHARACTERISTIC_TX_ATTRIBUTE_HANDLE_LOCATION 3 -#define RSI_BLE_CHARACTERISTIC_TX_MEASUREMENT_HANDLE_LOCATION 4 -#define RSI_BLE_CHARACTERISTIC_TX_GATT_SERVER_CLIENT_HANDLE_LOCATION 5 +#define RSI_BLE_CHARACTERISTIC_TX_ATTRIBUTE_HANDLE_LOCATION (3) +#define RSI_BLE_CHARACTERISTIC_TX_MEASUREMENT_HANDLE_LOCATION (4) +#define RSI_BLE_CHARACTERISTIC_TX_GATT_SERVER_CLIENT_HANDLE_LOCATION (5) // ALL Ble functions void rsi_ble_on_connect_event(rsi_ble_event_conn_status_t * resp_conn); @@ -127,4 +120,4 @@ void rsi_ble_app_clear_event(uint32_t event_num); void rsi_ble_app_init_events(); void rsi_ble_event_handling_task(void); -#endif \ No newline at end of file +#endif diff --git a/src/platform/silabs/SiWx917/wifi/dhcp_client.cpp b/src/platform/silabs/SiWx917/wifi/dhcp_client.cpp index e45f38bcaeaf8e..9356586e5d6024 100644 --- a/src/platform/silabs/SiWx917/wifi/dhcp_client.cpp +++ b/src/platform/silabs/SiWx917/wifi/dhcp_client.cpp @@ -30,7 +30,7 @@ #include "FreeRTOS.h" #include "event_groups.h" -#define MAX_DHCP_TRIES 4 +#define MAX_DHCP_TRIES (4) #define NETIF_IPV4_ADDRESS(X, Y) (((X) >> (8 * Y)) & 0xFF) /* Station IP address */ diff --git a/src/platform/silabs/SiWx917/wifi/dhcp_client.h b/src/platform/silabs/SiWx917/wifi/dhcp_client.h index 3040f7112fb954..4ee9d2f5d0d68d 100644 --- a/src/platform/silabs/SiWx917/wifi/dhcp_client.h +++ b/src/platform/silabs/SiWx917/wifi/dhcp_client.h @@ -23,12 +23,12 @@ extern "C" { #endif // DHCP client states -#define DHCP_OFF (uint8_t) 0 -#define DHCP_START (uint8_t) 1 -#define DHCP_WAIT_ADDRESS (uint8_t) 2 -#define DHCP_ADDRESS_ASSIGNED (uint8_t) 3 -#define DHCP_TIMEOUT (uint8_t) 4 -#define DHCP_LINK_DOWN (uint8_t) 5 +#define DHCP_OFF ((uint8_t) 0) +#define DHCP_START ((uint8_t) 1) +#define DHCP_WAIT_ADDRESS ((uint8_t) 2) +#define DHCP_ADDRESS_ASSIGNED ((uint8_t) 3) +#define DHCP_TIMEOUT ((uint8_t) 4) +#define DHCP_LINK_DOWN ((uint8_t) 5) /***************************************************************************** * @fn void dhcpclient_set_link_state(int link_up) diff --git a/src/platform/silabs/SiWx917/wifi/wfx_host_events.h b/src/platform/silabs/SiWx917/wifi/wfx_host_events.h index 4ba8370f5209e5..7e5e842f4a8200 100644 --- a/src/platform/silabs/SiWx917/wifi/wfx_host_events.h +++ b/src/platform/silabs/SiWx917/wifi/wfx_host_events.h @@ -20,13 +20,6 @@ #include "stdbool.h" #include "wfx_msgs.h" -/* Wi-Fi events*/ -#define SL_WFX_STARTUP_IND_ID 1 -#define SL_WFX_CONNECT_IND_ID 2 -#define SL_WFX_DISCONNECT_IND_ID 3 -#define SL_WFX_SCAN_COMPLETE_ID 4 -#define WFX_RSI_SSID_SIZE 64 - /* LwIP includes. */ #include "lwip/apps/httpd.h" #include "lwip/ip_addr.h" @@ -34,6 +27,15 @@ #include "lwip/netifapi.h" #include "lwip/tcpip.h" +#include "sl_status.h" + +/* Wi-Fi events*/ +#define SL_WFX_STARTUP_IND_ID (1) +#define SL_WFX_CONNECT_IND_ID (2) +#define SL_WFX_DISCONNECT_IND_ID (3) +#define SL_WFX_SCAN_COMPLETE_ID (4) +#define WFX_RSI_SSID_SIZE (64) + /* Wi-Fi bitmask events - for the task */ #define SL_WFX_CONNECT (1 << 1) #define SL_WFX_DISCONNECT (1 << 2) @@ -43,12 +45,10 @@ #define SL_WFX_SCAN_COMPLETE (1 << 6) #define SL_WFX_RETRY_CONNECT (1 << 7) -#include "sl_status.h" - -#define WLAN_TASK_STACK_SIZE 1024 -#define WLAN_TASK_PRIORITY 3 -#define WLAN_DRIVER_TASK_PRIORITY 2 -#define MAX_JOIN_RETRIES_COUNT 5 +#define WLAN_TASK_STACK_SIZE (1024) +#define WLAN_TASK_PRIORITY (3) +#define WLAN_DRIVER_TASK_PRIORITY (2) +#define MAX_JOIN_RETRIES_COUNT (5) // WLAN retry time intervals in milli seconds #define WLAN_MAX_RETRY_TIMER_MS 30000 @@ -57,77 +57,75 @@ #define CONVERT_MS_TO_SEC(TimeInMS) (TimeInMS / 1000) // WLAN related Macros -#define ETH_FRAME 0 -#define CMP_SUCCESS 0 -#define BSSID_MAX_STR_LEN 6 -#define MAC_ADDRESS_FIRST_OCTET 6 -#define AP_START_SUCCESS 0 -#define BITS_TO_WAIT 0 -#define CONNECTION_STATUS_SUCCESS 1 -#define IP_STATUS_FAIL 0 -#define GET_IPV6_SUCCESS 1 -#define GET_IPV6_FAIL 0 -#define BEACON_1 0 -#define CHANNEL_LIST (const uint8_t *) 0 -#define CHANNEL_COUNT 0 -#define IE_DATA (const uint8_t *) 0 -#define IE_DATA_LENGTH 0 -#define BSSID_SCAN (const uint8_t *) 0 -#define CHANNEL_0 0 -#define PREVENT_ROAMING 1 -#define DISABLE_PMF_MODE 0 -#define STA_IP_FAIL 0 -#define IP_STATUS_SUCCESS 1 -#define ACTIVE_CHANNEL_TIME_100 100 -#define PASSIVE_CHANNEL_TIME_0 0 -#define PROBE_NUM_REQ_1 1 - -#define PINOUT_CLEAR_STATUS 0 -#define TICKS_TO_WAIT_0 0 -#define TICKS_TO_WAIT_3 3 -#define TICKS_TO_WAIT_1 1 -#define TICKS_TO_WAIT_500 500 +#define ETH_FRAME (0) +#define CMP_SUCCESS (0) +#define BSSID_MAX_STR_LEN (6) +#define MAC_ADDRESS_FIRST_OCTET (6) +#define AP_START_SUCCESS (0) +#define BITS_TO_WAIT (0) +#define CONNECTION_STATUS_SUCCESS (1) +#define IP_STATUS_FAIL (0) +#define GET_IPV6_SUCCESS (1) +#define GET_IPV6_FAIL (0) +#define BEACON_1 (0) +#define CHANNEL_LIST ((const uint8_t *) 0) +#define CHANNEL_COUNT (0) +#define IE_DATA ((const uint8_t *) 0) +#define IE_DATA_LENGTH (0) +#define BSSID_SCAN ((const uint8_t *) 0) +#define CHANNEL_0 (0) +#define PREVENT_ROAMING (1) +#define DISABLE_PMF_MODE (0) +#define STA_IP_FAIL (0) +#define IP_STATUS_SUCCESS (1) +#define ACTIVE_CHANNEL_TIME_100 (100) +#define PASSIVE_CHANNEL_TIME_0 (0) +#define PROBE_NUM_REQ_1 (1) + +#define PINOUT_CLEAR_STATUS (0) +#define TICKS_TO_WAIT_0 (0) +#define TICKS_TO_WAIT_3 (3) +#define TICKS_TO_WAIT_1 (1) +#define TICKS_TO_WAIT_500 (500) // TASK and Interrupt Macros -#define SUCCESS_STATUS 1 -#define LINK_UP 1 -#define LINK_DOWN 0 -#define MAC_48_BIT_SET 1 -#define STRUCT_PBUF (struct pbuf *) 0 -#define PRIORITY_0 0 -#define HEX_VALUE_FF 0XFF +#define SUCCESS_STATUS (1) +#define LINK_UP (1) +#define LINK_DOWN (0) +#define MAC_48_BIT_SET (1) +#define STRUCT_PBUF ((struct pbuf *) 0) +#define PRIORITY_0 (0) +#define HEX_VALUE_FF (0XFF) // Timer Delay -#define MAX_XLEN 16 -#define MIN_XLEN 0 -#define PINOUT_CLEAR 0 -#define PINOUT_SET 1 -#define WFX_SPI_NVIC_PRIORITY 5 -#define WFX_GPIO_NVIC_PRIORITY 5 -#define CB_VALUE (DMADRV_Callback_t) 0 +#define MAX_XLEN (16) +#define MIN_XLEN (0) +#define PINOUT_CLEAR (0) +#define PINOUT_SET (1) +#define WFX_SPI_NVIC_PRIORITY (5) +#define WFX_GPIO_NVIC_PRIORITY (5) +#define CB_VALUE ((DMADRV_Callback_t) 0) /* TIMER_TICKS_TO_WAIT Specifies the time, in ticks, that the calling task should * be held in the Blocked state to wait for the start command to be successfully * sent to the timer command queue. */ -#define TIMER_TICKS_TO_WAIT_0 pdMS_TO_TICKS(0) - -#define CONVERT_SEC_TO_MSEC 1000 +#define CONVERT_SEC_TO_MSEC (1000) #define CONVERT_USEC_TO_MSEC (1 / 1000) -#define RSI_RESPONSE_MAX_SIZE 28 -#define RSI_RESPONSE_HOLD_BUFF_SIZE 128 -#define RSI_DRIVER_STATUS 0 -#define OPER_MODE_0 0 -#define COEX_MODE_0 0 -#define RESP_BUFF_SIZE 6 -#define AP_CHANNEL_NO_0 0 -#define SCAN_BITMAP_OPTN_1 1 -#define IP_CONF_RSP_BUFF_LENGTH_4 4 -#define STATION 0 -#define BG_SCAN_RES_SIZE 500 +#define RSI_RESPONSE_MAX_SIZE (28) +#define RSI_RESPONSE_HOLD_BUFF_SIZE (128) +#define RSI_DRIVER_STATUS (0) +#define OPER_MODE_0 (0) +#define COEX_MODE_0 (0) +#define RESP_BUFF_SIZE (6) +#define AP_CHANNEL_NO_0 (0) +#define SCAN_BITMAP_OPTN_1 (1) +#define IP_CONF_RSP_BUFF_LENGTH_4 (4) +#define STATION (0) +#define BG_SCAN_RES_SIZE (500) -#define SPI_CONFIG_SUCCESS 0 +#define SPI_CONFIG_SUCCESS (0) typedef enum { @@ -189,40 +187,21 @@ typedef struct wfx_wifi_scan_ext uint32_t overrun_count; } wfx_wifi_scan_ext_t; -#ifdef RS911X_WIFI -/* - * This Sh%t is here to support WFXUtils - and the Matter stuff that uses it - * We took it from the SDK (for WF200) - */ -typedef enum -{ - SL_WFX_NOT_INIT = 0, - SL_WFX_STARTED = 1, - SL_WFX_STA_INTERFACE_CONNECTED = 2, - SL_WFX_AP_INTERFACE_UP = 3, - SL_WFX_SLEEPING = 4, - SL_WFX_POWER_SAVE_ACTIVE = 5, -} sl_wfx_state_t; - typedef enum { SL_WFX_STA_INTERFACE = 0, ///< Interface 0, linked to the station SL_WFX_SOFTAP_INTERFACE = 1, ///< Interface 1, linked to the softap } sl_wfx_interface_t; -#endif /* RS911X_WIFI */ #ifdef __cplusplus extern "C" { #endif -void sl_wfx_host_gpio_init(void); sl_status_t wfx_wifi_start(void); void wfx_enable_sta_mode(void); -sl_wfx_state_t wfx_get_wifi_state(void); void wfx_get_wifi_mac_addr(sl_wfx_interface_t interface, sl_wfx_mac_address_t * addr); void wfx_set_wifi_provision(wfx_wifi_provision_t * wifiConfig); bool wfx_get_wifi_provision(wfx_wifi_provision_t * wifiConfig); -bool wfx_is_sta_provisioned(void); bool wfx_is_sta_mode_enabled(void); int32_t wfx_get_ap_info(wfx_wifi_scan_result_t * ap); int32_t wfx_get_ap_ext(wfx_wifi_scan_ext_t * extra_info); @@ -254,21 +233,19 @@ void wfx_lwip_set_sta_link_up(void); void wfx_lwip_set_sta_link_down(void); void wfx_lwip_start(void); struct netif * wfx_get_netif(sl_wfx_interface_t interface); -#if CHIP_DEVICE_CONFIG_ENABLE_IPV4 -void wfx_dhcp_got_ipv4(uint32_t); -#endif /* CHIP_DEVICE_CONFIG_ENABLE_IPV4 */ bool wfx_hw_ready(void); + #if CHIP_DEVICE_CONFIG_ENABLE_IPV4 +void wfx_dhcp_got_ipv4(uint32_t); void wfx_ip_changed_notify(int got_ip); #endif /* CHIP_DEVICE_CONFIG_ENABLE_IPV4 */ + void wfx_ipv6_notify(int got_ip); -#ifdef RS911X_WIFI /* RSI for LWIP */ void * wfx_rsi_alloc_pkt(void); void wfx_rsi_pkt_add_data(void * p, uint8_t * buf, uint16_t len, uint16_t off); int32_t wfx_rsi_send_data(void * p, uint16_t len); -#endif /* RS911X_WIFI */ void wfx_retry_interval_handler(bool is_wifi_disconnection_event, uint16_t retryJoin); diff --git a/src/platform/silabs/SiWx917/wifi/wfx_msgs.h b/src/platform/silabs/SiWx917/wifi/wfx_msgs.h index edf0aec5828fa7..44ff525a56a347 100644 --- a/src/platform/silabs/SiWx917/wifi/wfx_msgs.h +++ b/src/platform/silabs/SiWx917/wifi/wfx_msgs.h @@ -62,29 +62,7 @@ typedef struct __attribute__((__packed__)) sl_wfx_startup_ind_body_s uint32_t status; ///< Initialization status. A value of zero indicates the boot is completed successfully (see enum sl_wfx_status_t) uint16_t hardware_id; ///<=RO misc_read_reg7 register value -#if 0 /* Not used in RS911x for now - use stuff here for the port */ - uint8_t opn[SL_WFX_OPN_SIZE]; ///<=OTP part_OPN - uint8_t uid[SL_WFX_UID_SIZE]; ///<=OTP UID - uint16_t num_inp_ch_bufs; ///DataLength()), data->Start()); if (status != RSI_SUCCESS) { - WFX_RSI_LOG("indication %d failed with error code %lx ", status); + SILABS_LOG("indication %d failed with error code %lx ", status); return false; } @@ -727,17 +728,17 @@ void BLEManagerImpl::HandleConnectionCloseEvent(uint16_t reason) status = rsi_bt_power_save_profile(RSI_SLEEP_MODE_2, RSI_MAX_PSP); if (status != RSI_SUCCESS) { - WFX_RSI_LOG("BT Powersave Config Failed, Error Code : 0x%lX", status); + SILABS_LOG("BT Powersave Config Failed, Error Code : 0x%lX", status); return; } status = rsi_wlan_power_save_profile(RSI_SLEEP_MODE_2, RSI_MAX_PSP); if (status != RSI_SUCCESS) { - WFX_RSI_LOG("WLAN Powersave Config Failed, Error Code : 0x%lX", status); + SILABS_LOG("WLAN Powersave Config Failed, Error Code : 0x%lX", status); return; } - WFX_RSI_LOG("Powersave Config Success"); + SILABS_LOG("Powersave Config Success"); #endif if (RemoveConnection(connHandle)) @@ -776,11 +777,11 @@ void BLEManagerImpl::HandleWriteEvent(rsi_ble_event_write_t evt) ChipLogProgress(DeviceLayer, "Char Write Req, packet type %d", evt.pkt_type); // uint8_t attribute = (uint8_t) event_msg.rsi_ble_measurement_hndl; - WFX_RSI_LOG("event_msg.rsi_ble_gatt_server_client_config_hndl = %d", event_msg.rsi_ble_gatt_server_client_config_hndl); + SILABS_LOG("event_msg.rsi_ble_gatt_server_client_config_hndl = %d", event_msg.rsi_ble_gatt_server_client_config_hndl); if (evt.handle[0] == (uint8_t) event_msg.rsi_ble_gatt_server_client_config_hndl) // TODO:: compare the handle exactly { - WFX_RSI_LOG("Inside HandleTXCharCCCDWrite "); + SILABS_LOG("Inside HandleTXCharCCCDWrite "); HandleTXCharCCCDWrite(&evt); } else diff --git a/src/platform/silabs/efr32/rs911x/rsi_ble_config.h b/src/platform/silabs/efr32/rs911x/rsi_ble_config.h index e2bf5b05b36158..8fa5097d37ea53 100644 --- a/src/platform/silabs/efr32/rs911x/rsi_ble_config.h +++ b/src/platform/silabs/efr32/rs911x/rsi_ble_config.h @@ -20,6 +20,7 @@ #include "rsi_ble_apis.h" #include + /****************************************************** * * Macros * ******************************************************/ @@ -266,4 +267,4 @@ typedef struct rsi_ble_s rsi_ble_att_list_t att_rec_list[NO_OF_VAL_ATT]; } rsi_ble_t; -#endif \ No newline at end of file +#endif diff --git a/src/platform/silabs/efr32/rs911x/wfx_sl_ble_init.c b/src/platform/silabs/efr32/rs911x/wfx_sl_ble_init.c index b2323e13980a69..d93e173cef9d36 100644 --- a/src/platform/silabs/efr32/rs911x/wfx_sl_ble_init.c +++ b/src/platform/silabs/efr32/rs911x/wfx_sl_ble_init.c @@ -53,7 +53,7 @@ const uint8_t ShortUUID_CHIPoBLEService[] = { 0xF6, 0xFF }; */ void rsi_ble_app_init_events() { - WFX_RSI_LOG("%s: starting", __func__); + SILABS_LOG("%s: starting", __func__); event_msg.ble_app_event_map = 0; event_msg.ble_app_event_mask = 0xFFFFFFFF; event_msg.ble_app_event_mask = event_msg.ble_app_event_mask; // To suppress warning while compiling @@ -71,7 +71,7 @@ void rsi_ble_app_init_events() */ void rsi_ble_app_clear_event(uint32_t event_num) { - WFX_RSI_LOG("%s: starting", __func__); + SILABS_LOG("%s: starting", __func__); event_msg.event_num = event_num; event_msg.ble_app_event_map &= ~BIT(event_num); return; @@ -88,7 +88,7 @@ void rsi_ble_app_clear_event(uint32_t event_num) */ void rsi_ble_on_mtu_event(rsi_ble_event_mtu_t * rsi_ble_mtu) { - WFX_RSI_LOG("%s: starting", __func__); + SILABS_LOG("%s: starting", __func__); memcpy(&event_msg.rsi_ble_mtu, rsi_ble_mtu, sizeof(rsi_ble_event_mtu_t)); rsi_ble_app_set_event(RSI_BLE_MTU_EVENT); } @@ -105,7 +105,7 @@ void rsi_ble_on_mtu_event(rsi_ble_event_mtu_t * rsi_ble_mtu) */ void rsi_ble_on_gatt_write_event(uint16_t event_id, rsi_ble_event_write_t * rsi_ble_write) { - WFX_RSI_LOG("%s: starting", __func__); + SILABS_LOG("%s: starting", __func__); event_msg.event_id = event_id; memcpy(&event_msg.rsi_ble_write, rsi_ble_write, sizeof(rsi_ble_event_write_t)); rsi_ble_app_set_event(RSI_BLE_GATT_WRITE_EVENT); @@ -122,7 +122,7 @@ void rsi_ble_on_gatt_write_event(uint16_t event_id, rsi_ble_event_write_t * rsi_ */ void rsi_ble_on_enhance_conn_status_event(rsi_ble_event_enhance_conn_status_t * resp_enh_conn) { - WFX_RSI_LOG("%s: starting", __func__); + SILABS_LOG("%s: starting", __func__); event_msg.connectionHandle = 1; event_msg.bondingHandle = 255; memcpy(event_msg.resp_enh_conn.dev_addr, resp_enh_conn->dev_addr, RSI_DEV_ADDR_LEN); @@ -141,7 +141,7 @@ void rsi_ble_on_enhance_conn_status_event(rsi_ble_event_enhance_conn_status_t * */ void rsi_ble_on_disconnect_event(rsi_ble_event_disconnect_t * resp_disconnect, uint16_t reason) { - WFX_RSI_LOG("%s: starting", __func__); + SILABS_LOG("%s: starting", __func__); event_msg.reason = reason; rsi_ble_app_set_event(RSI_BLE_DISCONN_EVENT); } @@ -157,7 +157,7 @@ void rsi_ble_on_disconnect_event(rsi_ble_event_disconnect_t * resp_disconnect, u */ void rsi_ble_on_event_indication_confirmation(uint16_t resp_status, rsi_ble_set_att_resp_t * rsi_ble_event_set_att_rsp) { - WFX_RSI_LOG("%s: starting", __func__); + SILABS_LOG("%s: starting", __func__); event_msg.resp_status = resp_status; memcpy(&event_msg.rsi_ble_event_set_att_rsp, rsi_ble_event_set_att_rsp, sizeof(rsi_ble_set_att_resp_t)); rsi_ble_app_set_event(RSI_BLE_GATT_INDICATION_CONFIRMATION); @@ -200,7 +200,7 @@ int32_t rsi_ble_app_get_event(void) */ void rsi_ble_app_set_event(uint32_t event_num) { - WFX_RSI_LOG("%s: starting", __func__); + SILABS_LOG("%s: starting", __func__); event_msg.ble_app_event_map |= BIT(event_num); rsi_semaphore_post(&sl_ble_event_sem); return; @@ -419,4 +419,4 @@ uint32_t rsi_ble_add_matter_service(void) memset(&data, 0, sizeof(data)); return 0; -} \ No newline at end of file +} diff --git a/src/platform/silabs/efr32/wifi/dhcp_client.h b/src/platform/silabs/efr32/wifi/dhcp_client.h index 3040f7112fb954..4ee9d2f5d0d68d 100644 --- a/src/platform/silabs/efr32/wifi/dhcp_client.h +++ b/src/platform/silabs/efr32/wifi/dhcp_client.h @@ -23,12 +23,12 @@ extern "C" { #endif // DHCP client states -#define DHCP_OFF (uint8_t) 0 -#define DHCP_START (uint8_t) 1 -#define DHCP_WAIT_ADDRESS (uint8_t) 2 -#define DHCP_ADDRESS_ASSIGNED (uint8_t) 3 -#define DHCP_TIMEOUT (uint8_t) 4 -#define DHCP_LINK_DOWN (uint8_t) 5 +#define DHCP_OFF ((uint8_t) 0) +#define DHCP_START ((uint8_t) 1) +#define DHCP_WAIT_ADDRESS ((uint8_t) 2) +#define DHCP_ADDRESS_ASSIGNED ((uint8_t) 3) +#define DHCP_TIMEOUT ((uint8_t) 4) +#define DHCP_LINK_DOWN ((uint8_t) 5) /***************************************************************************** * @fn void dhcpclient_set_link_state(int link_up) diff --git a/src/platform/silabs/efr32/wifi/wifi_config.h b/src/platform/silabs/efr32/wifi/wifi_config.h index 88ad34b5741649..8e00201b7fc102 100644 --- a/src/platform/silabs/efr32/wifi/wifi_config.h +++ b/src/platform/silabs/efr32/wifi/wifi_config.h @@ -15,8 +15,8 @@ * limitations under the License. */ -#ifndef DEMO_CONFIG_H -#define DEMO_CONFIG_H +#ifndef WIFI_CONFIG_H +#define WIFI_CONFIG_H #define USE_DHCP_CLIENT_DEFAULT 1 ///< If defined, DHCP is enabled, otherwise static address below is used @@ -38,24 +38,6 @@ #define STA_GW_ADDR2_DEFAULT (uint8_t) 0 ///< Static IP: Gateway value 2 #define STA_GW_ADDR3_DEFAULT (uint8_t) 0 ///< Static IP: Gateway value 3 -/************************** Access Point Static Default ****************************/ -// #define AP_IP_ADDR0_DEFAULT (uint8_t) 10 ///< Static IP: IP address value 0 -// #define AP_IP_ADDR1_DEFAULT (uint8_t) 10 ///< Static IP: IP address value 1 -// #define AP_IP_ADDR2_DEFAULT (uint8_t) 0 ///< Static IP: IP address value 2 -// #define AP_IP_ADDR3_DEFAULT (uint8_t) 1 ///< Static IP: IP address value 3 - -/*NETMASK*/ -// #define AP_NETMASK_ADDR0_DEFAULT (uint8_t) 255 ///< Static IP: Netmask value 0 -// #define AP_NETMASK_ADDR1_DEFAULT (uint8_t) 255 ///< Static IP: Netmask value 1 -// #define AP_NETMASK_ADDR2_DEFAULT (uint8_t) 255 ///< Static IP: Netmask value 2 -// #define AP_NETMASK_ADDR3_DEFAULT (uint8_t) 0 ///< Static IP: Netmask value 3 - -/*Gateway Address*/ -// #define AP_GW_ADDR0_DEFAULT (uint8_t) 0 ///< Static IP: Gateway value 0 -// #define AP_GW_ADDR1_DEFAULT (uint8_t) 0 ///< Static IP: Gateway value 1 -// #define AP_GW_ADDR2_DEFAULT (uint8_t) 0 ///< Static IP: Gateway value 2 -// #define AP_GW_ADDR3_DEFAULT (uint8_t) 0 ///< Static IP: Gateway value 3 - #define WLAN_SSID_DEFAULT "AP_name" ///< wifi ssid for client mode #define WLAN_PASSKEY_DEFAULT "passkey" ///< wifi password for client mode #define WLAN_SECURITY_DEFAULT WFM_SECURITY_MODE_WPA2_PSK ///< wifi security mode for client mode: @@ -68,4 +50,4 @@ #define SOFTAP_CHANNEL_DEFAULT 6 ///< wifi channel for soft ap -#endif // DEMO_CONFIG_H +#endif // WIFI_CONFIG_H diff --git a/third_party/silabs/SiWx917_sdk.gni b/third_party/silabs/SiWx917_sdk.gni index 57f9b29ff87db9..e56d949feaca46 100644 --- a/third_party/silabs/SiWx917_sdk.gni +++ b/third_party/silabs/SiWx917_sdk.gni @@ -107,6 +107,7 @@ template("siwx917_sdk") { "TINYCRYPT_PRIMITIVES", "OPTIMIZE_TINYCRYPT_ASM", "__error_t_defined", + "RSI_SAMPLE_HAL", ] if (chip_build_libshell) {