get rssi from iwinfo lib

This commit is contained in:
PolynomialDivision 2017-10-26 20:56:47 +02:00
parent bd1dbf39d6
commit eadbaa2765
3 changed files with 35 additions and 0 deletions

View file

@ -7,4 +7,6 @@
int get_rssi_from_iwinfo(__uint8_t *client_addr);
int get_rssi_iwinfo();
#endif //DAWN_RSSI_H

View file

@ -124,6 +124,8 @@ void free(void *p)
int main(int argc, char **argv) {
//free_counter = 0;
get_rssi_iwinfo();
const char *ubus_socket = NULL;
int ch;

View file

@ -10,6 +10,37 @@ int call_iwinfo(char *client_addr);
int parse_rssi(char *iwinfo_string);
#define IWINFO_BUFSIZE 24 * 1024
int get_rssi_iwinfo()
{
int i, len;
char buf[IWINFO_BUFSIZE];
struct iwinfo_assoclist_entry *e;
const struct iwinfo_ops *iw = NULL;
iw = iwinfo_backend("wlan0");
if (iw->assoclist(ifname, buf, &len))
{
printf("No information available\n");
return;
}
else if (len <= 0)
{
printf("No station connected\n");
return;
}
for (i = 0; i < len; i += sizeof(struct iwinfo_assoclist_entry))
{
e = (struct iwinfo_assoclist_entry *) &buf[i];
printf("iwinfo rssi: %d\n", e->signal);
}
}
int get_rssi_from_iwinfo(__uint8_t *client_addr) {
char mac_buf[20];
sprintf(mac_buf, MACSTR, MAC2STR(client_addr));