Skip to content

Commit 94f8ff9

Browse files
committed
Wifi: print channel band
1 parent 7000317 commit 94f8ff9

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

src/detection/wifi/wifi_apple.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,8 @@ @interface CWInterface()
296296
switch (inf.wlanChannel.channelBand)
297297
{
298298
case kCWChannelBand2GHz: item->conn.frequency = 2400; break;
299-
case kCWChannelBand5GHz: item->conn.frequency = 5000; break;
300-
case 3 /*kCWChannelBand6GHz*/: item->conn.frequency = 6000; break;
299+
case kCWChannelBand5GHz: item->conn.frequency = 5400; break;
300+
case 3 /*kCWChannelBand6GHz*/: item->conn.frequency = 6400; break;
301301
default: item->conn.frequency = 0; break;
302302
}
303303
}

src/modules/wifi/wifi.c

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "modules/wifi/wifi.h"
55
#include "util/stringUtils.h"
66

7-
#define FF_WIFI_NUM_FORMAT_ARGS 11
7+
#define FF_WIFI_NUM_FORMAT_ARGS 13
88

99
void ffPrintWifi(FFWifiOptions* options)
1010
{
@@ -29,6 +29,27 @@ void ffPrintWifi(FFWifiOptions* options)
2929
FFWifiResult* item = FF_LIST_GET(FFWifiResult, result, index);
3030
uint8_t moduleIndex = result.length == 1 ? 0 : (uint8_t)(index + 1);
3131

32+
// https://en.wikipedia.org/wiki/List_of_WLAN_channels
33+
char bandStr[8];
34+
if (item->conn.frequency > 58000)
35+
strcpy(bandStr, "60");
36+
if (item->conn.frequency > 40000)
37+
strcpy(bandStr, "45");
38+
else if (item->conn.frequency > 5900)
39+
strcpy(bandStr, "6");
40+
else if (item->conn.frequency > 5100)
41+
strcpy(bandStr, "5");
42+
else if (item->conn.frequency > 4900)
43+
strcpy(bandStr, "4.9");
44+
else if (item->conn.frequency > 3600)
45+
strcpy(bandStr, "3.65");
46+
else if (item->conn.frequency > 2000)
47+
strcpy(bandStr, "2.4");
48+
else if (item->conn.frequency > 800)
49+
strcpy(bandStr, "0.9");
50+
else
51+
bandStr[0] = '\0';
52+
3253
if(options->moduleArgs.outputFormat.length == 0)
3354
{
3455
ffPrintLogoAndKey(FF_WIFI_MODULE_NAME, moduleIndex, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
@@ -54,6 +75,8 @@ void ffPrintWifi(FFWifiOptions* options)
5475
ffStrbufAppendS(&buffer, " - ");
5576
ffStrbufAppend(&buffer, &item->conn.protocol);
5677
}
78+
if (bandStr[0])
79+
ffStrbufAppendF(&buffer, " - %s GHz", bandStr);
5780
if(item->conn.security.length)
5881
{
5982
ffStrbufAppendS(&buffer, " - ");
@@ -97,6 +120,8 @@ void ffPrintWifi(FFWifiOptions* options)
97120
FF_FORMAT_ARG(item->conn.txRate, "tx-rate"),
98121
FF_FORMAT_ARG(item->conn.security, "security"),
99122
FF_FORMAT_ARG(percentBar, "signal-quality-bar"),
123+
FF_FORMAT_ARG(item->conn.channel, "channel"),
124+
FF_FORMAT_ARG(bandStr, "band"),
100125
}));
101126
}
102127

@@ -211,6 +236,8 @@ void ffPrintWifiHelpFormat(void)
211236
"Connection TX rate - tx-rate",
212237
"Connection Security algorithm - security",
213238
"Connection signal quality (percentage bar) - signal-quality-bar",
239+
"Connection channel number - channel",
240+
"Connection channel band in GHz - band",
214241
}));
215242
}
216243

0 commit comments

Comments
 (0)