Skip to content

Commit

Permalink
Merging from upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
rbultman committed Feb 9, 2024
2 parents 2006f86 + 1913dba commit e628d56
Show file tree
Hide file tree
Showing 36 changed files with 708 additions and 209 deletions.
1 change: 1 addition & 0 deletions docs/ERROR_CODES.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ This file was **AUTOMATICALLY** generated by
| 121 | 0x79 | `CHIP_ERROR_INSUFFICIENT_PRIVILEGE` |
| 125 | 0x7D | `CHIP_ERROR_MESSAGE_COUNTER_EXHAUSTED` |
| 126 | 0x7E | `CHIP_ERROR_FABRIC_EXISTS` |
| 127 | 0x7F | `CHIP_ERROR_ENDPOINT_EXISTS` |
| 128 | 0x80 | `CHIP_ERROR_WRONG_ENCRYPTION_TYPE_FROM_PEER` |
| 133 | 0x85 | `CHIP_ERROR_INVALID_KEY_ID` |
| 134 | 0x86 | `CHIP_ERROR_INVALID_TIME` |
Expand Down
8 changes: 4 additions & 4 deletions examples/bridge-app/asr/subdevice/SubDeviceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,19 @@ int AddDeviceEndpoint(SubDevice * dev, EmberAfEndpointType * ep, const Span<cons
if (NULL == gSubDevices[index])
{
gSubDevices[index] = dev;
EmberAfStatus ret;
CHIP_ERROR err;
while (1)
{
dev->SetEndpointId(gCurrentEndpointId);
ret =
err =
emberAfSetDynamicEndpoint(index, gCurrentEndpointId, ep, dataVersionStorage, deviceTypeList, parentEndpointId);
if (ret == EMBER_ZCL_STATUS_SUCCESS)
if (err == CHIP_NO_ERROR)
{
ChipLogProgress(DeviceLayer, "Added device %s to dynamic endpoint %d (index=%d)", dev->GetName(),
gCurrentEndpointId, index);
return index;
}
else if (ret != EMBER_ZCL_STATUS_DUPLICATE_EXISTS)
else if (err != CHIP_ERROR_ENDPOINT_EXISTS)
{
return -1;
}
Expand Down
8 changes: 4 additions & 4 deletions examples/bridge-app/esp32/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,19 +166,19 @@ int AddDeviceEndpoint(Device * dev, EmberAfEndpointType * ep, const Span<const E
if (NULL == gDevices[index])
{
gDevices[index] = dev;
EmberAfStatus ret;
CHIP_ERROR err;
while (true)
{
dev->SetEndpointId(gCurrentEndpointId);
ret =
err =
emberAfSetDynamicEndpoint(index, gCurrentEndpointId, ep, dataVersionStorage, deviceTypeList, parentEndpointId);
if (ret == EMBER_ZCL_STATUS_SUCCESS)
if (err == CHIP_NO_ERROR)
{
ChipLogProgress(DeviceLayer, "Added device %s to dynamic endpoint %d (index=%d)", dev->GetName(),
gCurrentEndpointId, index);
return index;
}
else if (ret != EMBER_ZCL_STATUS_DUPLICATE_EXISTS)
else if (err != CHIP_ERROR_ENDPOINT_EXISTS)
{
return -1;
}
Expand Down
8 changes: 4 additions & 4 deletions examples/bridge-app/linux/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,22 +259,22 @@ int AddDeviceEndpoint(Device * dev, EmberAfEndpointType * ep, const Span<const E
if (nullptr == gDevices[index])
{
gDevices[index] = dev;
EmberAfStatus ret;
CHIP_ERROR err;
while (true)
{
// Todo: Update this to schedule the work rather than use this lock
DeviceLayer::StackLock lock;
dev->SetEndpointId(gCurrentEndpointId);
dev->SetParentEndpointId(parentEndpointId);
ret =
err =
emberAfSetDynamicEndpoint(index, gCurrentEndpointId, ep, dataVersionStorage, deviceTypeList, parentEndpointId);
if (ret == EMBER_ZCL_STATUS_SUCCESS)
if (err == CHIP_NO_ERROR)
{
ChipLogProgress(DeviceLayer, "Added device %s to dynamic endpoint %d (index=%d)", dev->GetName(),
gCurrentEndpointId, index);
return index;
}
if (ret != EMBER_ZCL_STATUS_DUPLICATE_EXISTS)
if (err != CHIP_ERROR_ENDPOINT_EXISTS)
{
return -1;
}
Expand Down
8 changes: 4 additions & 4 deletions examples/bridge-app/telink/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,19 +189,19 @@ int AddDeviceEndpoint(Device * dev, EmberAfEndpointType * ep, const Span<const E
if (NULL == gDevices[index])
{
gDevices[index] = dev;
EmberAfStatus ret;
CHIP_ERROR err;
while (true)
{
dev->SetEndpointId(gCurrentEndpointId);
ret =
err =
emberAfSetDynamicEndpoint(index, gCurrentEndpointId, ep, dataVersionStorage, deviceTypeList, parentEndpointId);
if (ret == EMBER_ZCL_STATUS_SUCCESS)
if (err == CHIP_NO_ERROR)
{
ChipLogProgress(DeviceLayer, "Added device %s to dynamic endpoint %d (index=%d)", dev->GetName(),
gCurrentEndpointId, index);
return index;
}
else if (ret != EMBER_ZCL_STATUS_DUPLICATE_EXISTS)
else if (err != CHIP_ERROR_ENDPOINT_EXISTS)
{
return -1;
}
Expand Down
2 changes: 2 additions & 0 deletions examples/rvc-app/rvc-common/pics/rvc-app-pics-values
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
PICS_SDK_CI_ONLY=1

RVCCLEANM.S=1
RVCCLEANM.S.A0000=1
RVCCLEANM.S.A0001=1
Expand Down
16 changes: 8 additions & 8 deletions src/app/app-platform/ContentAppPlatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,13 @@ EndpointId ContentAppPlatform::AddContentApp(ContentApp * app, EmberAfEndpointTy
index++;
continue;
}
EmberAfStatus ret;
CHIP_ERROR err;
EndpointId initEndpointId = mCurrentEndpointId;

do
{
ret = emberAfSetDynamicEndpoint(index, mCurrentEndpointId, ep, dataVersionStorage, deviceTypeList);
if (ret == EMBER_ZCL_STATUS_SUCCESS)
err = emberAfSetDynamicEndpoint(index, mCurrentEndpointId, ep, dataVersionStorage, deviceTypeList);
if (err == CHIP_NO_ERROR)
{
ChipLogProgress(DeviceLayer, "Added ContentApp %s to dynamic endpoint %d (index=%d)", vendorApp.applicationId,
mCurrentEndpointId, index);
Expand All @@ -151,9 +151,9 @@ EndpointId ContentAppPlatform::AddContentApp(ContentApp * app, EmberAfEndpointTy
IncrementCurrentEndpointID();
return app->GetEndpointId();
}
else if (ret != EMBER_ZCL_STATUS_DUPLICATE_EXISTS)
else if (err != CHIP_ERROR_ENDPOINT_EXISTS)
{
ChipLogError(DeviceLayer, "Adding ContentApp error=%d", ret);
ChipLogError(DeviceLayer, "Adding ContentApp error=%" CHIP_ERROR_FORMAT, err.Format());
return kNoCurrentEndpointId;
}
IncrementCurrentEndpointID();
Expand Down Expand Up @@ -202,10 +202,10 @@ EndpointId ContentAppPlatform::AddContentApp(ContentApp * app, EmberAfEndpointTy
index++;
continue;
}
EmberAfStatus ret = emberAfSetDynamicEndpoint(index, desiredEndpointId, ep, dataVersionStorage, deviceTypeList);
if (ret != EMBER_ZCL_STATUS_SUCCESS)
CHIP_ERROR err = emberAfSetDynamicEndpoint(index, desiredEndpointId, ep, dataVersionStorage, deviceTypeList);
if (err != CHIP_NO_ERROR)
{
ChipLogError(DeviceLayer, "Adding ContentApp error=%d", ret);
ChipLogError(DeviceLayer, "Adding ContentApp error : %" CHIP_ERROR_FORMAT, err.Format());
return kNoCurrentEndpointId;
}
ChipLogProgress(DeviceLayer, "Added ContentApp %s to dynamic endpoint %d (index=%d)", vendorApp.applicationId,
Expand Down
1 change: 0 additions & 1 deletion src/app/util/af-enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ enum EmberAfStatus : uint8_t
EMBER_ZCL_STATUS_CONSTRAINT_ERROR = 0x87,
EMBER_ZCL_STATUS_UNSUPPORTED_WRITE = 0x88,
EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED = 0x89,
EMBER_ZCL_STATUS_DUPLICATE_EXISTS = 0x8A,
EMBER_ZCL_STATUS_NOT_FOUND = 0x8B,
EMBER_ZCL_STATUS_UNREPORTABLE_ATTRIBUTE = 0x8C,
EMBER_ZCL_STATUS_INVALID_DATA_TYPE = 0x8D,
Expand Down
16 changes: 8 additions & 8 deletions src/app/util/attribute-storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,33 +253,33 @@ uint16_t emberAfGetDynamicIndexFromEndpoint(EndpointId id)
return kEmberInvalidEndpointIndex;
}

EmberAfStatus emberAfSetDynamicEndpoint(uint16_t index, EndpointId id, const EmberAfEndpointType * ep,
const chip::Span<chip::DataVersion> & dataVersionStorage,
chip::Span<const EmberAfDeviceType> deviceTypeList, EndpointId parentEndpointId)
CHIP_ERROR emberAfSetDynamicEndpoint(uint16_t index, EndpointId id, const EmberAfEndpointType * ep,
const chip::Span<chip::DataVersion> & dataVersionStorage,
chip::Span<const EmberAfDeviceType> deviceTypeList, EndpointId parentEndpointId)
{
auto realIndex = index + FIXED_ENDPOINT_COUNT;

if (realIndex >= MAX_ENDPOINT_COUNT)
{
return EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED;
return CHIP_ERROR_NO_MEMORY;
}
if (id == kInvalidEndpointId)
{
return EMBER_ZCL_STATUS_CONSTRAINT_ERROR;
return CHIP_ERROR_INVALID_ARGUMENT;
}

auto serverClusterCount = emberAfClusterCountForEndpointType(ep, /* server = */ true);
if (dataVersionStorage.size() < serverClusterCount)
{
return EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED;
return CHIP_ERROR_NO_MEMORY;
}

index = static_cast<uint16_t>(realIndex);
for (uint16_t i = FIXED_ENDPOINT_COUNT; i < MAX_ENDPOINT_COUNT; i++)
{
if (emAfEndpoints[i].endpoint == id)
{
return EMBER_ZCL_STATUS_DUPLICATE_EXISTS;
return CHIP_ERROR_ENDPOINT_EXISTS;
}
}

Expand Down Expand Up @@ -307,7 +307,7 @@ EmberAfStatus emberAfSetDynamicEndpoint(uint16_t index, EndpointId id, const Emb
// Now enable the endpoint.
emberAfEndpointEnableDisable(id, true);

return EMBER_ZCL_STATUS_SUCCESS;
return CHIP_NO_ERROR;
}

EndpointId emberAfClearDynamicEndpoint(uint16_t index)
Expand Down
13 changes: 9 additions & 4 deletions src/app/util/attribute-storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,15 @@ CHIP_ERROR SetTagList(chip::EndpointId endpoint,
//
// An optional parent endpoint id should be passed for child endpoints of composed device.
//
EmberAfStatus emberAfSetDynamicEndpoint(uint16_t index, chip::EndpointId id, const EmberAfEndpointType * ep,
const chip::Span<chip::DataVersion> & dataVersionStorage,
chip::Span<const EmberAfDeviceType> deviceTypeList = {},
chip::EndpointId parentEndpointId = chip::kInvalidEndpointId);
// Returns CHIP_NO_ERROR No error.
// CHIP_ERROR_NO_MEMORY MAX_ENDPOINT_COUNT is reached or when no storage is left for clusters
// CHIP_ERROR_INVALID_ARGUMENT The EndpointId value passed is kInvalidEndpointId
// CHIP_ERROR_ENDPOINT_EXISTS If the EndpointId value passed already exists
//
CHIP_ERROR emberAfSetDynamicEndpoint(uint16_t index, chip::EndpointId id, const EmberAfEndpointType * ep,
const chip::Span<chip::DataVersion> & dataVersionStorage,
chip::Span<const EmberAfDeviceType> deviceTypeList = {},
chip::EndpointId parentEndpointId = chip::kInvalidEndpointId);
chip::EndpointId emberAfClearDynamicEndpoint(uint16_t index);
uint16_t emberAfGetDynamicIndexFromEndpoint(chip::EndpointId id);

Expand Down
16 changes: 6 additions & 10 deletions src/crypto/CHIPCryptoPAL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
*/

#include "CHIPCryptoPAL.h"

#include "SessionKeystore.h"

#include <lib/asn1/ASN1.h>
#include <lib/asn1/ASN1Macros.h>
#include <lib/core/CHIPEncoding.h>
Expand Down Expand Up @@ -498,18 +501,11 @@ CHIP_ERROR Spake2p::KeyConfirm(const uint8_t * in, size_t in_len)
return CHIP_NO_ERROR;
}

CHIP_ERROR Spake2p::GetKeys(uint8_t * out, size_t * out_len)
CHIP_ERROR Spake2p::GetKeys(SessionKeystore & keystore, HkdfKeyHandle & key) const
{
CHIP_ERROR error = CHIP_ERROR_INTERNAL;

VerifyOrExit(state == CHIP_SPAKE2P_STATE::KC, error = CHIP_ERROR_INTERNAL);
VerifyOrExit(*out_len >= hash_size / 2, error = CHIP_ERROR_INVALID_ARGUMENT);
VerifyOrReturnError(state == CHIP_SPAKE2P_STATE::KC, CHIP_ERROR_INTERNAL);

memcpy(out, Ke, hash_size / 2);
error = CHIP_NO_ERROR;
exit:
*out_len = hash_size / 2;
return error;
return keystore.CreateKey(ByteSpan(Ke, hash_size / 2), key);
}

CHIP_ERROR Spake2p_P256_SHA256_HKDF_HMAC::InitImpl()
Expand Down
Loading

0 comments on commit e628d56

Please sign in to comment.