Merge branch 'keypad-input' into 'main'

Add keypad-input cluster

See merge request app-frameworks/esp-matter!566
This commit is contained in:
Hrishikesh Dhayagude
2024-01-12 13:50:15 +08:00
6 changed files with 169 additions and 4 deletions
+41 -4
View File
@@ -3244,6 +3244,47 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
}
} /* rvc_operational_state */
namespace keypad_input {
const function_generic_t *function_list = NULL;
const int function_flags = CLUSTER_FLAG_NONE;
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
{
cluster_t *cluster = cluster::create(endpoint, KeypadInput::Id, flags);
if (!cluster) {
ESP_LOGE(TAG, "Could not create cluster");
return NULL;
}
if (flags & CLUSTER_FLAG_CLIENT) {
create_default_binding_cluster(endpoint);
}
if (flags & CLUSTER_FLAG_SERVER) {
add_function_list(cluster, function_list, function_flags);
/* Attributes managed internally */
global::attribute::create_feature_map(cluster, 0);
#if CHIP_CONFIG_ENABLE_EVENTLIST_ATTRIBUTE
global::attribute::create_event_list(cluster, NULL, 0, 0);
#endif
/* Attributes not managed internally */
if (config) {
global::attribute::create_cluster_revision(cluster, config->cluster_revision);
} else {
ESP_LOGE(TAG, "Config is NULL. Cannot add some attributes.");
}
}
/* Commands */
command::create_send_key(cluster);
command::create_send_key_response(cluster);
return cluster;
}
} /* keypad_input */
// namespace binary_input_basic {
// // ToDo
// } /* binary_input_basic */
@@ -3304,10 +3345,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
// // ToDo
// } /* lowpower */
// namespace keypad_input {
// // ToDo
// } /* keypad_input */
// namespace content_launcher {
// // ToDo
// } /* content_launcher */
@@ -777,5 +777,14 @@ typedef struct config {
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags);
} /* rvc_operational_state */
namespace keypad_input {
typedef struct config {
uint16_t cluster_revision;
config() : cluster_revision(1) {}
} config_t;
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags);
} /* keypad_input */
} /* cluster */
} /* esp_matter */
@@ -1227,6 +1227,16 @@ static esp_err_t esp_matter_command_callback_disable_action_with_duration(const
return ESP_OK;
}
static esp_err_t esp_matter_command_callback_send_key(const ConcreteCommandPath &command_path, TLVReader &tlv_data, void *opaque_ptr)
{
chip::app::Clusters::KeypadInput::Commands::SendKey::DecodableType command_data;
CHIP_ERROR error = Decode(tlv_data, command_data);
if (error == CHIP_NO_ERROR) {
emberAfKeypadInputClusterSendKeyCallback((CommandHandler *)opaque_ptr, command_path, command_data);
}
return ESP_OK;
}
namespace esp_matter {
namespace cluster {
@@ -2353,6 +2363,21 @@ command_t *create_change_to_mode(cluster_t *cluster)
} /* command */
} /* rvc_clean_mode */
namespace keypad_input {
namespace command {
command_t *create_send_key(cluster_t *cluster)
{
return esp_matter::command::create(cluster, KeypadInput::Commands::SendKey::Id, COMMAND_FLAG_ACCEPTED, esp_matter_command_callback_send_key);
}
command_t *create_send_key_response(cluster_t *cluster)
{
return esp_matter::command::create(cluster, KeypadInput::Commands::SendKeyResponse::Id, COMMAND_FLAG_GENERATED, NULL);
}
} /* command */
} /* keypad_input */
} /* cluster */
} /* esp_matter */
@@ -359,5 +359,12 @@ command_t *create_change_to_mode(cluster_t *cluster);
} /* command */
} /* rvc_clean_mode */
namespace keypad_input {
namespace command {
command_t *create_send_key(cluster_t *cluster);
command_t *create_send_key_response(cluster_t *cluster);
} /* command */
} /* keypad_input */
} /* cluster */
} /* esp_matter */
@@ -3346,5 +3346,68 @@ esp_err_t add(cluster_t *cluster, config_t *config)
} /* feature */
} /* fan_control */
namespace keypad_input {
namespace feature {
namespace navigation_key_codes {
uint32_t get_id()
{
return (uint32_t)KeypadInput::Feature::kNavigationKeyCodes;
}
esp_err_t add(cluster_t *cluster)
{
if (!cluster) {
ESP_LOGE(TAG, "Cluster cannot be NULL");
return ESP_ERR_INVALID_ARG;
}
update_feature_map(cluster, get_id());
return ESP_OK;
}
} /* navigation_key_codes */
namespace location_keys {
uint32_t get_id()
{
return (uint32_t)KeypadInput::Feature::kLocationKeys;
}
esp_err_t add(cluster_t *cluster)
{
if (!cluster) {
ESP_LOGE(TAG, "Cluster cannot be NULL");
return ESP_ERR_INVALID_ARG;
}
update_feature_map(cluster, get_id());
return ESP_OK;
}
} /* location_keys */
namespace number_keys {
uint32_t get_id()
{
return (uint32_t)KeypadInput::Feature::kNumberKeys;
}
esp_err_t add(cluster_t *cluster)
{
if (!cluster) {
ESP_LOGE(TAG, "Cluster cannot be NULL");
return ESP_ERR_INVALID_ARG;
}
update_feature_map(cluster, get_id());
return ESP_OK;
}
} /* number_keys */
} /* feature */
} /* keypad_input */
} /* cluster */
} /* esp_matter */
@@ -1542,5 +1542,29 @@ esp_err_t add(cluster_t *cluster, config_t *config);
} /* feature */
} /* fan_control */
namespace keypad_input {
namespace feature {
namespace navigation_key_codes {
uint32_t get_id();
esp_err_t add(cluster_t *cluster);
} /* navigation_key_codes */
namespace location_keys {
uint32_t get_id();
esp_err_t add(cluster_t *cluster);
} /* location_keys */
namespace number_keys {
uint32_t get_id();
esp_err_t add(cluster_t *cluster);
} /* number_keys */
} /* feature */
} /* keypad_input */
} /* cluster */
} /* esp_matter */