Skip to content

Commit

Permalink
Fix merge/compile/runtime issues (project-chip#19309)
Browse files Browse the repository at this point in the history
* Fix merge/compile/runtime issues

Signed-off-by: Doru Gucea <doru-cristian.gucea@nxp.com>

* Restyled by clang-format

* Fix compilation issue

Signed-off-by: Doru Gucea <doru-cristian.gucea@nxp.com>

Co-authored-by: Restyled.io <commits@restyled.io>
  • Loading branch information
doru91 and restyled-commits authored Jun 8, 2022
1 parent a76dc09 commit 1b4320e
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 50 deletions.
2 changes: 1 addition & 1 deletion examples/lighting-app/nxp/k32w/k32w0/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# CHIP K32W061 Lighting Example Application

The Project CHIP K32W061 Lighting Example demonstrates how to remotely control a
light bulb. The light bulb is simulated using one of the LEDs from the expansion
light bulb. The Light Bulb is simulated using one of the LEDs from the expansion
board. It uses buttons to test turn on/turn off of the light bulb. You can use
this example as a reference for creating your own application.

Expand Down
16 changes: 0 additions & 16 deletions examples/lighting-app/nxp/k32w/k32w0/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,27 +184,11 @@ CHIP_ERROR AppTask::Init()
return err;
}

void LockOpenThreadTask(void)
{
chip::DeviceLayer::ThreadStackMgr().LockThreadStack();
}

void UnlockOpenThreadTask(void)
{
chip::DeviceLayer::ThreadStackMgr().UnlockThreadStack();
}

void AppTask::InitServer(intptr_t arg)
{
static chip::CommonCaseDeviceServerInitParams initParams;
(void) initParams.InitializeStaticResourcesBeforeServerInit();

// Init ZCL Data Model and start server
chip::Inet::EndPointStateOpenThread::OpenThreadEndpointInitParam nativeParams;
nativeParams.lockCb = LockOpenThreadTask;
nativeParams.unlockCb = UnlockOpenThreadTask;
nativeParams.openThreadInstancePtr = chip::DeviceLayer::ThreadStackMgrImpl().OTInstance();
initParams.endpointNativeParams = static_cast<void *>(&nativeParams);
VerifyOrDie((chip::Server::GetInstance().Init(initParams)) == CHIP_NO_ERROR);
}

Expand Down
15 changes: 0 additions & 15 deletions examples/lock-app/nxp/k32w/k32w0/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,27 +164,12 @@ CHIP_ERROR AppTask::Init()
return err;
}

void LockOpenThreadTask(void)
{
chip::DeviceLayer::ThreadStackMgr().LockThreadStack();
}

void UnlockOpenThreadTask(void)
{
chip::DeviceLayer::ThreadStackMgr().UnlockThreadStack();
}

void AppTask::InitServer(intptr_t arg)
{
static chip::CommonCaseDeviceServerInitParams initParams;
(void) initParams.InitializeStaticResourcesBeforeServerInit();

// Init ZCL Data Model and start server
chip::Inet::EndPointStateOpenThread::OpenThreadEndpointInitParam nativeParams;
nativeParams.lockCb = LockOpenThreadTask;
nativeParams.unlockCb = UnlockOpenThreadTask;
nativeParams.openThreadInstancePtr = chip::DeviceLayer::ThreadStackMgrImpl().OTInstance();
initParams.endpointNativeParams = static_cast<void *>(&nativeParams);
VerifyOrDie((chip::Server::GetInstance().Init(initParams)) == CHIP_NO_ERROR);
}

Expand Down
16 changes: 1 addition & 15 deletions examples/shell/nxp/k32w/k32w0/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,28 +71,14 @@ CHIP_ERROR AppTask::StartAppTask()
return err;
}

void LockOpenThreadTask(void)
{
chip::DeviceLayer::ThreadStackMgr().LockThreadStack();
}

void UnlockOpenThreadTask(void)
{
chip::DeviceLayer::ThreadStackMgr().UnlockThreadStack();
}

CHIP_ERROR AppTask::Init()
{
CHIP_ERROR err = CHIP_NO_ERROR;

// Init ZCL Data Model and start server
static chip::CommonCaseDeviceServerInitParams initParams;
(void) initParams.InitializeStaticResourcesBeforeServerInit();
chip::Inet::EndPointStateOpenThread::OpenThreadEndpointInitParam nativeParams;
nativeParams.lockCb = LockOpenThreadTask;
nativeParams.unlockCb = UnlockOpenThreadTask;
nativeParams.openThreadInstancePtr = chip::DeviceLayer::ThreadStackMgrImpl().OTInstance();
initParams.endpointNativeParams = static_cast<void *>(&nativeParams);

chip::Server::GetInstance().Init(initParams);

// Initialize device attestation config
Expand Down
15 changes: 13 additions & 2 deletions src/platform/nxp/k32w/k32w0/KeyValueStoreManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ KeyValueStoreManagerImpl KeyValueStoreManagerImpl::sInstance;

uint16_t GetStringKeyId(const char * key, uint16_t * freeId)
{
CHIP_ERROR err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND;
CHIP_ERROR err = CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND;
uint8_t keyId = 0;
uint8_t pdmIdKvsKey = chip::DeviceLayer::Internal::K32WConfig::kPDMId_KVSKey;
bool bFreeIdxFound = false;
Expand Down Expand Up @@ -100,6 +100,7 @@ CHIP_ERROR KeyValueStoreManagerImpl::_Get(const char * key, void * value, size_t
}

exit:
ConvertError(err);
return err;
}

Expand Down Expand Up @@ -159,12 +160,13 @@ CHIP_ERROR KeyValueStoreManagerImpl::_Put(const char * key, const void * value,
}

exit:
ConvertError(err);
return err;
}

CHIP_ERROR KeyValueStoreManagerImpl::_Delete(const char * key)
{
CHIP_ERROR err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND;
CHIP_ERROR err = CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND;
uint8_t pdmIdKvsKey = chip::DeviceLayer::Internal::K32WConfig::kPDMId_KVSKey;
uint8_t pdmIdKvsValue = chip::DeviceLayer::Internal::K32WConfig::kPDMId_KVSValue;
uint8_t keyId = 0;
Expand Down Expand Up @@ -205,9 +207,18 @@ CHIP_ERROR KeyValueStoreManagerImpl::_Delete(const char * key)
}
}
exit:
ConvertError(err);
return err;
}

void KeyValueStoreManagerImpl::ConvertError(CHIP_ERROR & err)
{
if (err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND)
{
err = CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND;
}
}

} // namespace PersistedStorage
} // namespace DeviceLayer
} // namespace chip
5 changes: 5 additions & 0 deletions src/platform/nxp/k32w/k32w0/KeyValueStoreManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ class KeyValueStoreManagerImpl final : public KeyValueStoreManager
friend KeyValueStoreManager & KeyValueStoreMgr();
friend KeyValueStoreManagerImpl & KeyValueStoreMgrImpl();

// Reading config values uses the K32WConfig API, which returns CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND
// error if a key was not found. Convert this error to the correct error KeyValueStoreManagerImpl
// should return: CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND
void ConvertError(CHIP_ERROR & err);

static KeyValueStoreManagerImpl sInstance;
};

Expand Down
2 changes: 1 addition & 1 deletion third_party/nxp/k32w0_sdk/k32w0_sdk.gni
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ template("k32w0_sdk") {
"USE_SDK_OSA=0",
"gSerialManagerMaxInterfaces_c=2",
"FSL_RTOS_FREE_RTOS=1",
"gTotalHeapSize_c=0xB000",
"gTotalHeapSize_c=0xB900",
"gUartDebugConsole_d=1",
"DEBUG_SERIAL_INTERFACE_INSTANCE=0",
"APP_SERIAL_INTERFACE_INSTANCE=1",
Expand Down

0 comments on commit 1b4320e

Please sign in to comment.