Skip to content

Commit 46b53f5

Browse files
authored
Merge branch 'master' into feature/refresh-content-app-acl
2 parents b603a5e + 171843d commit 46b53f5

15 files changed

+186
-21
lines changed

examples/darwin-framework-tool/commands/common/CHIPCommandBridge.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class CHIPCommandBridge : public Command {
3939
{
4040
AddArgument("commissioner-name", &mCommissionerName);
4141
AddArgument("commissioner-nodeId", 0, UINT64_MAX, &mCommissionerNodeId,
42-
"Sets the commisser node ID of the given "
42+
"Sets the commissioner node ID of the given "
4343
"commissioner-name. Interactive mode will only set a single commissioner on the inital command. "
4444
"The commissioner node ID will be persisted until a different one is specified.");
4545
AddArgument("paa-trust-store-path", &mPaaTrustStorePath,

examples/darwin-framework-tool/commands/pairing/DeviceControllerDelegateBridge.mm

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ - (void)controller:(MTRDeviceController *)controller statusUpdate:(MTRCommission
3636
ChipLogError(chipTool, "MTRCommissioningStatusDiscoveringMoreDevices: This should not happen.");
3737
break;
3838
case MTRCommissioningStatusUnknown:
39-
ChipLogError(chipTool, "Uknown Pairing Status");
39+
ChipLogError(chipTool, "Unknown Pairing Status");
4040
break;
4141
}
4242
}

src/darwin/Framework/CHIP/MTRDevice.mm

+5-1
Original file line numberDiff line numberDiff line change
@@ -844,11 +844,13 @@ - (void)_addDelegate:(id<MTRDeviceDelegate>)delegate queue:(dispatch_queue_t)que
844844
#endif
845845

846846
if (shouldSetUpSubscription) {
847+
MTR_LOG("%@ - starting subscription setup", self);
847848
// Record the time of first addDelegate call that triggers initial subscribe, and do not reset this value on subsequent addDelegate calls
848849
if (!_initialSubscribeStart) {
849850
_initialSubscribeStart = [NSDate now];
850851
}
851852
if ([self _deviceUsesThread]) {
853+
MTR_LOG(" => %@ - device is a thread device, scheduling in pool", self);
852854
[self _scheduleSubscriptionPoolWork:^{
853855
std::lock_guard lock(self->_lock);
854856
[self _setupSubscriptionWithReason:@"delegate is set and scheduled subscription is happening"];
@@ -1301,7 +1303,7 @@ - (void)_scheduleSubscriptionPoolWork:(dispatch_block_t)workBlock inNanoseconds:
13011303

13021304
// Sanity check we are not scheduling for this device multiple times in the pool
13031305
if (_subscriptionPoolWorkCompletionBlock) {
1304-
MTR_LOG_ERROR("%@ already scheduled in subscription pool for this device - ignoring: %@", self, description);
1306+
MTR_LOG("%@ already scheduled in subscription pool for this device - ignoring: %@", self, description);
13051307
return;
13061308
}
13071309

@@ -1310,6 +1312,7 @@ - (void)_scheduleSubscriptionPoolWork:(dispatch_block_t)workBlock inNanoseconds:
13101312
// In the case where a resubscription triggering event happened and already established, running the work block should result in a no-op
13111313
MTRAsyncWorkItem * workItem = [[MTRAsyncWorkItem alloc] initWithQueue:self.queue];
13121314
[workItem setReadyHandler:^(id _Nonnull context, NSInteger retryCount, MTRAsyncWorkCompletionBlock _Nonnull completion) {
1315+
MTR_LOG("%@ - work item is ready to attempt pooled subscription", self);
13131316
os_unfair_lock_lock(&self->_lock);
13141317
#ifdef DEBUG
13151318
[self _callDelegatesWithBlock:^(id testDelegate) {
@@ -1335,6 +1338,7 @@ - (void)_scheduleSubscriptionPoolWork:(dispatch_block_t)workBlock inNanoseconds:
13351338
workBlock();
13361339
}];
13371340
[self->_deviceController.concurrentSubscriptionPool enqueueWorkItem:workItem description:description];
1341+
MTR_LOG("%@ - enqueued in the subscription pool", self);
13381342
});
13391343
}
13401344

src/darwin/Framework/CHIP/MTRError_Internal.h

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626

2727
NS_ASSUME_NONNULL_BEGIN
2828

29+
#ifndef YES_NO
30+
#define YES_NO(x) ((x) ? @"YES" : @"NO")
31+
#endif
32+
2933
MTR_DIRECT_MEMBERS
3034
@interface MTRError : NSObject
3135
+ (NSError *)errorWithCode:(MTRErrorCode)code;

src/platform/nxp/common/CHIPDeviceNXPPlatformDefaultConfig.h

+12
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,15 @@
106106
#define CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONABLE_DISCOVERY 1
107107
#define CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY 1
108108
#endif
109+
110+
#ifndef CHIP_DEVICE_CONFIG_USE_ZEPHYR_BLE
111+
#define CHIP_DEVICE_CONFIG_USE_ZEPHYR_BLE 1
112+
#endif // CHIP_DEVICE_CONFIG_USE_ZEPHYR_BLE
113+
114+
#ifndef CHIP_DEVICE_CONFIG_PROCESS_BLE_IN_THREAD
115+
#define CHIP_DEVICE_CONFIG_PROCESS_BLE_IN_THREAD 0
116+
#endif // CHIP_DEVICE_CONFIG_PROCESS_BLE_IN_THREAD
117+
118+
#ifndef CHIP_DEVICE_CONFIG_INIT_OT_PLAT_ALARM
119+
#define CHIP_DEVICE_CONFIG_INIT_OT_PLAT_ALARM 1
120+
#endif // CHIP_DEVICE_CONFIG_INIT_OT_PLAT_ALARM

src/platform/nxp/common/CHIPDevicePlatformEvent.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*/
2525

2626
#pragma once
27-
#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
27+
#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE && CHIP_DEVICE_CONFIG_USE_ZEPHYR_BLE
2828
#include <sys/atomic.h>
2929
#include <toolchain.h>
3030
#include <zephyr/bluetooth/bluetooth.h>
@@ -74,7 +74,7 @@ enum InternalPlatformSpecificEventTypes
7474

7575
} // namespace DeviceEventType
7676

77-
#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
77+
#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE && CHIP_DEVICE_CONFIG_USE_ZEPHYR_BLE
7878
struct BleConnEventType
7979
{
8080
bt_conn * BtConn;
@@ -108,7 +108,7 @@ struct ChipDevicePlatformEvent final
108108
{
109109
union
110110
{
111-
#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
111+
#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE && CHIP_DEVICE_CONFIG_USE_ZEPHYR_BLE
112112
BleConnEventType BleConnEvent;
113113
BleCCCWriteEventType BleCCCWriteEvent;
114114
BleC1WriteEventType BleC1WriteEvent;

src/platform/nxp/common/CHIPNXPPlatformDefaultConfig.h

+28
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,34 @@
217217
#define WDM_PUBLISHER_MAX_NOTIFIES_IN_FLIGHT 2
218218
#endif // WDM_PUBLISHER_MAX_NOTIFIES_IN_FLIGHT
219219

220+
// ==================== ICD Configuration Overrides ====================
221+
222+
#ifndef NXP_ICD_ENABLED
223+
#define NXP_ICD_ENABLED 0
224+
#endif // NXP_ICD_ENABLED
225+
226+
#if NXP_ICD_ENABLED
227+
#ifndef CHIP_CONFIG_ICD_IDLE_MODE_DURATION_SEC
228+
#define CHIP_CONFIG_ICD_IDLE_MODE_DURATION_SEC NXP_IDLE_MODE_DURATION_SEC
229+
#endif // CHIP_CONFIG_ICD_IDLE_MODE_DURATION_SEC
230+
231+
#ifndef CHIP_CONFIG_ICD_ACTIVE_MODE_DURATION_MS
232+
#define CHIP_CONFIG_ICD_ACTIVE_MODE_DURATION_MS NXP_ACTIVE_MODE_DURATION_MS
233+
#endif // CHIP_CONFIG_ICD_ACTIVE_MODE_DURATION_MS
234+
235+
#ifndef CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD_MS
236+
#define CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD_MS NXP_ACTIVE_MODE_THRESHOLD
237+
#endif // CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD_MS
238+
239+
#ifndef CHIP_CONFIG_ICD_CLIENTS_SUPPORTED_PER_FABRIC
240+
#define CHIP_CONFIG_ICD_CLIENTS_SUPPORTED_PER_FABRIC NXP_ICD_SUPPORTED_CLIENTS_PER_FABRIC
241+
#endif // CHIP_CONFIG_ICD_CLIENTS_SUPPORTED_PER_FABRIC
242+
243+
#ifndef CHIP_CONFIG_SYNCHRONOUS_REPORTS_ENABLED
244+
#define CHIP_CONFIG_SYNCHRONOUS_REPORTS_ENABLED 1
245+
#endif
246+
#endif // NXP_ICD_ENABLED
247+
220248
// ==================== Other Configuration Overrides ====================
221249

222250
#ifndef CHIP_CONFIG_RMP_DEFAULT_MAX_RETRANS

src/platform/nxp/common/ConfigurationManagerImpl.cpp

+57-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333

3434
#include "fsl_device_registers.h"
3535

36+
#if CONFIG_BOOT_REASON_SDK_SUPPORT
37+
#include "fsl_power.h"
38+
#endif
39+
3640
#if CONFIG_CHIP_PLAT_LOAD_REAL_FACTORY_DATA
3741
#include "FactoryDataProvider.h"
3842
#endif
@@ -54,12 +58,61 @@ ConfigurationManagerImpl & ConfigurationManagerImpl::GetDefaultInstance()
5458
return sInstance;
5559
}
5660

61+
#if CONFIG_BOOT_REASON_SDK_SUPPORT
62+
CHIP_ERROR ConfigurationManagerImpl::DetermineBootReason(uint8_t rebootCause)
63+
{
64+
/*
65+
With current implementation kBrownOutReset couldn't be catched
66+
*/
67+
BootReasonType bootReason = BootReasonType::kUnspecified;
68+
69+
if (rebootCause == 0)
70+
{
71+
bootReason = BootReasonType::kPowerOnReboot;
72+
}
73+
74+
else if (rebootCause == kPOWER_ResetCauseWdt)
75+
{
76+
/* Reboot can be due to hardware or software watchdog */
77+
bootReason = BootReasonType::kHardwareWatchdogReset;
78+
}
79+
else if (rebootCause == kPOWER_ResetCauseSysResetReq)
80+
{
81+
/*
82+
kConfigKey_SoftwareUpdateCompleted not supported for now
83+
if (NXPConfig::ConfigValueExists(NXPConfig::kConfigKey_SoftwareUpdateCompleted))
84+
{
85+
bootReason = BootReasonType::kSoftwareUpdateCompleted;
86+
}
87+
else
88+
{
89+
bootReason = BootReasonType::kSoftwareReset;
90+
}
91+
*/
92+
bootReason = BootReasonType::kSoftwareReset;
93+
}
94+
95+
return StoreBootReason(to_underlying(bootReason));
96+
}
97+
#endif
98+
99+
CHIP_ERROR ConfigurationManagerImpl::StoreSoftwareUpdateCompleted()
100+
{
101+
/* Empty implementation*/
102+
return CHIP_NO_ERROR;
103+
}
104+
57105
CHIP_ERROR ConfigurationManagerImpl::Init()
58106
{
59107
CHIP_ERROR err;
60108
uint32_t rebootCount = 0;
61109
bool failSafeArmed;
62110

111+
#if CONFIG_BOOT_REASON_SDK_SUPPORT
112+
uint8_t rebootCause = POWER_GetResetCause();
113+
POWER_ClearResetCause(rebootCause);
114+
#endif
115+
63116
// Initialize the generic implementation base class.
64117
err = Internal::GenericConfigurationManagerImpl<NXPConfig>::Init();
65118
SuccessOrExit(err);
@@ -84,12 +137,15 @@ CHIP_ERROR ConfigurationManagerImpl::Init()
84137
err = StoreTotalOperationalHours(0);
85138
SuccessOrExit(err);
86139
}
87-
140+
#if CONFIG_BOOT_REASON_SDK_SUPPORT
141+
SuccessOrExit(err = DetermineBootReason(rebootCause));
142+
#else
88143
if (!NXPConfig::ConfigValueExists(NXPConfig::kCounterKey_BootReason))
89144
{
90145
err = StoreBootReason(to_underlying(BootReasonType::kUnspecified));
91146
SuccessOrExit(err);
92147
}
148+
#endif
93149

94150
// TODO: Initialize the global GroupKeyStore object here
95151

src/platform/nxp/common/ConfigurationManagerImpl.h

+4
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class ConfigurationManagerImpl final : public Internal::GenericConfigurationMana
3939
public:
4040
// This returns an instance of this class.
4141
static ConfigurationManagerImpl & GetDefaultInstance();
42+
CHIP_ERROR StoreSoftwareUpdateCompleted();
4243

4344
private:
4445
// ===== Members that implement the ConfigurationManager public interface.
@@ -78,6 +79,9 @@ class ConfigurationManagerImpl final : public Internal::GenericConfigurationMana
7879
// ===== Private members reserved for use by this class only.
7980

8081
static void DoFactoryReset(intptr_t arg);
82+
#if CONFIG_BOOT_REASON_SDK_SUPPORT
83+
CHIP_ERROR DetermineBootReason(uint8_t rebootCause);
84+
#endif
8185
};
8286

8387
/**

src/platform/nxp/common/ConnectivityManagerImpl.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@
3232
#include <platform/internal/GenericConnectivityManagerImpl_TCP.ipp>
3333
#endif
3434

35+
#if CHIP_SYSTEM_CONFIG_USE_LWIP
3536
#include <lwip/dns.h>
3637
#include <lwip/ip_addr.h>
3738
#include <lwip/nd6.h>
3839
#include <lwip/netif.h>
40+
#endif
3941

4042
#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
4143
#include <platform/internal/GenericConnectivityManagerImpl_BLE.ipp>

src/platform/nxp/common/DiagnosticDataProviderImpl.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@
2929
#include <platform/DiagnosticDataProvider.h>
3030

3131
#include <inet/InetInterface.h>
32+
33+
#if CHIP_SYSTEM_CONFIG_USE_LWIP
3234
#include <lwip/tcpip.h>
35+
#endif
3336

3437
#if CHIP_DEVICE_CONFIG_ENABLE_WPA
3538
extern "C" {

src/platform/nxp/common/ThreadStackManagerImpl.cpp

+33-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
/**
2121
* @file
2222
* Provides an implementation of the ThreadStackManager object for
23-
* NXP platforms using the NXP SDK and the OpenThread
24-
* stack.
23+
* NXP platforms using the NXP SDK and the OpenThread stack.
2524
*
2625
*/
2726

@@ -32,7 +31,11 @@
3231
#include <platform/ThreadStackManager.h>
3332

3433
#include <platform/FreeRTOS/GenericThreadStackManagerImpl_FreeRTOS.hpp>
34+
#if CHIP_SYSTEM_CONFIG_USE_LWIP
3535
#include <platform/OpenThread/GenericThreadStackManagerImpl_OpenThread_LwIP.cpp>
36+
#else
37+
#include <platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.hpp>
38+
#endif
3639

3740
#include <lib/support/CHIPPlatformMemory.h>
3841

@@ -59,21 +62,44 @@ CHIP_ERROR ThreadStackManagerImpl::_InitThreadStack(void)
5962
{
6063
CHIP_ERROR err = CHIP_NO_ERROR;
6164

65+
#if CHIP_DEVICE_CONFIG_INIT_OT_PLAT_ALARM
6266
/* Initialize the OpenThread Alarm module to make sure that if calling otInstance,
6367
* it can schedule events
6468
*/
6569
otPlatAlarmInit();
70+
#endif
6671

6772
// Initialize the generic implementation base classes.
6873
err = GenericThreadStackManagerImpl_FreeRTOS<ThreadStackManagerImpl>::DoInit();
6974
SuccessOrExit(err);
75+
#if CHIP_SYSTEM_CONFIG_USE_LWIP
7076
err = GenericThreadStackManagerImpl_OpenThread_LwIP<ThreadStackManagerImpl>::DoInit(NULL);
77+
#else
78+
err = GenericThreadStackManagerImpl_OpenThread<ThreadStackManagerImpl>::DoInit(NULL);
79+
#endif
7180
SuccessOrExit(err);
7281

7382
exit:
7483
return err;
7584
}
7685

86+
#if CHIP_DEVICE_CONFIG_PROCESS_BLE_IN_THREAD
87+
void ThreadStackManagerImpl::ProcessThreadActivity()
88+
{
89+
/* reuse thread task for ble processing.
90+
* by doing this, we avoid allocating a new stack for short-lived
91+
* BLE processing (e.g.: only during Matter commissioning)
92+
*/
93+
#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
94+
auto * bleManager = &chip::DeviceLayer::Internal::BLEMgrImpl();
95+
bleManager->DoBleProcessing();
96+
#endif
97+
98+
otTaskletsProcess(OTInstance());
99+
otSysProcessDrivers(OTInstance());
100+
}
101+
#endif
102+
77103
bool ThreadStackManagerImpl::IsInitialized()
78104
{
79105
return sInstance.mThreadStackLock != NULL;
@@ -112,3 +138,8 @@ extern "C" void otPlatFree(void * aPtr)
112138
{
113139
return CHIPPlatformMemoryFree(aPtr);
114140
}
141+
142+
extern "C" void * otPlatRealloc(void * p, size_t aSize)
143+
{
144+
return CHIPPlatformMemoryRealloc(p, aSize);
145+
}

0 commit comments

Comments
 (0)