Derive the RSSI of a measurement-report based on it's RCPI.
Signed-off-by: David Bauer <mail@david-bauer.net>
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)
{
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);
}
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);