Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
yufengwangca committed Apr 30, 2021
1 parent 4bf9503 commit ad9f007
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ using namespace chip;
bool emberAfGeneralCommissioningClusterArmFailSafeCallback(chip::app::Command * commandObj, uint16_t expiryLengthSeconds,
uint64_t breadcrumb, uint32_t timeoutMs)
{
CHIP_ERROR err = DeviceLayer::Internal::DeviceControlSvr().HandleArmFailSafe(expiryLengthSeconds);
CHIP_ERROR err = DeviceLayer::Internal::DeviceControlSvr().ArmFailSafe(expiryLengthSeconds);
emberAfSendImmediateDefaultResponse(err == CHIP_NO_ERROR ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE);

return true;
}

bool emberAfGeneralCommissioningClusterCommissioningCompleteCallback(chip::app::Command * commandObj)
{
CHIP_ERROR err = DeviceLayer::Internal::DeviceControlSvr().HandleCommissioningComplete();
CHIP_ERROR err = DeviceLayer::Internal::DeviceControlSvr().CommissioningComplete();
emberAfSendImmediateDefaultResponse(err == CHIP_NO_ERROR ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE);

return true;
Expand All @@ -49,7 +49,12 @@ bool emberAfGeneralCommissioningClusterCommissioningCompleteCallback(chip::app::
bool emberAfGeneralCommissioningClusterSetRegulatoryConfigCallback(chip::app::Command * commandObj, uint8_t location,
uint8_t * countryCode, uint64_t breadcrumb, uint32_t timeoutMs)
{
CHIP_ERROR err = DeviceLayer::Internal::DeviceControlSvr().HandleSetRegulatoryConfig(location, countryCode, breadcrumb);
CHIP_ERROR err = CHIP_NO_ERROR;

// TODO: countryCode is defined as Null terminated CHAR_STRING, which was interpreted as 'str' before, some recent changes broke
// this and interpreted as 'bytes'.
// err = DeviceLayer::Internal::DeviceControlSvr().SetRegulatoryConfig(location, countryCode, breadcrumb);

emberAfSendImmediateDefaultResponse(err == CHIP_NO_ERROR ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE);

return true;
Expand Down
8 changes: 4 additions & 4 deletions src/include/platform/internal/DeviceControlServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ class DeviceControlServer final
public:
// ===== Members for internal use by other Device Layer components.

CHIP_ERROR HandleArmFailSafe(uint16_t expiryLengthSeconds);
CHIP_ERROR HandleDisarmFailSafe(void);
CHIP_ERROR HandleCommissioningComplete(void);
CHIP_ERROR HandleSetRegulatoryConfig(uint8_t location, uint8_t * countryCode, uint64_t breadcrumb);
CHIP_ERROR ArmFailSafe(uint16_t expiryLengthSeconds);
CHIP_ERROR DisarmFailSafe();
CHIP_ERROR CommissioningComplete();
CHIP_ERROR SetRegulatoryConfig(uint8_t location, const char * countryCode, uint64_t breadcrumb);

private:
// ===== Members for internal use by the following friends.
Expand Down
13 changes: 5 additions & 8 deletions src/platform/DeviceControlServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,37 +28,34 @@ namespace chip {
namespace DeviceLayer {
namespace Internal {

// Conforms to ISO 3166-1 Alpha-2
static constexpr size_t kCountryCodeLen = 2;

DeviceControlServer DeviceControlServer::sInstance;

CHIP_ERROR DeviceControlServer::HandleArmFailSafe(uint16_t expiryLengthSeconds)
CHIP_ERROR DeviceControlServer::ArmFailSafe(uint16_t expiryLengthSeconds)
{
// TODO
return CHIP_NO_ERROR;
}

CHIP_ERROR DeviceControlServer::HandleDisarmFailSafe(void)
CHIP_ERROR DeviceControlServer::DisarmFailSafe()
{
// TODO
return CHIP_NO_ERROR;
}

CHIP_ERROR DeviceControlServer::HandleCommissioningComplete(void)
CHIP_ERROR DeviceControlServer::CommissioningComplete()
{
// TODO
return CHIP_NO_ERROR;
}

CHIP_ERROR DeviceControlServer::HandleSetRegulatoryConfig(uint8_t location, uint8_t * countryCode, uint64_t breadcrumb)
CHIP_ERROR DeviceControlServer::SetRegulatoryConfig(uint8_t location, const char * countryCode, uint64_t breadcrumb)
{
CHIP_ERROR err = CHIP_NO_ERROR;

err = ConfigurationMgr().StoreRegulatoryLocation(location);
SuccessOrExit(err);

err = ConfigurationMgr().StoreCountryCode(reinterpret_cast<const char *>(countryCode), kCountryCodeLen);
err = ConfigurationMgr().StoreCountryCode(countryCode, strlen(countryCode));
SuccessOrExit(err);

err = ConfigurationMgr().StoreBreadcrumb(breadcrumb);
Expand Down

0 comments on commit ad9f007

Please sign in to comment.