diff --git a/examples/tv-casting-app/linux/simple-app-helper.h b/examples/tv-casting-app/linux/simple-app-helper.h index 90d6379b9fa4bb..5003d32851909a 100644 --- a/examples/tv-casting-app/linux/simple-app-helper.h +++ b/examples/tv-casting-app/linux/simple-app-helper.h @@ -30,6 +30,9 @@ */ const uint64_t kTargetPlayerDeviceType = 35; +/** + * @brief Test values used for demo command and attribute read/subscribe calls + */ const char kContentURL[] = "https://www.test.com/videoid"; const char kContentDisplayStr[] = "Test video"; const unsigned short kTimedInvokeCommandTimeoutMs = 5 * 1000; diff --git a/examples/tv-casting-app/tv-casting-common/clusters/Clusters.h b/examples/tv-casting-app/tv-casting-common/clusters/Clusters.h index 0aef66af086c3b..2da2f61e4825aa 100644 --- a/examples/tv-casting-app/tv-casting-common/clusters/Clusters.h +++ b/examples/tv-casting-app/tv-casting-common/clusters/Clusters.h @@ -24,6 +24,9 @@ #include +/** + * @brief This file contains classes representing all the Matter clusters supported by the Matter TV Casting library + */ namespace matter { namespace casting { namespace clusters { diff --git a/examples/tv-casting-app/tv-casting-common/core/Attribute.h b/examples/tv-casting-app/tv-casting-common/core/Attribute.h index a1f4177b9e6516..8bd3db78a9af2d 100644 --- a/examples/tv-casting-app/tv-casting-common/core/Attribute.h +++ b/examples/tv-casting-app/tv-casting-common/core/Attribute.h @@ -26,8 +26,6 @@ namespace matter { namespace casting { namespace core { -using WriteAttributeCallback = std::function; - template using ReadResponseSuccessCallbackFn = std::function before, TypeInfoDecodableType after)>; @@ -67,6 +65,14 @@ class Attribute return hasValue ? chip::MakeOptional(value) : chip::NullOptional; } + /** + * @brief Reads the value of the Attribute that belongs to the associated Endpoint and corresponding Cluster + * + * @param context + * @param successCb Called when the Attribute is read successfully, with the value of the attribute after reading, as well as + * before (if the Attribute had been previously read) + * @param failureCb Called when there is a failure in reading the Attribute + */ void Read(void * context, ReadResponseSuccessCallbackFn successCb, ReadResponseFailureCallbackFn failureCb) { @@ -149,6 +155,15 @@ class Attribute } } + /** + * @brief Writes the value of the Attribute to an associated Endpoint and corresponding Cluster + * + * @param requestData value of the Attribute to be written + * @param context + * @param successCb Called when the Attribute is written successfully + * @param failureCb Called when there is a failure in writing the Attribute + * @param aTimedWriteTimeoutMs write timeout + */ void Write(const typename TypeInfo::Type & requestData, void * context, WriteResponseSuccessCallbackFn successCb, WriteResponseFailureCallbackFn failureCb, const chip::Optional & aTimedWriteTimeoutMs) { @@ -222,6 +237,16 @@ class Attribute } } + /** + * @brief Subscribes to the value of the Attribute that belongs to the associated Endpoint and corresponding Cluster + * + * @param context + * @param successCb Called when the Attribute is read successfully, with the value of the attribute after reading, as well as + * before (if the Attribute had been previously read) + * @param failureCb Called when there is a failure in reading the Attribute + * @param minIntervalFloorSeconds + * @param maxIntervalCeilingSeconds + */ void Subscribe(void * context, ReadResponseSuccessCallbackFn successCb, ReadResponseFailureCallbackFn failureCb, uint16_t minIntervalFloorSeconds, uint16_t maxIntervalCeilingSeconds) { @@ -309,6 +334,9 @@ class Attribute } }; +/** + * @brief Context object used by the Attribute class during the Read API's execution + */ template struct ReadAttributeContext { @@ -327,6 +355,9 @@ struct ReadAttributeContext ReadResponseFailureCallbackFn mFailureCb; }; +/** + * @brief Context object used by the Attribute class during the Write API's execution + */ template struct WriteAttributeContext { @@ -350,6 +381,9 @@ struct WriteAttributeContext chip::Optional & mTimedWriteTimeoutMs; }; +/** + * @brief Context object used by the Attribute class during the Subscribe API's execution + */ template struct SubscribeAttributeContext { diff --git a/examples/tv-casting-app/tv-casting-common/core/BaseCluster.h b/examples/tv-casting-app/tv-casting-common/core/BaseCluster.h index 7e842e11df913b..e98f690cee0087 100644 --- a/examples/tv-casting-app/tv-casting-common/core/BaseCluster.h +++ b/examples/tv-casting-app/tv-casting-common/core/BaseCluster.h @@ -50,12 +50,30 @@ class BaseCluster memory::Weak GetEndpoint() const { return mEndpoint.lock(); } + /** + * @brief Registers Commands and Attributes to this cluster + */ virtual void SetUp() {} + + /** + * @return Pointer to the Attribute registered in this cluster, corresponding to attributeId + */ void * GetAttribute(const chip::AttributeId attributeId) { return mAttributes[attributeId]; } + + /** + * @return Pointer to the Command registered in this cluster, corresponding to commandId + */ void * GetCommand(const chip::CommandId commandId) { return mCommands[commandId]; } protected: + /** + * @brief Registers the attribute (expected to be of type Attribute *) against the attributeId in this cluster + */ void RegisterAttribute(const chip::AttributeId attributeId, void * attribute) { mAttributes[attributeId] = attribute; } + + /** + * @brief Registers the command (expected to be of type Command *) against the commandId in this cluster + */ void RegisterCommand(const chip::CommandId commandId, void * command) { mCommands[commandId] = command; } memory::Weak mEndpoint; diff --git a/examples/tv-casting-app/tv-casting-common/core/Command.h b/examples/tv-casting-app/tv-casting-common/core/Command.h index 92b0e6838ece4a..1840f4446928ed 100644 --- a/examples/tv-casting-app/tv-casting-common/core/Command.h +++ b/examples/tv-casting-app/tv-casting-common/core/Command.h @@ -39,6 +39,15 @@ class Command public: Command(memory::Weak endpoint) { this->mEndpoint = endpoint; } + /** + * @brief Invokes this command on the associated Endpoint and corresponding Cluster + * + * @param request request data corresponding to this command invocation + * @param context + * @param successCb Called on command execution success, with responseData + * @param failureCb Called on command execution failure + * @param timedInvokeTimeoutMs command timeout + */ void Invoke(RequestType request, void * context, CommandSuccessCallbackType successCb, CommandFailureCallbackType failureCb, const chip::Optional & timedInvokeTimeoutMs) { @@ -112,6 +121,9 @@ class Command memory::Weak mEndpoint; }; +/** + * @brief Context object used by the Command class during the Invoke API's execution + */ template struct CommandContext {