mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-12 10:22:12 +02:00
Wifi: adds 6 GHz channels detection
This commit is contained in:
@@ -29,13 +29,34 @@ typedef struct FFWifiResult {
|
||||
const char* ffDetectWifi(FFlist* result /*list of FFWifiItem*/);
|
||||
|
||||
static inline uint16_t ffWifiFreqToChannel(uint16_t frequency) {
|
||||
// https://github.com/opetryna/win32wifi/blob/master/win32wifi/Win32Wifi.py#L140
|
||||
// FIXME: Does it work for 6 GHz?
|
||||
// Return 0 for unknown / non-standard frequencies.
|
||||
if (frequency == 2484) {
|
||||
return 14;
|
||||
} else if (frequency < 2484) {
|
||||
return (uint16_t) ((frequency - 2407) / 5);
|
||||
} else {
|
||||
return (uint16_t) ((frequency / 5) - 1000);
|
||||
}
|
||||
|
||||
// 2.4 GHz channels 1-13
|
||||
if (frequency >= 2412 && frequency <= 2472 && ((frequency - 2407) % 5) == 0) {
|
||||
return (uint16_t) ((frequency - 2407) / 5);
|
||||
}
|
||||
|
||||
// 4.9 GHz public safety band (e.g. channels 182-196)
|
||||
if (frequency >= 4910 && frequency <= 4980 && ((frequency - 4000) % 5) == 0) {
|
||||
return (uint16_t) ((frequency - 4000) / 5);
|
||||
}
|
||||
|
||||
// 5 GHz channels
|
||||
if (frequency >= 5000 && frequency <= 5895 && ((frequency - 5000) % 5) == 0) {
|
||||
return (uint16_t) ((frequency - 5000) / 5);
|
||||
}
|
||||
|
||||
// 6 GHz channels (Wi-Fi 6E/7)
|
||||
// 5935 MHz is a special case mapped to channel 2.
|
||||
if (frequency == 5935) {
|
||||
return 2;
|
||||
}
|
||||
if (frequency >= 5955 && frequency <= 7115 && ((frequency - 5950) % 5) == 0) {
|
||||
return (uint16_t) ((frequency - 5950) / 5);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user