Skip to content

Commit

Permalink
respondd-module-airtime: add idx
Browse files Browse the repository at this point in the history
  • Loading branch information
AiyionPrime authored and blocktrron committed Apr 22, 2021
1 parent 0229863 commit 8d53ff5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
10 changes: 8 additions & 2 deletions net/respondd-module-airtime/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ The format is the following:
"busy": 46496566,
"rx": 808415,
"tx": 41711344,
"noise": 162
"noise": 162,
"phy": 1
},
{
"frequency": 2437,
"active": 366649704,
"busy": 205221222,
"rx": 108121446,
"tx": 85453679,
"noise": 161
"noise": 161,
"phy": 0
}
]
}
Expand All @@ -29,8 +31,12 @@ The format is the following:
The numbers `active`, `busy`, `rx` and `tx` are times in milliseconds, where
`busy`, `rx` and `tx` have to be interpreted by taking the quotient with
`active`.
`phy` is the index of the radio in the mac80211 subsystem.

The motivation for having a list with the frequency as a value in the objects
instead of having an object with the frequency as keys is that multiple wifi
devices might be present, in which case the same frequency can appear multiple
times (because the statistics are reported once for every phy).

The field `phy` is added to distinguish multiple radios in the same band.
It is not the key of mapped data due to backwards compatibility.
12 changes: 9 additions & 3 deletions net/respondd-module-airtime/src/respondd.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
#include "ifaces.h"

static struct json_object *respondd_provider_statistics(void) {
struct json_object *result, *wireless;
bool ok;
int newest_element_index;
struct json_object *last, *result, *wireless;
struct iface_list *ifaces;

result = json_object_new_object();
Expand All @@ -22,8 +24,12 @@ static struct json_object *respondd_provider_statistics(void) {

ifaces = get_ifaces();
while (ifaces != NULL) {
get_airtime(wireless, ifaces->ifx);

ok = get_airtime(wireless, ifaces->ifx);
if (ok) {
newest_element_index = json_object_array_length(wireless)-1;
last = json_object_array_get_idx(wireless, newest_element_index);
json_object_object_add(last, "phy", json_object_new_int(ifaces->wiphy));
}
void *freeptr = ifaces;
ifaces = ifaces->next;
free(freeptr);
Expand Down

0 comments on commit 8d53ff5

Please sign in to comment.