Skip to content

Commit

Permalink
Merge remote-tracking branch 'official/master' into bouffalolab-bl704l
Browse files Browse the repository at this point in the history
  • Loading branch information
wy-hh committed Jun 21, 2023
2 parents 6f4ffc8 + 9ce8a6c commit 9344141
Show file tree
Hide file tree
Showing 10 changed files with 271 additions and 52 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/examples-efr32.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ jobs:
path: |
.environment/gn_out/.ninja_log
.environment/pigweed-venv/*.log
- name: Test SLC gen
timeout-minutes: 30
run: |
scripts/examples/gn_silabs_example.sh examples/lighting-app/silabs ./out/light-app BRD4187C --slc_generate --docker
scripts/examples/gn_silabs_example.sh examples/lighting-app/silabs ./out/light-app BRD4164A --slc_generate --docker
rm -rf ./out/
# - name: Test SLC gen
# timeout-minutes: 30
# run: |
# scripts/examples/gn_silabs_example.sh examples/lighting-app/silabs ./out/light-app BRD4187C --slc_generate --docker
# scripts/examples/gn_silabs_example.sh examples/lighting-app/silabs ./out/light-app BRD4164A --slc_generate --docker
# rm -rf ./out/
- name: Build some BRD4187C variants
timeout-minutes: 90
run: |
Expand Down
154 changes: 154 additions & 0 deletions examples/light-switch-app/telink/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,157 @@ chip_configure_data_model(app
if(CONFIG_CHIP_OTA_REQUESTOR)
target_sources(app PRIVATE ${TELINK_COMMON}/util/src/OTAUtil.cpp)
endif()

# Fix for unused swap parameter in: zephyr/include/zephyr/arch/riscv/irq.h:70
add_compile_options(-Wno-error=unused-parameter)

if (CONFIG_CHIP_PW_RPC)

# Make all targets created below depend on zephyr_interface to inherit MCU-related compilation flags
link_libraries($<BUILD_INTERFACE:zephyr_interface>)

set(PIGWEED_ROOT "${CHIP_ROOT}/third_party/pigweed/repo")
include(${PIGWEED_ROOT}/pw_build/pigweed.cmake)
include(${PIGWEED_ROOT}/pw_protobuf_compiler/proto.cmake)

include($ENV{PW_ROOT}/pw_assert/backend.cmake)
include($ENV{PW_ROOT}/pw_log/backend.cmake)
include($ENV{PW_ROOT}/pw_sys_io/backend.cmake)

pw_set_module_config(pw_rpc_CONFIG pw_rpc.disable_global_mutex_config)
pw_set_backend(pw_log pw_log_basic)
pw_set_backend(pw_assert.check pw_assert_log.check_backend)
pw_set_backend(pw_assert.assert pw_assert.assert_compatibility_backend)
pw_set_backend(pw_sys_io pw_sys_io.telink)

set(dir_pw_third_party_nanopb "${CHIP_ROOT}/third_party/nanopb/repo" CACHE STRING "" FORCE)

add_subdirectory(third_party/connectedhomeip/third_party/pigweed/repo)
add_subdirectory(third_party/connectedhomeip/third_party/nanopb/repo)
add_subdirectory(third_party/connectedhomeip/examples/platform/telink/pw_sys_io)

pw_proto_library(attributes_service
SOURCES
${CHIP_ROOT}/examples/common/pigweed/protos/attributes_service.proto
INPUTS
${CHIP_ROOT}/examples/common/pigweed/protos/attributes_service.options
PREFIX
attributes_service
STRIP_PREFIX
${CHIP_ROOT}/examples/common/pigweed/protos
DEPS
pw_protobuf.common_proto
)

pw_proto_library(button_service
SOURCES
${CHIP_ROOT}/examples/common/pigweed/protos/button_service.proto
PREFIX
button_service
STRIP_PREFIX
${CHIP_ROOT}/examples/common/pigweed/protos
DEPS
pw_protobuf.common_proto
)

pw_proto_library(descriptor_service
SOURCES
${CHIP_ROOT}/examples/common/pigweed/protos/descriptor_service.proto
PREFIX
descriptor_service
STRIP_PREFIX
${CHIP_ROOT}/examples/common/pigweed/protos
DEPS
pw_protobuf.common_proto
)

pw_proto_library(device_service
SOURCES
${CHIP_ROOT}/examples/common/pigweed/protos/device_service.proto
INPUTS
${CHIP_ROOT}/examples/common/pigweed/protos/device_service.options
PREFIX
device_service
STRIP_PREFIX
${CHIP_ROOT}/examples/common/pigweed/protos
DEPS
pw_protobuf.common_proto
)

pw_proto_library(lighting_service
SOURCES
${CHIP_ROOT}/examples/common/pigweed/protos/lighting_service.proto
STRIP_PREFIX
${CHIP_ROOT}/examples/common/pigweed/protos
PREFIX
lighting_service
DEPS
pw_protobuf.common_proto
)

pw_proto_library(ot_cli_service
SOURCES
${CHIP_ROOT}/examples/common/pigweed/protos/ot_cli_service.proto
INPUTS
${CHIP_ROOT}/examples/common/pigweed/protos/ot_cli_service.options
STRIP_PREFIX
${CHIP_ROOT}/examples/common/pigweed/protos
PREFIX
ot_cli_service
DEPS
pw_protobuf.common_proto
)

pw_proto_library(thread_service
SOURCES
${CHIP_ROOT}/examples/common/pigweed/protos/thread_service.proto
INPUTS
${CHIP_ROOT}/examples/common/pigweed/protos/thread_service.options
STRIP_PREFIX
${CHIP_ROOT}/examples/common/pigweed/protos
PREFIX
thread_service
DEPS
pw_protobuf.common_proto
)

target_sources(app PRIVATE
../../common/pigweed/RpcService.cpp
../../common/pigweed/telink/PigweedLoggerMutex.cpp
${TELINK_COMMON}/Rpc.cpp
${TELINK_COMMON}/util/src/PigweedLogger.cpp
)

target_include_directories(app PRIVATE
${PIGWEED_ROOT}/pw_sys_io/public
${CHIP_ROOT}/src/lib/support
${CHIP_ROOT}/src/system
${TELINK_COMMON}
../../common
../../common/pigweed
../../common/pigweed/telink)

target_compile_options(app PRIVATE
"-DPW_RPC_ATTRIBUTE_SERVICE=1"
"-DPW_RPC_BUTTON_SERVICE=1"
"-DPW_RPC_DESCRIPTOR_SERVICE=1"
"-DPW_RPC_DEVICE_SERVICE=1"
"-DPW_RPC_LIGHTING_SERVICE=1"
"-DPW_RPC_THREAD_SERVICE=1")

target_link_libraries(app PRIVATE
attributes_service.nanopb_rpc
button_service.nanopb_rpc
descriptor_service.nanopb_rpc
device_service.nanopb_rpc
lighting_service.nanopb_rpc
thread_service.nanopb_rpc
pw_checksum
pw_hdlc
pw_hdlc.pw_rpc
pw_log
pw_rpc.server
pw_sys_io
)

endif(CONFIG_CHIP_PW_RPC)
47 changes: 47 additions & 0 deletions examples/light-switch-app/telink/rpc.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#
# Copyright (c) 2023 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.
#

# This file should be used as a configuration overlay to build Pigweed RPCs to
# light-switch-app.

# Enable Pigweed RPC
CONFIG_CHIP_PW_RPC=y

# Add support for C++17 to build Pigweed components
CONFIG_STD_CPP14=n
CONFIG_STD_CPP17=y

# Add support for Zephyr console component to use it for Pigweed console purposes
CONFIG_CONSOLE_SUBSYS=y
CONFIG_CONSOLE_GETCHAR=y
CONFIG_CONSOLE_PUTCHAR_BUFSIZE=256

# Disable features which may interfere with Pigweed HDLC transport
CONFIG_SHELL=n
CONFIG_OPENTHREAD_SHELL=n
CONFIG_BOOT_BANNER=n

# Configure Zephyr logger with defaults backends disabled as the app provides its own,
# based on Pigweed HDLC.
CONFIG_LOG=y
CONFIG_LOG_MODE_MINIMAL=n
CONFIG_LOG_MODE_IMMEDIATE=y
CONFIG_LOG_BACKEND_UART=n
CONFIG_LOG_BACKEND_RTT=n
CONFIG_LOG_OUTPUT=y

# Increase zephyr tty rx buffer
CONFIG_CONSOLE_GETCHAR_BUFSIZE=128
18 changes: 0 additions & 18 deletions examples/lighting-app/telink/include/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,14 @@

#include "AppTaskCommon.h"

#ifdef CONFIG_CHIP_PW_RPC
#include "Rpc.h"
#endif

class AppTask : public AppTaskCommon
{
public:
void SetInitiateAction(PWMDevice::Action_t aAction, int32_t aActor, uint8_t * value);
void UpdateClusterState(void);
PWMDevice & GetPWMDevice(void) { return mPwmRgbBlueLed; }

#ifdef CONFIG_CHIP_PW_RPC
enum ButtonId_t
{
kButtonId_LightingAction = 1,
kButtonId_FactoryReset,
kButtonId_StartThread,
kButtonId_StartBleAdv
} ButtonId;
#endif

private:
#ifdef CONFIG_CHIP_PW_RPC
friend class chip::rpc::TelinkButton;
static void ButtonEventHandler(ButtonId_t btnId, bool btnPressed);
#endif
friend AppTask & GetAppTask(void);
friend class AppTaskCommon;

Expand Down
26 changes: 0 additions & 26 deletions examples/lighting-app/telink/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,32 +127,6 @@ void AppTask::LightingActionEventHandler(AppEvent * aEvent)
}
}

#ifdef CONFIG_CHIP_PW_RPC
void AppTask::ButtonEventHandler(ButtonId_t btnId, bool btnPressed)
{
if (!btnPressed)
{
return;
}

switch (btnId)
{
case kButtonId_LightingAction:
ExampleActionButtonEventHandler();
break;
case kButtonId_FactoryReset:
FactoryResetButtonEventHandler();
break;
case kButtonId_StartThread:
StartThreadButtonEventHandler();
break;
case kButtonId_StartBleAdv:
StartBleAdvButtonEventHandler();
break;
}
}
#endif

void AppTask::ActionInitiated(PWMDevice::Action_t aAction, int32_t aActor)
{
if (aAction == PWMDevice::ON_ACTION)
Expand Down
19 changes: 19 additions & 0 deletions examples/platform/telink/common/include/AppTaskCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
#include <platform/telink/FactoryDataProvider.h>
#endif

#ifdef CONFIG_CHIP_PW_RPC
#include "Rpc.h"
#endif

#include <credentials/examples/DeviceAttestationCredsExample.h>

#include <cstdint>
Expand All @@ -64,6 +68,16 @@ class AppTaskCommon

static void IdentifyEffectHandler(Clusters::Identify::EffectIdentifierEnum aEffect);

#ifdef CONFIG_CHIP_PW_RPC
enum ButtonId_t
{
kButtonId_ExampleAction = 1,
kButtonId_FactoryReset,
kButtonId_StartThread,
kButtonId_StartBleAdv
} ButtonId;
#endif

protected:
CHIP_ERROR InitCommonParts(void);

Expand Down Expand Up @@ -110,4 +124,9 @@ class AppTaskCommon
#if CONFIG_CHIP_FACTORY_DATA
chip::DeviceLayer::FactoryDataProvider<chip::DeviceLayer::ExternalFlashFactoryData> mFactoryDataProvider;
#endif

#ifdef CONFIG_CHIP_PW_RPC
friend class chip::rpc::TelinkButton;
static void ButtonEventHandler(ButtonId_t btnId, bool btnPressed);
#endif
};
26 changes: 26 additions & 0 deletions examples/platform/telink/common/src/AppTaskCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,32 @@ CHIP_ERROR AppTaskCommon::InitCommonParts(void)
return CHIP_NO_ERROR;
}

#ifdef CONFIG_CHIP_PW_RPC
void AppTaskCommon::ButtonEventHandler(ButtonId_t btnId, bool btnPressed)
{
if (!btnPressed)
{
return;
}

switch (btnId)
{
case kButtonId_ExampleAction:
ExampleActionButtonEventHandler();
break;
case kButtonId_FactoryReset:
FactoryResetButtonEventHandler();
break;
case kButtonId_StartThread:
StartThreadButtonEventHandler();
break;
case kButtonId_StartBleAdv:
StartBleAdvButtonEventHandler();
break;
}
}
#endif

void AppTaskCommon::InitButtons(void)
{
#if CONFIG_CHIP_BUTTON_MANAGER_IRQ_MODE
Expand Down
5 changes: 3 additions & 2 deletions integrations/docker/images/chip-build-efr32/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ RUN wget https://www.silabs.com/documents/login/software/slc_cli_linux.zip && \

ENV PATH="${PATH}:/slc_cli/"

RUN slc configuration --sdk="$GSDK_ROOT" && \
slc signature trust --sdk "$GSDK_ROOT"
# TODO Fix me
# RUN slc configuration --sdk="$GSDK_ROOT" && \
# slc signature trust --sdk "$GSDK_ROOT"


RUN pip3 install lark jinja2 stringcase
12 changes: 12 additions & 0 deletions src/platform/ESP32/ConfigurationManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <platform/internal/GenericConfigurationManagerImpl.ipp>

#include "esp_ota_ops.h"
#include "esp_phy_init.h"
#include "esp_wifi.h"
#include "nvs.h"
#include "nvs_flash.h"
Expand Down Expand Up @@ -236,6 +237,17 @@ CHIP_ERROR ConfigurationManagerImpl::GetLocationCapability(uint8_t & location)
#endif
}

CHIP_ERROR ConfigurationManagerImpl::StoreCountryCode(const char * code, size_t codeLen)
{
// As per spec, codeLen has to be 2
VerifyOrReturnError((code != nullptr) && (codeLen == 2), CHIP_ERROR_INVALID_ARGUMENT);
// Write CountryCode to esp_phy layer
ReturnErrorOnFailure(MapConfigError(esp_phy_update_country_info(code)));
// As we do not have API to read country code from esp_phy layer, we are writing to NVS and when client reads the
// CountryCode then we read from NVS
return GenericConfigurationManagerImpl<ESP32Config>::StoreCountryCode(code, codeLen);
}

CHIP_ERROR ConfigurationManagerImpl::GetPrimaryWiFiMACAddress(uint8_t * buf)
{
#if CHIP_DEVICE_CONFIG_ENABLE_WIFI
Expand Down
Loading

0 comments on commit 9344141

Please sign in to comment.