Skip to content

Commit

Permalink
Merge branch 'master' into YamlTests_SpecDefinitionsFromPath_helper
Browse files Browse the repository at this point in the history
  • Loading branch information
vivien-apple authored Jan 24, 2023
2 parents 828fccd + 95c1888 commit d6c6b99
Show file tree
Hide file tree
Showing 101 changed files with 1,450 additions and 817 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16819,7 +16819,7 @@
"reportableChange": 0
},
{
"name": "IntrinsicBalanceFactor",
"name": "IntrinsicBallastFactor",
"code": 20,
"mfgCode": null,
"side": "server",
Expand Down
14 changes: 9 additions & 5 deletions examples/all-clusters-app/esp32/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ void AppTask::ActionCompleted(BoltLockManager::Action_t aAction)
}
}

CHIP_ERROR AppTask::LockInit()
{
ReturnErrorOnFailure(BoltLockMgr().InitLockState());
BoltLockMgr().SetCallbacks(ActionInitiated, ActionCompleted);
return CHIP_NO_ERROR;
}

CHIP_ERROR AppTask::Init()
{
/* Print chip information */
Expand All @@ -179,10 +186,7 @@ CHIP_ERROR AppTask::Init()
(void *) this, // init timer id = app task obj context
TimerEventHandler // timer callback handler
);

CHIP_ERROR err = BoltLockMgr().InitLockState();

BoltLockMgr().SetCallbacks(ActionInitiated, ActionCompleted);
VerifyOrReturnError(sFunctionTimer != NULL, CHIP_ERROR_NO_MEMORY, ESP_LOGE(TAG, "Failed to create function selection timer"));

statusLED1.Init(STATUS_LED_GPIO_NUM);
// Our second LED doesn't map to any physical LEDs so far, just to virtual
Expand All @@ -199,7 +203,7 @@ CHIP_ERROR AppTask::Init()
InitDeviceDisplay();
#endif

return err;
return CHIP_NO_ERROR;
}

void AppTask::AppTaskMain(void * pvParameter)
Expand Down
1 change: 0 additions & 1 deletion examples/all-clusters-app/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ set(PRIV_INCLUDE_DIRS_LIST
)
set(SRC_DIRS_LIST
"${CMAKE_CURRENT_LIST_DIR}"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/all-clusters-app/zap-generated"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated/attributes"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/providers"
Expand Down
1 change: 1 addition & 0 deletions examples/all-clusters-app/esp32/main/include/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class AppTask
void PostEvent(const AppEvent * event);
void ButtonEventHandler(uint8_t btnIdx, uint8_t btnAction);
static void ButtonPressedAction(AppEvent * aEvent);
CHIP_ERROR LockInit();

private:
CHIP_ERROR Init();
Expand Down
7 changes: 7 additions & 0 deletions examples/all-clusters-app/esp32/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ static void InitServer(intptr_t context)
emberAfEndpointEnableDisable(kNetworkCommissioningEndpointSecondary, false);

InitBindingHandlers();

CHIP_ERROR err = GetAppTask().LockInit();
if (err != CHIP_NO_ERROR)
{
ESP_LOGE(TAG, "Failed to initialize app task lock, err:%" CHIP_ERROR_FORMAT, err.Format());
}

#if CONFIG_DEVICE_TYPE_M5STACK
SetupPretendDevices();
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ struct LabelStruct {
char_string<16> value = 1;
}

struct ApplicationStruct {
int16u catalogVendorID = 0;
char_string applicationID = 1;
}

server cluster Identify = 3 {
enum IdentifyEffectIdentifier : ENUM8 {
kBlink = 0;
Expand Down Expand Up @@ -2928,11 +2933,6 @@ server cluster ApplicationLauncher = 1292 {
kApplicationPlatform = 0x1;
}

struct ApplicationStruct {
int16u catalogVendorID = 0;
char_string applicationID = 1;
}

readonly attribute bitmap32 featureMap = 65532;
readonly attribute int16u clusterRevision = 65533;

Expand Down Expand Up @@ -2967,13 +2967,8 @@ server cluster ApplicationBasic = 1293 {
kActiveVisibleNotFocus = 3;
}

struct ApplicationBasicApplication {
int16u catalogVendorId = 0;
char_string applicationId = 1;
}

readonly attribute char_string<32> applicationName = 2;
readonly attribute ApplicationBasicApplication application = 4;
readonly attribute ApplicationStruct application = 4;
readonly attribute ApplicationStatusEnum status = 5;
readonly attribute char_string<32> applicationVersion = 6;
readonly attribute vendor_id allowedVendorList[] = 7;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16311,7 +16311,7 @@
"reportableChange": 0
},
{
"name": "IntrinsicBalanceFactor",
"name": "IntrinsicBallastFactor",
"code": 20,
"mfgCode": null,
"side": "server",
Expand Down Expand Up @@ -16461,7 +16461,7 @@
"side": "server",
"type": "array",
"included": 1,
"storageOption": "RAM",
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
Expand All @@ -16477,7 +16477,7 @@
"side": "server",
"type": "array",
"included": 1,
"storageOption": "RAM",
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
Expand All @@ -16493,7 +16493,7 @@
"side": "server",
"type": "array",
"included": 1,
"storageOption": "RAM",
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
Expand Down Expand Up @@ -18865,7 +18865,7 @@
"code": 4,
"mfgCode": null,
"side": "server",
"type": "ApplicationBasicApplication",
"type": "ApplicationStruct",
"included": 1,
"storageOption": "External",
"singleton": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ set(PRIV_INCLUDE_DIRS_LIST
)
set(SRC_DIRS_LIST
"${CMAKE_CURRENT_LIST_DIR}"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/all-clusters-minimal-app/zap-generated"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated/attributes"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/ota"
Expand Down
1 change: 0 additions & 1 deletion examples/bridge-app/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ idf_component_register(PRIV_INCLUDE_DIRS
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/providers"
SRC_DIRS
"${CMAKE_CURRENT_LIST_DIR}"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/bridge-app/zap-generated"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated/attributes"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server"
Expand Down
2 changes: 2 additions & 0 deletions examples/chip-tool/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ static_library("chip-tool-utils") {
"commands/common/Commands.h",
"commands/common/CredentialIssuerCommands.h",
"commands/common/HexConversion.h",
"commands/common/RemoteDataModelLogger.cpp",
"commands/common/RemoteDataModelLogger.h",
"commands/delay/SleepCommand.cpp",
"commands/delay/WaitForCommissioneeCommand.cpp",
"commands/discover/DiscoverCommand.cpp",
Expand Down
6 changes: 3 additions & 3 deletions examples/chip-tool/commands/clusters/ClusterCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class ClusterCommand : public InteractionModelCommands, public ModelCommand, pub
CHIP_ERROR error = status.ToChipError();
if (CHIP_NO_ERROR != error)
{
ReturnOnFailure(DataModelLogger::LogErrorAsJSON(path, status));
ReturnOnFailure(RemoteDataModelLogger::LogErrorAsJSON(path, status));

ChipLogError(chipTool, "Response Failure: %s", chip::ErrorStr(error));
mError = error;
Expand All @@ -83,7 +83,7 @@ class ClusterCommand : public InteractionModelCommands, public ModelCommand, pub

if (data != nullptr)
{
ReturnOnFailure(DataModelLogger::LogCommandAsJSON(path, data));
ReturnOnFailure(RemoteDataModelLogger::LogCommandAsJSON(path, data));

error = DataModelLogger::LogCommand(path, data);
if (CHIP_NO_ERROR != error)
Expand All @@ -97,7 +97,7 @@ class ClusterCommand : public InteractionModelCommands, public ModelCommand, pub

virtual void OnError(const chip::app::CommandSender * client, CHIP_ERROR error) override
{
ReturnOnFailure(DataModelLogger::LogErrorAsJSON(error));
ReturnOnFailure(RemoteDataModelLogger::LogErrorAsJSON(error));

ChipLogProgress(chipTool, "Error: %s", chip::ErrorStr(error));
mError = error;
Expand Down
130 changes: 1 addition & 129 deletions examples/chip-tool/commands/clusters/DataModelLogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,8 @@
#include <app/EventHeader.h>
#include <app/MessageDef/StatusIB.h>
#include <app/data-model/DecodableList.h>
#include <commands/common/RemoteDataModelLogger.h>
#include <lib/support/BytesToHex.h>
#include <lib/support/jsontlv/TlvJson.h>

constexpr const char * kClusterIdKey = "clusterId";
constexpr const char * kEndpointIdKey = "endpointId";
constexpr const char * kAttributeIdKey = "attributeId";
constexpr const char * kEventIdKey = "eventId";
constexpr const char * kCommandIdKey = "commandId";
constexpr const char * kErrorIdKey = "error";
constexpr const char * kClusterErrorIdKey = "clusterError";

class DataModelLoggerJSONDelegate
{
public:
CHIP_ERROR virtual LogJSON(const char *) = 0;
virtual ~DataModelLoggerJSONDelegate(){};
};

class DataModelLogger
{
Expand All @@ -51,119 +36,7 @@ class DataModelLogger
static CHIP_ERROR LogCommand(const chip::app::ConcreteCommandPath & path, chip::TLV::TLVReader * data);
static CHIP_ERROR LogEvent(const chip::app::EventHeader & header, chip::TLV::TLVReader * data);

static CHIP_ERROR LogAttributeAsJSON(const chip::app::ConcreteDataAttributePath & path, chip::TLV::TLVReader * data)
{
VerifyOrReturnError(mJSONDelegate != nullptr, CHIP_NO_ERROR);

Json::Value value;
value[kClusterIdKey] = path.mClusterId;
value[kEndpointIdKey] = path.mEndpointId;
value[kAttributeIdKey] = path.mAttributeId;

chip::TLV::TLVReader reader;
reader.Init(*data);
ReturnErrorOnFailure(chip::TlvToJson(reader, value));

auto valueStr = chip::JsonToString(value);
return mJSONDelegate->LogJSON(valueStr.c_str());
}

static CHIP_ERROR LogErrorAsJSON(const chip::app::ConcreteDataAttributePath & path, const chip::app::StatusIB & status)
{
VerifyOrReturnError(mJSONDelegate != nullptr, CHIP_NO_ERROR);

Json::Value value;
value[kClusterIdKey] = path.mClusterId;
value[kEndpointIdKey] = path.mEndpointId;
value[kAttributeIdKey] = path.mAttributeId;

return LogError(value, status);
}

static CHIP_ERROR LogCommandAsJSON(const chip::app::ConcreteCommandPath & path, chip::TLV::TLVReader * data)
{
VerifyOrReturnError(mJSONDelegate != nullptr, CHIP_NO_ERROR);

Json::Value value;
value[kClusterIdKey] = path.mClusterId;
value[kEndpointIdKey] = path.mEndpointId;
value[kCommandIdKey] = path.mCommandId;

chip::TLV::TLVReader reader;
reader.Init(*data);
ReturnErrorOnFailure(chip::TlvToJson(reader, value));

auto valueStr = chip::JsonToString(value);
return mJSONDelegate->LogJSON(valueStr.c_str());
}

static CHIP_ERROR LogErrorAsJSON(const chip::app::ConcreteCommandPath & path, const chip::app::StatusIB & status)
{
VerifyOrReturnError(mJSONDelegate != nullptr, CHIP_NO_ERROR);

Json::Value value;
value[kClusterIdKey] = path.mClusterId;
value[kEndpointIdKey] = path.mEndpointId;
value[kCommandIdKey] = path.mCommandId;

return LogError(value, status);
}

static CHIP_ERROR LogEventAsJSON(const chip::app::EventHeader & header, chip::TLV::TLVReader * data)
{
VerifyOrReturnError(mJSONDelegate != nullptr, CHIP_NO_ERROR);

Json::Value value;
value[kClusterIdKey] = header.mPath.mClusterId;
value[kEndpointIdKey] = header.mPath.mEndpointId;
value[kEventIdKey] = header.mPath.mEventId;

chip::TLV::TLVReader reader;
reader.Init(*data);
ReturnErrorOnFailure(chip::TlvToJson(reader, value));

auto valueStr = chip::JsonToString(value);
return mJSONDelegate->LogJSON(valueStr.c_str());
}

static CHIP_ERROR LogErrorAsJSON(const chip::app::EventHeader & header, const chip::app::StatusIB & status)
{
VerifyOrReturnError(mJSONDelegate != nullptr, CHIP_NO_ERROR);

Json::Value value;
value[kClusterIdKey] = header.mPath.mClusterId;
value[kEndpointIdKey] = header.mPath.mEndpointId;
value[kEventIdKey] = header.mPath.mEventId;

return LogError(value, status);
}

static CHIP_ERROR LogErrorAsJSON(const CHIP_ERROR & error)
{
Json::Value value;
chip::app::StatusIB status;
status.InitFromChipError(error);
return LogError(value, status);
}

static void SetJSONDelegate(DataModelLoggerJSONDelegate * delegate) { mJSONDelegate = delegate; }

private:
static CHIP_ERROR LogError(Json::Value & value, const chip::app::StatusIB & status)
{
if (status.mClusterStatus.HasValue())
{
auto statusValue = status.mClusterStatus.Value();
value[kClusterErrorIdKey] = statusValue;
}

auto statusName = chip::Protocols::InteractionModel::StatusName(status.mStatus);
value[kErrorIdKey] = statusName;

auto valueStr = chip::JsonToString(value);
return mJSONDelegate->LogJSON(valueStr.c_str());
}

static CHIP_ERROR LogValue(const char * label, size_t indent, bool value)
{
DataModelLogger::LogString(label, indent, value ? "TRUE" : "FALSE");
Expand Down Expand Up @@ -323,5 +196,4 @@ class DataModelLogger
}

static size_t ComputePrefixSize(const std::string label, size_t indent) { return ComputePrefix(label, indent).size(); }
static DataModelLoggerJSONDelegate * mJSONDelegate;
};
6 changes: 3 additions & 3 deletions examples/chip-tool/commands/clusters/ReportCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ReportCommand : public InteractionModelReports, public ModelCommand, publi
CHIP_ERROR error = status.ToChipError();
if (CHIP_NO_ERROR != error)
{
ReturnOnFailure(DataModelLogger::LogErrorAsJSON(path, status));
ReturnOnFailure(RemoteDataModelLogger::LogErrorAsJSON(path, status));

ChipLogError(chipTool, "Response Failure: %s", chip::ErrorStr(error));
mError = error;
Expand All @@ -51,7 +51,7 @@ class ReportCommand : public InteractionModelReports, public ModelCommand, publi
return;
}

ReturnOnFailure(DataModelLogger::LogAttributeAsJSON(path, data));
ReturnOnFailure(RemoteDataModelLogger::LogAttributeAsJSON(path, data));

error = DataModelLogger::LogAttribute(path, data);
if (CHIP_NO_ERROR != error)
Expand All @@ -70,7 +70,7 @@ class ReportCommand : public InteractionModelReports, public ModelCommand, publi
CHIP_ERROR error = status->ToChipError();
if (CHIP_NO_ERROR != error)
{
ReturnOnFailure(DataModelLogger::LogErrorAsJSON(eventHeader, *status));
ReturnOnFailure(RemoteDataModelLogger::LogErrorAsJSON(eventHeader, *status));

ChipLogError(chipTool, "Response Failure: %s", chip::ErrorStr(error));
mError = error;
Expand Down
Loading

0 comments on commit d6c6b99

Please sign in to comment.