[PATCH BlueZ 01/10 v2] tools/mesh: Remove extra dependencies from agent.c

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

 



This removes dependency on glib and mesh/util.c.
Also, fixes few style glitches.
---
 tools/mesh/agent.c | 32 +++++++++++++++++++++++---------
 1 file changed, 23 insertions(+), 9 deletions(-)

diff --git a/tools/mesh/agent.c b/tools/mesh/agent.c
index 08e498541..0ec76f3b7 100644
--- a/tools/mesh/agent.c
+++ b/tools/mesh/agent.c
@@ -30,12 +30,9 @@
 #include <stdbool.h>
 #include <inttypes.h>
 
-#include <glib.h>
-
 #include <lib/bluetooth.h>
 
 #include "src/shared/shell.h"
-#include "tools/mesh/util.h"
 #include "tools/mesh/agent.h"
 
 struct input_request {
@@ -63,6 +60,22 @@ static void reset_input_request(void)
 	pending_request.user_data = NULL;
 }
 
+static bool str2hex(const char *str, uint16_t in_len, uint8_t *out,
+							uint16_t out_len)
+{
+	uint16_t i;
+
+	if (in_len < out_len * 2)
+		return false;
+
+	for (i = 0; i < out_len; i++) {
+		if (sscanf(&str[i * 2], "%02hhx", &out[i]) != 1)
+			return false;
+	}
+
+	return true;
+}
+
 static void response_hexadecimal(const char *input, void *user_data)
 {
 	uint8_t buf[MAX_HEXADECIMAL_OOB_LEN];
@@ -111,8 +124,8 @@ static bool request_hexadecimal(uint16_t len)
 		return false;
 
 	bt_shell_printf("Request hexadecimal key (hex %d octets)\n", len);
-	bt_shell_prompt_input("mesh", "Enter key (hex number):", response_hexadecimal,
-								NULL);
+	bt_shell_prompt_input("mesh", "Enter key (hex number):",
+						response_hexadecimal, NULL);
 
 	return true;
 }
@@ -130,7 +143,8 @@ static uint32_t power_ten(uint8_t power)
 static bool request_decimal(uint16_t len)
 {
 	bt_shell_printf("Request decimal key (0 - %d)\n", power_ten(len) - 1);
-	bt_shell_prompt_input("mesh", "Enter Numeric key:", response_decimal, NULL);
+	bt_shell_prompt_input("mesh-agent", "Enter Numeric key:",
+							response_decimal, NULL);
 
 	return true;
 }
@@ -141,8 +155,8 @@ static bool request_ascii(uint16_t len)
 		return false;
 
 	bt_shell_printf("Request ASCII key (max characters %d)\n", len);
-	bt_shell_prompt_input("mesh", "Enter key (ascii string):", response_ascii,
-									NULL);
+	bt_shell_prompt_input("mesh", "Enter key (ascii string):",
+							response_ascii, NULL);
 
 	return true;
 }
@@ -153,7 +167,7 @@ bool agent_input_request(oob_type_t type, uint16_t max_len, agent_input_cb cb,
 	bool result;
 
 	if (pending_request.type != NONE)
-		return FALSE;
+		return false;
 
 	switch (type) {
 	case HEXADECIMAL:
-- 
2.21.0




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux