* [PATCH] Remove unused MTU variable in Gattrib struct
From: Bruna Moreira @ 2011-02-24 21:20 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Bruna Moreira
The MTU variable in Gattrib struct was not beind used for any operation
so it should be removed.
---
attrib/gattrib.c | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index ef10b5b..c4cfd95 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -41,7 +41,6 @@
struct _GAttrib {
GIOChannel *io;
gint refs;
- gint mtu;
guint read_watch;
guint write_watch;
guint timeout_watch;
@@ -397,7 +396,6 @@ GAttrib *g_attrib_new(GIOChannel *io)
return NULL;
attrib->io = g_io_channel_ref(io);
- attrib->mtu = 512;
attrib->queue = g_queue_new();
attrib->read_watch = g_io_add_watch(attrib->io,
--
1.7.0.4
^ permalink raw reply related
* [PATCH v2 2/2] Use attribute data list memory allocation function on attrib server
From: Claudio Takahasi @ 2011-02-24 21:19 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <=1298500393-4894-2-git-send-email-claudio.takahasi@openbossa.org>
---
src/attrib-server.c | 18 +++---------------
1 files changed, 3 insertions(+), 15 deletions(-)
diff --git a/src/attrib-server.c b/src/attrib-server.c
index 62c10f4..2bfeed4 100644
--- a/src/attrib-server.c
+++ b/src/attrib-server.c
@@ -381,17 +381,13 @@ static uint16_t read_by_group(struct gatt_channel *channel, uint16_t start,
length = g_slist_length(groups);
- adl = g_new0(struct att_data_list, 1);
- adl->len = last_size + 4; /* Length of each element */
- adl->num = length; /* Number of primary or secondary services */
- adl->data = g_malloc(length * sizeof(uint8_t *));
+ adl = att_data_list_alloc(length, last_size + 4);
for (i = 0, l = groups; l; l = l->next, i++) {
uint8_t *value;
cur = l->data;
- adl->data[i] = g_malloc(adl->len);
value = (void *) adl->data[i];
att_put_u16(cur->handle, value);
@@ -472,16 +468,12 @@ static uint16_t read_by_type(struct gatt_channel *channel, uint16_t start,
/* Handle length plus attribute value length */
length += 2;
- adl = g_new0(struct att_data_list, 1);
- adl->len = length; /* Length of each element */
- adl->num = num; /* Number of primary or secondary services */
- adl->data = g_malloc(num * sizeof(uint8_t *));
+ adl = att_data_list_alloc(num, length);
for (i = 0, l = types; l; i++, l = l->next) {
uint8_t *value;
a = l->data;
- adl->data[i] = g_malloc(length);
value = (void *) adl->data[i];
@@ -545,16 +537,12 @@ static int find_info(uint16_t start, uint16_t end, uint8_t *pdu, int len)
format = 0x02;
}
- adl = g_new0(struct att_data_list, 1);
- adl->len = length + 2; /* Length of each element */
- adl->num = num; /* Number of primary or secondary services */
- adl->data = g_malloc(num * sizeof(uint8_t *));
+ adl = att_data_list_alloc(num, length + 2);
for (i = 0, l = info; l; i++, l = l->next) {
uint8_t *value;
a = l->data;
- adl->data[i] = g_malloc(adl->len);
value = (void *) adl->data[i];
--
1.7.4.1
^ permalink raw reply related
* [PATCH v2 1/2] Coding standard change replacing malloc by glib functions
From: Claudio Takahasi @ 2011-02-24 21:18 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <AANLkTi=uNVCKVMFXNE7oAQVckB8XqkDthoZeXCvfdf5V@mail.gmail.com>
Use glib memory allocation functions instead of malloc for attribute
data list in ATT protocol utility functions.
---
attrib/att.c | 76 ++++++++++++++++++++++++++++++++++-----------------------
attrib/att.h | 1 +
2 files changed, 46 insertions(+), 31 deletions(-)
diff --git a/attrib/att.c b/attrib/att.c
index 3259fca..b96b97d 100644
--- a/attrib/att.c
+++ b/attrib/att.c
@@ -80,13 +80,34 @@ const char *att_ecode2str(uint8_t status)
void att_data_list_free(struct att_data_list *list)
{
+ if (list == NULL)
+ return;
+
+ if (list->data) {
+ int i;
+ for (i = 0; i < list->num; i++)
+ g_free(list->data[i]);
+ }
+
+ g_free(list->data);
+ g_free(list);
+}
+
+struct att_data_list *att_data_list_alloc(uint16_t num, uint16_t len)
+{
+ struct att_data_list *list;
int i;
- for (i = 0; i < list->num; i++)
- free(list->data[i]);
+ list = g_new0(struct att_data_list, 1);
+ list->len = len;
+ list->num = num;
- free(list->data);
- free(list);
+ list->data = g_malloc0(sizeof(uint8_t *) * num);
+
+ for (i = 0; i < num; i++)
+ list->data[i] = g_malloc0(sizeof(uint8_t) * len);
+
+ return list;
}
uint16_t enc_read_by_grp_req(uint16_t start, uint16_t end, uuid_t *uuid,
@@ -178,20 +199,19 @@ struct att_data_list *dec_read_by_grp_resp(const uint8_t *pdu, int len)
{
struct att_data_list *list;
const uint8_t *ptr;
+ uint16_t elen, num;
int i;
if (pdu[0] != ATT_OP_READ_BY_GROUP_RESP)
return NULL;
- list = malloc(sizeof(struct att_data_list));
- list->len = pdu[1];
- list->num = (len - 2) / list->len;
+ elen = pdu[1];
+ num = (len - 2) / elen;
+ list = att_data_list_alloc(num, elen);
- list->data = malloc(sizeof(uint8_t *) * list->num);
ptr = &pdu[2];
- for (i = 0; i < list->num; i++) {
- list->data[i] = malloc(sizeof(uint8_t) * list->len);
+ for (i = 0; i < num; i++) {
memcpy(list->data[i], ptr, list->len);
ptr += list->len;
}
@@ -307,7 +327,7 @@ GSList *dec_find_by_type_resp(const uint8_t *pdu, int len)
return NULL;
for (offset = 1, matches = NULL; len >= (offset + 4); offset += 4) {
- range = malloc(sizeof(struct att_range));
+ range = g_new0(struct att_range, 1);
range->start = att_get_u16(&pdu[offset]);
range->end = att_get_u16(&pdu[offset + 2]);
@@ -406,20 +426,19 @@ struct att_data_list *dec_read_by_type_resp(const uint8_t *pdu, int len)
{
struct att_data_list *list;
const uint8_t *ptr;
+ uint16_t elen, num;
int i;
if (pdu[0] != ATT_OP_READ_BY_TYPE_RESP)
return NULL;
- list = malloc(sizeof(struct att_data_list));
- list->len = pdu[1];
- list->num = (len - 2) / list->len;
+ elen = pdu[1];
+ num = (len - 2) / elen;
+ list = att_data_list_alloc(num, elen);
- list->data = malloc(sizeof(uint8_t *) * list->num);
ptr = &pdu[2];
- for (i = 0; i < list->num; i++) {
- list->data[i] = malloc(sizeof(uint8_t) * list->len);
+ for (i = 0; i < num; i++) {
memcpy(list->data[i], ptr, list->len);
ptr += list->len;
}
@@ -775,6 +794,7 @@ struct att_data_list *dec_find_info_resp(const uint8_t *pdu, int len,
{
struct att_data_list *list;
uint8_t *ptr;
+ uint16_t elen, num;
int i;
if (pdu == NULL)
@@ -787,22 +807,19 @@ struct att_data_list *dec_find_info_resp(const uint8_t *pdu, int len,
return 0;
*format = pdu[1];
-
- list = malloc(sizeof(struct att_data_list));
-
- list->len = sizeof(pdu[0]) + sizeof(*format);
+ elen = sizeof(pdu[0]) + sizeof(*format);
if (*format == 0x01)
- list->len += 2;
+ elen += 2;
else if (*format == 0x02)
- list->len += 16;
+ elen += 16;
- list->num = (len - 2) / list->len;
- list->data = malloc(sizeof(uint8_t *) * list->num);
+ num = (len - 2) / elen;
ptr = (void *) &pdu[2];
- for (i = 0; i < list->num; i++) {
- list->data[i] = malloc(list->len);
+ list = att_data_list_alloc(num, elen);
+
+ for (i = 0; i < num; i++) {
memcpy(list->data[i], ptr, list->len);
ptr += list->len;
}
@@ -859,10 +876,7 @@ struct attribute *dec_indication(const uint8_t *pdu, int len)
if (len < min_len)
return NULL;
- a = malloc(sizeof(struct attribute) + len - min_len);
- if (a == NULL)
- return NULL;
-
+ a = g_malloc0(sizeof(struct attribute) + len - min_len);
a->len = len - min_len;
a->handle = att_get_u16(&pdu[1]);
diff --git a/attrib/att.h b/attrib/att.h
index 9b0b538..b62f254 100644
--- a/attrib/att.h
+++ b/attrib/att.h
@@ -188,6 +188,7 @@ static inline void att_put_u32(uint32_t src, void *dst)
bt_put_unaligned(htobl(src), (uint32_t *) dst);
}
+struct att_data_list *att_data_list_alloc(uint16_t num, uint16_t len);
void att_data_list_free(struct att_data_list *list);
const char *att_ecode2str(uint8_t status);
--
1.7.4.1
^ permalink raw reply related
* Re: [PATCH 1/2] Coding standard change replacing malloc by glib functions
From: Claudio Takahasi @ 2011-02-24 21:15 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1298500393-4894-1-git-send-email-claudio.takahasi@openbossa.org>
Hi Johan,
On Wed, Feb 23, 2011 at 10:33 PM, Claudio Takahasi
<claudio.takahasi@openbossa.org> wrote:
> Use glib memory allocation functions instead of malloc for attribute
> data list in ATT protocol utility functions.
> ---
> attrib/att.c | 101 ++++++++++++++++++++++++++++++++++++++++++----------------
> attrib/att.h | 1 +
> 2 files changed, 74 insertions(+), 28 deletions(-)
>
> diff --git a/attrib/att.c b/attrib/att.c
> index 3259fca..1de93c4 100644
> --- a/attrib/att.c
> +++ b/attrib/att.c
> @@ -80,13 +80,47 @@ const char *att_ecode2str(uint8_t status)
>
> void att_data_list_free(struct att_data_list *list)
> {
> + if (list == NULL)
> + return;
> +
> + if (list->data) {
> + int i;
> + for (i = 0; i < list->num; i++)
> + g_free(list->data[i]);
> + }
> +
> + g_free(list->data);
> + g_free(list);
> +}
> +
> +struct att_data_list *att_data_list_alloc(uint16_t num, uint16_t len)
> +{
> + struct att_data_list *list;
> int i;
>
> - for (i = 0; i < list->num; i++)
> - free(list->data[i]);
> + list = g_try_new0(struct att_data_list, 1);
> + if (list == NULL)
> + return NULL;
> +
> + list->len = len;
> + list->num = num;
> +
> + list->data = g_try_malloc0(sizeof(uint8_t *) * num);
> + if (list->data == NULL)
> + goto enomem;
>
> - free(list->data);
> - free(list);
> + for (i = 0; i < num; i++) {
> + list->data[i] = g_try_malloc0(sizeof(uint8_t) * len);
> + if (list->data[i] == NULL)
> + goto enomem;
> + }
> +
> + return list;
> +
> +enomem:
> + att_data_list_free(list);
> +
> + return NULL;
> }
>
> uint16_t enc_read_by_grp_req(uint16_t start, uint16_t end, uuid_t *uuid,
> @@ -178,20 +212,21 @@ struct att_data_list *dec_read_by_grp_resp(const uint8_t *pdu, int len)
> {
> struct att_data_list *list;
> const uint8_t *ptr;
> + uint16_t elen, num;
> int i;
>
> if (pdu[0] != ATT_OP_READ_BY_GROUP_RESP)
> return NULL;
>
> - list = malloc(sizeof(struct att_data_list));
> - list->len = pdu[1];
> - list->num = (len - 2) / list->len;
> + elen = pdu[1];
> + num = (len - 2) / elen;
> + list = att_data_list_alloc(num, elen);
> + if (list == NULL)
> + return NULL;
>
> - list->data = malloc(sizeof(uint8_t *) * list->num);
> ptr = &pdu[2];
>
> - for (i = 0; i < list->num; i++) {
> - list->data[i] = malloc(sizeof(uint8_t) * list->len);
> + for (i = 0; i < num; i++) {
> memcpy(list->data[i], ptr, list->len);
> ptr += list->len;
> }
> @@ -307,7 +342,10 @@ GSList *dec_find_by_type_resp(const uint8_t *pdu, int len)
> return NULL;
>
> for (offset = 1, matches = NULL; len >= (offset + 4); offset += 4) {
> - range = malloc(sizeof(struct att_range));
> + range = g_try_new0(struct att_range, 1);
> + if (range == NULL)
> + goto enomem;
> +
> range->start = att_get_u16(&pdu[offset]);
> range->end = att_get_u16(&pdu[offset + 2]);
>
> @@ -315,6 +353,12 @@ GSList *dec_find_by_type_resp(const uint8_t *pdu, int len)
> }
>
> return matches;
> +
> +enomem:
> + g_slist_foreach(matches, (GFunc) g_free, NULL);
> + g_slist_free(matches);
> +
> + return NULL;
> }
>
> uint16_t enc_read_by_type_req(uint16_t start, uint16_t end, uuid_t *uuid,
> @@ -406,20 +450,21 @@ struct att_data_list *dec_read_by_type_resp(const uint8_t *pdu, int len)
> {
> struct att_data_list *list;
> const uint8_t *ptr;
> + uint16_t elen, num;
> int i;
>
> if (pdu[0] != ATT_OP_READ_BY_TYPE_RESP)
> return NULL;
>
> - list = malloc(sizeof(struct att_data_list));
> - list->len = pdu[1];
> - list->num = (len - 2) / list->len;
> + elen = pdu[1];
> + num = (len - 2) / elen;
> + list = att_data_list_alloc(num, elen);
> + if (list == NULL)
> + return NULL;
>
> - list->data = malloc(sizeof(uint8_t *) * list->num);
> ptr = &pdu[2];
>
> - for (i = 0; i < list->num; i++) {
> - list->data[i] = malloc(sizeof(uint8_t) * list->len);
> + for (i = 0; i < num; i++) {
> memcpy(list->data[i], ptr, list->len);
> ptr += list->len;
> }
> @@ -775,6 +820,7 @@ struct att_data_list *dec_find_info_resp(const uint8_t *pdu, int len,
> {
> struct att_data_list *list;
> uint8_t *ptr;
> + uint16_t elen, num;
> int i;
>
> if (pdu == NULL)
> @@ -787,22 +833,21 @@ struct att_data_list *dec_find_info_resp(const uint8_t *pdu, int len,
> return 0;
>
> *format = pdu[1];
> -
> - list = malloc(sizeof(struct att_data_list));
> -
> - list->len = sizeof(pdu[0]) + sizeof(*format);
> + elen = sizeof(pdu[0]) + sizeof(*format);
> if (*format == 0x01)
> - list->len += 2;
> + elen += 2;
> else if (*format == 0x02)
> - list->len += 16;
> + elen += 16;
>
> - list->num = (len - 2) / list->len;
> - list->data = malloc(sizeof(uint8_t *) * list->num);
> + num = (len - 2) / elen;
>
> ptr = (void *) &pdu[2];
>
> - for (i = 0; i < list->num; i++) {
> - list->data[i] = malloc(list->len);
> + list = att_data_list_alloc(num, elen);
> + if (list == NULL)
> + return NULL;
> +
> + for (i = 0; i < num; i++) {
> memcpy(list->data[i], ptr, list->len);
> ptr += list->len;
> }
> @@ -859,7 +904,7 @@ struct attribute *dec_indication(const uint8_t *pdu, int len)
> if (len < min_len)
> return NULL;
>
> - a = malloc(sizeof(struct attribute) + len - min_len);
> + a = g_try_malloc0(sizeof(struct attribute) + len - min_len);
> if (a == NULL)
> return NULL;
>
> diff --git a/attrib/att.h b/attrib/att.h
> index 7d9afeb..76072c0 100644
> --- a/attrib/att.h
> +++ b/attrib/att.h
> @@ -185,6 +185,7 @@ static inline void att_put_u32(uint32_t src, void *dst)
> bt_put_unaligned(htobl(src), (uint32_t *) dst);
> }
>
> +struct att_data_list *att_data_list_alloc(uint16_t num, uint16_t len);
> void att_data_list_free(struct att_data_list *list);
>
> const char *att_ecode2str(uint8_t status);
> --
> 1.7.4.1
>
>
A new patch series will be sent replacing g_try_malloc0 and g_try_new0
by g_malloc0 and g_new0 respectively.
Claudio.
^ permalink raw reply
* Re: [PATCH 3/3] gatttool: Remove extra reference to the connection IO Channel
From: Johan Hedberg @ 2011-02-24 20:47 UTC (permalink / raw)
To: Vinicius Costa Gomes; +Cc: linux-bluetooth
In-Reply-To: <1298579668-3143-3-git-send-email-vinicius.gomes@openbossa.org>
Hi Vinicius,
On Thu, Feb 24, 2011, Vinicius Costa Gomes wrote:
> As we want the connection to be closed when the last GAttrib
> reference is dropped, we don't need to keep this reference.
> ---
> attrib/gatttool.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
All three patches have been pushed upstream. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH 1/2 v3] Add generic descriptor support to Attribute API document
From: Anderson Lizardo @ 2011-02-24 20:46 UTC (permalink / raw)
To: Elvis Pfützenreuter; +Cc: linux-bluetooth
In-Reply-To: <C0C1E181-6699-4545-9AEC-EB813F387EBD@signove.com>
Hi Elvis,
On Thu, Feb 24, 2011 at 4:34 PM, Elvis Pfützenreuter <epx@signove.com> wrote:
>> With all those restrictions for writing, do you think it makes sense
>> to allow writing to the "Descriptors" property? Can you mention
>> situations where you might want applications to modify descriptors?
>
> Apart from CCC (which we plan to deal with in another series), no :(
>
> But GATT has this feature, so a general API should IMHO have it, since some
> future GATT-based profile may well use it.
>
> Actually, there is just one restriction for writing: one descriptor at a time,
> and I propose this just because of difficulties in error reporting (if e.g.
> 2 out of 5 descriptors could not be updated due to lack of permissions, yet
> just 1 error can be reported back).
As we discussed on IRC, let's wait for stabilization and clarification
or our D-Bus API for GATT services and characteristics, then we can
introduce a descriptor access API upstream.
Anyway, your patch is useful for whoever wants direct access to descriptors :)
Regards,
--
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil
^ permalink raw reply
* Re: [PATCH] hcitool: fix interval and window parameters
From: Johan Hedberg @ 2011-02-24 20:41 UTC (permalink / raw)
To: Andre Guedes; +Cc: linux-bluetooth
In-Reply-To: <1298573768-26751-1-git-send-email-andre.guedes@openbossa.org>
Hi André,
On Thu, Feb 24, 2011, Andre Guedes wrote:
> Set interval and window parameters properly if --discovery option
> is present in lescan command.
>
> According to the Bluetooth spec, during a general or limited discovery
> procedure the scan interval and the scan window should be set to
> 11.25 ms. If --discovery option isn't present, both parameters are set
> to the default value (10 ms) defined in LE Set Scan Parameters Command.
>
> According to that command description, the interval and window parameters
> should be set as follows:
>
> Time = N * 0.625 msec
>
> So, in order to set the time values to 11.25 and 10 ms, the parameters
> should be equal to 18 (0x0012) and 16 (0x0010), respectively.
> ---
> tools/hcitool.c | 9 +++++++--
> 1 files changed, 7 insertions(+), 2 deletions(-)
Pushed upstream. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH] hcitool: add discovery procedure to lescan command
From: Johan Hedberg @ 2011-02-24 20:40 UTC (permalink / raw)
To: Anderson Lizardo; +Cc: Andre Guedes, linux-bluetooth
In-Reply-To: <AANLkTi=ZGNaLi7VUBzEWoDffcJaP9HPmxf_AmAcPw_g-@mail.gmail.com>
Hi,
On Thu, Feb 24, 2011, Anderson Lizardo wrote:
> On Wed, Feb 23, 2011 at 11:54 PM, Johan Hedberg <johan.hedberg@gmail.com> wrote:
> > Hi André,
> >
> > On Wed, Feb 23, 2011, Andre Guedes wrote:
> >> + "\tlescan [--discovery=g|l] enable general or limited discovery"
> >
> > To make this consistent with the other options please default to general
> > and have a --limited switch to enable limited discovery.
>
> Note that there are actually three modes:
>
> 1) the default one, when no parameters are given: do not filter
> anything, useful for debugging (this is what is currently done)
> 2) limited discovery
> 3) general discovery
>
> limited/general are done according to the procedure description on the spec.
Ok, then the patch makes sense. It has now been pushed upstream.
Johan
^ permalink raw reply
* [PATCH 6/6] Add sec-level option to interactive gattool
From: Sheldon Demario @ 2011-02-24 20:38 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Sheldon Demario
In-Reply-To: <1298579910-15198-1-git-send-email-sheldon.demario@openbossa.org>
---
attrib/interactive.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 44 insertions(+), 0 deletions(-)
diff --git a/attrib/interactive.c b/attrib/interactive.c
index e5817ab..ff676b4 100644
--- a/attrib/interactive.c
+++ b/attrib/interactive.c
@@ -551,6 +551,48 @@ static void cmd_char_write_req(int argcp, char **argvp)
g_free(value);
}
+static void cmd_sec_level(int argcp, char **argvp)
+{
+ GError *gerr = NULL;
+ BtIOSecLevel sec_level;
+
+ if (argcp < 2) {
+ printf("sec-level: %s\n", opt_sec_level);
+ return;
+ }
+
+ if (strcasecmp(argvp[1], "medium") == 0)
+ sec_level = BT_IO_SEC_MEDIUM;
+ else if (strcasecmp(argvp[1], "high") == 0)
+ sec_level = BT_IO_SEC_HIGH;
+ else if (strcasecmp(argvp[1], "low") == 0)
+ sec_level = BT_IO_SEC_LOW;
+ else {
+ printf("Allowed values: low | medium | high\n");
+ return;
+ }
+
+ g_free(opt_sec_level);
+ opt_sec_level = strdup(argvp[1]);
+
+ if (conn_state != STATE_CONNECTED)
+ return;
+
+ if (opt_psm) {
+ printf("It must be reconnected to this change take effect\n");
+ return;
+ }
+
+ bt_io_set(iochannel, BT_IO_L2CAP, &gerr,
+ BT_IO_OPT_SEC_LEVEL, sec_level,
+ BT_IO_OPT_INVALID);
+
+ if (gerr) {
+ printf("Error: %s\n", gerr->message);
+ g_error_free(gerr);
+ }
+}
+
static struct {
const char *cmd;
void (*func)(int argcp, char **argvp);
@@ -577,6 +619,8 @@ static struct {
"Characteristics Value/Descriptor Read by UUID" },
{ "char-write-req", cmd_char_write_req, "<handle> <new value>",
"Characteristic Value Write (Write Request)" },
+ { "sec-level", cmd_sec_level, "[low | medium | high]",
+ "Set security level. Default: low" },
{ NULL, NULL, NULL}
};
--
1.7.1
^ permalink raw reply related
* [PATCH 5/6] Add Write Request in interactive gatttool
From: Sheldon Demario @ 2011-02-24 20:38 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Bruna Moreira
In-Reply-To: <1298579910-15198-1-git-send-email-sheldon.demario@openbossa.org>
From: Bruna Moreira <bruna.moreira@openbossa.org>
---
attrib/interactive.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 52 insertions(+), 0 deletions(-)
diff --git a/attrib/interactive.c b/attrib/interactive.c
index c5dd2b7..e5817ab 100644
--- a/attrib/interactive.c
+++ b/attrib/interactive.c
@@ -501,6 +501,56 @@ static void cmd_read_uuid(int argcp, char **argvp)
char_read_by_uuid_cb, char_data);
}
+static void char_write_req_cb(guint8 status, const guint8 *pdu, guint16 plen,
+ gpointer user_data)
+{
+ if (status != 0) {
+ printf("Characteristic Write Request failed: "
+ "%s\n", att_ecode2str(status));
+ return;
+ }
+
+ if (!dec_write_resp(pdu, plen)) {
+ printf("Protocol error\n");
+ return;
+ }
+
+ printf("Characteristic value was written successfully\n");
+}
+
+static void cmd_char_write_req(int argcp, char **argvp)
+{
+ uint8_t *value;
+ size_t plen;
+ int handle;
+
+ if (conn_state != STATE_CONNECTED) {
+ printf("Command failed: disconnected\n");
+ return;
+ }
+
+ if (argcp < 3) {
+ printf("Usage: char-write-req <handle> <new value>\n");
+ return;
+ }
+
+ handle = strtoll(argvp[1], NULL, 16);
+ if (errno != 0 || handle <= 0) {
+ printf("A valid handle is required\n");
+ return;
+ }
+
+ plen = gatt_attr_data_from_string(argvp[2], &value);
+ if (plen == 0) {
+ g_printerr("Invalid value\n");
+ return;
+ }
+
+ gatt_write_char(attrib, handle, value, plen, char_write_req_cb, NULL);
+
+ g_free(value);
+}
+
static struct {
const char *cmd;
void (*func)(int argcp, char **argvp);
@@ -525,6 +575,8 @@ static struct {
"Characteristics Value/Descriptor Read by handle" },
{ "char-read-uuid", cmd_read_uuid, "<UUID> [start hnd] [end hnd]",
"Characteristics Value/Descriptor Read by UUID" },
+ { "char-write-req", cmd_char_write_req, "<handle> <new value>",
+ "Characteristic Value Write (Write Request)" },
{ NULL, NULL, NULL}
};
--
1.7.1
^ permalink raw reply related
* [PATCH 4/6] Move attr_data_from_string() to utils.c
From: Sheldon Demario @ 2011-02-24 20:38 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Bruna Moreira
In-Reply-To: <1298579910-15198-1-git-send-email-sheldon.demario@openbossa.org>
From: Bruna Moreira <bruna.moreira@openbossa.org>
The attr_data_from_string() function will be used in interactive and
usual gatttool so this function was moved to common file utils.c.
---
attrib/gatttool.c | 23 ++---------------------
attrib/gatttool.h | 1 +
attrib/utils.c | 19 +++++++++++++++++++
3 files changed, 22 insertions(+), 21 deletions(-)
diff --git a/attrib/gatttool.c b/attrib/gatttool.c
index 7478043..d7887c6 100644
--- a/attrib/gatttool.c
+++ b/attrib/gatttool.c
@@ -313,25 +313,6 @@ static gboolean characteristics_read(gpointer user_data)
return FALSE;
}
-static size_t attr_data_from_string(const char *str, uint8_t **data)
-{
- char tmp[3];
- size_t size, i;
-
- size = strlen(str) / 2;
- *data = g_try_malloc0(size);
- if (*data == NULL)
- return 0;
-
- tmp[2] = '\0';
- for (i = 0; i < size; i++) {
- memcpy(tmp, str + (i * 2), 2);
- (*data)[i] = (uint8_t) strtol(tmp, NULL, 16);
- }
-
- return size;
-}
-
static void mainloop_quit(gpointer user_data)
{
uint8_t *value = user_data;
@@ -356,7 +337,7 @@ static gboolean characteristics_write(gpointer user_data)
goto error;
}
- len = attr_data_from_string(opt_value, &value);
+ len = gatt_attr_data_from_string(opt_value, &value);
if (len == 0) {
g_printerr("Invalid value\n");
goto error;
@@ -408,7 +389,7 @@ static gboolean characteristics_write_req(gpointer user_data)
goto error;
}
- len = attr_data_from_string(opt_value, &value);
+ len = gatt_attr_data_from_string(opt_value, &value);
if (len == 0) {
g_printerr("Invalid value\n");
goto error;
diff --git a/attrib/gatttool.h b/attrib/gatttool.h
index 7eae18d..2fd4a46 100644
--- a/attrib/gatttool.h
+++ b/attrib/gatttool.h
@@ -25,3 +25,4 @@ int interactive(gchar *dst, gboolean le);
GIOChannel *gatt_connect(const gchar *src, const gchar *dst,
const gchar *sec_level, int psm, int mtu,
BtIOConnect connect_cb);
+size_t gatt_attr_data_from_string(const char *str, uint8_t **data);
diff --git a/attrib/utils.c b/attrib/utils.c
index 4d0000d..8d1ca74 100644
--- a/attrib/utils.c
+++ b/attrib/utils.c
@@ -104,3 +104,22 @@ GIOChannel *gatt_connect(const gchar *src, const gchar *dst,
return chan;
}
+
+size_t gatt_attr_data_from_string(const char *str, uint8_t **data)
+{
+ char tmp[3];
+ size_t size, i;
+
+ size = strlen(str) / 2;
+ *data = g_try_malloc0(size);
+ if (*data == NULL)
+ return 0;
+
+ tmp[2] = '\0';
+ for (i = 0; i < size; i++) {
+ memcpy(tmp, str + (i * 2), 2);
+ (*data)[i] = (uint8_t) strtol(tmp, NULL, 16);
+ }
+
+ return size;
+}
--
1.7.1
^ permalink raw reply related
* [PATCH 3/6] Add characteristics read options in interactive gatttool
From: Sheldon Demario @ 2011-02-24 20:38 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Sheldon Demario
In-Reply-To: <1298579910-15198-1-git-send-email-sheldon.demario@openbossa.org>
---
attrib/interactive.c | 157 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 156 insertions(+), 1 deletions(-)
diff --git a/attrib/interactive.c b/attrib/interactive.c
index 89e244a..c5dd2b7 100644
--- a/attrib/interactive.c
+++ b/attrib/interactive.c
@@ -50,6 +50,13 @@ static gchar *opt_sec_level = NULL;
static int opt_psm = 0;
static int opt_mtu = 0;
+struct characteristic_data {
+ uint16_t orig_start;
+ uint16_t start;
+ uint16_t end;
+ uuid_t uuid;
+};
+
static void cmd_help(int argcp, char **argvp);
enum state {
@@ -210,6 +217,79 @@ static void char_desc_cb(guint8 status, const guint8 *pdu, guint16 plen,
rl_forced_update_display();
}
+static void char_read_cb(guint8 status, const guint8 *pdu, guint16 plen,
+ gpointer user_data)
+{
+ uint8_t value[ATT_MAX_MTU];
+ int i, vlen;
+
+ if (status != 0) {
+ printf("Characteristic value/descriptor read failed: %s\n",
+ att_ecode2str(status));
+ return;
+ }
+
+ if (!dec_read_resp(pdu, plen, value, &vlen)) {
+ printf("Protocol error\n");
+ return;
+ }
+
+ printf("\nCharacteristic value/descriptor: ");
+ for (i = 0; i < vlen; i++)
+ printf("%02x ", value[i]);
+ printf("\n");
+
+ rl_forced_update_display();
+}
+
+static void char_read_by_uuid_cb(guint8 status, const guint8 *pdu,
+ guint16 plen, gpointer user_data)
+{
+ struct characteristic_data *char_data = user_data;
+ struct att_data_list *list;
+ int i;
+
+ if (status == ATT_ECODE_ATTR_NOT_FOUND &&
+ char_data->start != char_data->orig_start)
+ goto done;
+
+ if (status != 0) {
+ printf("Read characteristics by UUID failed: %s\n",
+ att_ecode2str(status));
+ goto done;
+ }
+
+ list = dec_read_by_type_resp(pdu, plen);
+ if (list == NULL)
+ goto done;
+
+ for (i = 0; i < list->num; i++) {
+ uint8_t *value = list->data[i];
+ int j;
+
+ char_data->start = att_get_u16(value) + 1;
+
+ printf("\nhandle: 0x%04x \t value: ", att_get_u16(value));
+ value += 2;
+ for (j = 0; j < list->len - 2; j++, value++)
+ printf("%02x ", *value);
+ printf("\n");
+ }
+
+ att_data_list_free(list);
+
+ gatt_read_char_by_uuid(attrib, char_data->start, char_data->end,
+ &char_data->uuid, char_read_by_uuid_cb,
+ char_data);
+
+ rl_forced_update_display();
+
+ return;
+
+done:
+ g_free(char_data);
+}
+
static void cmd_exit(int argcp, char **argvp)
{
rl_callback_handler_remove();
@@ -350,6 +430,77 @@ static void cmd_char_desc(int argcp, char **argvp)
gatt_find_info(attrib, start, end, char_desc_cb, NULL);
}
+static void cmd_read_hnd(int argcp, char **argvp)
+{
+ int handle;
+
+ if (conn_state != STATE_CONNECTED) {
+ printf("Command failed: disconnected\n");
+ return;
+ }
+
+ if (argcp < 2) {
+ printf("Missing argument: handle\n");
+ return;
+ }
+
+ handle = strtohandle(argvp[1]);
+ if (handle < 0) {
+ printf("Invalid handle: %s\n", argvp[1]);
+ return;
+ }
+
+ gatt_read_char(attrib, handle, char_read_cb, attrib);
+}
+
+static void cmd_read_uuid(int argcp, char **argvp)
+{
+ struct characteristic_data *char_data;
+ int start = 0x0001;
+ int end = 0xffff;
+ uuid_t uuid;
+
+ if (conn_state != STATE_CONNECTED) {
+ printf("Command failed: disconnected\n");
+ return;
+ }
+
+ if (argcp < 2) {
+ printf("Missing argument: UUID\n");
+ return;
+ }
+
+ if (bt_string2uuid(&uuid, argvp[1]) < 0) {
+ printf("Invalid UUID\n");
+ return;
+ }
+
+ if (argcp > 2) {
+ start = strtohandle(argvp[2]);
+ if (start < 0) {
+ printf("Invalid start handle: %s\n", argvp[1]);
+ return;
+ }
+ }
+
+ if (argcp > 3) {
+ end = strtohandle(argvp[3]);
+ if (end < 0) {
+ printf("Invalid end handle: %s\n", argvp[2]);
+ return;
+ }
+ }
+
+ char_data = g_new(struct characteristic_data, 1);
+ char_data->orig_start = start;
+ char_data->start = start;
+ char_data->end = end;
+ char_data->uuid = uuid;
+
+ gatt_read_char_by_uuid(attrib, start, end, &char_data->uuid,
+ char_read_by_uuid_cb, char_data);
+}
+
static struct {
const char *cmd;
void (*func)(int argcp, char **argvp);
@@ -370,6 +521,10 @@ static struct {
"Characteristics Discovery" },
{ "char-desc", cmd_char_desc, "[start hnd] [end hnd]",
"Characteristics Descriptor Discovery" },
+ { "char-read-hnd", cmd_read_hnd, "<handle>",
+ "Characteristics Value/Descriptor Read by handle" },
+ { "char-read-uuid", cmd_read_uuid, "<UUID> [start hnd] [end hnd]",
+ "Characteristics Value/Descriptor Read by UUID" },
{ NULL, NULL, NULL}
};
@@ -378,7 +533,7 @@ static void cmd_help(int argcp, char **argvp)
int i;
for (i = 0; commands[i].cmd; i++)
- printf("%-15s %-25s %s\n", commands[i].cmd,
+ printf("%-15s %-30s %s\n", commands[i].cmd,
commands[i].params, commands[i].desc);
}
--
1.7.1
^ permalink raw reply related
* [PATCH 2/6] Add Characteristics Descriptor Discovery option in interactive gatttool
From: Sheldon Demario @ 2011-02-24 20:38 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Sheldon Demario
In-Reply-To: <1298579910-15198-1-git-send-email-sheldon.demario@openbossa.org>
---
attrib/interactive.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 72 insertions(+), 0 deletions(-)
diff --git a/attrib/interactive.c b/attrib/interactive.c
index 7b18e90..89e244a 100644
--- a/attrib/interactive.c
+++ b/attrib/interactive.c
@@ -169,6 +169,47 @@ static void char_cb(GSList *characteristics, guint8 status, gpointer user_data)
rl_forced_update_display();
}
+static void char_desc_cb(guint8 status, const guint8 *pdu, guint16 plen,
+ gpointer user_data)
+{
+ struct att_data_list *list;
+ guint8 format;
+ int i;
+
+ if (status != 0) {
+ printf("Discover all characteristic descriptors failed: "
+ "%s\n", att_ecode2str(status));
+ return;
+ }
+
+ list = dec_find_info_resp(pdu, plen, &format);
+ if (list == NULL)
+ return;
+
+ printf("\n");
+ for (i = 0; i < list->num; i++) {
+ char uuidstr[MAX_LEN_UUID_STR];
+ uint16_t handle;
+ uint8_t *value;
+ uuid_t uuid;
+
+ value = list->data[i];
+ handle = att_get_u16(value);
+
+ if (format == 0x01)
+ sdp_uuid16_create(&uuid, att_get_u16(&value[2]));
+ else
+ sdp_uuid128_create(&uuid, &value[2]);
+
+ sdp_uuid2strn(&uuid, uuidstr, MAX_LEN_UUID_STR);
+ printf("handle: 0x%04x, uuid: %s\n", handle, uuidstr);
+ }
+
+ att_data_list_free(list);
+
+ rl_forced_update_display();
+}
+
static void cmd_exit(int argcp, char **argvp)
{
rl_callback_handler_remove();
@@ -280,6 +321,35 @@ static void cmd_char(int argcp, char **argvp)
gatt_discover_char(attrib, start, end, char_cb, NULL);
}
+static void cmd_char_desc(int argcp, char **argvp)
+{
+ int start = 0x0001;
+ int end = 0xffff;
+
+ if (conn_state != STATE_CONNECTED) {
+ printf("Command failed: disconnected\n");
+ return;
+ }
+
+ if (argcp > 1) {
+ start = strtohandle(argvp[1]);
+ if (start < 0) {
+ printf("Invalid start handle: %s\n", argvp[1]);
+ return;
+ }
+ }
+
+ if (argcp > 2) {
+ end = strtohandle(argvp[2]);
+ if (end < 0) {
+ printf("Invalid end handle: %s\n", argvp[2]);
+ return;
+ }
+ }
+
+ gatt_find_info(attrib, start, end, char_desc_cb, NULL);
+}
+
static struct {
const char *cmd;
void (*func)(int argcp, char **argvp);
@@ -298,6 +368,8 @@ static struct {
"Primary Service Discovery" },
{ "characteristics", cmd_char, "[start hnd] [end hnd]",
"Characteristics Discovery" },
+ { "char-desc", cmd_char_desc, "[start hnd] [end hnd]",
+ "Characteristics Descriptor Discovery" },
{ NULL, NULL, NULL}
};
--
1.7.1
^ permalink raw reply related
* [PATCH 1/6] Create a helper function to deal with handles on interactive gatttool
From: Sheldon Demario @ 2011-02-24 20:38 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Sheldon Demario
In-Reply-To: <1298579910-15198-1-git-send-email-sheldon.demario@openbossa.org>
---
attrib/interactive.c | 27 +++++++++++++++++----------
1 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/attrib/interactive.c b/attrib/interactive.c
index 7cc03bc..7b18e90 100644
--- a/attrib/interactive.c
+++ b/attrib/interactive.c
@@ -238,6 +238,19 @@ static void cmd_primary(int argcp, char **argvp)
gatt_discover_primary(attrib, &uuid, primary_by_uuid_cb, NULL);
}
+static int strtohandle(const char *src)
+{
+ char *e;
+ int dst;
+
+ errno = 0;
+ dst = strtoll(src, &e, 16);
+ if (errno != 0 || *e != '\0')
+ return -EINVAL;
+
+ return dst;
+}
+
static void cmd_char(int argcp, char **argvp)
{
int start = 0x0001;
@@ -249,28 +262,22 @@ static void cmd_char(int argcp, char **argvp)
}
if (argcp > 1) {
- char *e;
-
- start = strtoll(argvp[1], &e, 16);
- if (errno != 0 || *e != '\0') {
+ start = strtohandle(argvp[1]);
+ if (start < 0) {
printf("Invalid start handle: %s\n", argvp[1]);
return;
}
}
if (argcp > 2) {
- char *e;
-
- end = strtoll(argvp[2], &e, 16);
- if (errno != 0 || *e != '\0') {
+ end = strtohandle(argvp[2]);
+ if (end < 0) {
printf("Invalid end handle: %s\n", argvp[2]);
return;
}
}
gatt_discover_char(attrib, start, end, char_cb, NULL);
-
- return;
}
static struct {
--
1.7.1
^ permalink raw reply related
* [PATCH 0/6] *** SUBJECT HERE ***
From: Sheldon Demario @ 2011-02-24 20:38 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Sheldon Demario
Please ignore my all not-applied previous patches. I am resending them
with a few corrections.
Bruna Moreira (2):
Move attr_data_from_string() to utils.c
Add Write Request in interactive gatttool
Sheldon Demario (4):
Create a helper function to deal with handles on interactive gatttool
Add Characteristics Descriptor Discovery option in interactive
gatttool
Add characteristics read options in interactive gatttool
Add sec-level option to interactive gattool
attrib/gatttool.c | 23 +---
attrib/gatttool.h | 1 +
attrib/interactive.c | 348 ++++++++++++++++++++++++++++++++++++++++++++++++--
attrib/utils.c | 19 +++
4 files changed, 361 insertions(+), 30 deletions(-)
^ permalink raw reply
* [PATCH 3/3] gatttool: Remove extra reference to the connection IO Channel
From: Vinicius Costa Gomes @ 2011-02-24 20:34 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Vinicius Costa Gomes
In-Reply-To: <1298579668-3143-1-git-send-email-vinicius.gomes@openbossa.org>
As we want the connection to be closed when the last GAttrib
reference is dropped, we don't need to keep this reference.
---
attrib/gatttool.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/attrib/gatttool.c b/attrib/gatttool.c
index 7478043..547757d 100644
--- a/attrib/gatttool.c
+++ b/attrib/gatttool.c
@@ -620,6 +620,7 @@ int main(int argc, char *argv[])
}
attrib = g_attrib_new(chan);
+ g_io_channel_unref(chan);
event_loop = g_main_loop_new(NULL, FALSE);
@@ -634,7 +635,6 @@ int main(int argc, char *argv[])
g_main_loop_unref(event_loop);
- g_io_channel_unref(chan);
g_attrib_unref(attrib);
done:
--
1.7.4.1
^ permalink raw reply related
* [PATCH 2/3] Add support for GATT client timeouts
From: Vinicius Costa Gomes @ 2011-02-24 20:34 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Vinicius Costa Gomes
In-Reply-To: <1298579668-3143-1-git-send-email-vinicius.gomes@openbossa.org>
This patch adds support to destroying the GATT connection
when a GATT server doesn't respond for more than 30 seconds.
A function to destroy the GAttrib is introduced and it is used
in the timeout case and when the last GAttrib reference is
dropped.
---
attrib/gattrib.c | 43 ++++++++++++++++++++++++++++++++++++-------
1 files changed, 36 insertions(+), 7 deletions(-)
diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index 5b8b590..cf49ede 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -36,12 +36,15 @@
#include "btio.h"
#include "gattrib.h"
+#define GATT_TIMEOUT 30
+
struct _GAttrib {
GIOChannel *io;
gint refs;
gint mtu;
guint read_watch;
guint write_watch;
+ guint timeout_watch;
GQueue *queue;
GSList *events;
guint next_cmd_id;
@@ -164,17 +167,11 @@ static void event_destroy(struct event *evt)
g_free(evt);
}
-void g_attrib_unref(GAttrib *attrib)
+static void attrib_destroy(GAttrib *attrib)
{
GSList *l;
struct command *c;
- if (!attrib)
- return;
-
- if (g_atomic_int_dec_and_test(&attrib->refs) == FALSE)
- return;
-
while ((c = g_queue_pop_head(attrib->queue)))
command_destroy(c);
@@ -187,6 +184,9 @@ void g_attrib_unref(GAttrib *attrib)
g_slist_free(attrib->events);
attrib->events = NULL;
+ if (attrib->timeout_watch> 0)
+ g_source_remove(attrib->timeout_watch);
+
if (attrib->write_watch > 0)
g_source_remove(attrib->write_watch);
@@ -201,6 +201,17 @@ void g_attrib_unref(GAttrib *attrib)
g_free(attrib);
}
+void g_attrib_unref(GAttrib *attrib)
+{
+ if (!attrib)
+ return;
+
+ if (g_atomic_int_dec_and_test(&attrib->refs) == FALSE)
+ return;
+
+ attrib_destroy(attrib);
+}
+
GIOChannel *g_attrib_get_channel(GAttrib *attrib)
{
if (!attrib)
@@ -233,6 +244,15 @@ gboolean g_attrib_set_destroy_function(GAttrib *attrib,
return TRUE;
}
+static gboolean disconnect_timeout(gpointer data)
+{
+ struct _GAttrib *attrib = data;
+
+ attrib_destroy(attrib);
+
+ return FALSE;
+}
+
static gboolean can_write_data(GIOChannel *io, GIOCondition cond,
gpointer data)
{
@@ -267,6 +287,10 @@ static gboolean can_write_data(GIOChannel *io, GIOCondition cond,
cmd->sent = TRUE;
+ if (attrib->timeout_watch == 0)
+ attrib->timeout_watch = g_timeout_add_seconds(GATT_TIMEOUT,
+ disconnect_timeout, attrib);
+
return FALSE;
}
@@ -295,6 +319,11 @@ static gboolean received_data(GIOChannel *io, GIOCondition cond, gpointer data)
GIOStatus iostat;
gboolean qempty;
+ if (attrib->timeout_watch > 0) {
+ g_source_remove(attrib->timeout_watch);
+ attrib->timeout_watch = 0;
+ }
+
if (cond & (G_IO_HUP | G_IO_ERR | G_IO_NVAL)) {
attrib->read_watch = 0;
if (attrib->disconnect)
--
1.7.4.1
^ permalink raw reply related
* [PATCH 1/3] Fix gattrib.c coding style
From: Vinicius Costa Gomes @ 2011-02-24 20:34 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Vinicius Costa Gomes
Just remove an extra empty line.
---
attrib/gattrib.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index 779a471..5b8b590 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -195,7 +195,6 @@ void g_attrib_unref(GAttrib *attrib)
g_io_channel_unref(attrib->io);
}
-
if (attrib->destroy)
attrib->destroy(attrib->destroy_user_data);
--
1.7.4.1
^ permalink raw reply related
* Re: [PATCH] Maemo6 MCE: skip first adapter_powered callback
From: Johan Hedberg @ 2011-02-24 19:42 UTC (permalink / raw)
To: Daniel Westerlund; +Cc: linux-bluetooth
In-Reply-To: <AANLkTinzSuO8a87BuqAxakQS5=pd9zRd7zdmBasjXrxs@mail.gmail.com>
Hi Daniel,
> From: Daniel Orstadius <daniel.orstadius@nokia.com>
> Date: Thu, 24 Feb 2011 13:45:33 +0200
> Subject: [PATCH] Maemo6 MCE: skip first adapter_powered callback
>
> The maemo6 MCE plugin should be used with the flag InitiallyPowered
> in main.conf set to 'true' so that BlueZ powers on the adapter
> and leaves it in that state when the daemon is started. The plugin
> will read the radio state from the MCE and set the state
> accordingly. The maemo6 plugin is a btd_adapter_driver and those
> drivers are loaded after BlueZ has read the BD address etc from the
> adapter.
>
> This patch adds a boolean flag in the callback to ignore the initial
> powering on of the adapter by BlueZ, since it shouldn't be
> propagated to the MCE. With InitiallyPowered set to 'false' the
> adapter_powered callback is not called when the adapter is turned
> on at BlueZ startup, which is why this wasn't implemented before.
> ---
> plugins/maemo6.c | 6 ++++++
> 1 files changed, 6 insertions(+), 0 deletions(-)
This patch has been pushed upstream. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH 1/2 v3] Add generic descriptor support to Attribute API document
From: Elvis Pfützenreuter @ 2011-02-24 19:34 UTC (permalink / raw)
To: Anderson Lizardo; +Cc: linux-bluetooth
In-Reply-To: <AANLkTik9wa_Pzezs3_udVD9MzwjxOaAAdEugjrD_U-KG@mail.gmail.com>
On 24 Feb 2011, at 15:29 , Anderson Lizardo wrote:
> Hi Elvis,
>
> On Wed, Feb 23, 2011 at 10:49 AM, Elvis Pfützenreuter <epx@signove.com> wrote:
>> This patch proposes extensions to Attribute API, giving access to all
>> characteristic descriptors (beyond 'Description' and 'Format').
>>
>> Client Characteristic Configuration automatic update upon Watcher
>> registering will be handled by another patch series.
>> ---
>> doc/attribute-api.txt | 30 ++++++++++++++++++++++++++++++
>> 1 files changed, 30 insertions(+), 0 deletions(-)
>>
>> diff --git a/doc/attribute-api.txt b/doc/attribute-api.txt
>> index 23808e6..bb7cbfa 100644
>> --- a/doc/attribute-api.txt
>> +++ b/doc/attribute-api.txt
>> @@ -104,6 +104,7 @@ Methods dict GetProperties()
>>
>> Possible Errors: org.bluez.Error.InvalidArguments
>>
>> +
>> Properties string UUID [readonly]
>>
>> UUID128 of this characteristic.
>> @@ -143,6 +144,35 @@ Properties string UUID [readonly]
>> Friendly representation of the Characteristic Value
>> based on the format attribute.
>>
>> + dict Descriptors [readwrite]
>> +
>> + Dict of descriptors for this characteristic.
>> +
>> + This dict contains only the descriptors not already
>> + covered by other properties (v.g. Description, Format).
>> +
>> + Each descriptor is mapped to an unique object path,
>> + which is the dict key.
>> +
>> + Each dict value is, in turn, a dict with at least
>> + the following keys:
>> +
>> + {
>> + "UUID": string. Descriptor UUID, always present
>> + "Value": array of bytes. Raw descriptor value,
>> + present only when/if descriptor value
>> + has been fetched.
>> + }
>> +
>> + When updating a descriptor value using SetProperty(),
>> + only one descriptor at a time may be updated in order
>> + to guarantee unambiguous error reporting. In other
>> + words, when calling SetProperty('Descriptors', dict),
>> + dict must have exactly one entry.
>> +
>> + Descriptor's UUID may not be updated. If present, it is
>> + ignored by SetProperty().
>
> With all those restrictions for writing, do you think it makes sense
> to allow writing to the "Descriptors" property? Can you mention
> situations where you might want applications to modify descriptors?
Apart from CCC (which we plan to deal with in another series), no :(
But GATT has this feature, so a general API should IMHO have it, since some
future GATT-based profile may well use it.
Actually, there is just one restriction for writing: one descriptor at a time,
and I propose this just because of difficulties in error reporting (if e.g.
2 out of 5 descriptors could not be updated due to lack of permissions, yet
just 1 error can be reported back).
^ permalink raw reply
* Re: [PATCH v3 5/5] Implement ATT handle indication
From: Johan Hedberg @ 2011-02-24 19:10 UTC (permalink / raw)
To: Anderson Lizardo; +Cc: linux-bluetooth, Elvis Pfützenreuter
In-Reply-To: <1298474061-18410-5-git-send-email-anderson.lizardo@openbossa.org>
Hi,
On Wed, Feb 23, 2011, Anderson Lizardo wrote:
> ---
> src/attrib-server.c | 40 ++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 40 insertions(+), 0 deletions(-)
I've pushed patches 1-4, but as there was some debate about this one
I'll wait until there's an updated version.
Johan
^ permalink raw reply
* [PATCH] hcitool: fix interval and window parameters
From: Andre Guedes @ 2011-02-24 18:56 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Andre Guedes
Set interval and window parameters properly if --discovery option
is present in lescan command.
According to the Bluetooth spec, during a general or limited discovery
procedure the scan interval and the scan window should be set to
11.25 ms. If --discovery option isn't present, both parameters are set
to the default value (10 ms) defined in LE Set Scan Parameters Command.
According to that command description, the interval and window parameters
should be set as follows:
Time = N * 0.625 msec
So, in order to set the time values to 11.25 and 10 ms, the parameters
should be equal to 18 (0x0012) and 16 (0x0010), respectively.
---
tools/hcitool.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/tools/hcitool.c b/tools/hcitool.c
index cb7d181..c5254ea 100644
--- a/tools/hcitool.c
+++ b/tools/hcitool.c
@@ -2429,6 +2429,8 @@ static void cmd_lescan(int dev_id, int argc, char **argv)
uint8_t own_type = 0x00;
uint8_t scan_type = 0x01;
uint8_t filter_type = 0;
+ uint16_t interval = htobs(0x0010);
+ uint16_t window = htobs(0x0010);
for_each_opt(opt, lescan_options, NULL) {
switch (opt) {
@@ -2444,6 +2446,9 @@ static void cmd_lescan(int dev_id, int argc, char **argv)
fprintf(stderr, "Unknown discovery procedure\n");
exit(1);
}
+
+ interval = htobs(0x0012);
+ window = htobs(0x0012);
break;
default:
printf("%s", lescan_help);
@@ -2461,8 +2466,8 @@ static void cmd_lescan(int dev_id, int argc, char **argv)
exit(1);
}
- err = hci_le_set_scan_parameters(dd, scan_type, htobs(0x0010),
- htobs(0x0010), own_type, 0x00);
+ err = hci_le_set_scan_parameters(dd, scan_type, interval, window,
+ own_type, 0x00);
if (err < 0) {
perror("Set scan parameters failed");
exit(1);
--
1.7.1
^ permalink raw reply related
* [PATCH 1/1] Remove unneeded Service ID from service SDP record
From: Brian Gix @ 2011-02-24 18:50 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Brian Gix
In-Reply-To: <1298573402-21739-1-git-send-email-bgix@codeaurora.org>
---
src/attrib-server.c | 4 +---
1 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/src/attrib-server.c b/src/attrib-server.c
index 7ec0f56..08a9b23 100644
--- a/src/attrib-server.c
+++ b/src/attrib-server.c
@@ -89,7 +89,7 @@ static uuid_t snd_uuid = {
static sdp_record_t *server_record_new(uuid_t *uuid, uint16_t start, uint16_t end)
{
sdp_list_t *svclass_id, *apseq, *proto[2], *root, *aproto;
- uuid_t root_uuid, proto_uuid, gatt_uuid, l2cap;
+ uuid_t root_uuid, proto_uuid, l2cap;
sdp_record_t *record;
sdp_data_t *psm, *sh, *eh;
uint16_t lp = GATT_PSM;
@@ -130,8 +130,6 @@ static sdp_record_t *server_record_new(uuid_t *uuid, uint16_t start, uint16_t en
aproto = sdp_list_append(NULL, apseq);
sdp_set_access_protos(record, aproto);
- sdp_set_service_id(record, gatt_uuid);
-
sdp_data_free(psm);
sdp_data_free(sh);
sdp_data_free(eh);
--
1.7.1
--
Brian Gix
bgix@codeaurora.org
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum
^ permalink raw reply related
* [PATCH 0/1] Fix valgrind error report
From: Brian Gix @ 2011-02-24 18:50 UTC (permalink / raw)
To: linux-bluetooth
I don't have valgrind, but the error was pretty straight forward, and this should fix it.
--
Brian Gix
bgix@codeaurora.org
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum
^ permalink raw reply
* Re: "Conditional jump or move" errors on attrib_create_sdp()
From: Brian Gix @ 2011-02-24 18:40 UTC (permalink / raw)
To: Anderson Lizardo; +Cc: Claudio Takahasi, BlueZ development
In-Reply-To: <AANLkTimZKv2D3BZy+QWiutokQUGrnBWWT_uHQ0Lp06n8@mail.gmail.com>
Hi Lizardo,
On 2/24/2011 9:56 AM, Anderson Lizardo wrote:
> Hi Brian,
>
> I just noticed "Conditional jump or move depends on uninitialised
> value(s)" errors when running bluez with valgrind:
>
> ==690== Conditional jump or move depends on uninitialised value(s)
> ==690== at 0x4837EA0: sdp_set_service_id (sdp.c:2456)
> ==690== by 0x166F79: attrib_create_sdp (attrib-server.c:133)
> ==690== by 0x167436: register_core_services (attrib-server.c:856)
> ==690== by 0x1675E3: attrib_server_init (attrib-server.c:902)
> ==690== by 0x162424: main (main.c:462)
>
> Full log is attached, it was generated with:
>
> env G_SLICE=always-malloc valgrind bluetoothd -n -d
>
> Can you take a look at this? Thanks,
This can be fixed in one of about 3 ways:
1. Eliminate the call to sdp_set_service_id all together (it's not
required by the specification)
2. Set the service ID to services UUID (doesn't service a useful purpose)
3. Let the profile deal with the SDP service ID. (same as 1 for now)
The offending code attempts to give the SDP record a "Service ID" which
is not required by the specification, but is useful if there is more
than one instance of the service being declared in SDP.
An example of this in the case of GATT might be Two Primary Battery
meter services, where both would have the same service UUID, but one
would be referring to a "Main" battery, and the other an "Aux" battery.
In LE mode, the Service ID is unavailable and would be superfluous
because everything you need to know about the service can be determined
from the other Attributes. Therefore, I think the argument can be made
that specific instance information is equally superflous, and should not
be included in the service record.
If there are no objections, I am just going to eliminate the call to
sdp_set_service_id in the attribute server all together.
--
Brian Gix
bgix@codeaurora.org
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox