summaryrefslogtreecommitdiff
path: root/src/print_wireless_info.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/print_wireless_info.c')
-rw-r--r--src/print_wireless_info.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/print_wireless_info.c b/src/print_wireless_info.c
index 18f6580..7f7c52e 100644
--- a/src/print_wireless_info.c
+++ b/src/print_wireless_info.c
@@ -55,6 +55,7 @@
#define WIRELESS_INFO_FLAG_HAS_QUALITY (1 << 1)
#define WIRELESS_INFO_FLAG_HAS_SIGNAL (1 << 2)
#define WIRELESS_INFO_FLAG_HAS_NOISE (1 << 3)
+#define WIRELESS_INFO_FLAG_HAS_FREQUENCY (1 << 4)
#define PERCENT_VALUE(value, total) ((int)(value * 100 / (float)total + 0.5f))
@@ -69,6 +70,7 @@ typedef struct {
int noise_level;
int noise_level_max;
int bitrate;
+ double frequency;
} wireless_info_t;
static int get_wireless_info(const char *interface, wireless_info_t *info) {
@@ -93,6 +95,11 @@ static int get_wireless_info(const char *interface, wireless_info_t *info) {
info->essid[IW_ESSID_MAX_SIZE] = '\0';
}
+ if (wcfg.has_freq) {
+ info->frequency = wcfg.freq;
+ info->flags |= WIRELESS_INFO_FLAG_HAS_FREQUENCY;
+ }
+
/* If the function iw_get_stats does not return proper stats, the
wifi is considered as down.
Since ad-hoc network does not have theses stats, we need to return
@@ -395,6 +402,14 @@ void print_wireless_info(yajl_gen json_gen, char *buffer, const char *interface,
walk += strlen("essid");
}
+ if (BEGINS_WITH(walk+1, "frequency")) {
+ if (info.flags & WIRELESS_INFO_FLAG_HAS_FREQUENCY)
+ outwalk += sprintf(outwalk, "%1.1f GHz", info.frequency / 1e9);
+ else
+ *(outwalk++) = '?';
+ walk += strlen("frequency");
+ }
+
if (BEGINS_WITH(walk+1, "ip")) {
outwalk += sprintf(outwalk, "%s", ip_address);
walk += strlen("ip");