mirror of
https://github.com/jayofelony/pwnagotchi.git
synced 2025-07-01 18:37:27 -04:00
Update on Wi-Fi channels
Signed-off-by: Jeroen Oudshoorn <oudshoorn.jeroen@gmail.com>
This commit is contained in:
@ -1,14 +1,27 @@
|
||||
|
||||
NumChannels: int = 233
|
||||
|
||||
def freq_to_channel(freq: int) -> int:
|
||||
if 2412 <= freq <= 2472: # 2.4ghz wifi
|
||||
def freq_to_channel(freq: float) -> int:
|
||||
"""
|
||||
Convert a Wi-Fi frequency (in MHz) to its corresponding channel number.
|
||||
Supports 2.4 GHz, 5 GHz, and 6 GHz Wi-Fi bands.
|
||||
Args:
|
||||
freq: The frequency in MHz.
|
||||
Returns:
|
||||
The Wi-Fi channel as an integer, or ValueError if the frequency is invalid.
|
||||
"""
|
||||
# 2.4 GHz Wi-Fi channels
|
||||
if 2412 <= freq <= 2472: # 2.4 GHz Wi-Fi
|
||||
return int(((freq - 2412) / 5) + 1)
|
||||
elif freq == 2484: # channel 14 special
|
||||
return int(14)
|
||||
elif 5150 <= freq <= 5895: # 5ghz wifi
|
||||
return int(((freq - 5180) / 5) + 36)
|
||||
elif 5925 <= freq <= 7115: # 6ghz wifi
|
||||
return int(((freq - 5950) / 5) + 11)
|
||||
else:
|
||||
return 0
|
||||
elif freq == 2484: # Channel 14 special
|
||||
return 14
|
||||
# 5 GHz Wi-Fi channels
|
||||
elif 5150 <= freq <= 5850: # 5 GHz Wi-Fi
|
||||
if freq < 5270: # Channels 36-48
|
||||
return int(((freq - 5180) / 20) + 36)
|
||||
else: # Channels 149-165
|
||||
return int(((freq - 5745) / 20) + 149)
|
||||
# 6 GHz Wi-Fi channels
|
||||
elif 5925 <= freq <= 7125: # 6 GHz Wi-Fi
|
||||
return int(((freq - 5950) / 20) + 11)
|
||||
# If the frequency does not match any valid channel
|
||||
raise ValueError(f"The frequency {freq} MHz is not a valid Wi-Fi frequency.")
|
Reference in New Issue
Block a user