From 76424950e373d3b04ac3dd13019151bfba3e8423 Mon Sep 17 00:00:00 2001 From: sumuel Date: Mon, 17 Aug 2026 20:44:55 +0000 Subject: Add the files --- src/detection/wifi/wifi.h | 62 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/detection/wifi/wifi.h (limited to 'src/detection/wifi/wifi.h') diff --git a/src/detection/wifi/wifi.h b/src/detection/wifi/wifi.h new file mode 100644 index 0000000..e457295 --- /dev/null +++ b/src/detection/wifi/wifi.h @@ -0,0 +1,62 @@ +#pragma once + +#include "fastfetch.h" +#include "modules/wifi/option.h" + +struct FFWifiInterface { + FFstrbuf description; + FFstrbuf status; +}; + +struct FFWifiConnection { + FFstrbuf status; + FFstrbuf ssid; + FFstrbuf bssid; + FFstrbuf protocol; + FFstrbuf security; + double signalQuality; // Percentage + double rxRate; + double txRate; + uint16_t channel; + uint16_t frequency; // MHz +}; + +typedef struct FFWifiResult { + struct FFWifiInterface inf; + struct FFWifiConnection conn; +} FFWifiResult; + +const char* ffDetectWifi(FFlist* result /*list of FFWifiItem*/); + +static inline uint16_t ffWifiFreqToChannel(uint16_t frequency) { + // Return 0 for unknown / non-standard frequencies. + if (frequency == 2484) { + return 14; + } + + // 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; +} -- cgit v1.2.3