[BlueZ PATCH] adv_monitor: parse AD type as hex value

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

 



Currently bluetoothctl parse pattern as a decimal string, but the
Bluetooth SIG website uses hex value instead.
(https://www.bluetooth.com/specifications/assigned-numbers/generic-access-
profile/)

Reviewed-by: Manish Mandlik <mmandlik@xxxxxxxxxxxx>
---

 client/adv_monitor.c | 4 ++--
 client/main.c        | 4 ++++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/client/adv_monitor.c b/client/adv_monitor.c
index 90ab0be093d2..74f19d2d93e4 100644
--- a/client/adv_monitor.c
+++ b/client/adv_monitor.c
@@ -435,7 +435,7 @@ static struct pattern *parse_pattern(char *parameter_list[])
 	}
 
 	pat->start_pos = atoi(parameter_list[0]);
-	pat->ad_data_type = atoi(parameter_list[1]);
+	pat->ad_data_type = strtol(parameter_list[1], NULL, 16);
 	pat->content_len = str2bytearray(parameter_list[2], pat->content);
 	if (pat->content_len == 0) {
 		free_pattern(pat);
@@ -542,7 +542,7 @@ static void print_adv_monitor(struct adv_monitor *adv_monitor)
 			bt_shell_printf("\tpattern %d:\n", idx);
 			bt_shell_printf("\t\tstart position: %hhu\n",
 							pattern->start_pos);
-			bt_shell_printf("\t\tAD data type: %hhu\n",
+			bt_shell_printf("\t\tAD data type: 0x%02x\n",
 							pattern->ad_data_type);
 			print_bytearray("\t\tcontent: ", pattern->content,
 							pattern->content_len);
diff --git a/client/main.c b/client/main.c
index 60f1eb86e26a..16cb0234c48e 100644
--- a/client/main.c
+++ b/client/main.c
@@ -2724,6 +2724,8 @@ static void print_add_or_pattern_with_rssi_usage(void)
 						RSSI_DEFAULT_HIGH_TIMEOUT);
 	bt_shell_printf("pattern format:\n"
 			"\t<start_position> <ad_data_type> <content_of_pattern>\n");
+	bt_shell_printf("Note: both ad_data_type and content_of_pattern are "
+			"hex string\n");
 	bt_shell_printf("e.g.\n"
 			"\tadd-or-pattern-rssi -10, ,10 1 2 01ab55\n");
 	bt_shell_printf("or\n"
@@ -2734,6 +2736,8 @@ static void print_add_or_pattern_usage(void)
 {
 	bt_shell_printf("pattern format:\n"
 			"\t<start_position> <ad_data_type> <content_of_pattern>\n");
+	bt_shell_printf("Note: both ad_data_type and content_of_pattern are "
+			"hex string\n");
 	bt_shell_printf("e.g.\n"
 			"\tadd-or-pattern 1 2 01ab55 3 4 23cd66\n");
 }
-- 
2.28.0.806.g8561365e88-goog




[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