Skip to content

Commit

Permalink
[nrf noup] Initial Matter over WiFi implementation.
Browse files Browse the repository at this point in the history
Some WiFi related features might not work as expected yet.
This will be fixed when the Zephyr NRF WiFi module is improved.

Signed-off-by: Marcin Kajor <[email protected]>
  • Loading branch information
markaj-nordic authored and Damian-Nordic committed Aug 12, 2022
1 parent 632800f commit a585abf
Show file tree
Hide file tree
Showing 64 changed files with 1,855 additions and 132 deletions.
7 changes: 6 additions & 1 deletion config/nrfconnect/chip-module/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ chip_gn_arg_bool ("chip_progress_logging" CONFIG_MATTER_LOG_LE
chip_gn_arg_bool ("chip_detail_logging" CONFIG_MATTER_LOG_LEVEL GREATER_EQUAL 4)
chip_gn_arg_bool ("chip_automation_logging" "false")
chip_gn_arg_bool ("chip_malloc_sys_heap" CONFIG_CHIP_MALLOC_SYS_HEAP)
chip_gn_arg_bool ("chip_enable_wifi" CONFIG_WIFI_NRF700X)

if (CONFIG_CHIP_FACTORY_DATA)
chip_gn_arg_bool ("chip_use_transitional_commissionable_data_provider" "false")
Expand All @@ -232,8 +233,12 @@ if (CONFIG_CHIP_ROTATING_DEVICE_ID)
chip_gn_arg_bool("chip_enable_additional_data_advertising" "true")
endif()

if (CONFIG_CHIP_ENABLE_DNSSD_SRP)
if (CONFIG_NET_L2_OPENTHREAD)
chip_gn_arg_string("chip_mdns" "platform")
elseif(CONFIG_WIFI_NRF700X)
chip_gn_arg_string("chip_mdns" "minimal")
else()
chip_gn_arg_string("chip_mdns" "none")
endif()

if (CHIP_PROJECT_CONFIG)
Expand Down
96 changes: 90 additions & 6 deletions config/nrfconnect/chip-module/Kconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,22 @@ config LOG_DEFAULT_LEVEL

endif

config FLASH
bool
default y

config SETTINGS
bool
default y

config NVS
bool
default y

config FLASH_MAP
bool
default y

config PRINTK_SYNC
bool
default y
Expand Down Expand Up @@ -198,20 +214,88 @@ config NVS_LOOKUP_CACHE
bool
default y

# Enable OpenThread

config NET_L2_OPENTHREAD
bool
default y if !WIFI_NRF700X

if NET_L2_OPENTHREAD

config OPENTHREAD_PANID
int
default 4660

config OPENTHREAD_CHANNEL
int
default 15

config OPENTHREAD_NETWORK_NAME
string
default "OpenThread"

config OPENTHREAD_XPANID
string
default "11:11:11:11:22:22:22:22"

# Increase the default RX stack size
config IEEE802154_NRF5_RX_STACK_SIZE
int
default 1024

# Enable OpenThread
endif

config NET_L2_OPENTHREAD
if CHIP_WIFI

config MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG
bool
default y
default n

config SYSTEM_WORKQUEUE_STACK_SIZE
int
default 1120

# align these numbers to match the OpenThread config
config NET_IF_UNICAST_IPV6_ADDR_COUNT
int
default 6

config NET_IF_MCAST_IPV6_ADDR_COUNT
int
default 8

config NET_SOCKETS_POSIX_NAMES
bool
default n

config MBEDTLS_SSL_OUT_CONTENT_LEN
int
default 900

config CHIP_ENABLE_DNSSD_SRP
bool
default n

# options managed by IP4/IP6 simultaneous support
# aligned here to match OpenThread config
config NET_MAX_ROUTERS
int
default 1

config NET_MAX_CONN
int
default 4

config SHELL_STACK_SIZE
int
default 2616

config HEAP_MEM_POOL_SIZE
int
default 200000

endif

choice OPENTHREAD_STACK_VERSION
default OPENTHREAD_THREAD_VERSION_1_3
endchoice

# Enable mbedTLS from nrf_security library

Expand Down
21 changes: 21 additions & 0 deletions config/nrfconnect/chip-module/Kconfig.features
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,27 @@

if CHIP

config CHIP_WIFI
bool "Enable nrfconnect Wi-Fi support"
default y if SHIELD_NRF7002_EK || BOARD_NRF7002DK_NRF5340_CPUAPP
select WIFI_NRF700X
select WIFI
select WPA_SUPP
imply NORDIC_SECURITY_BACKEND
imply MBEDTLS_ENTROPY_C
imply MBEDTLS_PSA_CRYPTO_C
imply NET_STATISTICS
imply NET_L2_ETHERNET
imply NET_PKT_TXTIME
imply NET_PKT_TIMESTAMP
imply MBEDTLS_PROMPTLESS
imply BUILD_OUTPUT_META
imply USE_DT_CODE_PARTITION # might be removed when the OTA is enabled
imply NET_IPV6_ND # enable Neighbor Discovery to handle Router Advertisements
imply NET_IPV6_NBR_CACHE
imply NET_STATISTICS_IPV6
imply NET_STATISTICS_USER_API

config CHIP_QSPI_NOR
bool "Enable QSPI NOR feature set"
help
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@
&adc {
status = "disabled";
};
&gpio1 {
status = "disabled";
};
&i2c1 {
status = "disabled";
};
Expand Down
2 changes: 2 additions & 0 deletions examples/all-clusters-app/nrfconnect/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ CHIP_ERROR AppTask::Init()
return err;
}

#if defined(CONFIG_NET_L2_OPENTHREAD)
err = ThreadStackMgr().InitThreadStack();
if (err != CHIP_NO_ERROR)
{
Expand All @@ -159,6 +160,7 @@ CHIP_ERROR AppTask::Init()
LOG_ERR("ConnectivityMgr().SetThreadDeviceType() failed");
return err;
}
#endif

// Initialize LEDs
LEDWidget::InitGpio();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@
&adc {
status = "disabled";
};
&gpio1 {
status = "disabled";
};
&i2c1 {
status = "disabled";
};
Expand Down
2 changes: 1 addition & 1 deletion examples/chef/nrfconnect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ target_sources(app PRIVATE
${CHEF}/common/stubs.cpp
${GEN_DIR}/callback-stub.cpp
${GEN_DIR}/IMClusterCommandHandler.cpp
${NRFCONNECT_COMMON}/util/ThreadUtil.cpp
$<$<BOOL:${CONFIG_NET_L2_OPENTHREAD}>:${NRFCONNECT_COMMON}/util/ThreadUtil.cpp>
)

message(STATUS ${CHEF}/devices/${SAMPLE_NAME}.zap)
Expand Down
7 changes: 5 additions & 2 deletions examples/chef/nrfconnect/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ CHIP_ERROR main()
#if CHIP_DEVICE_CONFIG_ENABLE_WPA
ConnectivityManagerImpl().StartWiFiManagement();
#endif
#if CHIP_ENABLE_OPENTHREAD

#if defined(CHIP_ENABLE_OPENTHREAD)
err = ThreadStackMgr().InitThreadStack();
if (err != CHIP_NO_ERROR)
{
Expand All @@ -97,7 +98,9 @@ CHIP_ERROR main()
ChipLogError(AppServer, "ConnectivityMgr().SetThreadDeviceType() failed");
return err;
}
#endif /* CHIP_ENABLE_OPENTHREAD */
#elif !defined(CONFIG_WIFI_NRF700X)
return CHIP_ERROR_INTERNAL;
#endif

// Device Attestation & Onboarding codes
chip::Credentials::SetDeviceAttestationCredentialsProvider(chip::Credentials::Examples::GetExampleDACProvider());
Expand Down
6 changes: 0 additions & 6 deletions examples/chef/nrfconnect/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ CONFIG_PWM=y
# OpenThread configs
CONFIG_OPENTHREAD_NORDIC_LIBRARY_FTD=y

# Default OpenThread network settings
CONFIG_OPENTHREAD_PANID=4660
CONFIG_OPENTHREAD_CHANNEL=15
CONFIG_OPENTHREAD_NETWORK_NAME="OpenThread"
CONFIG_OPENTHREAD_XPANID="11:11:11:11:22:22:22:22"

# Bluetooth overrides
CONFIG_BT_DEVICE_NAME="MatterLight"

Expand Down
2 changes: 1 addition & 1 deletion examples/light-switch-app/nrfconnect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ target_sources(app PRIVATE
${GEN_DIR}/light-switch-app/zap-generated/callback-stub.cpp
${GEN_DIR}/light-switch-app/zap-generated/IMClusterCommandHandler.cpp
${NRFCONNECT_COMMON}/util/LEDWidget.cpp
${NRFCONNECT_COMMON}/util/ThreadUtil.cpp)
$<$<BOOL:${CONFIG_NET_L2_OPENTHREAD}>:${NRFCONNECT_COMMON}/util/ThreadUtil.cpp>)


if(CONFIG_CHIP_OTA_REQUESTOR)
Expand Down
6 changes: 6 additions & 0 deletions examples/light-switch-app/nrfconnect/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
#include "AppConfig.h"
#include "LEDWidget.h"
#include "LightSwitch.h"
#ifdef CONFIG_NET_L2_OPENTHREAD
#include "ThreadUtil.h"
#endif

#include <DeviceInfoProviderImpl.h>
#include <app/clusters/identify-server/identify-server.h>
Expand Down Expand Up @@ -114,6 +116,7 @@ CHIP_ERROR AppTask::Init()
return err;
}

#if defined(CONFIG_NET_L2_OPENTHREAD)
err = ThreadStackMgr().InitThreadStack();
if (err != CHIP_NO_ERROR)
{
Expand All @@ -131,6 +134,9 @@ CHIP_ERROR AppTask::Init()
LOG_ERR("ConnectivityMgr().SetThreadDeviceType() failed: %s", ErrorStr(err));
return err;
}
#elif !defined(CONFIG_WIFI_NRF700X)
return CHIP_ERROR_INTERNAL;
#endif

LightSwitch::GetInstance().Init(kLightDimmerSwitchEndpointId, kLightGenericSwitchEndpointId);

Expand Down
2 changes: 1 addition & 1 deletion examples/lighting-app/nrfconnect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ target_sources(app PRIVATE
${GEN_DIR}/lighting-app/zap-generated/IMClusterCommandHandler.cpp
${NRFCONNECT_COMMON}/util/LEDWidget.cpp
${NRFCONNECT_COMMON}/util/PWMDevice.cpp
${NRFCONNECT_COMMON}/util/ThreadUtil.cpp)
$<$<BOOL:${CONFIG_NET_L2_OPENTHREAD}>:${NRFCONNECT_COMMON}/util/ThreadUtil.cpp>)

chip_configure_data_model(app
INCLUDE_SERVER
Expand Down
10 changes: 10 additions & 0 deletions examples/lighting-app/nrfconnect/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
#include "AppEvent.h"
#include "LEDWidget.h"
#include "PWMDevice.h"
#ifdef CONFIG_NET_L2_OPENTHREAD
#include "ThreadUtil.h"
#endif

#include <DeviceInfoProviderImpl.h>
#include <app-common/zap-generated/attribute-id.h>
Expand Down Expand Up @@ -113,6 +115,7 @@ CHIP_ERROR AppTask::Init()
return err;
}

#if defined(CONFIG_NET_L2_OPENTHREAD)
err = ThreadStackMgr().InitThreadStack();
if (err != CHIP_NO_ERROR)
{
Expand All @@ -127,6 +130,9 @@ CHIP_ERROR AppTask::Init()
LOG_ERR("ConnectivityMgr().SetThreadDeviceType() failed");
return err;
}
#elif !defined(CONFIG_WIFI_NRF700X)
return CHIP_ERROR_INTERNAL;
#endif

// Initialize LEDs
LEDWidget::InitGpio();
Expand Down Expand Up @@ -270,13 +276,15 @@ void AppTask::ButtonEventHandler(uint32_t button_state, uint32_t has_changed)
sAppTask.PostEvent(&button_event);
}

#ifdef CONFIG_NET_L2_OPENTHREAD
if (THREAD_START_BUTTON_MASK & button_state & has_changed)
{
button_event.ButtonEvent.PinNo = THREAD_START_BUTTON;
button_event.ButtonEvent.Action = kButtonPushEvent;
button_event.Handler = StartThreadHandler;
sAppTask.PostEvent(&button_event);
}
#endif

if (BLE_ADVERTISEMENT_START_BUTTON_MASK & button_state & has_changed)
{
Expand Down Expand Up @@ -399,6 +407,7 @@ void AppTask::FunctionHandler(AppEvent * aEvent)
}
}

#ifdef CONFIG_NET_L2_OPENTHREAD
void AppTask::StartThreadHandler(AppEvent * aEvent)
{
if (aEvent->ButtonEvent.PinNo != THREAD_START_BUTTON)
Expand All @@ -414,6 +423,7 @@ void AppTask::StartThreadHandler(AppEvent * aEvent)
LOG_INF("Device is commissioned to a Thread network.");
}
}
#endif

void AppTask::StartBLEAdvertisementHandler(AppEvent *)
{
Expand Down
2 changes: 2 additions & 0 deletions examples/lighting-app/nrfconnect/main/include/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ class AppTask
static void UpdateLedStateEventHandler(AppEvent * aEvent);
static void FunctionTimerEventHandler(AppEvent * aEvent);
static void FunctionHandler(AppEvent * aEvent);
#ifdef CONFIG_NET_L2_OPENTHREAD
static void StartThreadHandler(AppEvent * aEvent);
#endif
static void LightingActionEventHandler(AppEvent * aEvent);
static void StartBLEAdvertisementHandler(AppEvent * aEvent);

Expand Down
6 changes: 0 additions & 6 deletions examples/lighting-app/nrfconnect/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ CONFIG_PWM=y
# OpenThread configs
CONFIG_OPENTHREAD_NORDIC_LIBRARY_FTD=y

# Default OpenThread network settings
CONFIG_OPENTHREAD_PANID=4660
CONFIG_OPENTHREAD_CHANNEL=15
CONFIG_OPENTHREAD_NETWORK_NAME="OpenThread"
CONFIG_OPENTHREAD_XPANID="11:11:11:11:22:22:22:22"

# Bluetooth overrides
CONFIG_BT_DEVICE_NAME="MatterLight"

Expand Down
6 changes: 0 additions & 6 deletions examples/lighting-app/nrfconnect/prj_no_dfu.conf
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ CONFIG_PWM=y
# OpenThread configs
CONFIG_OPENTHREAD_NORDIC_LIBRARY_FTD=y

# Default OpenThread network settings
CONFIG_OPENTHREAD_PANID=4660
CONFIG_OPENTHREAD_CHANNEL=15
CONFIG_OPENTHREAD_NETWORK_NAME="OpenThread"
CONFIG_OPENTHREAD_XPANID="11:11:11:11:22:22:22:22"

# Bluetooth overrides
CONFIG_BT_DEVICE_NAME="MatterLight"

Expand Down
Loading

0 comments on commit a585abf

Please sign in to comment.