Skip to content

Commit

Permalink
Merge branch 'master' into granbery/atomic_write
Browse files Browse the repository at this point in the history
  • Loading branch information
hasty committed Jul 29, 2024
2 parents ac3fc9f + d9bcdd3 commit 031d33e
Show file tree
Hide file tree
Showing 23 changed files with 1,018 additions and 647 deletions.
67 changes: 42 additions & 25 deletions examples/platform/silabs/BaseApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,22 +166,6 @@ bool BaseApplication::sIsFactoryResetTriggered = false;
LEDWidget * BaseApplication::sAppActionLed = nullptr;
BaseApplicationDelegate BaseApplication::sAppDelegate = BaseApplicationDelegate();

#ifdef DIC_ENABLE
namespace {
void AppSpecificConnectivityEventCallback(const ChipDeviceEvent * event, intptr_t arg)
{
SILABS_LOG("AppSpecificConnectivityEventCallback: call back for IPV4");
if ((event->Type == DeviceEventType::kInternetConnectivityChange) &&
(event->InternetConnectivityChange.IPv4 == kConnectivity_Established))
{
SILABS_LOG("Got IPv4 Address! Starting DIC module\n");
if (DIC_OK != dic_init(dic::control::subscribeCB))
SILABS_LOG("Failed to initialize DIC module\n");
}
}
} // namespace
#endif // DIC_ENABLE

void BaseApplicationDelegate::OnCommissioningSessionStarted()
{
isComissioningStarted = true;
Expand All @@ -203,7 +187,7 @@ void BaseApplicationDelegate::OnCommissioningWindowClosed()
ChipLogError(DeviceLayer, "Failed to enable the TA Deep Sleep");
}
}
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI917qq
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI917
}

void BaseApplicationDelegate::OnFabricCommitted(const FabricTable & fabricTable, FabricIndex fabricIndex)
Expand Down Expand Up @@ -297,10 +281,6 @@ CHIP_ERROR BaseApplication::Init()
SILABS_LOG("Current Software Version String: %s", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING);
SILABS_LOG("Current Software Version: %d", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION);

#ifdef DIC_ENABLE
chip::DeviceLayer::PlatformMgr().AddEventHandler(AppSpecificConnectivityEventCallback, reinterpret_cast<intptr_t>(nullptr));
#endif // DIC_ENABLE

ConfigurationMgr().LogDeviceConfig();

OutputQrCode(true /*refreshLCD at init*/);
Expand Down Expand Up @@ -730,14 +710,25 @@ SilabsLCD & BaseApplication::GetLCD(void)
return slLCD;
}

void BaseApplication::UpdateLCDStatusScreen(void)
void BaseApplication::UpdateLCDStatusScreen(bool withChipStackLock)
{
SilabsLCD::DisplayStatus_t status;
bool enabled, attached;
chip::DeviceLayer::PlatformMgr().LockChipStack();
if (withChipStackLock)
{
chip::DeviceLayer::PlatformMgr().LockChipStack();
}
#ifdef SL_WIFI
enabled = ConnectivityMgr().IsWiFiStationEnabled();
attached = ConnectivityMgr().IsWiFiStationConnected();
chip::DeviceLayer::NetworkCommissioning::Network network;
memset(reinterpret_cast<void *>(&network), 0, sizeof(network));
chip::DeviceLayer::NetworkCommissioning::GetConnectedNetwork(network);
if (network.networkIDLen)
{
chip::Platform::CopyString(status.networkName, sizeof(status.networkName),
reinterpret_cast<const char *>(network.networkID));
}
#endif /* SL_WIFI */
#if CHIP_ENABLE_OPENTHREAD
enabled = ConnectivityMgr().IsThreadEnabled();
Expand All @@ -751,7 +742,10 @@ void BaseApplication::UpdateLCDStatusScreen(void)
? SilabsLCD::ICDMode_e::SIT
: SilabsLCD::ICDMode_e::LIT;
#endif
chip::DeviceLayer::PlatformMgr().UnlockChipStack();
if (withChipStackLock)
{
chip::DeviceLayer::PlatformMgr().UnlockChipStack();
}
slLCD.SetStatus(status);
}
#endif
Expand Down Expand Up @@ -822,10 +816,33 @@ void BaseApplication::DoProvisioningReset()

void BaseApplication::OnPlatformEvent(const ChipDeviceEvent * event, intptr_t)
{
if (event->Type == DeviceEventType::kServiceProvisioningChange)
switch (event->Type)
{
case DeviceEventType::kServiceProvisioningChange:
// Note: This is only called on Attach, we need to add a method to detect Thread Network Detach
BaseApplication::sIsProvisioned = event->ServiceProvisioningChange.IsServiceProvisioned;
break;
case DeviceEventType::kInternetConnectivityChange:
#ifdef DIC_ENABLE
VerifyOrReturn(event->InternetConnectivityChange.IPv4 == kConnectivity_Established);
if (DIC_OK != dic_init(dic::control::subscribeCB))
{
SILABS_LOG("Failed to initialize DIC module\n");
}
#endif // DIC_ENABLE
break;
case DeviceEventType::kWiFiConnectivityChange:
#ifdef DISPLAY_ENABLED
SilabsLCD::Screen_e screen;
AppTask::GetLCD().GetScreen(screen);
// Update the LCD screen with SSID and connected state
VerifyOrReturn(screen == SilabsLCD::Screen_e::StatusScreen);
BaseApplication::UpdateLCDStatusScreen(false);
AppTask::GetLCD().SetScreen(screen);
#endif // DISPLAY_ENABLED
break;
default:
break;
}
}

Expand Down
2 changes: 1 addition & 1 deletion examples/platform/silabs/BaseApplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class BaseApplication
*/
static SilabsLCD & GetLCD(void);

static void UpdateLCDStatusScreen(void);
static void UpdateLCDStatusScreen(bool withChipStackLock = true);
#endif

/**
Expand Down
6 changes: 6 additions & 0 deletions examples/platform/silabs/display/lcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@ void SilabsLCD::SetCustomUI(customUICB cb)
customUI = cb;
}

void SilabsLCD::GetScreen(Screen_e & screen)
{
screen = static_cast<Screen_e>(mCurrentScreen);
}

void SilabsLCD::SetScreen(Screen_e screen)
{
if (screen >= InvalidScreen)
Expand All @@ -226,6 +231,7 @@ void SilabsLCD::SetScreen(Screen_e screen)
default:
break;
}
mCurrentScreen = screen;
}

void SilabsLCD::CycleScreens(void)
Expand Down
14 changes: 7 additions & 7 deletions examples/platform/silabs/display/lcd.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
#endif // QR_CODE_ENABLED

#include "demo-ui.h"

#define MAX_STR_LEN 48
#include <platform/internal/DeviceNetworkInfo.h>

class SilabsLCD
{
Expand All @@ -52,11 +51,11 @@ class SilabsLCD

typedef struct dStatus
{
uint8_t nbFabric = 0;
bool connected = false;
char networkName[50] = { "TODO" };
bool advertising = false;
ICDMode_e icdMode = NotICD;
uint8_t nbFabric = 0;
bool connected = false;
char networkName[chip::DeviceLayer::Internal::kMaxWiFiSSIDLength] = { 0 };
bool advertising = false;
ICDMode_e icdMode = NotICD;
} DisplayStatus_t;

typedef void (*customUICB)(GLIB_Context_t * context);
Expand All @@ -68,6 +67,7 @@ class SilabsLCD
void WriteDemoUI(bool state);
void SetCustomUI(customUICB cb);

void GetScreen(Screen_e & screen);
void SetScreen(Screen_e screen);
void CycleScreens(void);
void SetStatus(DisplayStatus_t & status);
Expand Down
6 changes: 3 additions & 3 deletions scripts/py_matter_idl/matter_idl/backwards_compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ def attribute_name(attribute: Attribute) -> str:

def not_stable(maturity: ApiMaturity):
"""Determine if the given api maturity allows binary/api changes or not."""
# TODO: internal and deprecated not currently widely used,
# so we enforce stability on them for now.
return maturity == ApiMaturity.PROVISIONAL
# NOTE: deprecated are not to be used, so we expect no changes. They were
# probably "stable" at some point
return (maturity == ApiMaturity.PROVISIONAL) or (maturity == ApiMaturity.INTERNAL)


class CompatibilityChecker:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,13 @@ def test_provisional_cluster(self):
"provisional server cluster A = 16 { enum X : ENUM8 { A = 1; B = 3; } info event A = 2 { int16u x = 1;} }",
Compatibility.ALL_OK)

def test_internal_cluster(self):
self.ValidateUpdate(
"Internal cluster changes are ok.",
"internal server cluster A = 16 { enum X : ENUM8 { A = 1; B = 2; } info event A = 1 { int8u x = 1;} }",
"internal server cluster A = 16 { enum X : ENUM8 { A = 1; B = 3; } info event A = 2 { int16u x = 1;} }",
Compatibility.ALL_OK)

def test_clusters_enum_code(self):
self.ValidateUpdate(
"Adding an enum is ok. Also validates code formatting",
Expand Down
2 changes: 2 additions & 0 deletions src/app/cluster-building-blocks/QuieterReporting.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ class QuieterReportingAttribute
{
public:
explicit QuieterReportingAttribute(const Nullable<T> & initialValue) : mValue(initialValue), mLastDirtyValue(initialValue) {}
// constructor that works with arrays of QuieterReportingAttribute
explicit QuieterReportingAttribute() : mValue(DataModel::NullNullable), mLastDirtyValue(DataModel::NullNullable) {}

struct SufficientChangePredicateCandidate
{
Expand Down
Loading

0 comments on commit 031d33e

Please sign in to comment.