diff --git a/components/esp_matter/esp_matter_attribute.cpp b/components/esp_matter/esp_matter_attribute.cpp index a5a029792..92246ec2e 100644 --- a/components/esp_matter/esp_matter_attribute.cpp +++ b/components/esp_matter/esp_matter_attribute.cpp @@ -837,5 +837,41 @@ attribute_t *create_temperature_max_measured_value(cluster_t *cluster, int16_t v } /* attribute */ } /* temperature_measurement */ +namespace occupancy_sensing { +namespace attribute { + +attribute_t *create_occupancy(cluster_t *cluster, uint8_t value) +{ + return esp_matter::attribute::create(cluster, OccupancySensing::Attributes::Occupancy::Id, ATTRIBUTE_FLAG_NONE, + esp_matter_bitmap8(value)); +} + +attribute_t *create_occupancy_sensor_type(cluster_t *cluster, uint8_t value) +{ + return esp_matter::attribute::create(cluster, OccupancySensing::Attributes::OccupancySensorType::Id, + ATTRIBUTE_FLAG_NONE, esp_matter_enum8(value)); +} + +attribute_t *create_occupancy_sensor_type_bitmap(cluster_t *cluster, uint8_t value) +{ + return esp_matter::attribute::create(cluster, OccupancySensing::Attributes::OccupancySensorTypeBitmap::Id, + ATTRIBUTE_FLAG_NONE, esp_matter_bitmap8(value)); +} + +} /* attribute */ +} /* occupancy_sensing */ + +namespace boolean_state { +namespace attribute { + +attribute_t *state_value(cluster_t *cluster, bool value) +{ + return esp_matter::attribute::create(cluster, BooleanState::Attributes::StateValue::Id, ATTRIBUTE_FLAG_NONE, + esp_matter_bool(value)); +} + +} /* attribute */ +} /* boolean_state */ + } /* cluster */ } /* esp_matter */ diff --git a/components/esp_matter/esp_matter_attribute.h b/components/esp_matter/esp_matter_attribute.h index 7f3f1e3d3..b7e19125d 100644 --- a/components/esp_matter/esp_matter_attribute.h +++ b/components/esp_matter/esp_matter_attribute.h @@ -257,5 +257,19 @@ attribute_t *create_temperature_max_measured_value(cluster_t *cluster, int16_t v } /* attribute */ } /* temperature_measurement */ +namespace occupancy_sensing { +namespace attribute { +attribute_t *create_occupancy(cluster_t *cluster, uint8_t value); +attribute_t *create_occupancy_sensor_type(cluster_t *cluster, uint8_t value); +attribute_t *create_occupancy_sensor_type_bitmap(cluster_t *cluster, uint8_t value); +} /* attribute */ +} /* occupancy_sensing */ + +namespace boolean_state { +namespace attribute { +attribute_t *state_value(cluster_t *cluster, bool value); +} /* attribute */ +} /* boolean_state */ + } /* cluster */ } /* esp_matter */ diff --git a/components/esp_matter/esp_matter_cluster.cpp b/components/esp_matter/esp_matter_cluster.cpp index f86fd3b77..65e907ac4 100644 --- a/components/esp_matter/esp_matter_cluster.cpp +++ b/components/esp_matter/esp_matter_cluster.cpp @@ -1068,5 +1068,67 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) } } /* temperature_measurement */ +namespace occupancy_sensing { +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, OccupancySensing::Id, flags); + if (!cluster) { + ESP_LOGE(TAG, "Could not create cluster"); + return NULL; + } + + if (flags & CLUSTER_FLAG_SERVER) { + set_plugin_server_init_callback(cluster, MatterOccupancySensingPluginServerInitCallback); + add_function_list(cluster, function_list, function_flags); + } + if (flags & CLUSTER_FLAG_CLIENT) { + set_plugin_client_init_callback(cluster, MatterOccupancySensingPluginClientInitCallback); + } + + if (flags & CLUSTER_FLAG_SERVER) { + /* Attributes not managed internally */ + global::attribute::create_cluster_revision(cluster, config->cluster_revision); + attribute::create_occupancy(cluster, config->occupancy); + attribute::create_occupancy_sensor_type(cluster, config->occupancy_sensor_type); + attribute::create_occupancy_sensor_type_bitmap(cluster, config->occupancy_sensor_type_bitmap); + } + + return cluster; +} +} /* occupancy_sensing */ + +namespace boolean_state { +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, BooleanState::Id, flags); + if (!cluster) { + ESP_LOGE(TAG, "Could not create cluster"); + return NULL; + } + + if (flags & CLUSTER_FLAG_SERVER) { + set_plugin_server_init_callback(cluster, MatterBooleanStatePluginServerInitCallback); + add_function_list(cluster, function_list, function_flags); + } + if (flags & CLUSTER_FLAG_CLIENT) { + set_plugin_client_init_callback(cluster, MatterBooleanStatePluginClientInitCallback); + } + + if (flags & CLUSTER_FLAG_SERVER) { + /* Attributes not managed internally */ + global::attribute::create_cluster_revision(cluster, config->cluster_revision); + attribute::state_value(cluster, config->state_value); + } + + return cluster; +} +} /* boolean_state */ + } /* cluster */ } /* esp_matter */ diff --git a/components/esp_matter/esp_matter_cluster.h b/components/esp_matter/esp_matter_cluster.h index b521f2225..651c801d5 100644 --- a/components/esp_matter/esp_matter_cluster.h +++ b/components/esp_matter/esp_matter_cluster.h @@ -313,5 +313,28 @@ typedef struct config { cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); } /* temperature_measurement */ +namespace occupancy_sensing { +typedef struct config { + uint16_t cluster_revision; + uint8_t occupancy; + uint8_t occupancy_sensor_type; + uint8_t occupancy_sensor_type_bitmap; + config() : cluster_revision(3), occupancy(0), occupancy_sensor_type(0), + occupancy_sensor_type_bitmap(0) {} +} config_t; + +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); +} /* occupancy_sensing */ + +namespace boolean_state { +typedef struct config { + uint16_t cluster_revision; + bool state_value; + config() : cluster_revision(3), state_value(0) {} +} config_t; + +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); +} /* boolean_state */ + } /* cluster */ } /* esp_matter */ diff --git a/components/esp_matter/esp_matter_endpoint.cpp b/components/esp_matter/esp_matter_endpoint.cpp index 69b6ccf72..a59b16bf6 100644 --- a/components/esp_matter/esp_matter_endpoint.cpp +++ b/components/esp_matter/esp_matter_endpoint.cpp @@ -34,10 +34,13 @@ #define ESP_MATTER_ON_OFF_PLUGIN_UNIT_DEVICE_TYPE_ID 0x010A #define ESP_MATTER_DIMMABLE_PLUGIN_UNIT_DEVICE_TYPE_ID 0x010B +#define ESP_MATTER_TEMPERATURE_SENSOR_DEVICE_TYPE_ID 0x0302 +#define ESP_MATTER_OCCUPANCY_SENSOR_DEVICE_TYPE_ID 0x0107 +#define ESP_MATTER_CONTACT_SENSOR_DEVICE_TYPE_ID 0x0015 + #define ESP_MATTER_FAN_DEVICE_TYPE_ID 0x002B #define ESP_MATTER_THERMOSTAT_DEVICE_TYPE_ID 0x0301 #define ESP_MATTER_DOOR_LOCK_DEVICE_TYPE_ID 0x000A -#define ESP_MATTER_TEMPERATURE_SENSOR_DEVICE_TYPE_ID 0x0302 static const char *TAG = "esp_matter_endpoint"; @@ -483,6 +486,50 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags) return endpoint; } } /* temperature_sensor */ + +namespace occupancy_sensor { +uint32_t get_device_type_id() +{ + return ESP_MATTER_OCCUPANCY_SENSOR_DEVICE_TYPE_ID; +} + +endpoint_t *create(node_t *node, config_t *config, uint8_t flags) +{ + endpoint_t *endpoint = endpoint::create(node, flags); + if (!endpoint) { + ESP_LOGE(TAG, "Could not create endpoint"); + return NULL; + } + set_device_type_id(endpoint, get_device_type_id()); + + identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER | CLUSTER_FLAG_CLIENT); + occupancy_sensing::create(endpoint, &(config->occupancy_sensing), CLUSTER_FLAG_SERVER); + + return endpoint; +} +} /* occupancy_sensor */ + +namespace contact_sensor { +uint32_t get_device_type_id() +{ + return ESP_MATTER_CONTACT_SENSOR_DEVICE_TYPE_ID; +} + +endpoint_t *create(node_t *node, config_t *config, uint8_t flags) +{ + endpoint_t *endpoint = endpoint::create(node, flags); + if (!endpoint) { + ESP_LOGE(TAG, "Could not create endpoint"); + return NULL; + } + set_device_type_id(endpoint, get_device_type_id()); + + identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER | CLUSTER_FLAG_CLIENT); + boolean_state::create(endpoint, &(config->boolean_state), CLUSTER_FLAG_SERVER); + + return endpoint; +} +} /* contact_sensor */ } /* endpoint */ namespace node { diff --git a/components/esp_matter/esp_matter_endpoint.h b/components/esp_matter/esp_matter_endpoint.h index bf8893f52..c4d241842 100644 --- a/components/esp_matter/esp_matter_endpoint.h +++ b/components/esp_matter/esp_matter_endpoint.h @@ -244,6 +244,27 @@ typedef struct config { uint32_t get_device_type_id(); endpoint_t *create(node_t *node, config_t *config, uint8_t flags); } /* temperature_sensor */ + +namespace occupancy_sensor { +typedef struct config { + identify::config_t identify; + occupancy_sensing::config_t occupancy_sensing; +} config_t; + +uint32_t get_device_type_id(); +endpoint_t *create(node_t *node, config_t *config, uint8_t flags); +} /* occupancy_sensor */ + +namespace contact_sensor { +typedef struct config { + identify::config_t identify; + boolean_state::config_t boolean_state; +} config_t; + +uint32_t get_device_type_id(); +endpoint_t *create(node_t *node, config_t *config, uint8_t flags); +} /* contact_sensor */ + } /* endpoint */ namespace node { diff --git a/docs/_static/software_components.png b/docs/_static/software_components.png index 4da02fd8b..c5cb18ddc 100644 Binary files a/docs/_static/software_components.png and b/docs/_static/software_components.png differ diff --git a/docs/_static/solution_architecture.png b/docs/_static/solution_architecture.png index 079c7a4ce..8045aced9 100644 Binary files a/docs/_static/solution_architecture.png and b/docs/_static/solution_architecture.png differ diff --git a/docs/en/faq.rst b/docs/en/faq.rst index f735e1177..120736ac5 100644 --- a/docs/en/faq.rst +++ b/docs/en/faq.rst @@ -96,7 +96,7 @@ A1.4 Device not crashed but not responding My device is not responding to commands: -- Make sure your device is commissioned successfully and connected is +- Make sure your device is commissioned successfully and is connected to the Wi-Fi. - Make sure the node_id and the endpoint_id are correct in the command from chip-tool. diff --git a/docs/en/introduction.rst b/docs/en/introduction.rst index fecf0e6a8..e8fb1fb26 100644 --- a/docs/en/introduction.rst +++ b/docs/en/introduction.rst @@ -49,13 +49,6 @@ In addition, ESP Matter SDK also integrates `ESP RainMaker `__ can provide remote control for Matter devices and enable the Cloud-based device management of Matter devices' massive data resources. -todo. Add a supported services diagram similar to the one ad the end of this page https://rainmaker.espressif.com/? - -.. figure:: ../_static/supported_services.png - :align: center - :alt: ESP Matter Supported Services - :figclass: align-center - By combining the above-mentioned Matter hardware and software solutions with ESP RainMaker, this one-stop Matter ecosystem solution provides: - Interconnection with Amazon, Google and Apple @@ -112,52 +105,12 @@ These can be used to control other Matter devices. - Touch-screen control panel - Hub with internet connectivity for remote control -1.3 Examples ------------- - -1.3.1 Light -~~~~~~~~~~~ - -This application creates a Color Dimmable Light device using the ESP -Matter data model. - -1.3.2 RainMaker Light -~~~~~~~~~~~~~~~~~~~~~ - -This application creates a Color Dimmable Light device using the ESP -Matter data model. - -It also initializes ESP RainMaker which enables Device Management and -OTA using the RainMaker cloud. If user node association is done, it also -enables Remote Control through RainMaker. - -1.3.3 Light Switch -~~~~~~~~~~~~~~~~~~ - -This application creates an On/Off Light Switch device using the ESP Matter -data model. - -It creates the On/Off client and other devices can be bound to the -switch and then controlled from the switch. - -1.3.4 Zap Light -~~~~~~~~~~~~~~~ - -This application creates a Color Dimmable Light device using the Zap -data model instead of the ESP Matter data model. - -1.3.5 ZigBee Bridge -~~~~~~~~~~~~~~~~~~~ - -This application demonstrates a Matter-ZigBee Bridge that bridges ZigBee devices to Matter fabric. - -1.4 Try it yourself +1.3 Try it yourself ------------------- -1.4.1 ESP Launchpad +1.3.1 ESP Launchpad ~~~~~~~~~~~~~~~~~~~ This allows you to quickly try out Matter on Espressif devices through a web browser. - ESP Launchpad: https://espressif.github.io/esp-launchpad/.