Skip to content

Commit

Permalink
add frequency and rx,tx for WirelessInfos
Browse files Browse the repository at this point in the history
  • Loading branch information
T0biii committed May 12, 2024
1 parent 23bff8d commit e418b80
Showing 1 changed file with 52 additions and 1 deletion.
53 changes: 52 additions & 1 deletion unifi_respondd/respondd_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,23 @@ class ClientInfo:
wifi24: int
wifi5: int

@dataclasses.dataclass
class WirelessInfo:
"""This class contains the Wireless information of an AP.
Attributes:
frequency:
noise:
active:
busy:
rx:
tx:"""

frequency: int
#noise: int
#active: int
#busy: int
rx: int
tx: int

@dataclasses.dataclass
class MemoryInfo:
Expand Down Expand Up @@ -178,7 +195,11 @@ class StatisticsInfo:
node_id: The node id of the AP. This is the same as the MAC address (without :).
loadavg: The load average of the AP.
memory: The memory information of the AP.
traffic: The traffic information of the AP."""
traffic: The traffic information of the AP.
gateway: The MAC of the IPv4 Gateway
gateway6: The MAC of the IPv6 Gateway
gateway_nexthop: The MAC of the nexthop Gateway
wireless: The WirelessInfos of the AP"""

clients: ClientInfo
uptime: int
Expand All @@ -189,6 +210,7 @@ class StatisticsInfo:
gateway: str
gateway6: str
gateway_nexthop: str
wireless: List[WirelessInfo]


@dataclasses.dataclass
Expand Down Expand Up @@ -268,11 +290,39 @@ def getNodeInfos(self):
)
return nodes

@staticmethod
def frequency_from_channel(channel):
if channel >= 36:
return 5000 + (channel - 36) * 5
else:
if channel == 14:
return 2484
elif channel < 14:
return 2407 + (channel - 1) * 5

def getStatistics(self):
"""This method returns the statistics information of all APs."""
aps = self._aps
statistics = []
for ap in aps.accesspoints:
wirelessinfos = []
frequency5 = self.frequency_from_channel(ap.channel5)
wirelessinfos.append(
WirelessInfo(
frequency=frequency5,
rx=ap.rx_bytes5,
tx=ap.tx_bytes5,
)
)
frequency24 = self.frequency_from_channel(ap.channel24)
wirelessinfos.append(
WirelessInfo(
frequency=frequency24,
rx=ap.rx_bytes5,
tx=ap.tx_bytes5,
)
)

statistics.append(
StatisticsInfo(
clients=ClientInfo(
Expand All @@ -296,6 +346,7 @@ def getStatistics(self):
gateway=ap.gateway,
gateway6=ap.gateway6,
gateway_nexthop=ap.gateway_nexthop,
wireless=wirelessinfos
)
)
return statistics
Expand Down

0 comments on commit e418b80

Please sign in to comment.