From 2b80d7bf27de15701dbabba96693c400caecce77 Mon Sep 17 00:00:00 2001 From: Bruna Moreira Date: Thu, 30 Sep 2010 16:00:37 -0400 Subject: [PATCH] Make handle parameter mandatory in gatttool If the characteristic read option (--char-read) is used, the handle option (-a) must be provided. --- attrib/gatttool.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/attrib/gatttool.c b/attrib/gatttool.c index 810fa8e31..59a4ee9a4 100644 --- a/attrib/gatttool.c +++ b/attrib/gatttool.c @@ -52,7 +52,7 @@ static gchar *opt_src = NULL; static gchar *opt_dst = NULL; static int opt_start = 0x0001; static int opt_end = 0xffff; -static int opt_handle = 0x0001; +static int opt_handle = -1; static int opt_mtu = 0; static gboolean opt_primary = FALSE; static gboolean opt_characteristics = FALSE; @@ -341,6 +341,12 @@ static gboolean characteristics_read(gpointer user_data) { GAttrib *attrib = user_data; + if (opt_handle <= 0) { + g_printerr("A valid handle is required\n"); + g_main_loop_quit(event_loop); + return FALSE; + } + gatt_read_char(attrib, opt_handle, char_read_cb, attrib); return FALSE; @@ -408,7 +414,7 @@ static GOptionEntry primary_char_options[] = { static GOptionEntry char_read_options[] = { { "handle", 'a' , 0, G_OPTION_ARG_INT, &opt_handle, - "Read characteristic by handle(optional)", "0x0001" }, + "Read characteristic by handle(required)", "0x0001" }, {NULL}, };