Skip to content

Commit

Permalink
Merge branch 'master' into add_libnl_to_dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
andy31415 authored Aug 22, 2022
2 parents 5c293a9 + 7c53493 commit 1ac53a1
Show file tree
Hide file tree
Showing 231 changed files with 8,339 additions and 3,055 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/examples-efr32.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ jobs:
- name: Build example EFR32 Lighting App for BRD4161A with RPCs
timeout-minutes: 15
run: |
scripts/examples/gn_efr32_example.sh examples/lighting-app/efr32/ out/lighting_app_debug_rpc BRD4161A \
'import("//with_pw_rpc.gni")'
scripts/examples/gn_efr32_example.sh examples/lighting-app/efr32/ out/lighting_app_debug_rpc BRD4161A "is_debug=false" \
disable_lcd=true 'import("//with_pw_rpc.gni")'
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py efr32 BRD4161A+rpc lighting-app \
out/lighting_app_debug_rpc/BRD4161A/chip-efr32-lighting-example.out /tmp/bloat_reports/
- name: Build example EFR32+WF200 WiFi Lock app for BRD4161A
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3850,7 +3850,14 @@ server cluster FaultInjection = 4294048774 {
BOOLEAN takeMutex = 4;
}

request struct FailRandomlyAtFaultRequest {
FaultType type = 0;
INT32U id = 1;
INT8U percentage = 2;
}

command access(invoke: manage) FailAtFault(FailAtFaultRequest): DefaultSuccess = 0;
command access(invoke: manage) FailRandomlyAtFault(FailRandomlyAtFaultRequest): DefaultSuccess = 1;
}

endpoint 0 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8461,6 +8461,14 @@
"source": "client",
"incoming": 1,
"outgoing": 1
},
{
"name": "FailRandomlyAtFault",
"code": 1,
"mfgCode": null,
"source": "client",
"incoming": 1,
"outgoing": 0
}
],
"attributes": [
Expand Down
6 changes: 5 additions & 1 deletion examples/chef/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,11 @@ efr32_executable("chef_app") {
}

if (!disable_lcd) {
sources += [ "${examples_plat_dir}/display/lcd.c" ]
sources += [
"${examples_plat_dir}/display/demo-ui.c",
"${examples_plat_dir}/display/lcd.cpp",
]
include_dirs += [ "${examples_plat_dir}/display" ]
defines += [ "DISPLAY_ENABLED" ]
if (show_qr_code) {
defines += [ "QR_CODE_ENABLED" ]
Expand Down
6 changes: 6 additions & 0 deletions examples/chip-tool/commands/common/CHIPCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,12 @@ CHIP_ERROR CHIPCommand::InitializeCommissioner(std::string key, chip::FabricId f
// store the credentials in persistent storage, and
// generate when not available in the storage.
ReturnLogErrorOnFailure(mCommissionerStorage.Init(key.c_str()));
if (mUseMaxSizedCerts.HasValue())
{
auto option = CredentialIssuerCommands::CredentialIssuerOptions::kMaximizeCertificateSizes;
mCredIssuerCmds->SetCredentialIssuerOption(option, mUseMaxSizedCerts.Value());
}

ReturnLogErrorOnFailure(mCredIssuerCmds->InitializeCredentialsIssuer(mCommissionerStorage));

chip::MutableByteSpan nocSpan(noc.Get(), chip::Controller::kMaxCHIPDERCertLength);
Expand Down
4 changes: 4 additions & 0 deletions examples/chip-tool/commands/common/CHIPCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ class CHIPCommand : public Command
"4. The default if not specified is \"alpha\".");
AddArgument("commissioner-nodeid", 0, UINT64_MAX, &mCommissionerNodeId,
"The node id to use for chip-tool. If not provided, kTestControllerNodeId (112233, 0x1B669) will be used.");
AddArgument("use-max-sized-certs", 0, 1, &mUseMaxSizedCerts,
"Maximize the size of operational certificates. If not provided or 0 (\"false\"), normally sized operational "
"certificates are generated.");
#if CHIP_CONFIG_TRANSPORT_TRACE_ENABLED
AddArgument("trace_file", &mTraceFile);
AddArgument("trace_log", 0, 1, &mTraceLog);
Expand Down Expand Up @@ -153,6 +156,7 @@ class CHIPCommand : public Command
chip::Optional<chip::NodeId> mCommissionerNodeId;
chip::Optional<uint16_t> mBleAdapterId;
chip::Optional<char *> mPaaTrustStorePath;
chip::Optional<bool> mUseMaxSizedCerts;

// Cached trust store so commands other than the original startup command
// can spin up commissioners as needed.
Expand Down
19 changes: 19 additions & 0 deletions examples/chip-tool/commands/common/CredentialIssuerCommands.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,23 @@ class CredentialIssuerCommands
virtual CHIP_ERROR GenerateControllerNOCChain(chip::NodeId nodeId, chip::FabricId fabricId, const chip::CATValues & cats,
chip::Crypto::P256Keypair & keypair, chip::MutableByteSpan & rcac,
chip::MutableByteSpan & icac, chip::MutableByteSpan & noc) = 0;

// All options must start false
enum CredentialIssuerOptions : uint8_t
{
kMaximizeCertificateSizes = 0, // If set, certificate chains will be maximized for testing via padding
};

virtual void SetCredentialIssuerOption(CredentialIssuerOptions option, bool isEnabled)
{
// Do nothing
(void) option;
(void) isEnabled;
}

virtual bool GetCredentialIssuerOption(CredentialIssuerOptions option)
{
// All options always start false
return false;
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,33 @@ class ExampleCredentialIssuerCommands : public CredentialIssuerCommands
return mOpCredsIssuer.GenerateNOCChainAfterValidation(nodeId, fabricId, cats, keypair.Pubkey(), rcac, icac, noc);
}

void SetCredentialIssuerOption(CredentialIssuerOptions option, bool isEnabled) override
{
switch (option)
{
case CredentialIssuerOptions::kMaximizeCertificateSizes:
mUsesMaxSizedCerts = isEnabled;
mOpCredsIssuer.SetMaximallyLargeCertsUsed(mUsesMaxSizedCerts);
break;
default:
break;
}
}

bool GetCredentialIssuerOption(CredentialIssuerOptions option) override
{
switch (option)
{
case CredentialIssuerOptions::kMaximizeCertificateSizes:
return mUsesMaxSizedCerts;
default:
return false;
}
}

protected:
bool mUsesMaxSizedCerts = false;

private:
chip::Controller::ExampleOperationalCredentialsIssuer mOpCredsIssuer;
};
11 changes: 9 additions & 2 deletions examples/light-switch-app/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,15 @@ efr32_executable("light_switch_app") {
}

if (!disable_lcd) {
sources += [ "${examples_plat_dir}/display/lcd.c" ]
defines += [ "DISPLAY_ENABLED" ]
sources += [
"${examples_plat_dir}/display/demo-ui.c",
"${examples_plat_dir}/display/lcd.cpp",
]
include_dirs += [ "${examples_plat_dir}/display" ]
defines += [
"DISPLAY_ENABLED",
"IS_DEMO_SWITCH=1",
]
if (show_qr_code) {
defines += [ "QR_CODE_ENABLED" ]
deps += [ "${chip_root}/examples/common/QRCode" ]
Expand Down
21 changes: 20 additions & 1 deletion examples/light-switch-app/efr32/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ namespace {

EmberAfIdentifyEffectIdentifier sIdentifyEffect = EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT;

bool mCurrentButtonState = false;

/**********************************************************
* Identify Callbacks
*********************************************************/
Expand Down Expand Up @@ -146,6 +148,9 @@ AppTask AppTask::sAppTask;
CHIP_ERROR AppTask::Init()
{
CHIP_ERROR err = CHIP_NO_ERROR;
#ifdef DISPLAY_ENABLED
GetLCD().Init((uint8_t *) "Light Switch");
#endif

err = BaseApplication::Init(&gIdentify);
if (err != CHIP_NO_ERROR)
Expand Down Expand Up @@ -221,9 +226,23 @@ void AppTask::SwitchActionEventHandler(AppEvent * aEvent)
if (aEvent->Type == AppEvent::kEventType_Button)
{
BindingCommandData * data = Platform::New<BindingCommandData>();
data->commandId = chip::app::Clusters::OnOff::Commands::Toggle::Id;
data->clusterId = chip::app::Clusters::OnOff::Id;

if (mCurrentButtonState)
{
mCurrentButtonState = false;
data->commandId = chip::app::Clusters::OnOff::Commands::Off::Id;
}
else
{
data->commandId = chip::app::Clusters::OnOff::Commands::On::Id;
mCurrentButtonState = true;
}

#ifdef DISPLAY_ENABLED
sAppTask.GetLCD().WriteDemoUI(mCurrentButtonState);
#endif

DeviceLayer::PlatformMgr().ScheduleWork(SwitchWorkerFunction, reinterpret_cast<intptr_t>(data));
}
}
Expand Down
12 changes: 10 additions & 2 deletions examples/lighting-app/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,16 @@ efr32_executable("lighting_app") {
}

if (!disable_lcd) {
sources += [ "${examples_plat_dir}/display/lcd.c" ]
defines += [ "DISPLAY_ENABLED" ]
sources += [
"${examples_plat_dir}/display/demo-ui.c",
"${examples_plat_dir}/display/lcd.cpp",
]

include_dirs += [ "${examples_plat_dir}/display" ]
defines += [
"DISPLAY_ENABLED",
"IS_DEMO_LIGHT=1",
]
if (show_qr_code) {
defines += [ "QR_CODE_ENABLED" ]

Expand Down
27 changes: 11 additions & 16 deletions examples/lighting-app/efr32/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,7 @@
#include "AppConfig.h"
#include "AppEvent.h"
#include "LEDWidget.h"
#ifdef DISPLAY_ENABLED
#include "lcd.h"
#ifdef QR_CODE_ENABLED
#include "qrcodegen.h"
#endif // QR_CODE_ENABLED
#endif // DISPLAY_ENABLED

#include "sl_simple_led_instances.h"
#include <app-common/zap-generated/attribute-id.h>
#include <app-common/zap-generated/attribute-type.h>
Expand Down Expand Up @@ -132,6 +127,9 @@ AppTask AppTask::sAppTask;
CHIP_ERROR AppTask::Init()
{
CHIP_ERROR err = CHIP_NO_ERROR;
#ifdef DISPLAY_ENABLED
GetLCD().Init((uint8_t *) "Lighting-App");
#endif

err = BaseApplication::Init(&gIdentify);
if (err != CHIP_NO_ERROR)
Expand Down Expand Up @@ -266,16 +264,13 @@ void AppTask::ButtonEventHandler(const sl_button_t * buttonHandle, uint8_t btnAc
void AppTask::ActionInitiated(LightingManager::Action_t aAction, int32_t aActor)
{
// Action initiated, update the light led
if (aAction == LightingManager::ON_ACTION)
{
EFR32_LOG("Turning light ON")
sLightLED.Set(true);
}
else if (aAction == LightingManager::OFF_ACTION)
{
EFR32_LOG("Turning light OFF")
sLightLED.Set(false);
}
bool lightOn = aAction == LightingManager::ON_ACTION;
EFR32_LOG("Turning light %s", (lightOn) ? "On" : "Off")
sLightLED.Set(lightOn);

#ifdef DISPLAY_ENABLED
sAppTask.GetLCD().WriteDemoUI(lightOn);
#endif

if (aActor == AppEvent::kEventType_Button)
{
Expand Down
11 changes: 9 additions & 2 deletions examples/lock-app/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,15 @@ efr32_executable("lock_app") {
}

if (!disable_lcd) {
sources += [ "${examples_plat_dir}/display/lcd.c" ]
defines += [ "DISPLAY_ENABLED" ]
sources += [
"${examples_plat_dir}/display/demo-ui.c",
"${examples_plat_dir}/display/lcd.cpp",
]
include_dirs += [ "${examples_plat_dir}/display" ]
defines += [
"DISPLAY_ENABLED",
"IS_DEMO_LOCK=1",
]
if (show_qr_code) {
defines += [ "QR_CODE_ENABLED" ]
deps += [ "${chip_root}/examples/common/QRCode" ]
Expand Down
20 changes: 11 additions & 9 deletions examples/lock-app/efr32/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ CHIP_ERROR AppTask::Init()
{
CHIP_ERROR err = CHIP_NO_ERROR;

#ifdef DISPLAY_ENABLED
GetLCD().Init((uint8_t *) "Lock-App", true);
#endif

err = BaseApplication::Init(&gIdentify);
if (err != CHIP_NO_ERROR)
{
Expand Down Expand Up @@ -354,16 +358,14 @@ void AppTask::ButtonEventHandler(const sl_button_t * buttonHandle, uint8_t btnAc

void AppTask::ActionInitiated(LockManager::Action_t aAction, int32_t aActor)
{
// Action initiated, update the light led
if (aAction == LockManager::LOCK_ACTION)
if (aAction == LockManager::UNLOCK_ACTION || aAction == LockManager::LOCK_ACTION)
{
EFR32_LOG("Lock Action has been initiated")
sLockLED.Set(false);
}
else if (aAction == LockManager::UNLOCK_ACTION)
{
EFR32_LOG("Unlock Action has been initiated")
sLockLED.Set(true);
bool locked = (aAction == LockManager::LOCK_ACTION);
EFR32_LOG("%s Action has been initiated", (locked) ? "Lock" : "Unlock");
sLockLED.Set(!locked);
#ifdef DISPLAY_ENABLED
sAppTask.GetLCD().WriteDemoUI(locked);
#endif
}

if (aActor == AppEvent::kEventType_Button)
Expand Down
19 changes: 18 additions & 1 deletion examples/platform/efr32/BaseApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ bool mFunctionTimerActive;

Identify * gIdentifyptr = nullptr;

#ifdef DISPLAY_ENABLED
SilabsLCD slLCD;
#endif

} // namespace

/**********************************************************
Expand Down Expand Up @@ -214,7 +218,8 @@ CHIP_ERROR BaseApplication::Init(Identify * identifyObj)

if (GetQRCode(QRCode, chip::RendezvousInformationFlags(chip::RendezvousInformationFlag::kBLE)) == CHIP_NO_ERROR)
{
LCDWriteQRCode((uint8_t *) QRCode.data());
slLCD.SetQRCode((uint8_t *) QRCode.data(), QRCode.size());
slLCD.ShowQRCode(true, true);
}
else
{
Expand Down Expand Up @@ -386,6 +391,11 @@ void BaseApplication::ButtonHandler(AppEvent * aEvent)
CancelFunctionTimer();
mFunction = kFunction_NoneSelected;

#ifdef DISPLAY_ENABLED
// TOGGLE QRCode/LCD demo UI
slLCD.ToggleQRCode();
#endif

#ifdef SL_WIFI
if (!ConnectivityMgr().IsWiFiStationProvisioned())
#else
Expand Down Expand Up @@ -469,6 +479,13 @@ void BaseApplication::LightTimerEventHandler(TimerHandle_t xTimer)
LightEventHandler();
}

#ifdef DISPLAY_ENABLED
SilabsLCD & BaseApplication::GetLCD(void)
{
return slLCD;
}
#endif

void BaseApplication::PostEvent(const AppEvent * aEvent)
{
if (sAppEventQueue != NULL)
Expand Down
Loading

0 comments on commit 1ac53a1

Please sign in to comment.