Skip to content

Commit

Permalink
Merge branch 'master' into esp32/test-event-trigger-enable-key
Browse files Browse the repository at this point in the history
  • Loading branch information
wqx6 authored Sep 27, 2022
2 parents 5f7be02 + f2cd15f commit c6b795b
Show file tree
Hide file tree
Showing 105 changed files with 2,055 additions and 928 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/examples-bouffalolab.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,17 @@ jobs:
timeout-minutes: 30
run: |
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py --target bouffalolab-BL706-IoT-DVK-BL706C-22-light build"
"./scripts/build/build_examples.py --target bouffalolab-BL706-IoT-DVK-light build"
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py bl702 bl702 lighting-app \
out/bouffalolab-BL706-IoT-DVK-BL706C-22-light/chip-bl702-lighting-example.out /tmp/bloat_reports/
out/bouffalolab-BL706-IoT-DVK-light/chip-bl702-lighting-example.out /tmp/bloat_reports/
- name: Build example BL702 Lighting App with RPCs
timeout-minutes: 30
run: |
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py --target bouffalolab-BL706-IoT-DVK-BL706C-22-light-rpc build"
"./scripts/build/build_examples.py --target bouffalolab-BL706-IoT-DVK-light-rpc build"
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py bl702 bl702+rpc lighting-app \
out/bouffalolab-BL706-IoT-DVK-BL706C-22-light-rpc/chip-bl702-lighting-example.out /tmp/bloat_reports/
out/bouffalolab-BL706-IoT-DVK-light-rpc/chip-bl702-lighting-example.out /tmp/bloat_reports/
- name: Uploading Size Reports
uses: actions/upload-artifact@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/examples-efr32.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ concurrency:
jobs:
efr32:
name: EFR32
timeout-minutes: 110
timeout-minutes: 110

env:
EFR32_BOARD: BRD4161A
SILABS_BOARD: BRD4161A
BUILD_TYPE: gn_efr32

runs-on: ubuntu-latest
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release_artifacts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
efr32:
name: EFR32
env:
EFR32_BOARD: BRD4161A
SILABS_BOARD: BRD4161A
BUILD_DIRECTORY: out/lock_app_debug/BRD4161A

runs-on: ubuntu-latest
Expand Down Expand Up @@ -100,7 +100,7 @@ jobs:
.environment/pigweed-venv/*.log
- name: Build example EFR32 Lock App
run: scripts/examples/gn_efr32_example.sh examples/lock-app/efr32/
out/lock_app_debug $EFR32_BOARD
out/lock_app_debug $SILABS_BOARD

- name: Upload artifact
run: |
Expand All @@ -110,4 +110,4 @@ jobs:
--release-tag "${{ github.event.inputs.releaseTag }}" \
--bundle-files $BUILD_DIRECTORY/lock_app.flashbundle.txt \
--working-directory $BUILD_DIRECTORY \
--bundle-name efr32-$EFR32_BOARD-chip-lock-example
--bundle-name efr32-$SILABS_BOARD-chip-lock-example
12 changes: 6 additions & 6 deletions examples/chef/chef.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def load_config() -> None:
config["silabs-thread"]["GECKO_SDK"] = f"{_REPO_BASE_PATH}third_party/efr32_sdk/repo"
config["silabs-thread"]["TTY"] = None
config["silabs-thread"]["CU"] = None
config["silabs-thread"]["EFR32_BOARD"] = None
config["silabs-thread"]["SILABS_BOARD"] = None
config["ameba"]["AMEBA_SDK"] = None
config["ameba"]["MATTER_SDK"] = None
config["ameba"]["MODEL"] = 'D'
Expand Down Expand Up @@ -493,11 +493,11 @@ def main() -> int:
pass
elif options.build_target == "silabs-thread":
flush_print('Path to gecko sdk is configured within Matter.')
if 'EFR32_BOARD' not in config['silabs-thread'] or config['silabs-thread']['EFR32_BOARD'] is None:
if 'SILABS_BOARD' not in config['silabs-thread'] or config['silabs-thread']['SILABS_BOARD'] is None:
flush_print(
'EFR32_BOARD was not configured. Make sure silabs-thread.EFR32_BOARD is set on your config.yaml file')
'SILABS_BOARD was not configured. Make sure silabs-thread.SILABS_BOARD is set on your config.yaml file')
exit(1)
efr32_board = config['silabs-thread']['EFR32_BOARD']
silabs_board = config['silabs-thread']['SILABS_BOARD']
elif options.build_target == "ameba":
if config['ameba']['AMEBA_SDK'] is None:
flush_print(
Expand Down Expand Up @@ -669,7 +669,7 @@ def main() -> int:
f'{_REPO_BASE_PATH}/scripts/examples/gn_efr32_example.sh')
efr32_cmd_args.append('./')
efr32_cmd_args.append(f'out/{options.sample_device_type_name}')
efr32_cmd_args.append(f'{efr32_board}')
efr32_cmd_args.append(f'{silabs_board}')
efr32_cmd_args.append(
f'\'sample_name=\"{options.sample_device_type_name}\"\'')
if sw_ver_string:
Expand Down Expand Up @@ -808,7 +808,7 @@ def main() -> int:
elif (options.build_target == "silabs-thread") or (options.build_target == "silabs-wifi"):
shell.run_cmd(f"cd {_CHEF_SCRIPT_PATH}/efr32")
shell.run_cmd(
f"python3 out/{options.sample_device_type_name}/{efr32_board}/chip-efr32-chef-example.flash.py")
f"python3 out/{options.sample_device_type_name}/{silabs_board}/chip-efr32-chef-example.flash.py")

shell.run_cmd(f"cd {_CHEF_SCRIPT_PATH}")
elif (options.build_target == "ameba"):
Expand Down
15 changes: 9 additions & 6 deletions examples/chef/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ chip_data_model("chef-common") {
is_server = true
}

# ThunderBoards and Explorer Kit (No LCD)
if (efr32_board == "BRD4166A" || efr32_board == "BRD2601B" ||
efr32_board == "BRD2703A") {
# ThunderBoards, Explorer Kit and MGM240L do not support LCD (No LCD)
if (silabs_board == "BRD4166A" || silabs_board == "BRD2601B" ||
silabs_board == "BRD2703A" || silabs_board == "BRD4319A") {
show_qr_code = false
disable_lcd = true
}
Expand Down Expand Up @@ -135,7 +135,7 @@ efr32_sdk("sdk") {
]

defines = [
"BOARD_ID=${efr32_board}",
"BOARD_ID=${silabs_board}",
"CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}",
"CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR=${setupDiscriminator}",
"OTA_PERIODIC_TIMEOUT=${OTA_periodic_query_timeout}",
Expand Down Expand Up @@ -182,7 +182,6 @@ efr32_executable("chef_app") {

sources = [
"${examples_plat_dir}/BaseApplication.cpp",
"${examples_plat_dir}/LEDWidget.cpp",
"${examples_plat_dir}/efr32_utils.cpp",
"${examples_plat_dir}/heap_4_silabs.c",
"${examples_plat_dir}/init_efrPlatform.cpp",
Expand All @@ -193,6 +192,10 @@ efr32_executable("chef_app") {
"src/main.cpp",
]

if (use_wstk_leds) {
sources += [ "${examples_plat_dir}/LEDWidget.cpp" ]
}

if (chip_enable_pw_rpc || chip_build_libshell || enable_openthread_cli ||
use_wf200 || use_rs911x) {
sources += [ "${examples_plat_dir}/uart.cpp" ]
Expand Down Expand Up @@ -312,7 +315,7 @@ efr32_executable("chef_app") {
defines += [ "HEAP_MONITORING" ]
}

ldscript = "${examples_plat_dir}/ldscripts/${efr32_family}.ld"
ldscript = "${examples_plat_dir}/ldscripts/${silabs_family}.ld"

inputs = [ ldscript ]

Expand Down
6 changes: 6 additions & 0 deletions examples/chef/efr32/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@
#include "AppTask.h"
#include "AppConfig.h"
#include "AppEvent.h"

#ifdef ENABLE_WSTK_LEDS
#include "LEDWidget.h"
#include "sl_simple_led_instances.h"
#endif // ENABLE_WSTK_LEDS

#ifdef DISPLAY_ENABLED
#include "lcd.h"
Expand Down Expand Up @@ -52,7 +55,10 @@

#include <platform/CHIPDeviceLayer.h>

#ifdef ENABLE_WSTK_LEDS
#define SYSTEM_STATE_LED &sl_led_led0
#endif // ENABLE_WSTK_LEDS

#define APP_FUNCTION_BUTTON &sl_button_btn0

using namespace chip;
Expand Down
15 changes: 9 additions & 6 deletions examples/light-switch-app/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ if (chip_enable_wifi) {
enable_openthread_cli = false
}

# ThunderBoards and Explorer Kit (No LCD)
if (efr32_board == "BRD4166A" || efr32_board == "BRD2601B" ||
efr32_board == "BRD2703A") {
# ThunderBoards, Explorer Kit and MGM240L do not support LCD (No LCD)
if (silabs_board == "BRD4166A" || silabs_board == "BRD2601B" ||
silabs_board == "BRD2703A" || silabs_board == "BRD4319A") {
show_qr_code = false
disable_lcd = true
}
Expand Down Expand Up @@ -128,7 +128,7 @@ efr32_sdk("sdk") {
]

defines = [
"BOARD_ID=${efr32_board}",
"BOARD_ID=${silabs_board}",
"CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}",
"CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR=${setupDiscriminator}",
"OTA_PERIODIC_TIMEOUT=${OTA_periodic_query_timeout}",
Expand Down Expand Up @@ -175,7 +175,6 @@ efr32_executable("light_switch_app") {

sources = [
"${examples_plat_dir}/BaseApplication.cpp",
"${examples_plat_dir}/LEDWidget.cpp",
"${examples_plat_dir}/efr32_utils.cpp",
"${examples_plat_dir}/heap_4_silabs.c",
"${examples_plat_dir}/init_efrPlatform.cpp",
Expand All @@ -186,6 +185,10 @@ efr32_executable("light_switch_app") {
"src/main.cpp",
]

if (use_wstk_leds) {
sources += [ "${examples_plat_dir}/LEDWidget.cpp" ]
}

if (chip_enable_pw_rpc || chip_build_libshell || enable_openthread_cli ||
use_wf200 || use_rs911x) {
sources += [ "${examples_plat_dir}/uart.cpp" ]
Expand Down Expand Up @@ -314,7 +317,7 @@ efr32_executable("light_switch_app") {
defines += [ "HEAP_MONITORING" ]
}

ldscript = "${examples_plat_dir}/ldscripts/${efr32_family}.ld"
ldscript = "${examples_plat_dir}/ldscripts/${silabs_family}.ld"

inputs = [ ldscript ]

Expand Down
5 changes: 4 additions & 1 deletion examples/light-switch-app/efr32/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@
#include "AppTask.h"
#include "AppConfig.h"
#include "AppEvent.h"
#include "LEDWidget.h"
#include "binding-handler.h"

#ifdef ENABLE_WSTK_LEDS
#include "LEDWidget.h"
#include "sl_simple_led_instances.h"
#endif // ENABLE_WSTK_LEDS

#ifdef DISPLAY_ENABLED
#include "lcd.h"
Expand Down
3 changes: 3 additions & 0 deletions examples/lighting-app/bouffalolab/bl602/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ bl602_executable("lighting_app") {
sources = [
#"${bl602_project_dir}/include/CHIPProjectConfig.h",
"${examples_plat_dir}/InitPlatform.cpp",
"${examples_plat_dir}/route_hook/bl_route_hook.c",
"${examples_plat_dir}/route_hook/bl_route_table.c",
"include/CHIPProjectConfig.h",
"src/AppTask.cpp",
"src/CHIPDeviceManager.cpp",
Expand Down Expand Up @@ -162,6 +164,7 @@ bl602_executable("lighting_app") {
include_dirs += [
"${chip_root}/examples/common",
"${chip_root}/examples/common/pigweed/bouffalolab/bl602",
"${examples_plat_dir}/route_hook",
]
}

Expand Down
5 changes: 3 additions & 2 deletions examples/lighting-app/bouffalolab/bl602/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
This example functions as a wifi light bulb device type, with on/off
capabilities. The steps were verified on BL602-IoT-Matter-V1 board.

BL602-IoT-Matter-V1 board:
BL602-IoT-Matter-V1 board and
[purchase link](https://www.amazon.com/dp/B0B9ZVGXD8):
<img src="../../../platform/bouffalolab/bl602/doc/images/BL602-IoT-Matter_V1.png" style="zoom:25%;" />

## Initial setup
Expand Down Expand Up @@ -66,7 +67,7 @@ The steps in this document were validated on Ubuntu 18.04 and 20.04.
```
cd third_party/bouffalolab/repo/tools/flash_tool
./bflb_iot_tool --chipname=BL602 --baudrate=115200 --port=/dev/ttyACM0 --pt=chips/bl602/partition/partition_cfg_4M.toml --dts=chips/bl602/device_tree/bl_factory_params_IoTKitA_40M.dts --firmware=../../../../../out/bl602-light/chip-bl602-lighting-example.bin
./bflb_iot_tool-ubuntu --chipname=BL602 --baudrate=115200 --port=/dev/ttyACM0 --pt=chips/bl602/partition/partition_cfg_4M.toml --dts=chips/bl602/device_tree/bl_factory_params_IoTKitA_40M.dts --firmware=../../../../../out/bl602-light/chip-bl602-lighting-example.bin
```
```
Expand Down
1 change: 1 addition & 0 deletions examples/lighting-app/bouffalolab/bl602/include/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class AppTask
void PostEvent(const AppEvent * event);
void ButtonEventHandler(uint8_t btnIdx, uint8_t btnAction);
void LightStateUpdateEventHandler(void);
void LightStateInit(void);

private:
friend AppTask & GetAppTask(void);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ class DLL_EXPORT CHIPDeviceManagerCallbacks
* @param size size of the attribute
* @param value pointer to the new value
*/
void PostAttributeChangeCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, chip::AttributeId attributeId,
uint8_t type, uint16_t size, uint8_t * value)
virtual void PostAttributeChangeCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, chip::AttributeId attributeId,
uint8_t type, uint16_t size, uint8_t * value)
{}
// virtual ~CHIPDeviceManagerCallbacks();
};
Expand Down
15 changes: 15 additions & 0 deletions examples/lighting-app/bouffalolab/bl602/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ CHIP_ERROR AppTask::Init()
PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE));

InitButtons();

#if PW_RPC_ENABLED
chip::rpc::Init();
#endif
Expand Down Expand Up @@ -576,10 +577,24 @@ void AppTask::LightStateUpdateEventHandler(void)
{
statusLED.SetBrightness(0);
statusLED.Set(0);
PostLightActionRequest(AppEvent::kEventType_Light, LightingManager::OFF_ACTION);
}
else
{
statusLED.SetBrightness(level);
PostLightActionRequest(AppEvent::kEventType_Light, LightingManager::ON_ACTION);
}
} while (0);
}

void AppTask::LightStateInit(void)
{
uint8_t onoff = 1;
uint8_t level = 254;
EndpointId endpoint = 1;

emberAfWriteAttribute(endpoint, ZCL_LEVEL_CONTROL_CLUSTER_ID, ZCL_CURRENT_LEVEL_ATTRIBUTE_ID, (uint8_t *) &level,
ZCL_INT8U_ATTRIBUTE_TYPE);

emberAfWriteAttribute(endpoint, ZCL_ON_OFF_CLUSTER_ID, ZCL_ON_OFF_ATTRIBUTE_ID, (uint8_t *) &onoff, ZCL_BOOLEAN_ATTRIBUTE_TYPE);
}
13 changes: 8 additions & 5 deletions examples/lighting-app/bouffalolab/bl602/src/DeviceCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <app/util/util.h>
#include <lib/dnssd/Advertiser.h>
#include <lib/support/CodeUtils.h>
#include <route_hook/bl_route_hook.h>

using namespace ::chip;
using namespace ::chip::Inet;
Expand All @@ -47,7 +48,6 @@ uint32_t identifyTimerCount;
constexpr uint32_t kIdentifyTimerDelayMS = 250;

static LEDWidget statusLED1;
// static LEDWidget statusLED2;

void DeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, intptr_t arg)
{
Expand All @@ -67,6 +67,7 @@ void DeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, intptr_

case DeviceEventType::kCommissioningComplete:
log_info("Commissioning complete\r\n");
GetAppTask().LightStateInit();
break;

case DeviceEventType::kWiFiConnectivityChange:
Expand All @@ -85,6 +86,12 @@ void DeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, intptr_
// newly selected address.
chip::app::DnssdServer::Instance().StartServer();
}

if (event->InterfaceIpAddressChanged.Type == InterfaceIpChangeType::kIpV6_Assigned)
{
ChipLogProgress(DeviceLayer, "Initializing route hook...");
bl_route_hook_init();
}
break;
}
}
Expand Down Expand Up @@ -125,15 +132,11 @@ void DeviceCallbacks::OnInternetConnectivityChange(const ChipDeviceEvent * event
if (event->InternetConnectivityChange.IPv4 == kConnectivity_Established)
{
log_info("IPv4 Server ready...\r\n");
// TODO
// wifiLED.Set(true);
chip::app::DnssdServer::Instance().StartServer();
}
else if (event->InternetConnectivityChange.IPv4 == kConnectivity_Lost)
{
log_info("Lost IPv4 connectivity...\r\n");
// TODO
// wifiLED.Set(false);
}
if (event->InternetConnectivityChange.IPv6 == kConnectivity_Established)
{
Expand Down
Loading

0 comments on commit c6b795b

Please sign in to comment.