From 4319ab16cb0e3cfec1d1cbaf5f93aa94cc7dffff Mon Sep 17 00:00:00 2001 From: Kamil Kasperczyk <66371704+kkasperczyk-no@users.noreply.github.com> Date: Tue, 7 May 2024 12:56:31 +0200 Subject: [PATCH] [nrfconnect] Pulled patches for the nRF Wi-Fi platform (#33196) * [nrfconnect] Adapt Matter SDK to the WiFi FW patch on external flash This commit sets the default kconfigs if the WiFi FW patch on external flash is enabled. * [nrfconnect] Wi-FI directed scan implementation This patch implements directed scanning and single ssid scanning during commissioning. Signed-off-by: Marcin Kajor * [nrfconnect] Fix build for 7001 Emulation For nRF7001DK (emulation) build fails with SPI driver errors, this fixes the build. Signed-off-by: Chaitanya Tata --------- Signed-off-by: Marcin Kajor Signed-off-by: Chaitanya Tata Co-authored-by: Arkadiusz Balys Co-authored-by: Marcin Kajor --- config/nrfconnect/chip-module/Kconfig.defaults | 14 +++++++++++++- config/nrfconnect/chip-module/Kconfig.features | 4 ++-- .../chip-module/Kconfig.mcuboot.defaults | 2 +- src/platform/nrfconnect/wifi/WiFiManager.cpp | 17 ++++++++++++++++- src/platform/nrfconnect/wifi/WiFiManager.h | 4 +++- 5 files changed, 35 insertions(+), 6 deletions(-) diff --git a/config/nrfconnect/chip-module/Kconfig.defaults b/config/nrfconnect/chip-module/Kconfig.defaults index 7e3c2a6077d5ce..218f39a3fa8f8a 100644 --- a/config/nrfconnect/chip-module/Kconfig.defaults +++ b/config/nrfconnect/chip-module/Kconfig.defaults @@ -203,15 +203,27 @@ config CHIP_QSPI_NOR default y if BOARD_NRF5340DK_NRF5340_CPUAPP || BOARD_NRF52840DK_NRF52840 # nRF7002DK uses SPI NOR external flash + +if BOARD_NRF7002DK_NRF5340_CPUAPP || BOARD_NRF7002DK_NRF7001_NRF5340_CPUAPP + config CHIP_SPI_NOR - default y if BOARD_NRF7002DK_NRF5340_CPUAPP + default y + +endif # BOARD_NRF7002DK_NRF5340_CPUAPP || BOARD_NRF7002DK_NRF7001_NRF5340_CPUAPP config BOOT_IMAGE_ACCESS_HOOKS default y if SOC_SERIES_NRF53X config UPDATEABLE_IMAGE_NUMBER + default 3 if NRF_WIFI_PATCHES_EXT_FLASH_STORE default 2 if SOC_SERIES_NRF53X +config DFU_MULTI_IMAGE_MAX_IMAGE_COUNT + default 3 if NRF_WIFI_PATCHES_EXT_FLASH_STORE + +config NRF_WIFI_FW_PATCH_DFU + default y if NRF_WIFI_PATCHES_EXT_FLASH_STORE + # ============================================================================== # OpenThread configuration # ============================================================================== diff --git a/config/nrfconnect/chip-module/Kconfig.features b/config/nrfconnect/chip-module/Kconfig.features index e6a4e52d500e13..667894c7696d85 100644 --- a/config/nrfconnect/chip-module/Kconfig.features +++ b/config/nrfconnect/chip-module/Kconfig.features @@ -21,7 +21,7 @@ if CHIP config CHIP_WIFI bool "Enable nrfconnect Wi-Fi support" - default y if SHIELD_NRF7002EK || BOARD_NRF7002DK_NRF5340_CPUAPP || SHIELD_NRF7002EB + default y if SHIELD_NRF7002EK || BOARD_NRF7002DK_NRF5340_CPUAPP || SHIELD_NRF7002EB || BOARD_NRF7002DK_NRF7001_NRF5340_CPUAPP select WIFI_NRF700X select WIFI select WPA_SUPP @@ -149,7 +149,7 @@ endif config CHIP_DFU_OVER_BT_SMP bool "Enable DFU over Bluetooth LE SMP feature set" imply CHIP_QSPI_NOR if BOARD_NRF5340DK_NRF5340_CPUAPP || BOARD_NRF52840DK_NRF52840 - imply CHIP_SPI_NOR if BOARD_NRF7002DK_NRF5340_CPUAPP + imply CHIP_SPI_NOR if BOARD_NRF7002DK_NRF5340_CPUAPP || BOARD_NRF7002DK_NRF7001_NRF5340_CPUAPP imply BOOTLOADER_MCUBOOT select MCUMGR select MCUMGR_TRANSPORT_BT diff --git a/config/nrfconnect/chip-module/Kconfig.mcuboot.defaults b/config/nrfconnect/chip-module/Kconfig.mcuboot.defaults index 224dc57bfc2769..11c7dd0320f464 100644 --- a/config/nrfconnect/chip-module/Kconfig.mcuboot.defaults +++ b/config/nrfconnect/chip-module/Kconfig.mcuboot.defaults @@ -39,7 +39,7 @@ choice LIBC_IMPLEMENTATION endchoice # nRF7002DK uses SPI NOR external flash -if BOARD_NRF7002DK_NRF5340_CPUAPP +if BOARD_NRF7002DK_NRF5340_CPUAPP || BOARD_NRF7002DK_NRF7001_NRF5340_CPUAPP config SPI default y diff --git a/src/platform/nrfconnect/wifi/WiFiManager.cpp b/src/platform/nrfconnect/wifi/WiFiManager.cpp index d5783fa060c558..11784f4475cfe0 100644 --- a/src/platform/nrfconnect/wifi/WiFiManager.cpp +++ b/src/platform/nrfconnect/wifi/WiFiManager.cpp @@ -189,7 +189,22 @@ CHIP_ERROR WiFiManager::Scan(const ByteSpan & ssid, ScanResultCallback resultCal mWiFiState = WIFI_STATE_SCANNING; mSsidFound = false; - if (0 != net_mgmt(NET_REQUEST_WIFI_SCAN, mNetIf, NULL, 0)) + wifi_scan_params * scanParams{ nullptr }; + size_t scanParamsSize{ 0 }; + + if (!ssid.empty()) + { + /* We must assume that the ssid is handled as a NULL-terminated string. + Note that the mScanSsidBuffer is initialized with zeros. */ + VerifyOrReturnError(ssid.size() < sizeof(mScanSsidBuffer), CHIP_ERROR_INVALID_ARGUMENT); + memcpy(mScanSsidBuffer, ssid.data(), ssid.size()); + mScanSsidBuffer[ssid.size()] = 0; // indicate the end of ssid string + mScanParams.ssids[0] = mScanSsidBuffer; + mScanParams.ssids[1] = nullptr; // indicate the end of ssids list + scanParams = &mScanParams; + scanParamsSize = sizeof(*scanParams); + } + if (0 != net_mgmt(NET_REQUEST_WIFI_SCAN, mNetIf, scanParams, scanParamsSize)) { ChipLogError(DeviceLayer, "Scan request failed"); return CHIP_ERROR_INTERNAL; diff --git a/src/platform/nrfconnect/wifi/WiFiManager.h b/src/platform/nrfconnect/wifi/WiFiManager.h index a4e3a8afb39256..0fa51e6fd6615e 100644 --- a/src/platform/nrfconnect/wifi/WiFiManager.h +++ b/src/platform/nrfconnect/wifi/WiFiManager.h @@ -222,7 +222,9 @@ class WiFiManager net_if * mNetIf{ nullptr }; ConnectionParams mWiFiParams{}; - ConnectionHandling mHandling; + ConnectionHandling mHandling{}; + wifi_scan_params mScanParams{}; + char mScanSsidBuffer[DeviceLayer::Internal::kMaxWiFiSSIDLength + 1] = { 0 }; wifi_iface_state mWiFiState; wifi_iface_state mCachedWiFiState; net_mgmt_event_callback mWiFiMgmtClbk{};