mirror of
https://github.com/espressif/esp-matter.git
synced 2026-04-27 19:13:13 +00:00
CI: add astyle pre-commit hook
This commit is contained in:
@@ -60,7 +60,7 @@ static uint8_t idlePosition = 0;
|
||||
|
||||
static void app_driver_button_initial_pressed(void *arg, void *data)
|
||||
{
|
||||
if(!is_multipress) {
|
||||
if (!is_multipress) {
|
||||
ESP_LOGI(TAG, "Initial button pressed");
|
||||
gpio_button * button = (gpio_button*)data;
|
||||
int switch_endpoint_id = (button != NULL) ? get_endpoint(button) : 1;
|
||||
@@ -119,7 +119,7 @@ static void app_driver_button_multipress_ongoing(void *arg, void *data)
|
||||
uint32_t feature_map = val.val.u32;
|
||||
uint32_t msm_feature_map = switch_cluster::feature::momentary_switch_multi_press::get_id();
|
||||
uint32_t as_feature_map = switch_cluster::feature::action_switch::get_id();
|
||||
if(((feature_map & msm_feature_map) == msm_feature_map) && ((feature_map & as_feature_map) != as_feature_map)) {
|
||||
if (((feature_map & msm_feature_map) == msm_feature_map) && ((feature_map & as_feature_map) != as_feature_map)) {
|
||||
chip::DeviceLayer::SystemLayer().ScheduleLambda([switch_endpoint_id, newPosition]() {
|
||||
chip::app::Clusters::Switch::Attributes::CurrentPosition::Set(switch_endpoint_id, newPosition);
|
||||
// MultiPress Ongoing event takes newPosition and current_number_of_presses_counted as event data
|
||||
@@ -144,7 +144,7 @@ static void app_driver_button_multipress_complete(void *arg, void *data)
|
||||
esp_matter_attr_val_t val = esp_matter_invalid(NULL);
|
||||
attribute::get_val(attribute, &val);
|
||||
uint8_t multipress_max = val.val.u8;
|
||||
int total_number_of_presses_counted = (current_number_of_presses_counted > multipress_max)? 0:current_number_of_presses_counted;
|
||||
int total_number_of_presses_counted = (current_number_of_presses_counted > multipress_max) ? 0 : current_number_of_presses_counted;
|
||||
chip::DeviceLayer::SystemLayer().ScheduleLambda([switch_endpoint_id, previousPosition, total_number_of_presses_counted]() {
|
||||
chip::app::Clusters::Switch::Attributes::CurrentPosition::Set(switch_endpoint_id, idlePosition);
|
||||
// MultiPress Complete event takes previousPosition and total_number_of_presses_counted as event data
|
||||
@@ -182,7 +182,6 @@ app_driver_handle_t app_driver_button_init(gpio_button * button)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if CONFIG_GENERIC_SWITCH_TYPE_LATCHING
|
||||
iot_button_register_cb(handle, BUTTON_PRESS_DOWN, NULL, app_driver_button_switch_latched, button);
|
||||
#endif
|
||||
|
||||
@@ -56,10 +56,12 @@ constexpr const uint8_t kTagPositionRight = 1;
|
||||
|
||||
const Descriptor::Structs::SemanticTagStruct::Type gEp1TagList[] = {
|
||||
{.namespaceID = kNamespaceSwitches, .tag = kTagSwitchOn},
|
||||
{.namespaceID = kNamespacePosition, .tag = kTagPositionRight}};
|
||||
{.namespaceID = kNamespacePosition, .tag = kTagPositionRight}
|
||||
};
|
||||
const Descriptor::Structs::SemanticTagStruct::Type gEp2TagList[] = {
|
||||
{.namespaceID = kNamespaceSwitches, .tag = kTagSwitchOff},
|
||||
{.namespaceID = kNamespacePosition, .tag = kTagPositionLeft}};
|
||||
{.namespaceID = kNamespacePosition, .tag = kTagPositionLeft}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -136,7 +138,7 @@ static esp_err_t create_button(struct gpio_button* button, node_t* node)
|
||||
generic_switch::config_t switch_config;
|
||||
switch_config.switch_cluster.feature_flags =
|
||||
#if CONFIG_GENERIC_SWITCH_TYPE_LATCHING
|
||||
cluster::switch_cluster::feature::latching_switch::get_id();
|
||||
cluster::switch_cluster::feature::latching_switch::get_id();
|
||||
#endif
|
||||
|
||||
#if CONFIG_GENERIC_SWITCH_TYPE_MOMENTARY
|
||||
@@ -145,12 +147,11 @@ static esp_err_t create_button(struct gpio_button* button, node_t* node)
|
||||
|
||||
endpoint_t *endpoint = generic_switch::create(node, &switch_config, ENDPOINT_FLAG_NONE, button_handle);
|
||||
|
||||
cluster_t* descriptor = cluster::get(endpoint,Descriptor::Id);
|
||||
cluster_t* descriptor = cluster::get(endpoint, Descriptor::Id);
|
||||
descriptor::feature::tag_list::add(descriptor);
|
||||
|
||||
/* These node and endpoint handles can be used to create/add other endpoints and clusters. */
|
||||
if (!node || !endpoint)
|
||||
{
|
||||
if (!node || !endpoint) {
|
||||
ESP_LOGE(TAG, "Matter node creation failed");
|
||||
err = ESP_FAIL;
|
||||
return err;
|
||||
@@ -163,13 +164,11 @@ static esp_err_t create_button(struct gpio_button* button, node_t* node)
|
||||
}
|
||||
|
||||
/* Check for maximum physical buttons that can be configured. */
|
||||
if (configured_buttons <CONFIG_MAX_CONFIGURABLE_BUTTONS) {
|
||||
if (configured_buttons < CONFIG_MAX_CONFIGURABLE_BUTTONS) {
|
||||
button_list[configured_buttons].button = button;
|
||||
button_list[configured_buttons].endpoint = endpoint::get_id(endpoint);
|
||||
configured_buttons++;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
ESP_LOGI(TAG, "Cannot configure more buttons");
|
||||
err = ESP_FAIL;
|
||||
return err;
|
||||
@@ -192,7 +191,8 @@ static esp_err_t create_button(struct gpio_button* button, node_t* node)
|
||||
return err;
|
||||
}
|
||||
|
||||
int get_endpoint(gpio_button* button) {
|
||||
int get_endpoint(gpio_button* button)
|
||||
{
|
||||
for (int i = 0; i < configured_buttons; i++) {
|
||||
if (button_list[i].button == button) {
|
||||
return button_list[i].endpoint;
|
||||
|
||||
@@ -16,13 +16,11 @@
|
||||
#include "esp_openthread_types.h"
|
||||
#endif
|
||||
|
||||
struct gpio_button
|
||||
{
|
||||
gpio_num_t GPIO_PIN_VALUE;
|
||||
struct gpio_button {
|
||||
gpio_num_t GPIO_PIN_VALUE;
|
||||
};
|
||||
|
||||
struct button_endpoint
|
||||
{
|
||||
struct button_endpoint {
|
||||
gpio_button* button;
|
||||
uint16_t endpoint;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user