Skip to contentSkip to conversation

Implement btmgmt BTLE Network Management API

PATCH New Patrik Flykt 1 participant 4 messages Mar 4, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Implement btmgmt BTLE Network Management API

	Hi,

This patch set implements the commands in RFC v3 of the Network Management API proposal for the btmgmt tool.

Please review,

Patrik

Patrik Flykt (3):
btmgmt: Implement Get Networks Management API command
btmgmt: Implement Add Network Management API command
btmgmt: Implement Remove Network Management API command

 lib/mgmt.h     |  45 ++++++++++
 tools/btmgmt.c | 256 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 301 insertions(+)
Signature · 1 line
2.1.4
#1 lore raw

PATCH 1/3 btmgmt: Implement Get Networks Management API command

Send MGMT_OP_GET_NETWORKS Management API command and print out the connected networks, if any.

---
 lib/mgmt.h     | 11 +++++++++++
 tools/btmgmt.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 65 insertions(+)
lib/mgmt.h +11 -0
index f6a976a..9db853c 100644
@@ -530,6 +530,16 @@ struct mgmt_rp_get_adv_size_info {
 
 #define MGMT_OP_START_LIMITED_DISCOVERY	0x0041
 
+#define MGMT_OP_GET_NETWORKS		0x0042
+#define MGMT_GET_NETWORKS_SIZE		0
+struct mgmt_rp_get_networks {
+	uint16_t count;
+} __packed; /* followed by zero or more struct mgmt_rp_network */
+struct mgmt_rp_network {
+	struct mgmt_addr_info dst;
+	uint32_t ifindex;
+} __packed;
+
 #define MGMT_EV_CMD_COMPLETE		0x0001
 struct mgmt_ev_cmd_complete {
 	uint16_t opcode;
@@ -809,6 +819,7 @@ static const char *mgmt_op[] = {
 	"Remove Advertising",
 	"Get Advertising Size Information",		/* 0x0040 */
 	"Start Limited Discovery",
+	"Get Networks",
 };
 
 static const char *mgmt_ev[] = {
tools/btmgmt.c +54 -0

66 lines not on this page · raw message

Signature · 1 line
2.1.4
#2 lore raw

PATCH 2/3 btmgmt: Implement Add Network Management API command

In reply to Patrik Flykt

Send MGMT_OP_ADD_NETWORK Management API command to create a connection to a remote 6LowPAN device and wait for the command to complete before printing out a result.

Also listen for MGMT_EV_NETWORK_ADDED events that indicate creation of other connections not requested by us.

---
 lib/mgmt.h     |  18 ++++++++++
 tools/btmgmt.c | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 124 insertions(+)
lib/mgmt.h +18 -0
index 9db853c..8a9178e 100644
@@ -540,6 +540,16 @@ struct mgmt_rp_network {
 	uint32_t ifindex;
 } __packed;
 
+#define MGMT_OP_ADD_NETWORK		0x0043
+#define MGMT_ADD_NETWORK_SIZE		7
+struct mgmt_cp_add_network {
+	struct mgmt_addr_info dst;
+} __packed;
+struct mgmt_rp_add_network {
+	struct mgmt_addr_info dst;
+	int ifindex;
+} __packed;
+
 #define MGMT_EV_CMD_COMPLETE		0x0001
 struct mgmt_ev_cmd_complete {
 	uint16_t opcode;
@@ -752,6 +762,12 @@ struct mgmt_ev_advertising_removed {
 	uint8_t instance;
 } __packed;
 
+#define MGMT_EV_NETWORK_ADDED		0x0025
+struct mgmt_ev_network_added {
+	struct mgmt_addr_info dst;
+	int ifindex;
+} __packed;
+
 static const char *mgmt_op[] = {
 	"<0x0000>",
 	"Read Version",
@@ -820,6 +836,7 @@ static const char *mgmt_op[] = {
 	"Get Advertising Size Information",		/* 0x0040 */
 	"Start Limited Discovery",
 	"Get Networks",
+	"Add Network",
 };
 
 static const char *mgmt_ev[] = {
@@ -860,6 +877,7 @@ static const char *mgmt_ev[] = {
 	"Local Out Of Band Extended Data Updated",
 	"Advertising Added",
 	"Advertising Removed",
+	"Network Added",
 };
 
 static const char *mgmt_status[] = {
tools/btmgmt.c +106 -0

130 lines not on this page · raw message

Signature · 1 line
2.1.4
#3 lore raw

PATCH 3/3 btmgmt: Implement Remove Network Management API command

In reply to Patrik Flykt

Send MGMT_OP_REMOVE_NETWORK Management API command to disconnect a connection to a remote 6LowPAN device. Wait for the command to complete before printing out a result.

Also listen for MGMT_EV_NETWORK_REMOVED events that indicate disconnection of other connections not requested by us.

---
 lib/mgmt.h     | 16 ++++++++++
 tools/btmgmt.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 112 insertions(+)
lib/mgmt.h +16 -0
index 8a9178e..43475e7 100644
@@ -550,6 +550,15 @@ struct mgmt_rp_add_network {
 	int ifindex;
 } __packed;
 
+#define MGMT_OP_REMOVE_NETWORK		0x0044
+#define MGMT_REMOVE_NETWORK_SIZE	7
+struct mgmt_cp_remove_network {
+	struct mgmt_addr_info dst;
+} __packed;
+struct mgmt_rp_remove_network {
+        struct mgmt_addr_info dst;
+} __packed;
+
 #define MGMT_EV_CMD_COMPLETE		0x0001
 struct mgmt_ev_cmd_complete {
 	uint16_t opcode;
@@ -768,6 +777,11 @@ struct mgmt_ev_network_added {
 	int ifindex;
 } __packed;
 
+#define MGMT_EV_NETWORK_REMOVED		0x0026
+struct mgmt_ev_network_removed {
+	struct mgmt_addr_info dst;
+} __packed;
+
 static const char *mgmt_op[] = {
 	"<0x0000>",
 	"Read Version",
@@ -837,6 +851,7 @@ static const char *mgmt_op[] = {
 	"Start Limited Discovery",
 	"Get Networks",
 	"Add Network",
+	"Remove Network",
 };
 
 static const char *mgmt_ev[] = {
@@ -878,6 +893,7 @@ static const char *mgmt_ev[] = {
 	"Advertising Added",
 	"Advertising Removed",
 	"Network Added",
+	"Network Removed",
 };
 
 static const char *mgmt_status[] = {
tools/btmgmt.c +96 -0

120 lines not on this page · raw message

Signature · 1 line
2.1.4