mirror of
https://github.com/espressif/esp-matter.git
synced 2026-04-27 19:13:13 +00:00
Feature: Add optional features & attributes in basic cluster and wifinetworkdiag cluster
This commit is contained in:
@@ -181,6 +181,54 @@ attribute_t *create_capability_minima(cluster_t *cluster, uint8_t *value, uint16
|
||||
esp_matter_array(value, length, count));
|
||||
}
|
||||
|
||||
attribute_t *create_manufacturing_date(cluster_t *cluster, char *value, uint16_t length)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, Basic::Attributes::ManufacturingDate::Id, ATTRIBUTE_FLAG_NONE,
|
||||
esp_matter_char_str(value, length));
|
||||
}
|
||||
|
||||
attribute_t *create_part_number(cluster_t *cluster, char *value, uint16_t length)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, Basic::Attributes::PartNumber::Id, ATTRIBUTE_FLAG_NONE,
|
||||
esp_matter_char_str(value, length));
|
||||
}
|
||||
|
||||
attribute_t *create_product_url(cluster_t *cluster, char *value, uint16_t length)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, Basic::Attributes::ProductURL::Id, ATTRIBUTE_FLAG_NONE,
|
||||
esp_matter_char_str(value, length));
|
||||
}
|
||||
|
||||
attribute_t *create_product_label(cluster_t *cluster, char *value, uint16_t length)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, Basic::Attributes::ProductLabel::Id, ATTRIBUTE_FLAG_NONE,
|
||||
esp_matter_char_str(value, length));
|
||||
}
|
||||
|
||||
attribute_t *create_serial_number(cluster_t *cluster, char *value, uint16_t length)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, Basic::Attributes::SerialNumber::Id, ATTRIBUTE_FLAG_NONE,
|
||||
esp_matter_char_str(value, length));
|
||||
}
|
||||
|
||||
attribute_t *create_local_config_diabled(cluster_t *cluster, bool value)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, Basic::Attributes::LocalConfigDisabled::Id,
|
||||
ATTRIBUTE_FLAG_WRITABLE, esp_matter_bool(value));
|
||||
}
|
||||
|
||||
attribute_t *create_reachable(cluster_t *cluster, bool value)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, Basic::Attributes::Reachable::Id, ATTRIBUTE_FLAG_NONE,
|
||||
esp_matter_bool(value));
|
||||
}
|
||||
|
||||
attribute_t *create_unique_id(cluster_t *cluster, char *value, uint16_t length)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, Basic::Attributes::UniqueID::Id, ATTRIBUTE_FLAG_NONE,
|
||||
esp_matter_char_str(value, length));
|
||||
}
|
||||
|
||||
} /* attribute */
|
||||
} /* basic */
|
||||
|
||||
@@ -469,6 +517,54 @@ attribute_t *create_rssi(cluster_t *cluster, int8_t value)
|
||||
esp_matter_int8(value));
|
||||
}
|
||||
|
||||
attribute_t *create_beacon_lost_count(cluster_t *cluster, uint32_t value)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, WiFiNetworkDiagnostics::Attributes::BeaconLostCount::Id,
|
||||
ATTRIBUTE_FLAG_NONE, esp_matter_uint32(value));
|
||||
}
|
||||
|
||||
attribute_t *create_beacon_rx_count(cluster_t *cluster, uint32_t value)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, WiFiNetworkDiagnostics::Attributes::BeaconRxCount::Id,
|
||||
ATTRIBUTE_FLAG_NONE, esp_matter_uint32(value));
|
||||
}
|
||||
|
||||
attribute_t *create_packet_multicast_rx_count(cluster_t *cluster, uint32_t value)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, WiFiNetworkDiagnostics::Attributes::PacketMulticastRxCount::Id,
|
||||
ATTRIBUTE_FLAG_NONE, esp_matter_uint32(value));
|
||||
}
|
||||
|
||||
attribute_t *create_packet_multicast_tx_count(cluster_t *cluster, uint32_t value)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, WiFiNetworkDiagnostics::Attributes::PacketMulticastTxCount::Id,
|
||||
ATTRIBUTE_FLAG_NONE, esp_matter_uint32(value));
|
||||
}
|
||||
|
||||
attribute_t *create_packet_unicast_rx_count(cluster_t *cluster, uint32_t value)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, WiFiNetworkDiagnostics::Attributes::PacketUnicastRxCount::Id,
|
||||
ATTRIBUTE_FLAG_NONE, esp_matter_uint32(value));
|
||||
}
|
||||
|
||||
attribute_t *create_packet_unicast_tx_count(cluster_t *cluster, uint32_t value)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, WiFiNetworkDiagnostics::Attributes::PacketUnicastTxCount::Id,
|
||||
ATTRIBUTE_FLAG_NONE, esp_matter_uint32(value));
|
||||
}
|
||||
|
||||
attribute_t *create_current_max_rate(cluster_t *cluster, uint64_t value)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, WiFiNetworkDiagnostics::Attributes::CurrentMaxRate::Id,
|
||||
ATTRIBUTE_FLAG_NONE, esp_matter_uint64(value));
|
||||
}
|
||||
|
||||
attribute_t *create_overrun_count(cluster_t *cluster, uint64_t value)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, WiFiNetworkDiagnostics::Attributes::OverrunCount::Id,
|
||||
ATTRIBUTE_FLAG_NONE, esp_matter_uint64(value));
|
||||
}
|
||||
|
||||
} /* attribute */
|
||||
} /* diagnostics_network_wifi */
|
||||
|
||||
|
||||
@@ -66,6 +66,14 @@ attribute_t *create_hardware_version_string(cluster_t *cluster, char *value, uin
|
||||
attribute_t *create_software_version(cluster_t *cluster, uint32_t value);
|
||||
attribute_t *create_software_version_string(cluster_t *cluster, char *value, uint16_t length);
|
||||
attribute_t *create_capability_minima(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count);
|
||||
attribute_t *create_manufacturing_date(cluster_t *cluster, char *value, uint16_t length);
|
||||
attribute_t *create_part_number(cluster_t *cluster, char *value, uint16_t length);
|
||||
attribute_t *create_product_url(cluster_t *cluster, char *value, uint16_t length);
|
||||
attribute_t *create_product_label(cluster_t *cluster, char *value, uint16_t length);
|
||||
attribute_t *create_serial_number(cluster_t *cluster, char *value, uint16_t length);
|
||||
attribute_t *create_local_config_diabled(cluster_t *cluster, bool value);
|
||||
attribute_t *create_reachable(cluster_t *cluster, bool value);
|
||||
attribute_t *create_unique_id(cluster_t *cluster, char *value, uint16_t length);
|
||||
} /* attribute */
|
||||
} /* basic */
|
||||
|
||||
@@ -150,6 +158,14 @@ attribute_t *create_security_type(cluster_t *cluster, uint8_t value);
|
||||
attribute_t *create_wifi_version(cluster_t *cluster, uint8_t value);
|
||||
attribute_t *create_channel_number(cluster_t *cluster, uint16_t value);
|
||||
attribute_t *create_rssi(cluster_t *cluster, int8_t value);
|
||||
attribute_t *create_beacon_lost_count(cluster_t *cluster, uint32_t value);
|
||||
attribute_t *create_beacon_rx_count(cluster_t *cluster, uint32_t value);
|
||||
attribute_t *create_packet_multicast_rx_count(cluster_t *cluster, uint32_t value);
|
||||
attribute_t *create_packet_multicast_tx_count(cluster_t *cluster, uint32_t value);
|
||||
attribute_t *create_packet_unicast_rx_count(cluster_t *cluster, uint32_t value);
|
||||
attribute_t *create_packet_unicast_tx_count(cluster_t *cluster, uint32_t value);
|
||||
attribute_t *create_current_max_rate(cluster_t *cluster, uint64_t value);
|
||||
attribute_t *create_overrun_count(cluster_t *cluster, uint64_t value);
|
||||
} /* attribute */
|
||||
} /* diagnostics_network_wifi */
|
||||
|
||||
|
||||
@@ -992,8 +992,8 @@ static esp_err_t esp_matter_command_callback_setpoint_raise_lower(const Concrete
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t esp_matter_command_callback_reset_counts(const ConcreteCommandPath &command_path,
|
||||
TLVReader &tlv_data, void *opaque_ptr)
|
||||
static esp_err_t esp_matter_command_callback_thread_reset_counts(const ConcreteCommandPath &command_path,
|
||||
TLVReader &tlv_data, void *opaque_ptr)
|
||||
{
|
||||
chip::app::Clusters::ThreadNetworkDiagnostics::Commands::ResetCounts::DecodableType command_data;
|
||||
CHIP_ERROR error = Decode(tlv_data, command_data);
|
||||
@@ -1003,6 +1003,17 @@ static esp_err_t esp_matter_command_callback_reset_counts(const ConcreteCommandP
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t esp_matter_command_callback_wifi_reset_counts(const ConcreteCommandPath &command_path,
|
||||
TLVReader &tlv_data, void *opaque_ptr)
|
||||
{
|
||||
chip::app::Clusters::WiFiNetworkDiagnostics::Commands::ResetCounts::DecodableType command_data;
|
||||
CHIP_ERROR error = Decode(tlv_data, command_data);
|
||||
if (error == CHIP_NO_ERROR) {
|
||||
emberAfWiFiNetworkDiagnosticsClusterResetCountsCallback((CommandHandler *)opaque_ptr, command_path, command_data);
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t esp_matter_command_callback_test_event_trigger(const ConcreteCommandPath &command_path,
|
||||
TLVReader &tlv_data, void *opaque_ptr)
|
||||
{
|
||||
@@ -1023,12 +1034,25 @@ namespace command {
|
||||
command_t *create_reset_counts(cluster_t *cluster)
|
||||
{
|
||||
return esp_matter::command::create(cluster, ThreadNetworkDiagnostics::Commands::ResetCounts::Id, COMMAND_FLAG_ACCEPTED,
|
||||
esp_matter_command_callback_reset_counts);
|
||||
esp_matter_command_callback_thread_reset_counts);
|
||||
}
|
||||
|
||||
} /* command */
|
||||
} /* diagnostics_network_thread */
|
||||
|
||||
namespace diagnostics_network_wifi {
|
||||
namespace command {
|
||||
|
||||
command_t *create_reset_counts(cluster_t *cluster)
|
||||
{
|
||||
return esp_matter::command::create(cluster, WiFiNetworkDiagnostics::Commands::ResetCounts::Id, COMMAND_FLAG_ACCEPTED,
|
||||
esp_matter_command_callback_wifi_reset_counts);
|
||||
}
|
||||
|
||||
} /* command */
|
||||
} /* diagnostics_network_wifi */
|
||||
|
||||
|
||||
namespace general_diagnostics {
|
||||
namespace command {
|
||||
|
||||
|
||||
@@ -31,6 +31,12 @@ command_t *create_reset_counts(cluster_t *cluster);
|
||||
} /* command */
|
||||
} /* diagnostics_network_thread */
|
||||
|
||||
namespace diagnostics_network_wifi {
|
||||
namespace command {
|
||||
command_t *create_reset_counts(cluster_t *cluster);
|
||||
} /* command */
|
||||
} /* diagnostics_network_wifi */
|
||||
|
||||
namespace general_diagnostics {
|
||||
namespace command {
|
||||
command_t *create_test_event_trigger(cluster_t *cluster);
|
||||
|
||||
@@ -323,5 +323,69 @@ esp_err_t add(cluster_t *cluster, config_t *config)
|
||||
} /* feature */
|
||||
} /* color_control */
|
||||
|
||||
namespace diagnostics_network_wifi {
|
||||
namespace feature {
|
||||
|
||||
namespace packets_counts {
|
||||
|
||||
uint32_t get_id()
|
||||
{
|
||||
// The WiFiNetworkDiagnosticsFeature enum class is not added in the upstream code.
|
||||
// Return the code according to the SPEC
|
||||
return 0x01;
|
||||
}
|
||||
|
||||
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());
|
||||
|
||||
/* Attributes managed internally */
|
||||
attribute::create_beacon_rx_count(cluster, 0);
|
||||
attribute::create_packet_multicast_rx_count(cluster, 0);
|
||||
attribute::create_packet_multicast_tx_count(cluster, 0);
|
||||
attribute::create_packet_unicast_rx_count(cluster, 0);
|
||||
attribute::create_packet_unicast_tx_count(cluster, 0);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
} /* packets_counts */
|
||||
|
||||
namespace error_counts {
|
||||
|
||||
uint32_t get_id()
|
||||
{
|
||||
// The WiFiNetworkDiagnosticsFeature enum class is not added in the upstream code.
|
||||
// Return the code according to the SPEC
|
||||
return 0x02;
|
||||
}
|
||||
|
||||
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());
|
||||
|
||||
/* Attributes managed internally */
|
||||
attribute::create_beacon_lost_count(cluster, 0);
|
||||
attribute::create_overrun_count(cluster, 0);
|
||||
|
||||
/* Commands */
|
||||
command::create_reset_counts(cluster);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
} /* error_counts */
|
||||
|
||||
} /* feature */
|
||||
} /* diagnostics_network_wifi */
|
||||
|
||||
} /* cluster */
|
||||
} /* esp_matter */
|
||||
|
||||
@@ -166,5 +166,25 @@ esp_err_t add(cluster_t *cluster, config_t *config);
|
||||
} /* feature */
|
||||
} /* color_control */
|
||||
|
||||
namespace diagnostics_network_wifi {
|
||||
namespace feature {
|
||||
|
||||
namespace packets_counts {
|
||||
|
||||
uint32_t get_id();
|
||||
esp_err_t add(cluster_t *cluster);
|
||||
|
||||
} /* packets_counts */
|
||||
|
||||
namespace error_counts {
|
||||
|
||||
uint32_t get_id();
|
||||
esp_err_t add(cluster_t *cluster);
|
||||
|
||||
} /* error_counts */
|
||||
|
||||
} /* feature */
|
||||
} /* diagnostics_network_wifi */
|
||||
|
||||
} /* cluster */
|
||||
} /* esp_matter */
|
||||
|
||||
Reference in New Issue
Block a user