Skip to content

Commit

Permalink
BeaconRxCount attributes results is NULL instead of 0
Browse files Browse the repository at this point in the history
  • Loading branch information
Thirsrin committed Apr 2, 2024
1 parent 6c89640 commit ad538c1
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/platform/Linux/ConnectivityUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,29 @@ CHIP_ERROR ConnectivityUtils::GetWiFiBeaconLostCount(const char * ifname, uint32
return err;
}

CHIP_ERROR ConnectivityUtils::GetWiFiBeaconRxCount(const char * ifname, uint32_t & beaconRxCount)
{
CHIP_ERROR err = CHIP_ERROR_READ_FAILED;
struct iw_statistics stats;
int skfd;

if ((skfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
{
ChipLogError(DeviceLayer, "Failed to create a channel to the NET kernel.");
return CHIP_ERROR_OPEN_FAILED;
}

if (GetWiFiStats(skfd, ifname, &stats) == CHIP_NO_ERROR)
{
beaconRxCount = stats.miss.beacon;
err = CHIP_NO_ERROR;
}

close(skfd);

return err;
}

CHIP_ERROR ConnectivityUtils::GetWiFiCurrentMaxRate(const char * ifname, uint64_t & currentMaxRate)
{
CHIP_ERROR err = CHIP_ERROR_READ_FAILED;
Expand Down
1 change: 1 addition & 0 deletions src/platform/Linux/ConnectivityUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class ConnectivityUtils
static CHIP_ERROR GetWiFiChannelNumber(const char * ifname, uint16_t & channelNumber);
static CHIP_ERROR GetWiFiRssi(const char * ifname, int8_t & rssi);
static CHIP_ERROR GetWiFiBeaconLostCount(const char * ifname, uint32_t & beaconLostCount);
static CHIP_ERROR GetWiFiBeaconRxCount(const char * ifname, uint32_t & beaconRxCount);
static CHIP_ERROR GetWiFiCurrentMaxRate(const char * ifname, uint64_t & currentMaxRate);
static CHIP_ERROR GetEthInterfaceName(char * ifname, size_t bufSize);
static CHIP_ERROR GetEthPHYRate(const char * ifname, app::Clusters::EthernetNetworkDiagnostics::PHYRateEnum & pHYRate);
Expand Down
16 changes: 16 additions & 0 deletions src/platform/Linux/DiagnosticDataProviderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,22 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiOverrunCount(uint64_t & overrunCou
return CHIP_NO_ERROR;
}

CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiBeaconRxCount(uint32_t & beaconRxCount)
{
uint32_t count;

if (ConnectivityMgrImpl().GetWiFiIfName() == nullptr)
{
return CHIP_ERROR_READ_FAILED;
}

ReturnErrorOnFailure(ConnectivityUtils::GetWiFiBeaconRxCount(ConnectivityMgrImpl().GetWiFiIfName(), count));
VerifyOrReturnError(count >= mBeaconRxCount, CHIP_ERROR_INVALID_INTEGER_VALUE);
beaconRxCount = count - mBeaconRxCount;

return CHIP_NO_ERROR;
}

CHIP_ERROR DiagnosticDataProviderImpl::ResetWiFiNetworkDiagnosticsCounts()
{
CHIP_ERROR err = CHIP_ERROR_READ_FAILED;
Expand Down
2 changes: 2 additions & 0 deletions src/platform/Linux/DiagnosticDataProviderImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class DiagnosticDataProviderImpl : public DiagnosticDataProvider
CHIP_ERROR GetWiFiChannelNumber(uint16_t & channelNumber) override;
CHIP_ERROR GetWiFiRssi(int8_t & rssi) override;
CHIP_ERROR GetWiFiBeaconLostCount(uint32_t & beaconLostCount) override;
CHIP_ERROR GetWiFiBeaconRxCount(uint32_t & beaconRxCount) override;
CHIP_ERROR GetWiFiPacketMulticastRxCount(uint32_t & packetMulticastRxCount) override;
CHIP_ERROR GetWiFiPacketMulticastTxCount(uint32_t & packetMulticastTxCount) override;
CHIP_ERROR GetWiFiPacketUnicastRxCount(uint32_t & packetUnicastRxCount) override;
Expand All @@ -97,6 +98,7 @@ class DiagnosticDataProviderImpl : public DiagnosticDataProvider

#if CHIP_DEVICE_CONFIG_ENABLE_WIFI
uint32_t mBeaconLostCount = 0;
uint32_t mBeaconRxCount = 0;
uint32_t mPacketMulticastRxCount = 0;
uint32_t mPacketMulticastTxCount = 0;
uint32_t mPacketUnicastRxCount = 0;
Expand Down

0 comments on commit ad538c1

Please sign in to comment.