Skip to content

Commit

Permalink
Fixed linter/CI issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sharadb-amazon committed Dec 22, 2023
1 parent 39b0f94 commit dd24db4
Showing 1 changed file with 59 additions and 62 deletions.
121 changes: 59 additions & 62 deletions examples/tv-casting-app/tv-casting-common/core/Attribute.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,44 +85,44 @@ class Attribute
endpoint->GetCastingPlayer()->FindOrEstablishSession(
attributeContext,
// FindOrEstablishSession success handler
[](void * context, chip::Messaging::ExchangeManager & exchangeMgr, const chip::SessionHandle & sessionHandle) {
[](void * _context, chip::Messaging::ExchangeManager & exchangeMgr, const chip::SessionHandle & sessionHandle) {
ReadAttributeContext<typename TypeInfo::DecodableType> * _attributeContext =
static_cast<ReadAttributeContext<typename TypeInfo::DecodableType> *>(context);
static_cast<ReadAttributeContext<typename TypeInfo::DecodableType> *>(_context);
ChipLogProgress(AppServer, "<Attribute>::Read() Found or established session");

// Read attribute
MediaClusterBase mediaClusterBase(exchangeMgr, sessionHandle, _attributeContext->mEndpoint->GetId());
CHIP_ERROR err = mediaClusterBase.template ReadAttribute<TypeInfo>(
_attributeContext,
// Read success handler
[](void * context, typename TypeInfo::DecodableType response) {
ReadAttributeContext<typename TypeInfo::DecodableType> * _attributeContext =
static_cast<ReadAttributeContext<typename TypeInfo::DecodableType> *>(context);
[](void * __context, typename TypeInfo::DecodableType response) {
ReadAttributeContext<typename TypeInfo::DecodableType> * __attributeContext =
static_cast<ReadAttributeContext<typename TypeInfo::DecodableType> *>(__context);
ChipLogProgress(AppServer, "<Attribute>::Read() success");
Attribute<TypeInfo> * _attribute = static_cast<Attribute<TypeInfo> *>(_attributeContext->mAttribute);
_attribute->value = response;
if (_attribute->hasValue)
Attribute<TypeInfo> * __attr = static_cast<Attribute<TypeInfo> *>(__attributeContext->mAttribute);
__attr->value = response;
if (__attr->hasValue)
{
_attributeContext->mSuccessCb(_attributeContext->mClientContext,
chip::MakeOptional(_attribute->value), response);
__attributeContext->mSuccessCb(__attributeContext->mClientContext,
chip::MakeOptional(__attr->value), response);
}
else
{
_attribute->hasValue = true;
_attributeContext->mSuccessCb(_attributeContext->mClientContext, chip::NullOptional, response);
__attr->hasValue = true;
__attributeContext->mSuccessCb(__attributeContext->mClientContext, chip::NullOptional, response);
}
delete _attributeContext;
delete __attributeContext;
},
// Read failure handler
[](void * context, CHIP_ERROR error) {
ReadAttributeContext<typename TypeInfo::DecodableType> * _attributeContext =
static_cast<ReadAttributeContext<typename TypeInfo::DecodableType> *>(context);
[](void * __context, CHIP_ERROR error) {
ReadAttributeContext<typename TypeInfo::DecodableType> * __attributeContext =
static_cast<ReadAttributeContext<typename TypeInfo::DecodableType> *>(__context);
ChipLogError(AppServer,
"<Attribute>::Read() failure response on EndpointId: %d with error: "
"%" CHIP_ERROR_FORMAT,
_attributeContext->mEndpoint->GetId(), error.Format());
_attributeContext->mFailureCb(_attributeContext->mClientContext, error);
delete _attributeContext;
__attributeContext->mEndpoint->GetId(), error.Format());
__attributeContext->mFailureCb(__attributeContext->mClientContext, error);
delete __attributeContext;
});

// error in reading the attribute
Expand All @@ -137,9 +137,9 @@ class Attribute
}
},
// FindOrEstablishSession failure handler
[](void * context, const chip::ScopedNodeId & peerId, CHIP_ERROR error) {
[](void * _context, const chip::ScopedNodeId & peerId, CHIP_ERROR error) {
ReadAttributeContext<typename TypeInfo::DecodableType> * _attributeContext =
static_cast<ReadAttributeContext<typename TypeInfo::DecodableType> *>(context);
static_cast<ReadAttributeContext<typename TypeInfo::DecodableType> *>(_context);
ChipLogError(AppServer,
"<Attribute>::Read() failure in retrieving session info for peerId.nodeId: "
"0x" ChipLogFormatX64 ", peer.fabricIndex: %d with error: %" CHIP_ERROR_FORMAT,
Expand Down Expand Up @@ -176,34 +176,33 @@ class Attribute
endpoint->GetCastingPlayer()->FindOrEstablishSession(
attributeContext,
// FindOrEstablishSession success handler
[](void * context, chip::Messaging::ExchangeManager & exchangeMgr, const chip::SessionHandle & sessionHandle) {
[](void * _context, chip::Messaging::ExchangeManager & exchangeMgr, const chip::SessionHandle & sessionHandle) {
WriteAttributeContext<typename TypeInfo::Type> * _attributeContext =
static_cast<WriteAttributeContext<typename TypeInfo::Type> *>(context);
static_cast<WriteAttributeContext<typename TypeInfo::Type> *>(_context);
ChipLogProgress(AppServer, "<Attribute>::Write() Found or established session");

// Write attribute
MediaClusterBase mediaClusterBase(exchangeMgr, sessionHandle, _attributeContext->mEndpoint->GetId());
CHIP_ERROR err = mediaClusterBase.template WriteAttribute<TypeInfo>(
_attributeContext->mRequestData, _attributeContext,
// Write success handler
[](void * context) {
WriteAttributeContext<typename TypeInfo::Type> * _attributeContext =
static_cast<WriteAttributeContext<typename TypeInfo::Type> *>(context);
[](void * __context) {
WriteAttributeContext<typename TypeInfo::Type> * __attributeContext =
static_cast<WriteAttributeContext<typename TypeInfo::Type> *>(__context);
ChipLogProgress(AppServer, "<Attribute>::Write() success");
Attribute<TypeInfo> * _attribute = static_cast<Attribute<TypeInfo> *>(_attributeContext->mAttribute);
_attributeContext->mSuccessCb(_attributeContext->mClientContext);
delete _attributeContext;
__attributeContext->mSuccessCb(__attributeContext->mClientContext);
delete __attributeContext;
},
// Write failure handler
[](void * context, CHIP_ERROR error) {
WriteAttributeContext<typename TypeInfo::Type> * _attributeContext =
static_cast<WriteAttributeContext<typename TypeInfo::Type> *>(context);
[](void * __context, CHIP_ERROR error) {
WriteAttributeContext<typename TypeInfo::Type> * __attributeContext =
static_cast<WriteAttributeContext<typename TypeInfo::Type> *>(__context);
ChipLogError(AppServer,
"<Attribute>::Write() failure response on EndpointId: %d with error: "
"%" CHIP_ERROR_FORMAT,
_attributeContext->mEndpoint->GetId(), error.Format());
_attributeContext->mFailureCb(_attributeContext->mClientContext, error);
delete _attributeContext;
__attributeContext->mEndpoint->GetId(), error.Format());
__attributeContext->mFailureCb(__attributeContext->mClientContext, error);
delete __attributeContext;
},
_attributeContext->mTimedWriteTimeoutMs);

Expand All @@ -219,9 +218,9 @@ class Attribute
}
},
// FindOrEstablishSession failure handler
[](void * context, const chip::ScopedNodeId & peerId, CHIP_ERROR error) {
[](void * _context, const chip::ScopedNodeId & peerId, CHIP_ERROR error) {
WriteAttributeContext<typename TypeInfo::Type> * _attributeContext =
static_cast<WriteAttributeContext<typename TypeInfo::Type> *>(context);
static_cast<WriteAttributeContext<typename TypeInfo::Type> *>(_context);
ChipLogError(AppServer,
"<Attribute>::Write() failure in retrieving session info for peerId.nodeId: "
"0x" ChipLogFormatX64 ", peer.fabricIndex: %d with error: %" CHIP_ERROR_FORMAT,
Expand Down Expand Up @@ -260,44 +259,44 @@ class Attribute
endpoint->GetCastingPlayer()->FindOrEstablishSession(
attributeContext,
// FindOrEstablishSession success handler
[](void * context, chip::Messaging::ExchangeManager & exchangeMgr, const chip::SessionHandle & sessionHandle) {
[](void * _context, chip::Messaging::ExchangeManager & exchangeMgr, const chip::SessionHandle & sessionHandle) {
SubscribeAttributeContext<typename TypeInfo::DecodableType> * _attributeContext =
static_cast<SubscribeAttributeContext<typename TypeInfo::DecodableType> *>(context);
static_cast<SubscribeAttributeContext<typename TypeInfo::DecodableType> *>(_context);
ChipLogProgress(AppServer, "<Attribute>::Subscribe() Found or established session");

// Subscribe to attribute
MediaClusterBase mediaClusterBase(exchangeMgr, sessionHandle, _attributeContext->mEndpoint->GetId());
CHIP_ERROR err = mediaClusterBase.template SubscribeAttribute<TypeInfo>(
_attributeContext,
// Subscription success handler
[](void * context, typename TypeInfo::DecodableType response) {
SubscribeAttributeContext<typename TypeInfo::DecodableType> * _attributeContext =
static_cast<SubscribeAttributeContext<typename TypeInfo::DecodableType> *>(context);
[](void * __context, typename TypeInfo::DecodableType response) {
SubscribeAttributeContext<typename TypeInfo::DecodableType> * __attributeContext =
static_cast<SubscribeAttributeContext<typename TypeInfo::DecodableType> *>(__context);
ChipLogProgress(AppServer, "<Attribute>::Subscribe() success");
Attribute<TypeInfo> * _attribute = static_cast<Attribute<TypeInfo> *>(_attributeContext->mAttribute);
_attribute->value = response;
if (_attribute->hasValue)
Attribute<TypeInfo> * __attr = static_cast<Attribute<TypeInfo> *>(__attributeContext->mAttribute);
__attr->value = response;
if (__attr->hasValue)
{
_attributeContext->mSuccessCb(_attributeContext->mClientContext,
chip::MakeOptional(_attribute->value), response);
__attributeContext->mSuccessCb(__attributeContext->mClientContext,
chip::MakeOptional(__attr->value), response);
}
else
{
_attribute->hasValue = true;
_attributeContext->mSuccessCb(_attributeContext->mClientContext, chip::NullOptional, response);
__attr->hasValue = true;
__attributeContext->mSuccessCb(__attributeContext->mClientContext, chip::NullOptional, response);
}
delete _attributeContext;
delete __attributeContext;
},
// Subscription failure handler
[](void * context, CHIP_ERROR error) {
SubscribeAttributeContext<typename TypeInfo::DecodableType> * _attributeContext =
static_cast<SubscribeAttributeContext<typename TypeInfo::DecodableType> *>(context);
[](void * __context, CHIP_ERROR error) {
SubscribeAttributeContext<typename TypeInfo::DecodableType> * __attributeContext =
static_cast<SubscribeAttributeContext<typename TypeInfo::DecodableType> *>(__context);
ChipLogError(AppServer,
"<Attribute>::Subscribe() failure response on EndpointId: %d with error: "
"%" CHIP_ERROR_FORMAT,
_attributeContext->mEndpoint->GetId(), error.Format());
_attributeContext->mFailureCb(_attributeContext->mClientContext, error);
delete _attributeContext;
__attributeContext->mEndpoint->GetId(), error.Format());
__attributeContext->mFailureCb(__attributeContext->mClientContext, error);
delete __attributeContext;
},
_attributeContext->mMinIntervalFloorSeconds, _attributeContext->mMaxIntervalCeilingSeconds,
nullptr /* SubscriptionEstablishedCallback */, nullptr /* ResubscriptionAttemptCallback */,
Expand All @@ -315,9 +314,9 @@ class Attribute
}
},
// FindOrEstablishSession failure handler
[](void * context, const chip::ScopedNodeId & peerId, CHIP_ERROR error) {
[](void * _context, const chip::ScopedNodeId & peerId, CHIP_ERROR error) {
SubscribeAttributeContext<typename TypeInfo::DecodableType> * _attributeContext =
static_cast<SubscribeAttributeContext<typename TypeInfo::DecodableType> *>(context);
static_cast<SubscribeAttributeContext<typename TypeInfo::DecodableType> *>(_context);
ChipLogError(AppServer,
"<Attribute>::Subscribe() failure in retrieving session info for peerId.nodeId: "
"0x" ChipLogFormatX64 ", peer.fabricIndex: %d with error: %" CHIP_ERROR_FORMAT,
Expand Down Expand Up @@ -361,18 +360,16 @@ struct ReadAttributeContext
template <typename TypeInfoType>
struct WriteAttributeContext
{
WriteAttributeContext(void * attribute, memory::Strong<core::Endpoint> endpoint, const TypeInfoType & requestData,
void * clientContext, WriteResponseSuccessCallbackFn successCb, WriteResponseFailureCallbackFn failureCb,
WriteAttributeContext(memory::Strong<core::Endpoint> endpoint, const TypeInfoType & requestData, void * clientContext,
WriteResponseSuccessCallbackFn successCb, WriteResponseFailureCallbackFn failureCb,
const chip::Optional<uint16_t> & timedWriteTimeoutMs) :
mEndpoint(endpoint),
mClientContext(clientContext), mSuccessCb(successCb), mFailureCb(failureCb)
{
mAttribute = attribute;
mRequestData = requestData;
mTimedWriteTimeoutMs = timedWriteTimeoutMs;
}

void * mAttribute;
memory::Strong<core::Endpoint> mEndpoint;
TypeInfoType mRequestData;
void * mClientContext;
Expand Down

0 comments on commit dd24db4

Please sign in to comment.