ubus: derive RSSI from measurement report

Derive the RSSI of a measurement-report based on it's RCPI.

Signed-off-by: David Bauer <mail@david-bauer.net>
This commit is contained in:
David Bauer
2022-05-23 01:12:38 +02:00
parent 87de1ab655
commit 9059b9a537
3 changed files with 18 additions and 0 deletions

View File

@@ -20,6 +20,21 @@
LIST_HEAD(measurements);
static struct usteer_timeout_queue tq;
int
usteer_measurement_get_rssi(struct usteer_measurement_report *report)
{
/* Apple devices always set the RSNI to 0, while
* it should be set to 255 in case RSNI is unavailable.
*
* For them, RCPI seems to be calculated as RCPI = 255 + (RSSI)
*/
if (!report->rsni)
return report->rcpi - 255;
return (report->rcpi / 2) - 110;
}
void
usteer_measurement_report_node_cleanup(struct usteer_node *node)
{

1
ubus.c
View File

@@ -449,6 +449,7 @@ usteer_ubus_get_connected_clients(struct ubus_context *ctx, struct ubus_object *
blobmsg_add_string(&b, "node", usteer_node_name(mr->node));
blobmsg_add_u32(&b, "rcpi", mr->rcpi);
blobmsg_add_u32(&b, "rsni", mr->rsni);
blobmsg_add_u32(&b, "rssi", usteer_measurement_get_rssi(mr));
blobmsg_add_u64(&b, "timestamp", mr->timestamp);
blobmsg_close_table(&b, t);
}

View File

@@ -383,6 +383,8 @@ void usteer_run_hook(const char *name, const char *arg);
void usteer_dump_node(struct blob_buf *buf, struct usteer_node *node);
void usteer_dump_host(struct blob_buf *buf, struct usteer_remote_host *host);
int usteer_measurement_get_rssi(struct usteer_measurement_report *report);
struct usteer_measurement_report * usteer_measurement_report_get(struct sta *sta, struct usteer_node *node, bool create);
void usteer_measurement_report_node_cleanup(struct usteer_node *node);
void usteer_measurement_report_sta_cleanup(struct sta *sta);