Skip to content

Commit

Permalink
Docs
Browse files Browse the repository at this point in the history
  • Loading branch information
sharadb-amazon committed Dec 21, 2023
1 parent a4bb8bb commit a04dd42
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 2 deletions.
3 changes: 3 additions & 0 deletions examples/tv-casting-app/linux/simple-app-helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions examples/tv-casting-app/tv-casting-common/clusters/Clusters.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@

#include <app-common/zap-generated/cluster-objects.h>

/**
* @brief This file contains classes representing all the Matter clusters supported by the Matter TV Casting library
*/
namespace matter {
namespace casting {
namespace clusters {
Expand Down
38 changes: 36 additions & 2 deletions examples/tv-casting-app/tv-casting-common/core/Attribute.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ namespace matter {
namespace casting {
namespace core {

using WriteAttributeCallback = std::function<void(void * context, CHIP_ERROR)>;

template <typename TypeInfoDecodableType>
using ReadResponseSuccessCallbackFn =
std::function<void(void * context, chip::Optional<TypeInfoDecodableType> before, TypeInfoDecodableType after)>;
Expand Down Expand Up @@ -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<typename TypeInfo::DecodableType> successCb,
ReadResponseFailureCallbackFn failureCb)
{
Expand Down Expand Up @@ -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<uint16_t> & aTimedWriteTimeoutMs)
{
Expand Down Expand Up @@ -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<typename TypeInfo::DecodableType> successCb,
ReadResponseFailureCallbackFn failureCb, uint16_t minIntervalFloorSeconds, uint16_t maxIntervalCeilingSeconds)
{
Expand Down Expand Up @@ -309,6 +334,9 @@ class Attribute
}
};

/**
* @brief Context object used by the Attribute class during the Read API's execution
*/
template <typename TypeInfoDecodableType>
struct ReadAttributeContext
{
Expand All @@ -327,6 +355,9 @@ struct ReadAttributeContext
ReadResponseFailureCallbackFn mFailureCb;
};

/**
* @brief Context object used by the Attribute class during the Write API's execution
*/
template <typename TypeInfoType>
struct WriteAttributeContext
{
Expand All @@ -350,6 +381,9 @@ struct WriteAttributeContext
chip::Optional<uint16_t> & mTimedWriteTimeoutMs;
};

/**
* @brief Context object used by the Attribute class during the Subscribe API's execution
*/
template <typename TypeInfoDecodableType>
struct SubscribeAttributeContext
{
Expand Down
18 changes: 18 additions & 0 deletions examples/tv-casting-app/tv-casting-common/core/BaseCluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,30 @@ class BaseCluster

memory::Weak<Endpoint> 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<Endpoint> mEndpoint;
Expand Down
12 changes: 12 additions & 0 deletions examples/tv-casting-app/tv-casting-common/core/Command.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ class Command
public:
Command(memory::Weak<core::Endpoint> 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<typename RequestType::ResponseType> successCb,
CommandFailureCallbackType failureCb, const chip::Optional<uint16_t> & timedInvokeTimeoutMs)
{
Expand Down Expand Up @@ -112,6 +121,9 @@ class Command
memory::Weak<core::Endpoint> mEndpoint;
};

/**
* @brief Context object used by the Command class during the Invoke API's execution
*/
template <typename RequestType>
struct CommandContext
{
Expand Down

0 comments on commit a04dd42

Please sign in to comment.