From: David Bauer Date: Thu, 31 Mar 2022 22:19:59 +0000 (+0200) Subject: measurement: generalize measurement handling X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=7df969fd39d0cca7584a9498399add27d4529dd7;p=project%2Fusteer.git measurement: generalize measurement handling Generalize measurement handling in a way that RCPi and RSNI are stored regardless of the specific measurement type. This allows us to handle link-measurement reports the same way as we already handle beacon-reports. Signed-off-by: David Bauer --- diff --git a/local_node.c b/local_node.c index e5620e5..baaa608 100644 --- a/local_node.c +++ b/local_node.c @@ -205,8 +205,6 @@ usteer_local_node_handle_beacon_report(struct usteer_local_node *ln, struct blob [BR_RSNI] = { .name = "rsni", .type = BLOBMSG_TYPE_INT16 }, }; struct blob_attr *tb[__BR_MAX]; - - struct usteer_beacon_report br; struct usteer_node *node; uint8_t *addr; struct sta *sta; @@ -231,10 +229,10 @@ usteer_local_node_handle_beacon_report(struct usteer_local_node *ln, struct blob if (!node) return 0; - br.rcpi = (uint8_t)blobmsg_get_u16(tb[BR_RCPI]); - br.rsni = (uint8_t)blobmsg_get_u16(tb[BR_RSNI]); - - usteer_measurement_report_add_beacon_report(sta, node, &br, current_time); + usteer_measurement_report_add(sta, node, + (uint8_t)blobmsg_get_u16(tb[BR_RCPI]), + (uint8_t)blobmsg_get_u16(tb[BR_RSNI]), + current_time); return 0; } diff --git a/measurement.c b/measurement.c index c1b5ab4..c78aae8 100644 --- a/measurement.c +++ b/measurement.c @@ -73,8 +73,8 @@ usteer_measurement_report_get(struct sta *sta, struct usteer_node *node, bool cr } struct usteer_measurement_report * -usteer_measurement_report_add_beacon_report(struct sta *sta, struct usteer_node *node, - struct usteer_beacon_report *br, uint64_t timestamp) +usteer_measurement_report_add(struct sta *sta, struct usteer_node *node, + uint8_t rcpi, uint8_t rsni, uint64_t timestamp) { struct usteer_measurement_report *mr = usteer_measurement_report_get(sta, node, true); @@ -82,7 +82,8 @@ usteer_measurement_report_add_beacon_report(struct sta *sta, struct usteer_node return NULL; mr->timestamp = timestamp; - memcpy(&mr->beacon_report, br, sizeof(*br)); + mr->rsni = rsni; + mr->rcpi = rcpi; return mr; } diff --git a/ubus.c b/ubus.c index 95614b9..0fa7e36 100644 --- a/ubus.c +++ b/ubus.c @@ -446,8 +446,8 @@ usteer_ubus_get_connected_clients(struct ubus_context *ctx, struct ubus_object * list_for_each_entry(mr, &si->sta->measurements, sta_list) { t = blobmsg_open_table(&b, ""); blobmsg_add_string(&b, "node", usteer_node_name(mr->node)); - blobmsg_add_u32(&b, "rcpi", mr->beacon_report.rcpi); - blobmsg_add_u32(&b, "rsni", mr->beacon_report.rsni); + blobmsg_add_u32(&b, "rcpi", mr->rcpi); + blobmsg_add_u32(&b, "rsni", mr->rsni); blobmsg_add_u64(&b, "timestamp", mr->timestamp); blobmsg_close_table(&b, t); } diff --git a/usteer.h b/usteer.h index 7066355..34c958b 100644 --- a/usteer.h +++ b/usteer.h @@ -281,11 +281,6 @@ struct sta { uint8_t addr[6]; }; -struct usteer_beacon_report { - uint8_t rcpi; - uint8_t rsni; -}; - struct usteer_measurement_report { struct usteer_timeout timeout; @@ -299,7 +294,8 @@ struct usteer_measurement_report { uint64_t timestamp; - struct usteer_beacon_report beacon_report; + uint8_t rcpi; + uint8_t rsni; }; extern struct ubus_context *ubus_ctx; @@ -390,6 +386,6 @@ void usteer_measurement_report_sta_cleanup(struct sta *sta); void usteer_measurement_report_del(struct usteer_measurement_report *mr); struct usteer_measurement_report * -usteer_measurement_report_add_beacon_report(struct sta *sta, struct usteer_node *node, struct usteer_beacon_report *br, uint64_t timestamp); +usteer_measurement_report_add(struct sta *sta, struct usteer_node *node, uint8_t rcpi, uint8_t rsni, uint64_t timestamp); #endif