Skip to content

Commit

Permalink
Align WiFi network diagnostics XML to spec changes.
Browse files Browse the repository at this point in the history
More spec changes happened in CHIP-Specifications/connectedhomeip-spec#6178

Fixes #24996
  • Loading branch information
bzbarsky-apple committed Feb 16, 2023
1 parent 80ee243 commit d80deba
Show file tree
Hide file tree
Showing 36 changed files with 218 additions and 162 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ CHIP_ERROR WiFiDiagosticsAttrAccess::ReadWiFiBssId(AttributeValueEncoder & aEnco
CHIP_ERROR WiFiDiagosticsAttrAccess::ReadSecurityType(AttributeValueEncoder & aEncoder)
{
Attributes::SecurityType::TypeInfo::Type securityType;
uint8_t value = 0;
SecurityTypeEnum value = SecurityTypeEnum::kUnspecified;

if (DeviceLayer::GetDiagnosticDataProvider().GetWiFiSecurityType(value) == CHIP_NO_ERROR)
{
securityType.SetNonNull(static_cast<WiFiNetworkDiagnostics::SecurityType>(value));
ChipLogProgress(Zcl, "The current type of Wi-Fi security used: %d", value);
securityType.SetNonNull(value);
ChipLogProgress(Zcl, "The current type of Wi-Fi security used: %d", to_underlying(value));
}
else
{
Expand All @@ -123,7 +123,7 @@ CHIP_ERROR WiFiDiagosticsAttrAccess::ReadWiFiVersion(AttributeValueEncoder & aEn

if (DeviceLayer::GetDiagnosticDataProvider().GetWiFiVersion(value) == CHIP_NO_ERROR)
{
version.SetNonNull(static_cast<WiFiNetworkDiagnostics::WiFiVersionType>(value));
version.SetNonNull(static_cast<WiFiNetworkDiagnostics::WiFiVersionEnum>(value));
ChipLogProgress(Zcl, "The current 802.11 standard version in use by the Node: %d", value);
}
else
Expand Down Expand Up @@ -261,7 +261,7 @@ class WiFiDiagnosticsDelegate : public DeviceLayer::WiFiDiagnosticsDelegate
{
ChipLogProgress(Zcl, "WiFiDiagnosticsDelegate: OnAssociationFailureDetected");

Events::AssociationFailure::Type event{ static_cast<AssociationFailureCause>(associationFailureCause), status };
Events::AssociationFailure::Type event{ static_cast<AssociationFailureCauseEnum>(associationFailureCause), status };

for (auto endpoint : EnabledEndpointsWithServerCluster(WiFiNetworkDiagnostics::Id))
{
Expand All @@ -280,7 +280,7 @@ class WiFiDiagnosticsDelegate : public DeviceLayer::WiFiDiagnosticsDelegate
{
ChipLogProgress(Zcl, "WiFiDiagnosticsDelegate: OnConnectionStatusChanged");

Events::ConnectionStatus::Type event{ static_cast<WiFiConnectionStatus>(connectionStatus) };
Events::ConnectionStatus::Type event{ static_cast<ConnectionStatusEnum>(connectionStatus) };
for (auto endpoint : EnabledEndpointsWithServerCluster(WiFiNetworkDiagnostics::Id))
{
// If WiFi Network Diagnostics cluster is implemented on this endpoint
Expand Down
1 change: 0 additions & 1 deletion src/app/common/templates/config-data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ WeakEnums:
- RoutingRole
- SaturationMoveMode
- SaturationStepMode
- SecurityType
- StepMode
- TemperatureDisplayMode

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.
-->
<configurator>
<domain name="CHIP"/>
<enum name="SecurityType" type="ENUM8">
<enum name="SecurityTypeEnum" type="ENUM8">
<cluster code="0x0036"/>
<item name="Unspecified" value="0x00"/>
<item name="None" value="0x01"/>
Expand All @@ -25,7 +25,7 @@ limitations under the License.
<item name="WPA2" value="0x04"/>
<item name="WPA3" value="0x05"/>
</enum>
<enum name="WiFiVersionType" type="ENUM8">
<enum name="WiFiVersionEnum" type="ENUM8">
<cluster code="0x0036"/>
<item name="a" value="0x00"/>
<item name="b" value="0x01"/>
Expand All @@ -34,14 +34,14 @@ limitations under the License.
<item name="ac" value="0x04"/>
<item name="ax" value="0x05"/>
</enum>
<enum name="AssociationFailureCause" type="ENUM8">
<enum name="AssociationFailureCauseEnum" type="ENUM8">
<cluster code="0x0036"/>
<item name="Unknown" value="0x00"/>
<item name="AssociationFailed" value="0x01"/>
<item name="AuthenticationFailed" value="0x02"/>
<item name="SsidNotFound" value="0x03"/>
</enum>
<enum name="WiFiConnectionStatus" type="ENUM8">
<enum name="ConnectionStatusEnum" type="ENUM8">
<cluster code="0x0036"/>
<item name="Connected" value="0x00"/>
<item name="NotConnected" value="0x01"/>
Expand All @@ -58,8 +58,8 @@ limitations under the License.
<define>WIFI_NETWORK_DIAGNOSTICS_CLUSTER</define>
<description>The Wi-Fi Network Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems.</description>
<attribute side="server" code="0x00" define="BSSID" type="OCTET_STRING" length="6" writable="false" isNullable="true" optional="false">BSSID</attribute>
<attribute side="server" code="0x01" define="SECURITY_TYPE" type="SecurityType" writable="false" isNullable="true" optional="false">SecurityType</attribute>
<attribute side="server" code="0x02" define="WIFI_VERSION" type="WiFiVersionType" writable="false" isNullable="true" optional="false">WiFiVersion</attribute>
<attribute side="server" code="0x01" define="SECURITY_TYPE" type="SecurityTypeEnum" writable="false" isNullable="true" optional="false">SecurityType</attribute>
<attribute side="server" code="0x02" define="WIFI_VERSION" type="WiFiVersionEnum" writable="false" isNullable="true" optional="false">WiFiVersion</attribute>
<attribute side="server" code="0x03" define="CHANNEL_NUMBER" type="INT16U" min="0x0000" max="0xFFFF" writable="false" default="0x0000" isNullable="true" optional="false">ChannelNumber</attribute>
<attribute side="server" code="0x04" define="RSSI" type="INT8S" min="-120" max="0" writable="false" isNullable="true" optional="false">RSSI</attribute>
<attribute side="server" code="0x05" define="BEACON_LOST_COUNT" type="INT32U" min="0x00000000" max="0xFFFFFFFF" writable="false" default="0x00000000" isNullable="true" optional="true">BeaconLostCount</attribute>
Expand All @@ -79,12 +79,12 @@ limitations under the License.
</event>
<event side="server" code="0x01" name="AssociationFailure" priority="info" optional="true">
<description>Indicate that a Node has failed to connect, or reconnect, to a Wi-Fi access point.</description>
<field id="0" name="AssociationFailure" type="AssociationFailureCause"/>
<field id="0" name="AssociationFailure" type="AssociationFailureCauseEnum"/>
<field id="1" name="Status" type="INT16U"/>
</event>
<event side="server" code="0x02" name="ConnectionStatus" priority="info" optional="true">
<description>Indicate that a Node’s connection status to a Wi-Fi network has changed.</description>
<field id="0" name="ConnectionStatus" type="WiFiConnectionStatus"/>
<field id="0" name="ConnectionStatus" type="ConnectionStatusEnum"/>
</event>
</cluster>
</configurator>
40 changes: 36 additions & 4 deletions src/darwin/Framework/CHIP/templates/availability.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3100,8 +3100,14 @@
- RoutingRole
- ThreadConnectionStatus
WiFiNetworkDiagnostics:
- AssociationFailureCause
- SecurityType
# AssociationFailureCauseEnum was originally just named
# AssociationFailureCause, but we generate the same API for both
# of those names, so the name can just change here.
- AssociationFailureCauseEnum
# SecurityTypeEnum was originally just named SecurityType, but we
# generate the same API for both of those names, so the name can
# just change here.
- SecurityTypeEnum
- WiFiConnectionStatus
- WiFiVersionType
EthernetNetworkDiagnostics:
Expand Down Expand Up @@ -3480,12 +3486,18 @@
- Connected
- NotConnected
WiFiNetworkDiagnostics:
AssociationFailureCause:
# AssociationFailureCauseEnum was originally just named
# AssociationFailureCause, but we generate the same API for both
# of those names, so the name can just change here.
AssociationFailureCauseEnum:
- Unknown
- AssociationFailed
- AuthenticationFailed
- SsidNotFound
SecurityType:
# SecurityTypeEnum was originally just named SecurityType, but we
# generate the same API for both of those names, so the name can
# just change here.
SecurityTypeEnum:
- Unspecified
- None
- WEP
Expand Down Expand Up @@ -6675,6 +6687,9 @@
- IntentEnum
- StatusEnum
- TransferProtocolEnum
WiFiNetworkDiagnostics:
- ConnectionStatusEnum
- WiFiVersionEnum
enum values:
DoorLock:
LockDataTypeEnum:
Expand All @@ -6693,6 +6708,17 @@
TransferProtocolEnum:
- ResponsePayload
- BDX
WiFiNetworkDiagnostics:
ConnectionStatusEnum:
- Connected
- NotConnected
WiFiVersionEnum:
- A
- B
- G
- N
- Ac
- Ax
deprecated:
attributes:
TimeSynchronization:
Expand All @@ -6706,6 +6732,9 @@
- LogsIntent
- LogsStatus
- LogsTransferProtocol
WiFiNetworkDiagnostics:
- WiFiConnectionStatus
- WiFiVersionType
removed:
enum values:
DoorLock:
Expand All @@ -6726,3 +6755,6 @@
IntentEnum: LogsIntent
StatusEnum: LogsStatus
TransferProtocolEnum: LogsTransferProtocol
WiFiNetworkDiagnostics:
ConnectionStatusEnum: WiFiConnectionStatus
WiFiVersionEnum: WiFiVersionType
5 changes: 3 additions & 2 deletions src/include/platform/DiagnosticDataProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class DiagnosticDataProvider
* WiFi network diagnostics methods
*/
virtual CHIP_ERROR GetWiFiBssId(ByteSpan & value);
virtual CHIP_ERROR GetWiFiSecurityType(uint8_t & securityType);
virtual CHIP_ERROR GetWiFiSecurityType(app::Clusters::WiFiNetworkDiagnostics::SecurityTypeEnum & securityType);
virtual CHIP_ERROR GetWiFiVersion(uint8_t & wiFiVersion);
virtual CHIP_ERROR GetWiFiChannelNumber(uint16_t & channelNumber);
virtual CHIP_ERROR GetWiFiRssi(int8_t & rssi);
Expand Down Expand Up @@ -333,7 +333,8 @@ inline CHIP_ERROR DiagnosticDataProvider::GetWiFiBssId(ByteSpan & value)
return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
}

inline CHIP_ERROR DiagnosticDataProvider::GetWiFiSecurityType(uint8_t & securityType)
inline CHIP_ERROR
DiagnosticDataProvider::GetWiFiSecurityType(app::Clusters::WiFiNetworkDiagnostics::SecurityTypeEnum & securityType)
{
return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
}
Expand Down
14 changes: 7 additions & 7 deletions src/platform/Ameba/ConnectivityManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ void ConnectivityManagerImpl::OnStationConnected()
if (delegate)
{
delegate->OnConnectionStatusChanged(
chip::to_underlying(chip::app::Clusters::WiFiNetworkDiagnostics::WiFiConnectionStatus::kConnected));
chip::to_underlying(chip::app::Clusters::WiFiNetworkDiagnostics::ConnectionStatusEnum::kConnected));
}

UpdateInternetConnectivityState();
Expand All @@ -599,7 +599,7 @@ void ConnectivityManagerImpl::OnStationDisconnected()
WiFiDiagnosticsDelegate * delegate = GetDiagnosticDataProvider().GetWiFiDiagnosticsDelegate();
uint16_t reason = NetworkCommissioning::AmebaWiFiDriver::GetInstance().GetLastDisconnectReason();
uint8_t associationFailureCause =
chip::to_underlying(chip::app::Clusters::WiFiNetworkDiagnostics::AssociationFailureCause::kUnknown);
chip::to_underlying(chip::app::Clusters::WiFiNetworkDiagnostics::AssociationFailureCauseEnum::kUnknown);

if (delegate)
{
Expand All @@ -608,17 +608,17 @@ void ConnectivityManagerImpl::OnStationDisconnected()
case RTW_NO_ERROR:
case RTW_NONE_NETWORK:
associationFailureCause =
chip::to_underlying(chip::app::Clusters::WiFiNetworkDiagnostics::AssociationFailureCause::kSsidNotFound);
chip::to_underlying(chip::app::Clusters::WiFiNetworkDiagnostics::AssociationFailureCauseEnum::kSsidNotFound);
delegate->OnAssociationFailureDetected(associationFailureCause, reason);
break;
case RTW_CONNECT_FAIL:
associationFailureCause =
chip::to_underlying(chip::app::Clusters::WiFiNetworkDiagnostics::AssociationFailureCause::kAssociationFailed);
chip::to_underlying(chip::app::Clusters::WiFiNetworkDiagnostics::AssociationFailureCauseEnum::kAssociationFailed);
delegate->OnAssociationFailureDetected(associationFailureCause, reason);
break;
case RTW_WRONG_PASSWORD:
associationFailureCause =
chip::to_underlying(chip::app::Clusters::WiFiNetworkDiagnostics::AssociationFailureCause::kAuthenticationFailed);
associationFailureCause = chip::to_underlying(
chip::app::Clusters::WiFiNetworkDiagnostics::AssociationFailureCauseEnum::kAuthenticationFailed);
delegate->OnAssociationFailureDetected(associationFailureCause, reason);
break;
#if defined(CONFIG_PLATFORM_8710C)
Expand All @@ -634,7 +634,7 @@ void ConnectivityManagerImpl::OnStationDisconnected()
}
delegate->OnDisconnectionDetected(reason);
delegate->OnConnectionStatusChanged(
chip::to_underlying(chip::app::Clusters::WiFiNetworkDiagnostics::WiFiConnectionStatus::kNotConnected));
chip::to_underlying(chip::app::Clusters::WiFiNetworkDiagnostics::ConnectionStatusEnum::kNotConnected));
}

UpdateInternetConnectivityState();
Expand Down
36 changes: 18 additions & 18 deletions src/platform/Ameba/DiagnosticDataProviderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,42 +273,43 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiBssId(ByteSpan & BssId)
CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiVersion(uint8_t & wifiVersion)
{
// Support 802.11a/n Wi-Fi in AmebaD chipset
wifiVersion = to_underlying(app::Clusters::WiFiNetworkDiagnostics::WiFiVersionType::kN);
wifiVersion = to_underlying(app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum::kN);
return CHIP_NO_ERROR;
}

CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiSecurityType(uint8_t & securityType)
CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiSecurityType(app::Clusters::WiFiNetworkDiagnostics::SecurityTypeEnum & securityType)
{
using app::Clusters::WiFiNetworkDiagnostics::SecurityTypeEnum;

unsigned int _auth_type;
unsigned short _security = 0;
rtw_wifi_setting_t setting;

#ifdef CONFIG_PLATFORM_8721D
if (wext_get_enc_ext("wlan0", &_security, &setting.key_idx, setting.password) < 0)
{
securityType = 0;
securityType = SecurityTypeEnum::kUnspecified;
}
else
{
switch (_security)
{
case IW_ENCODE_ALG_NONE:
setting.security_type = EMBER_ZCL_SECURITY_TYPE_NONE;
securityType = SecurityTypeEnum::kNone;
break;
case IW_ENCODE_ALG_WEP:
setting.security_type = EMBER_ZCL_SECURITY_TYPE_WEP;
securityType = SecurityTypeEnum::kWep;
break;
case IW_ENCODE_ALG_TKIP:
setting.security_type = EMBER_ZCL_SECURITY_TYPE_WPA;
securityType = SecurityTypeEnum::kWpa;
break;
case IW_ENCODE_ALG_CCMP:
setting.security_type = EMBER_ZCL_SECURITY_TYPE_WPA2;
securityType = SecurityTypeEnum::kWpa2;
break;
default:
setting.security_type = EMBER_ZCL_SECURITY_TYPE_UNSPECIFIED;
securityType = SecurityTypeEnum::kUnspecified;
break;
}
securityType = setting.security_type;
}
#else
wext_get_enc_ext("wlan0", &_security, &setting.key_idx, setting.password);
Expand All @@ -321,30 +322,29 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiSecurityType(uint8_t & securityTyp
switch (_security)
{
case IW_ENCODE_ALG_NONE:
setting.security_type = EMBER_ZCL_SECURITY_TYPE_NONE;
securityType = SecurityTypeEnum::kNone;
break;
case IW_ENCODE_ALG_WEP:
setting.security_type = EMBER_ZCL_SECURITY_TYPE_WEP;
securityType = SecurityTypeEnum::kWep;
break;
case IW_ENCODE_ALG_TKIP:
if (_auth_type == WPA_SECURITY)
setting.security_type = EMBER_ZCL_SECURITY_TYPE_WPA;
securityType = SecurityTypeEnum::kWpa;
else if (_auth_type == WPA2_SECURITY)
setting.security_type = EMBER_ZCL_SECURITY_TYPE_WPA2;
securityType = SecurityTypeEnum::kWpa2;
break;
case IW_ENCODE_ALG_CCMP:
if (_auth_type == WPA_SECURITY)
setting.security_type = EMBER_ZCL_SECURITY_TYPE_WPA;
securityType = SecurityTypeEnum::kWpa;
else if (_auth_type == WPA2_SECURITY)
setting.security_type = EMBER_ZCL_SECURITY_TYPE_WPA2;
securityType = SecurityTypeEnum::kWpa2;
else if (_auth_type == WPA3_SECURITY)
setting.security_type = EMBER_ZCL_SECURITY_TYPE_WPA3;
securityType = SecurityTypeEnum::kWpa3;
break;
default:
setting.security_type = EMBER_ZCL_SECURITY_TYPE_UNSPECIFIED;
securityType = SecurityTypeEnum::Unspecified;
break;
}
securityType = setting.security_type;
}
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/platform/Ameba/DiagnosticDataProviderImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class DiagnosticDataProviderImpl : public DiagnosticDataProvider

#if CHIP_DEVICE_CONFIG_ENABLE_WIFI
CHIP_ERROR GetWiFiBssId(ByteSpan & BssId) override;
CHIP_ERROR GetWiFiSecurityType(uint8_t & securityType) override;
CHIP_ERROR GetWiFiSecurityType(app::Clusters::WiFiNetworkDiagnostics::SecurityTypeEnum & securityType) override;
CHIP_ERROR GetWiFiVersion(uint8_t & wifiVersion) override;
CHIP_ERROR GetWiFiChannelNumber(uint16_t & channelNumber) override;
CHIP_ERROR GetWiFiRssi(int8_t & rssi) override;
Expand Down
Loading

0 comments on commit d80deba

Please sign in to comment.