|
18 | 18 |
|
19 | 19 | static const char *TAG = "esp_matter_endpoint";
|
20 | 20 |
|
| 21 | +using namespace chip::app::Clusters; |
21 | 22 | namespace esp_matter {
|
22 | 23 | using namespace cluster;
|
23 | 24 |
|
@@ -2050,6 +2051,53 @@ esp_err_t add(endpoint_t *endpoint, config_t *config)
|
2050 | 2051 | }
|
2051 | 2052 | } /* water_heater */
|
2052 | 2053 |
|
| 2054 | +namespace solar_power { |
| 2055 | +uint32_t get_device_type_id() |
| 2056 | +{ |
| 2057 | + return ESP_MATTER_SOLAR_POWER_DEVICE_TYPE_ID; |
| 2058 | +} |
| 2059 | + |
| 2060 | +uint8_t get_device_type_version() |
| 2061 | +{ |
| 2062 | + return ESP_MATTER_SOLAR_POWER_DEVICE_TYPE_VERSION; |
| 2063 | +} |
| 2064 | + |
| 2065 | +endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data) |
| 2066 | +{ |
| 2067 | + return common::create<config_t>(node, config, flags, priv_data, add); |
| 2068 | +} |
| 2069 | + |
| 2070 | +esp_err_t add(endpoint_t *endpoint, config_t *config) |
| 2071 | +{ |
| 2072 | + VerifyOrReturnError(endpoint != nullptr, ESP_ERR_INVALID_ARG, ESP_LOGE(TAG, "Endpoint cannot be NULL")); |
| 2073 | + esp_err_t err = add_device_type(endpoint, get_device_type_id(), get_device_type_version()); |
| 2074 | + if (err != ESP_OK) { |
| 2075 | + ESP_LOGE(TAG, "Failed to add device type id:%" PRIu32 ",err: %d", get_device_type_id(), err); |
| 2076 | + return err; |
| 2077 | + } |
| 2078 | + |
| 2079 | + cluster_t *descriptor_cluster = cluster::get(endpoint, Descriptor::Id); |
| 2080 | + descriptor::feature::taglist::add(descriptor_cluster); |
| 2081 | + |
| 2082 | + power_source_device::add(endpoint, &config->power_source_device); |
| 2083 | + |
| 2084 | + cluster_t *power_source_cluster = cluster::get(endpoint, PowerSource::Id); |
| 2085 | + power_source::feature::wired::add(power_source_cluster, &config->power_source_device.power_source.wired); |
| 2086 | + |
| 2087 | + electrical_sensor::add(endpoint, &config->electrical_sensor); |
| 2088 | + electrical_energy_measurement::create(endpoint, &(config->electrical_energy_measurement), CLUSTER_FLAG_SERVER, electrical_energy_measurement::feature::exported_energy::get_id() | electrical_energy_measurement::feature::cumulative_energy::get_id()); |
| 2089 | + |
| 2090 | + cluster_t *ele_power_measurement_cluster = cluster::get(endpoint, ElectricalPowerMeasurement::Id); |
| 2091 | + |
| 2092 | + nullable<int64_t> voltage = 0, active_current = 0; |
| 2093 | + electrical_power_measurement::attribute::create_voltage(ele_power_measurement_cluster, voltage); |
| 2094 | + electrical_power_measurement::attribute::create_active_current(ele_power_measurement_cluster, active_current); |
| 2095 | + |
| 2096 | + |
| 2097 | + return ESP_OK; |
| 2098 | +} |
| 2099 | +} /* solar_power */ |
| 2100 | + |
2053 | 2101 | } /* endpoint */
|
2054 | 2102 |
|
2055 | 2103 | namespace node {
|
|
0 commit comments