Skip to content

Commit

Permalink
Fix K32W061 issues (#19372)
Browse files Browse the repository at this point in the history
* invert D2 and D3 LED states;
* return correct error codes from KVS.

Signed-off-by: Doru Gucea <[email protected]>
  • Loading branch information
doru91 authored Jun 9, 2022
1 parent 3b8810d commit 195181b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@

#define APP_BUTTON_PUSH 1

#define SYSTEM_STATE_LED LED2
#define LIGHT_STATE_LED LED1
#define SYSTEM_STATE_LED LED1
#define LIGHT_STATE_LED LED2

// Time it takes for the light to switch on/off
#define ACTUATOR_MOVEMENT_PERIOS_MS 50
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

0 comments on commit 195181b

Please sign in to comment.