[PATCH wpan-tools 2/6] phy: add support for tx power pib attribute

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Alexander Aring <alex.aring@xxxxxxxxx>
---
 src/nl802154.h |  4 ++++
 src/phy.c      | 28 ++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/src/nl802154.h b/src/nl802154.h
index 51d08b0..1af09ac 100644
--- a/src/nl802154.h
+++ b/src/nl802154.h
@@ -43,6 +43,8 @@ enum nl802154_commands {
 
 	NL802154_CMD_SET_PAN_ID,
 
+	NL802154_CMD_SET_TX_POWER,
+
 	/* add new commands above here */
 
 	/* used to define NL802154_CMD_MAX below */
@@ -71,6 +73,8 @@ enum nl802154_attrs {
 
 	NL802154_ATTR_PAN_ID,
 
+	NL802154_ATTR_TX_POWER,
+
 	/* add attributes here, update the policy in nl802154.c */
 
 	__NL802154_ATTR_AFTER_LAST,
diff --git a/src/phy.c b/src/phy.c
index 33365dd..811fc35 100644
--- a/src/phy.c
+++ b/src/phy.c
@@ -9,6 +9,7 @@
 #include <netlink/msg.h>
 #include <netlink/attr.h>
 
+#include "nl_updates.h"
 #include "nl802154.h"
 #include "iwpan.h"
 
@@ -65,3 +66,30 @@ nla_put_failure:
 }
 COMMAND(set, channel, "<channel>",
 	NL802154_CMD_SET_CHANNEL, 0, CIB_PHY, handle_channel_set, NULL);
+
+static int handle_tx_power_set(struct nl802154_state *state,
+			       struct nl_cb *cb,
+			       struct nl_msg *msg,
+			       int argc, char **argv,
+			       enum id_input id)
+{
+	long dbm;
+	char *end;
+
+	if (argc < 1)
+		return 1;
+
+	/* TX_POWER */
+	dbm = strtol(argv[0], &end, 10);
+	if (*end != '\0')
+		return 1;
+
+	NLA_PUT_S8(msg, NL802154_ATTR_TX_POWER, dbm);
+
+	return 0;
+
+nla_put_failure:
+	return -ENOBUFS;
+}
+COMMAND(set, tx_power, "<dBm>",
+	NL802154_CMD_SET_TX_POWER, 0, CIB_PHY, handle_tx_power_set, NULL);
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-wpan" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux