diff mbox series

[07/17] client: show frequency with ap show

Message ID 20221101201747.143379-7-prestwoj@gmail.com (mailing list archive)
State Accepted, archived
Headers show
Series [01/17] wiphy: add wiphy_get_supported_ciphers | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-ci-gitlint success GitLint

Commit Message

James Prestwood Nov. 1, 2022, 8:17 p.m. UTC
---
 client/ap.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
diff mbox series

Patch

diff --git a/client/ap.c b/client/ap.c
index b8849a1b..4ce727de 100644
--- a/client/ap.c
+++ b/client/ap.c
@@ -36,6 +36,7 @@  struct ap {
 	bool started;
 	char *name;
 	bool scanning;
+	uint32_t freq;
 };
 
 static void *ap_create(void)
@@ -126,10 +127,35 @@  static const char *get_scanning_tostr(const void *data)
 	return ap->scanning ? "yes" : "no";
 }
 
+static void update_freq(void *data, struct l_dbus_message_iter *variant)
+{
+	struct ap *ap = data;
+	uint32_t value;
+
+	if (!l_dbus_message_iter_get_variant(variant, "u", &value)) {
+		ap->freq = 0;
+
+		return;
+	}
+
+	ap->freq = value;
+}
+
+static const char *get_freq_tostr(const void *data)
+{
+	const struct ap *ap = data;
+	static char str[5];
+
+	sprintf(str, "%u", ap->freq);
+
+	return str;
+}
+
 static const struct proxy_interface_property ap_properties[] = {
 	{ "Started",  "b", update_started,  get_started_tostr },
 	{ "Name",     "s", update_name, get_name_tostr },
 	{ "Scanning", "b", update_scanning, get_scanning_tostr },
+	{ "Frequency", "u", update_freq, get_freq_tostr },
 	{ }
 };