Skip to content

Commit

Permalink
add wireless infos
Browse files Browse the repository at this point in the history
  • Loading branch information
T0biii committed May 12, 2024
1 parent ab0cd0f commit 23bff8d
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions unifi_respondd/unifi_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ class Accesspoint:
client_count: int
client_count24: int
client_count5: int
channel5: int
rx_bytes5: bytes
tx_bytes5: bytes
channel24: int
rx_bytes24: bytes
tx_bytes24: bytes
latitude: float
longitude: float
model: str
Expand Down Expand Up @@ -85,6 +91,23 @@ def get_client_count_for_ap(ap_mac, clients, cfg):
client24_count += 1
return client24_count + client5_count, client24_count, client5_count

def get_ap_channel_usage(ssids, cfg):
"""This function returns the channels used for the Freifunk SSIDs"""
for ssid in ssids:
if re.search(cfg.ssid_regex, ssid.get("essid", "")):
channel = ssid.get("channel", 0)
rx_bytes = ssid.get("rx_bytes", 0)
tx_bytes = ssid.get("tx_bytes", 0)
if channel > 14:
channel5 = channel
rx_bytes5 = rx_bytes
tx_bytes5 = tx_bytes
else:
channel24 = channel
rx_bytes24 = tx_bytes
tx_bytes24 = tx_bytes

return channel5, rx_bytes5, tx_bytes5, channel24, rx_bytes24, tx_bytes24

def get_location_by_address(address, app):
"""This function returns latitude and longitude of a given address."""
Expand Down Expand Up @@ -162,6 +185,16 @@ def get_infos():
client_count24,
client_count5,
) = get_client_count_for_ap(ap.get("mac", None), clients, cfg)

(
channel5,
rx_bytes5,
tx_bytes5,
channel24,
rx_bytes24,
tx_bytes24,
) = get_ap_channel_usage(ssids, cfg)

lat, lon = 0, 0
neighbour_macs = []
if ap.get("snmp_location", None) is not None:
Expand Down Expand Up @@ -203,6 +236,12 @@ def get_infos():
client_count=client_count,
client_count24=client_count24,
client_count5=client_count5,
channel5=channel5,
rx_bytes5=rx_bytes5,
tx_bytes5=tx_bytes5,
channel24=channel24,
rx_bytes24=rx_bytes24,
tx_bytes24=tx_bytes24,
latitude=float(lat),
longitude=float(lon),
model=ap.get("model", None),
Expand Down

0 comments on commit 23bff8d

Please sign in to comment.