Skip to content

Commit

Permalink
Merge branch 'master' into AA/setuppayloadv2
Browse files Browse the repository at this point in the history
  • Loading branch information
Alami-Amine authored Apr 24, 2024
2 parents 587ac68 + 03bf252 commit 462fd0b
Show file tree
Hide file tree
Showing 50 changed files with 1,962 additions and 1,712 deletions.
28 changes: 26 additions & 2 deletions examples/lit-icd-app/silabs/include/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#include "AppEvent.h"
#include "BaseApplication.h"
#include <app/icd/server/ICDStateObserver.h>
#include <ble/Ble.h>
#include <cmsis_os2.h>
#include <lib/core/CHIPError.h>
Expand All @@ -49,11 +50,12 @@
* AppTask Declaration
*********************************************************/

class AppTask : public BaseApplication
class AppTask : public BaseApplication, public chip::app::ICDStateObserver
{

public:
AppTask() = default;
AppTask() = default;
virtual ~AppTask() = default;

static AppTask & GetAppTask() { return sAppTask; }

Expand All @@ -76,6 +78,28 @@ class AppTask : public BaseApplication
*/
static void ButtonEventHandler(uint8_t button, uint8_t btnAction);

/**
* @brief When the ICD enters ActiveMode, update LCD to reflect the ICD current state.
* Set LCD to ActiveMode UI.
*/
void OnEnterActiveMode();

/**
* @brief When the ICD enters IdleMode, update LCD to reflect the ICD current state.
* Set LCD to IdleMode UI.
*/
void OnEnterIdleMode();

/**
* @brief AppTask has no action to do on this ICD event. Do nothing.
*/
void OnTransitionToIdle(){};

/**
* @brief AppTask has no action to do on this ICD event. Do nothing.
*/
void OnICDModeChange(){};

private:
static AppTask sAppTask;

Expand Down
7 changes: 7 additions & 0 deletions examples/lit-icd-app/silabs/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,10 @@
* A size, in bytes, of the individual debug event logging buffer.
*/
#define CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE (512)

/**
* @brief CHIP_CONFIG_ICD_OBSERVERS_POOL_SIZE
*
* Increase default(2) by 1 to account for the AppTask registering
*/
#define CHIP_CONFIG_ICD_OBSERVERS_POOL_SIZE 3
42 changes: 39 additions & 3 deletions examples/lit-icd-app/silabs/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,18 @@
#endif // QR_CODE_ENABLED
#endif // DISPLAY_ENABLED

#include <app-common/zap-generated/attributes/Accessors.h>
#include <app-common/zap-generated/ids/Clusters.h>
#include <app/server/OnboardingCodesUtil.h>
#include <app/server/Server.h>
#include <app/util/attribute-storage.h>
#include <assert.h>
#include <lib/support/CodeUtils.h>
#include <platform/CHIPDeviceLayer.h>
#include <platform/silabs/platformAbstraction/SilabsPlatform.h>
#include <setup_payload/QRCodeSetupPayloadGenerator.h>
#include <setup_payload/SetupPayload.h>

#include <platform/silabs/platformAbstraction/SilabsPlatform.h>

/**********************************************************
* Defines and Constants
*********************************************************/
Expand Down Expand Up @@ -103,6 +104,8 @@ void AppTask::AppTaskMain(void * pvParameter)
appError(err);
}

chip::Server::GetInstance().GetICDManager().RegisterObserver(&sAppTask);

#if !(defined(CHIP_CONFIG_ENABLE_ICD_SERVER) && CHIP_CONFIG_ENABLE_ICD_SERVER)
sAppTask.StartStatusLEDTimer();
#endif
Expand All @@ -122,7 +125,28 @@ void AppTask::AppTaskMain(void * pvParameter)
void AppTask::ApplicationEventHandler(AppEvent * aEvent)
{
VerifyOrReturn(aEvent->Type == AppEvent::kEventType_Button);
// TODO - trigger some application event
VerifyOrReturn(aEvent->ButtonEvent.Action == static_cast<uint8_t>(SilabsPlatform::ButtonAction::ButtonPressed));

// Simple Application logic that toggles the BoleanState StateValue attribute.
// DO NOT COPY for product logic. LIT ICD app is a test app with very simple application logic to enable testing.
// The goal of the app is just to enable testing of LIT ICD features without impacting product sample apps.
PlatformMgr().ScheduleWork([](intptr_t) {
bool state = true;

Protocols::InteractionModel::Status status = chip::app::Clusters::BooleanState::Attributes::StateValue::Get(1, &state);
if (status != Protocols::InteractionModel::Status::Success)
{
// Failed to read StateValue. Default to true (open state)
state = true;
ChipLogError(NotSpecified, "ERR: reading boolean status value %x", to_underlying(status));
}

status = chip::app::Clusters::BooleanState::Attributes::StateValue::Set(1, !state);
if (status != Protocols::InteractionModel::Status::Success)
{
ChipLogError(NotSpecified, "ERR: updating boolean status value %x", to_underlying(status));
}
});
}

void AppTask::ButtonEventHandler(uint8_t button, uint8_t btnAction)
Expand All @@ -142,3 +166,15 @@ void AppTask::ButtonEventHandler(uint8_t button, uint8_t btnAction)
sAppTask.PostEvent(&button_event);
}
}

// DO NOT COPY for product logic. LIT ICD app is a test app with very simple application logic to enable testing.
void AppTask::OnEnterActiveMode()
{
sAppTask.GetLCD().WriteDemoUI(true);
}

// DO NOT COPY for product logic. LIT ICD app is a test app with very simple application logic to enable testing.
void AppTask::OnEnterIdleMode()
{
sAppTask.GetLCD().WriteDemoUI(false);
}
16 changes: 16 additions & 0 deletions examples/minimal-mdns/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,21 @@ static_library("minimal-mdns-example-common") {
]
}

executable("minimal-mdns-tester") {
sources = [ "tester.cpp" ]

deps = [
":minimal-mdns-example-common",
"${chip_root}/examples/common/tracing:commandline",
"${chip_root}/src/lib",
"${chip_root}/src/lib/dnssd/minimal_mdns",
]

cflags = [ "-Wconversion" ]

output_dir = root_out_dir
}

executable("minimal-mdns-client") {
sources = [ "client.cpp" ]

Expand Down Expand Up @@ -83,5 +98,6 @@ group("default") {
":minimal-mdns-client",
":minimal-mdns-example-common",
":minimal-mdns-server",
":minimal-mdns-tester",
]
}
8 changes: 4 additions & 4 deletions examples/minimal-mdns/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,10 @@ class ReportDelegate : public mdns::Minimal::ServerDelegate
public:
void OnQuery(const mdns::Minimal::BytesRange & data, const chip::Inet::IPPacketInfo * info) override
{
char addr[32];
char addr[Inet::IPAddress::kMaxStringLength];
info->SrcAddress.ToString(addr, sizeof(addr));

char ifName[64];
char ifName[Inet::InterfaceId::kMaxIfNameLength];
VerifyOrDie(info->Interface.GetInterfaceName(ifName, sizeof(ifName)) == CHIP_NO_ERROR);

printf("QUERY from: %-15s on port %d, via interface %s\n", addr, info->SrcPort, ifName);
Expand All @@ -197,10 +197,10 @@ class ReportDelegate : public mdns::Minimal::ServerDelegate

void OnResponse(const mdns::Minimal::BytesRange & data, const chip::Inet::IPPacketInfo * info) override
{
char addr[32];
char addr[Inet::IPAddress::kMaxStringLength];
info->SrcAddress.ToString(addr, sizeof(addr));

char ifName[64];
char ifName[Inet::InterfaceId::kMaxIfNameLength];
VerifyOrDie(info->Interface.GetInterfaceName(ifName, sizeof(ifName)) == CHIP_NO_ERROR);

printf("RESPONSE from: %-15s on port %d, via interface %s\n", addr, info->SrcPort, ifName);
Expand Down
8 changes: 4 additions & 4 deletions examples/minimal-mdns/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ class ReplyDelegate : public mdns::Minimal::ServerDelegate, public mdns::Minimal

void OnQuery(const mdns::Minimal::BytesRange & data, const Inet::IPPacketInfo * info) override
{
char addr[INET6_ADDRSTRLEN];
char addr[Inet::IPAddress::kMaxStringLength];
info->SrcAddress.ToString(addr, sizeof(addr));

char ifName[64];
char ifName[Inet::InterfaceId::kMaxIfNameLength];
VerifyOrDie(info->Interface.GetInterfaceName(ifName, sizeof(ifName)) == CHIP_NO_ERROR);

printf("QUERY from: %-15s on port %d, via interface %s\n", addr, info->SrcPort, ifName);
Expand All @@ -145,10 +145,10 @@ class ReplyDelegate : public mdns::Minimal::ServerDelegate, public mdns::Minimal

void OnResponse(const mdns::Minimal::BytesRange & data, const Inet::IPPacketInfo * info) override
{
char addr[INET6_ADDRSTRLEN];
char addr[Inet::IPAddress::kMaxStringLength];
info->SrcAddress.ToString(addr, sizeof(addr));

char ifName[64];
char ifName[Inet::InterfaceId::kMaxIfNameLength];
VerifyOrDie(info->Interface.GetInterfaceName(ifName, sizeof(ifName)) == CHIP_NO_ERROR);

printf("RESPONSE from: %-15s on port %d, via interface %s\n", addr, info->SrcPort, ifName);
Expand Down
Loading

0 comments on commit 462fd0b

Please sign in to comment.