* Re: [PATCH 4/4] Better filtering input string contain bdaddr
From: Anderson Lizardo @ 2010-12-27 11:52 UTC (permalink / raw)
To: Michal Labedzki; +Cc: linux-bluetooth
In-Reply-To: <1293447745-8697-4-git-send-email-michal.labedzki@tieto.com>
On Mon, Dec 27, 2010 at 7:02 AM, Michal Labedzki
<michal.labedzki@tieto.com> wrote:
> + if (((*ptr < 'A' || *ptr > 'F') &&
> + (*ptr < 'a' || *ptr > 'f') &&
> + (*ptr < '0' || *ptr > '9')) ||
> + ( (ptr - str) == 2 && *ptr != ':')) {
> + bt_free(ba);
> + goto err_bdaddr;
> + }
The logic above seems wrong. Make sure you are not mixing || and &&.
> +
> + ++i;
> + ++ptr;
I think the usual coding style in bluez uses post-increment in these
cases (e.g. i++).
Regards,
--
Anderson Lizardo
OpenBossa Labs - INdT
Manaus - Brazil
^ permalink raw reply
* Re: [PATCH 2/4] Two merges very similar functions in bluetooth.c
From: Anderson Lizardo @ 2010-12-27 11:46 UTC (permalink / raw)
To: Michal Labedzki; +Cc: linux-bluetooth
In-Reply-To: <1293447745-8697-2-git-send-email-michal.labedzki@tieto.com>
On Mon, Dec 27, 2010 at 7:02 AM, Michal Labedzki
<michal.labedzki@tieto.com> wrote:
> in lib/bluetooth.c merge "str2ba" and "strtoba", "ba2str" and "batostr"
IMHO, you should keep str2ba and drop the few occurrences of
strtoba(). Same applies to ba2str/batostr.
strtoba() allocates memory by itself, so if you use it instead, you
need to deallocate memory. str2ba(), on the other hand, uses a buffer
given as argument.
Regards,
--
Anderson Lizardo
OpenBossa Labs - INdT
Manaus - Brazil
^ permalink raw reply
* [PATCH 4/4] Better filtering input string contain bdaddr
From: Michal Labedzki @ 2010-12-27 11:02 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Michal Labedzki
In-Reply-To: <1293447745-8697-1-git-send-email-michal.labedzki@tieto.com>
---
lib/bluetooth.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 48 insertions(+), 7 deletions(-)
diff --git a/lib/bluetooth.c b/lib/bluetooth.c
index 3a4e3f4..9333eeb 100644
--- a/lib/bluetooth.c
+++ b/lib/bluetooth.c
@@ -60,23 +60,64 @@ char *batostr(const bdaddr_t *ba)
return str;
}
+/* convert to bdaddr_t string describes with regular expression "(XX:){0,5}XX"
+ * where X is "[0-9A-Fa-f]"
+ * shorter address is filling with ":00" at the end
+ */
bdaddr_t *strtoba(const char *str)
{
const char *ptr = str;
int i;
+ int parts;
+ int length;
+ bdaddr_t *ba;
+ unsigned int b;
+
+ length = strlen(str);
+ if (length <= 1 || length > 17)
+ goto err_bdaddr;
- uint8_t *ba = bt_malloc(sizeof(bdaddr_t));
+ ba = bt_malloc(sizeof(bdaddr_t));
if (!ba)
return NULL;
- for (i = 0; i < 6; i++) {
- ba[i] = (uint8_t) strtol(ptr, NULL, 16);
- if (i != 5 && !(ptr = strchr(ptr,':')))
- ptr = ":00:00:00:00:00";
- ptr++;
+ i = 0;
+ parts = 0;
+ while (*ptr) {
+ if (i == 2 && *ptr == ':') {
+ i = 0;
+ ba->b[parts] = strtol(ptr - 2, NULL, 16);
+ ++parts;
+ ++ptr;
+ }
+
+ if (((*ptr < 'A' || *ptr > 'F') &&
+ (*ptr < 'a' || *ptr > 'f') &&
+ (*ptr < '0' || *ptr > '9')) ||
+ ( (ptr - str) == 2 && *ptr != ':')) {
+ bt_free(ba);
+ goto err_bdaddr;
+ }
+
+ ++i;
+ ++ptr;
}
- return (bdaddr_t *) ba;
+ if (*(ptr - 1) == ':' || i == 1) {
+ bt_free(ba);
+ goto err_bdaddr;
+ }
+
+ ba->b[parts] = strtol(ptr - 2, NULL, 16);
+ for (i = parts + 1 ; i < 6 ; ++i) {
+ ba->b[i] = 0;
+ }
+
+ return ba;
+
+err_bdaddr:
+ fprintf(stderr, "Incorrect bdaddr format\n");
+ exit(1);
}
/* reverse bdaddr and do batostr */
--
1.7.0.4
^ permalink raw reply related
* [PATCH 3/4] Fix memory leaks after using strtoba, batostr
From: Michal Labedzki @ 2010-12-27 11:02 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Michal Labedzki
In-Reply-To: <1293447745-8697-1-git-send-email-michal.labedzki@tieto.com>
---
compat/bnep.c | 5 +++--
compat/pand.c | 9 ++++++---
test/hciemu.c | 8 ++++++--
3 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/compat/bnep.c b/compat/bnep.c
index 9b0d8b8..f651dfd 100644
--- a/compat/bnep.c
+++ b/compat/bnep.c
@@ -137,9 +137,10 @@ int bnep_show_connections(void)
}
for (i = 0; i < req.cnum; i++) {
- printf("%s %s %s\n", ci[i].device,
- batostr((bdaddr_t *) ci[i].dst),
+ char *tmp_bastr = batostr((bdaddr_t *) ci[i].dst);
+ printf("%s %s %s\n", ci[i].device, tmp_bastr,
bnep_svc2str(ci[i].role));
+ bt_free(tmp_bastr);
}
return 0;
}
diff --git a/compat/pand.c b/compat/pand.c
index 7331fad..8a50020 100644
--- a/compat/pand.c
+++ b/compat/pand.c
@@ -456,10 +456,13 @@ static void do_show(void)
static void do_kill(char *dst)
{
- if (dst)
- bnep_kill_connection((void *) strtoba(dst));
- else
+ if (dst) {
+ bdaddr_t *tmp_ba = strtoba(dst);
+ bnep_kill_connection((void *) tmp_ba);
+ bt_free(tmp_ba);
+ } else {
bnep_kill_all_connections();
+ }
}
static void sig_hup(int sig)
diff --git a/test/hciemu.c b/test/hciemu.c
index ae33d72..031b867 100644
--- a/test/hciemu.c
+++ b/test/hciemu.c
@@ -499,8 +499,10 @@ static void accept_connection(uint8_t *data)
static void close_connection(struct vhci_conn *conn)
{
+ char *tmp_bastr = batostr(&conn->dest);
syslog(LOG_INFO, "Closing connection %s handle %d",
- batostr(&conn->dest), conn->handle);
+ tmp_bastr, conn->handle);
+ bt_free(tmp_bastr);
g_io_channel_close(conn->chan);
g_io_channel_unref(conn->chan);
@@ -1017,7 +1019,9 @@ static int getbdaddrbyname(char *str, bdaddr_t *ba)
if (n == 5) {
/* BD address */
- baswap(ba, strtoba(str));
+ bdaddr_t *tmp_ba = strtoba(str);
+ baswap(ba, tmp_ba);
+ bt_free(tmp_ba);
return 0;
}
--
1.7.0.4
^ permalink raw reply related
* [PATCH 2/4] Two merges very similar functions in bluetooth.c
From: Michal Labedzki @ 2010-12-27 11:02 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Michal Labedzki
In-Reply-To: <1293447745-8697-1-git-send-email-michal.labedzki@tieto.com>
in lib/bluetooth.c merge "str2ba" and "strtoba", "ba2str" and "batostr"
---
lib/bluetooth.c | 34 +++++++++++++++++-----------------
1 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/lib/bluetooth.c b/lib/bluetooth.c
index 4af2ef6..3a4e3f4 100644
--- a/lib/bluetooth.c
+++ b/lib/bluetooth.c
@@ -55,8 +55,7 @@ char *batostr(const bdaddr_t *ba)
return NULL;
sprintf(str, "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
- ba->b[0], ba->b[1], ba->b[2],
- ba->b[3], ba->b[4], ba->b[5]);
+ ba->b[0], ba->b[1], ba->b[2], ba->b[3], ba->b[4], ba->b[5]);
return str;
}
@@ -80,29 +79,30 @@ bdaddr_t *strtoba(const char *str)
return (bdaddr_t *) ba;
}
+/* reverse bdaddr and do batostr */
int ba2str(const bdaddr_t *ba, char *str)
{
- uint8_t b[6];
-
- baswap((bdaddr_t *) b, ba);
- return sprintf(str, "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
- b[0], b[1], b[2], b[3], b[4], b[5]);
+ bdaddr_t b;
+ char *bastr;
+
+ baswap(&b, ba);
+ bastr = batostr(&b);
+ strcpy(str, bastr);
+ bt_free(bastr);
+ return *str && 1;
}
+/* do strtoba and return reverse bdaddr */
int str2ba(const char *str, bdaddr_t *ba)
{
- uint8_t b[6];
- const char *ptr = str;
+ bdaddr_t *b;
int i;
- for (i = 0; i < 6; i++) {
- b[i] = (uint8_t) strtol(ptr, NULL, 16);
- if (i != 5 && !(ptr = strchr(ptr, ':')))
- ptr = ":00:00:00:00:00";
- ptr++;
- }
-
- baswap(ba, (bdaddr_t *) b);
+ b = strtoba(str);
+ if (b == NULL)
+ return 0;
+ baswap(ba, b);
+ bt_free(b);
return 0;
}
--
1.7.0.4
^ permalink raw reply related
* [PATCH 1/4] Filtering interface name from program arguments
From: Michal Labedzki @ 2010-12-27 11:02 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Michal Labedzki
tools: Name must be "hciX", where X is 0..HCI_MAX_DEV. Any other like "tty1, ""hci001"
or "hci1x" will no longer work as "hci1".
tools: Add info that "bdaddr" can be put for parameter "interface".
---
attrib/gatttool.c | 9 ++++++---
compat/pand.c | 2 +-
lib/hci.c | 53 +++++++++++++++++++++++++++++++++++++++++++++--------
lib/hci_lib.h | 1 +
test/hciemu.c | 9 +++++----
test/l2test.c | 8 +++++---
test/rctest.c | 10 ++++++----
tools/ciptool.c | 9 +++++----
tools/hciconfig.c | 8 +++++++-
tools/hcitool.c | 4 ++--
tools/l2ping.c | 12 +++++++-----
tools/main.c | 7 ++++---
tools/sdptool.c | 9 +++++----
13 files changed, 99 insertions(+), 42 deletions(-)
diff --git a/attrib/gatttool.c b/attrib/gatttool.c
index a234e36..43b4f57 100644
--- a/attrib/gatttool.c
+++ b/attrib/gatttool.c
@@ -105,10 +105,13 @@ static GIOChannel *do_connect(gboolean le)
/* Local adapter */
if (opt_src != NULL) {
- if (!strncmp(opt_src, "hci", 3))
- hci_devba(atoi(opt_src + 3), &sba);
- else
+ int devid;
+
+ devid = hci_filter_devname(opt_src);
+ if (devid < 0)
str2ba(opt_src, &sba);
+ else
+ hci_devba(devid, &sba);
} else
bacpy(&sba, BDADDR_ANY);
diff --git a/compat/pand.c b/compat/pand.c
index c3860fa..7331fad 100644
--- a/compat/pand.c
+++ b/compat/pand.c
@@ -586,7 +586,7 @@ static const char *main_help =
"\t--role -r <role> Local PAN role (PANU, NAP, GN)\n"
"\t--service -d <role> Remote PAN service (PANU, NAP, GN)\n"
"\t--ethernet -e <name> Network interface name\n"
- "\t--device -i <bdaddr> Source bdaddr\n"
+ "\t--device -i <hciX|bdaddr> Source interface or bdaddr\n"
"\t--nosdp -D Disable SDP\n"
"\t--auth -A Enable authentication\n"
"\t--encrypt -E Enable encryption\n"
diff --git a/lib/hci.c b/lib/hci.c
index 048fda4..bb01d90 100644
--- a/lib/hci.c
+++ b/lib/hci.c
@@ -887,22 +887,57 @@ int hci_get_route(bdaddr_t *bdaddr)
(long) (bdaddr ? bdaddr : BDADDR_ANY));
}
+/* return 1 if string is ecimal number without leading zeros
+ * return 0 if not */
+static int is_devnumber(const char *c)
+{
+ if (c[0] == '0' && c[1] != 0)
+ return 0;
+
+ while (*c) {
+ if (*c < '0' || *c > '9')
+ return 0;
+ ++c;
+ }
+ return 1;
+}
+
+/* return HCI dev_id from string like "hciX", where X is dev_id
+ * return -1 if string not match */
+int hci_filter_devname(const char *str)
+{
+ int dev_id;
+
+ if ((strlen(str) >= 4) && (!strncmp(str, "hci", 3)) &&
+ (is_devnumber(str + 3)))
+ dev_id = atoi(str + 3);
+ else
+ dev_id = -1;
+
+ if (dev_id >= HCI_MAX_DEV)
+ dev_id = -1;
+
+ return dev_id;
+}
+
+/* return dev_id, which is on UP state, from 'hciX' or 'bdaddr'
+ * otherwise return -1 */
int hci_devid(const char *str)
{
bdaddr_t ba;
- int id = -1;
+ int dev_id;
- if (!strncmp(str, "hci", 3) && strlen(str) >= 4) {
- id = atoi(str + 3);
- if (hci_devba(id, &ba) < 0)
- return -1;
- } else {
+ dev_id = hci_filter_devname(str);
+ if (dev_id < 0) {
errno = ENODEV;
str2ba(str, &ba);
- id = hci_for_each_dev(HCI_UP, __same_bdaddr, (long) &ba);
+ dev_id = hci_for_each_dev(HCI_UP, __same_bdaddr, (long) &ba);
+ } else {
+ if (hci_devba(dev_id, &ba) < 0)
+ return -1;
}
- return id;
+ return dev_id;
}
int hci_devinfo(int dev_id, struct hci_dev_info *di)
@@ -925,6 +960,8 @@ int hci_devinfo(int dev_id, struct hci_dev_info *di)
return ret;
}
+/* return status 0 and bdaddr assigned to dev_id
+ * otherwise status -1 */
int hci_devba(int dev_id, bdaddr_t *bdaddr)
{
struct hci_dev_info di;
diff --git a/lib/hci_lib.h b/lib/hci_lib.h
index b63a2a4..ef00f99 100644
--- a/lib/hci_lib.h
+++ b/lib/hci_lib.h
@@ -60,6 +60,7 @@ int hci_inquiry(int dev_id, int len, int num_rsp, const uint8_t *lap, inquiry_in
int hci_devinfo(int dev_id, struct hci_dev_info *di);
int hci_devba(int dev_id, bdaddr_t *bdaddr);
int hci_devid(const char *str);
+int hci_filter_devname(const char *str);
int hci_read_local_name(int dd, int len, char *name, int to);
int hci_write_local_name(int dd, const char *name, int to);
diff --git a/test/hciemu.c b/test/hciemu.c
index a20374f..ae33d72 100644
--- a/test/hciemu.c
+++ b/test/hciemu.c
@@ -1234,15 +1234,16 @@ int main(int argc, char *argv[])
exit(1);
}
- if (strlen(argv[0]) > 3 && !strncasecmp(argv[0], "hci", 3)) {
+ dev = hci_filter_devname(argv[0]);
+ if (dev < 0) {
+ if (getbdaddrbyname(argv[0], &vdev.bdaddr) < 0)
+ exit(1);
+ } else {
dev = hci_devid(argv[0]);
if (dev < 0) {
perror("Invalid device");
exit(1);
}
- } else {
- if (getbdaddrbyname(argv[0], &vdev.bdaddr) < 0)
- exit(1);
}
if (detach) {
diff --git a/test/l2test.c b/test/l2test.c
index 17883a9..438ba39 100644
--- a/test/l2test.c
+++ b/test/l2test.c
@@ -1101,6 +1101,7 @@ int main(int argc, char *argv[])
{
struct sigaction sa;
int opt, sk, mode = RECV, need_addr = 0;
+ int devid;
bacpy(&bdaddr, BDADDR_ANY);
@@ -1175,10 +1176,11 @@ int main(int argc, char *argv[])
break;
case 'i':
- if (!strncasecmp(optarg, "hci", 3))
- hci_devba(atoi(optarg + 3), &bdaddr);
- else
+ devid = hci_filter_devname(optarg);
+ if (devid < 0)
str2ba(optarg, &bdaddr);
+ else
+ hci_devba(devid, &bdaddr);
break;
case 'P':
diff --git a/test/rctest.c b/test/rctest.c
index b3804f5..a828ad9 100644
--- a/test/rctest.c
+++ b/test/rctest.c
@@ -579,7 +579,7 @@ static void usage(void)
"\t-m multiple connects\n");
printf("Options:\n"
- "\t[-b bytes] [-i device] [-P channel] [-U uuid]\n"
+ "\t[-b bytes] [-i hciX|bdaddr] [-P channel] [-U uuid]\n"
"\t[-L seconds] enabled SO_LINGER option\n"
"\t[-W seconds] enable deferred setup\n"
"\t[-B filename] use data packets from file\n"
@@ -597,6 +597,7 @@ int main(int argc, char *argv[])
{
struct sigaction sa;
int opt, sk, mode = RECV, need_addr = 0;
+ int devid;
bacpy(&bdaddr, BDADDR_ANY);
@@ -644,10 +645,11 @@ int main(int argc, char *argv[])
break;
case 'i':
- if (!strncasecmp(optarg, "hci", 3))
- hci_devba(atoi(optarg + 3), &bdaddr);
- else
+ devid = hci_filter_devname(optarg);
+ if (devid < 0)
str2ba(optarg, &bdaddr);
+ else
+ hci_devba(devid, &bdaddr);
break;
case 'P':
diff --git a/tools/ciptool.c b/tools/ciptool.c
index edce9da..ec602ef 100644
--- a/tools/ciptool.c
+++ b/tools/ciptool.c
@@ -427,7 +427,7 @@ static void usage(void)
"\n");
printf("Options:\n"
- "\t-i [hciX|bdaddr] Local HCI device or BD Address\n"
+ "\t-i <hciX|bdaddr> Local HCI device or BD Address\n"
"\t-h, --help Display help\n"
"\n");
@@ -455,10 +455,11 @@ int main(int argc, char *argv[])
while ((opt = getopt_long(argc, argv, "+i:h", main_options, NULL)) != -1) {
switch(opt) {
case 'i':
- if (!strncmp(optarg, "hci", 3))
- hci_devba(atoi(optarg + 3), &bdaddr);
- else
+ i = hci_filter_devname(optarg);
+ if (i < 0)
str2ba(optarg, &bdaddr);
+ else
+ hci_devba(i, &bdaddr);
break;
case 'h':
usage();
diff --git a/tools/hciconfig.c b/tools/hciconfig.c
index f0ae11c..e20963d 100644
--- a/tools/hciconfig.c
+++ b/tools/hciconfig.c
@@ -1849,7 +1849,13 @@ int main(int argc, char *argv[])
exit(0);
}
- di.dev_id = atoi(argv[0] + 3);
+ i = hci_filter_devname(argv[0]);
+ if (i < 0) {
+ fprintf(stderr, "No valid device name.\n");
+ exit(1);
+ }
+ di.dev_id = i;
+
argc--; argv++;
if (ioctl(ctl, HCIGETDEVINFO, (void *) &di)) {
diff --git a/tools/hcitool.c b/tools/hcitool.c
index d50adaf..dc70e63 100644
--- a/tools/hcitool.c
+++ b/tools/hcitool.c
@@ -2560,8 +2560,8 @@ static void usage(void)
printf("Usage:\n"
"\thcitool [options] <command> [command parameters]\n");
printf("Options:\n"
- "\t--help\tDisplay help\n"
- "\t-i dev\tHCI device\n");
+ "\t--help Display help\n"
+ "\t-i <hciX|bdaddr> Local HCI device or BD Address\n");
printf("Commands:\n");
for (i = 0; command[i].cmd; i++)
printf("\t%-4s\t%s\n", command[i].cmd,
diff --git a/tools/l2ping.c b/tools/l2ping.c
index 29fb3d0..dd0ccbd 100644
--- a/tools/l2ping.c
+++ b/tools/l2ping.c
@@ -255,7 +255,8 @@ static void usage(void)
{
printf("l2ping - L2CAP ping\n");
printf("Usage:\n");
- printf("\tl2ping [-i device] [-s size] [-c count] [-t timeout] [-d delay] [-f] [-r] [-v] <bdaddr>\n");
+ printf("\tl2ping [-i <hciX|bdaddr> local hci or bd address] [-s size]"
+ "[-c count] [-t timeout] [-d delay] [-f] [-r] [-v] <bdaddr>\n");
printf("\t-f Flood ping (delay = 0)\n");
printf("\t-r Reverse ping\n");
printf("\t-v Verify request and response payload\n");
@@ -264,17 +265,18 @@ static void usage(void)
int main(int argc, char *argv[])
{
int opt;
-
+ int devid;
/* Default options */
bacpy(&bdaddr, BDADDR_ANY);
while ((opt=getopt(argc,argv,"i:d:s:c:t:frv")) != EOF) {
switch(opt) {
case 'i':
- if (!strncasecmp(optarg, "hci", 3))
- hci_devba(atoi(optarg + 3), &bdaddr);
- else
+ devid = hci_filter_devname(optarg);
+ if (devid < 0)
str2ba(optarg, &bdaddr);
+ else
+ hci_devba(devid, &bdaddr);
break;
case 'd':
diff --git a/tools/main.c b/tools/main.c
index 6800445..c000fba 100644
--- a/tools/main.c
+++ b/tools/main.c
@@ -753,10 +753,11 @@ int main(int argc, char *argv[])
while ((opt = getopt_long(argc, argv, "+i:f:rahAESML:", main_options, NULL)) != -1) {
switch(opt) {
case 'i':
- if (strncmp(optarg, "hci", 3) == 0)
- hci_devba(atoi(optarg + 3), &bdaddr);
- else
+ dev_id = hci_filter_devname(optarg);
+ if (dev_id < 0)
str2ba(optarg, &bdaddr);
+ else
+ hci_devba(dev_id, &bdaddr);
break;
case 'f':
diff --git a/tools/sdptool.c b/tools/sdptool.c
index 140a46a..c782e62 100644
--- a/tools/sdptool.c
+++ b/tools/sdptool.c
@@ -4209,7 +4209,7 @@ static void usage(void)
"\tsdptool [options] <command> [command parameters]\n");
printf("Options:\n"
"\t-h\t\tDisplay help\n"
- "\t-i\t\tSpecify source interface\n");
+ "\t-i\t\tSpecify source interface or bdaddr\n");
printf("Commands:\n");
for (i = 0; command[i].cmd; i++)
@@ -4242,10 +4242,11 @@ int main(int argc, char *argv[])
while ((opt=getopt_long(argc, argv, "+i:h", main_options, NULL)) != -1) {
switch(opt) {
case 'i':
- if (!strncmp(optarg, "hci", 3))
- hci_devba(atoi(optarg + 3), &interface);
- else
+ i = hci_filter_devname(optarg);
+ if (i < 0)
str2ba(optarg, &interface);
+ else
+ hci_devba(i, &interface);
break;
case 'h':
--
1.7.0.4
^ permalink raw reply related
* Re: [PATCH] Add Broadcaster property in DeviceFound signal
From: Johan Hedberg @ 2010-12-23 22:40 UTC (permalink / raw)
To: Sheldon Demario; +Cc: linux-bluetooth
In-Reply-To: <1293139987-17536-1-git-send-email-sheldon.demario@openbossa.org>
Hi Sheldon,
On Thu, Dec 23, 2010, Sheldon Demario wrote:
> Broadcaster property is required to distinguish the device role. If the remote
> is sending an advertising event, two possible roles are possible: Peripheral or
> Broadcaster.
>
> This change is required to pass on qualification tests which require filtering
> Broadcasting devices during General Discovery Procedure.
> ---
> doc/adapter-api.txt | 3 ++-
> src/adapter.c | 8 ++++++++
> 2 files changed, 10 insertions(+), 1 deletions(-)
Pushed upstream after I reformated your commit message to properly fit a
80 column wide terminal. Please pay attention to that in the future.
Johan
^ permalink raw reply
* Re: [PATCH v5 2/5] Change CreatePairedDevice to support LE devices
From: Johan Hedberg @ 2010-12-23 22:37 UTC (permalink / raw)
To: Sheldon Demario; +Cc: linux-bluetooth
In-Reply-To: <1293139790-9646-1-git-send-email-sheldon.demario@openbossa.org>
Hi Sheldon,
On Thu, Dec 23, 2010, Sheldon Demario wrote:
> CreatePairedDevice implements now the same behaviour of CreateDevice,
> triggering Discover All Primary Services when needed. SMP negotiation
> starts when the link is established. LE capable kernel is required to
> test this method properly.
>
> Limitation: For dual mode devices, Discover All Primary Services is not
> being executed after SDP search if GATT record is found.
> ---
> src/adapter.c | 102 +++++++++++++++++++++++++++++++++++++----------------
> src/device.c | 89 ++++++++++++++++++++++++----------------------
> src/device.h | 5 ++-
> src/glib-helper.c | 12 +++++-
> src/glib-helper.h | 1 +
> 5 files changed, 132 insertions(+), 77 deletions(-)
Pushed upstream. Thanks.
Johan
^ permalink raw reply
* [PATCH] Add Broadcaster property in DeviceFound signal
From: Sheldon Demario @ 2010-12-23 21:33 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Sheldon Demario
Broadcaster property is required to distinguish the device role. If the remote
is sending an advertising event, two possible roles are possible: Peripheral or
Broadcaster.
This change is required to pass on qualification tests which require filtering
Broadcasting devices during General Discovery Procedure.
---
doc/adapter-api.txt | 3 ++-
src/adapter.c | 8 ++++++++
2 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/doc/adapter-api.txt b/doc/adapter-api.txt
index f287f29..5272d74 100644
--- a/doc/adapter-api.txt
+++ b/doc/adapter-api.txt
@@ -185,7 +185,8 @@ Signals PropertyChanged(string name, variant value)
The dictionary can contain basically the same values
that are returned by the GetProperties method
from the org.bluez.Device interface. In addition there
- can be values for the RSSI and the TX power level.
+ can be values for the RSSI, the TX power level and
+ Broadcaster role.
DeviceDisappeared(string address)
diff --git a/src/adapter.c b/src/adapter.c
index bf92211..fddf0ad 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2829,12 +2829,20 @@ void adapter_emit_device_found(struct btd_adapter *adapter,
}
if (dev->le) {
+ gboolean broadcaster;
+
+ if (dev->flags & (EIR_LIM_DISC | EIR_GEN_DISC))
+ broadcaster = FALSE;
+ else
+ broadcaster = TRUE;
+
emit_device_found(adapter->path, paddr,
"Address", DBUS_TYPE_STRING, &paddr,
"RSSI", DBUS_TYPE_INT16, &rssi,
"Name", DBUS_TYPE_STRING, &dev->name,
"Paired", DBUS_TYPE_BOOLEAN, &paired,
"UUIDs", DBUS_TYPE_ARRAY, &dev->uuids,
+ "Broadcaster", DBUS_TYPE_BOOLEAN, &broadcaster,
dev->uuid_count, NULL);
return;
}
--
1.7.3.2
^ permalink raw reply related
* [PATCH v5 2/5] Change CreatePairedDevice to support LE devices
From: Sheldon Demario @ 2010-12-23 21:29 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Sheldon Demario
In-Reply-To: <20101221084243.GA14108@jh-x301>
CreatePairedDevice implements now the same behaviour of CreateDevice,
triggering Discover All Primary Services when needed. SMP negotiation
starts when the link is established. LE capable kernel is required to
test this method properly.
Limitation: For dual mode devices, Discover All Primary Services is not
being executed after SDP search if GATT record is found.
---
src/adapter.c | 102 +++++++++++++++++++++++++++++++++++++----------------
src/device.c | 89 ++++++++++++++++++++++++----------------------
src/device.h | 5 ++-
src/glib-helper.c | 12 +++++-
src/glib-helper.h | 1 +
5 files changed, 132 insertions(+), 77 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index 1913171..fddf0ad 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -1520,15 +1520,48 @@ static gboolean event_is_connectable(uint8_t type)
}
}
+static struct btd_device *create_device_internal(DBusConnection *conn,
+ struct btd_adapter *adapter,
+ const gchar *address,
+ gboolean force, int *err)
+{
+ struct remote_dev_info *dev, match;
+ struct btd_device *device;
+ device_type_t type;
+
+ memset(&match, 0, sizeof(struct remote_dev_info));
+ str2ba(address, &match.bdaddr);
+ match.name_status = NAME_ANY;
+
+ dev = adapter_search_found_devices(adapter, &match);
+ if (dev && dev->flags)
+ type = flags2type(dev->flags);
+ else
+ type = DEVICE_TYPE_BREDR;
+
+ if (!force && type == DEVICE_TYPE_LE &&
+ !event_is_connectable(dev->evt_type)) {
+ if (err)
+ *err = -ENOTCONN;
+
+ return NULL;
+ }
+
+ device = adapter_create_device(conn, adapter, address, type);
+ if (!device && err)
+ *err = -ENOMEM;
+
+ return device;
+}
+
static DBusMessage *create_device(DBusConnection *conn,
DBusMessage *msg, void *data)
{
struct btd_adapter *adapter = data;
struct btd_device *device;
- struct remote_dev_info *dev, match;
const gchar *address;
+ DBusMessage *reply;
int err;
- device_type_t type;
if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &address,
DBUS_TYPE_INVALID) == FALSE)
@@ -1545,41 +1578,36 @@ static DBusMessage *create_device(DBusConnection *conn,
DBG("%s", address);
- memset(&match, 0, sizeof(struct remote_dev_info));
- str2ba(address, &match.bdaddr);
- match.name_status = NAME_ANY;
+ device = create_device_internal(conn, adapter, address, TRUE, &err);
+ if (!device)
+ goto failed;
- dev = adapter_search_found_devices(adapter, &match);
- if (dev && dev->flags)
- type = flags2type(dev->flags);
+ if (device_get_type(device) != DEVICE_TYPE_LE)
+ err = device_browse_sdp(device, conn, msg, NULL, FALSE);
else
- type = DEVICE_TYPE_BREDR;
+ err = device_browse_primary(device, conn, msg, FALSE);
- device = adapter_create_device(conn, adapter, address, type);
- if (!device)
- return NULL;
+ if (err < 0) {
+ adapter_remove_device(conn, adapter, device, TRUE);
+ return btd_error_failed(msg, strerror(-err));
+ }
- if (type == DEVICE_TYPE_LE && !event_is_connectable(dev->evt_type)) {
+ return NULL;
+
+failed:
+ if (err == -ENOTCONN) {
/* Device is not connectable */
const char *path = device_get_path(device);
- DBusMessage *reply;
reply = dbus_message_new_method_return(msg);
dbus_message_append_args(reply,
- DBUS_TYPE_OBJECT_PATH, &path,
- DBUS_TYPE_INVALID);
-
- return reply;
- }
-
- err = device_browse(device, conn, msg, NULL, FALSE);
- if (err < 0) {
- adapter_remove_device(conn, adapter, device, TRUE);
- return btd_error_failed(msg, strerror(-err));
- }
+ DBUS_TYPE_OBJECT_PATH, &path,
+ DBUS_TYPE_INVALID);
+ } else
+ reply = btd_error_failed(msg, strerror(-err));
- return NULL;
+ return reply;
}
static uint8_t parse_io_capability(const char *capability)
@@ -1604,6 +1632,7 @@ static DBusMessage *create_paired_device(DBusConnection *conn,
struct btd_device *device;
const gchar *address, *agent_path, *capability, *sender;
uint8_t cap;
+ int err;
if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &address,
DBUS_TYPE_OBJECT_PATH, &agent_path,
@@ -1628,12 +1657,23 @@ static DBusMessage *create_paired_device(DBusConnection *conn,
if (cap == IO_CAPABILITY_INVALID)
return btd_error_invalid_args(msg);
- device = adapter_get_device(conn, adapter, address);
- if (!device)
- return btd_error_failed(msg,
- "Unable to create a new device object");
+ device = adapter_find_device(adapter, address);
+ if (!device) {
+ device = create_device_internal(conn, adapter, address,
+ FALSE, &err);
+ if (!device)
+ return btd_error_failed(msg, strerror(-err));
+ }
+
+ if (device_get_type(device) != DEVICE_TYPE_LE)
+ return device_create_bonding(device, conn, msg,
+ agent_path, cap);
- return device_create_bonding(device, conn, msg, agent_path, cap);
+ err = device_browse_primary(device, conn, msg, TRUE);
+ if (err < 0)
+ return btd_error_failed(msg, strerror(-err));
+
+ return NULL;
}
static gint device_path_cmp(struct btd_device *device, const gchar *path)
diff --git a/src/device.c b/src/device.c
index e093b82..c33b22b 100644
--- a/src/device.c
+++ b/src/device.c
@@ -588,7 +588,7 @@ static DBusMessage *discover_services(DBusConnection *conn,
return btd_error_invalid_args(msg);
if (strlen(pattern) == 0) {
- err = device_browse(device, conn, msg, NULL, FALSE);
+ err = device_browse_sdp(device, conn, msg, NULL, FALSE);
if (err < 0)
goto fail;
} else {
@@ -599,7 +599,7 @@ static DBusMessage *discover_services(DBusConnection *conn,
sdp_uuid128_to_uuid(&uuid);
- err = device_browse(device, conn, msg, &uuid, FALSE);
+ err = device_browse_sdp(device, conn, msg, &uuid, FALSE);
if (err < 0)
goto fail;
}
@@ -992,6 +992,11 @@ void device_get_name(struct btd_device *device, char *name, size_t len)
strncpy(name, device->name, len);
}
+device_type_t device_get_type(struct btd_device *device)
+{
+ return device->type;
+}
+
void device_remove_bonding(struct btd_device *device)
{
char filename[PATH_MAX + 1];
@@ -1599,41 +1604,62 @@ done:
browse_request_free(req);
}
-static struct browse_req *browse_primary(struct btd_device *device, int *err)
+int device_browse_primary(struct btd_device *device, DBusConnection *conn,
+ DBusMessage *msg, gboolean secure)
{
struct btd_adapter *adapter = device->adapter;
struct browse_req *req;
bdaddr_t src;
- int ret;
+ int err;
+
+ if (device->browse)
+ return -EBUSY;
req = g_new0(struct browse_req, 1);
req->device = btd_device_ref(device);
adapter_get_address(adapter, &src);
- ret = bt_discover_primary(&src, &device->bdaddr, -1, primary_cb, req,
- NULL);
-
- if (ret < 0) {
+ err = bt_discover_primary(&src, &device->bdaddr, -1, primary_cb, req,
+ secure, NULL);
+ if (err < 0) {
browse_request_free(req);
- if (err)
- *err = ret;
+ return err;
+ }
- return NULL;
+ if (conn == NULL)
+ conn = get_dbus_connection();
+
+ req->conn = dbus_connection_ref(conn);
+ device->browse = req;
+
+ if (msg) {
+ const char *sender = dbus_message_get_sender(msg);
+
+ req->msg = dbus_message_ref(msg);
+ /* Track the request owner to cancel it
+ * automatically if the owner exits */
+ req->listener_id = g_dbus_add_disconnect_watch(conn,
+ sender,
+ discover_services_req_exit,
+ req, NULL);
}
- return req;
+ return err;
}
-static struct browse_req *browse_sdp(struct btd_device *device, uuid_t *search,
- gboolean reverse, int *err)
+int device_browse_sdp(struct btd_device *device, DBusConnection *conn,
+ DBusMessage *msg, uuid_t *search, gboolean reverse)
{
struct btd_adapter *adapter = device->adapter;
struct browse_req *req;
bt_callback_t cb;
bdaddr_t src;
uuid_t uuid;
- int ret;
+ int err;
+
+ if (device->browse)
+ return -EBUSY;
adapter_get_address(adapter, &src);
@@ -1648,34 +1674,11 @@ static struct browse_req *browse_sdp(struct btd_device *device, uuid_t *search,
cb = browse_cb;
}
- ret = bt_search_service(&src, &device->bdaddr, &uuid, cb, req, NULL);
- if (ret < 0) {
+ err = bt_search_service(&src, &device->bdaddr, &uuid, cb, req, NULL);
+ if (err < 0) {
browse_request_free(req);
- if (err)
- *err = ret;
-
- return NULL;
- }
-
- return req;
-}
-
-int device_browse(struct btd_device *device, DBusConnection *conn,
- DBusMessage *msg, uuid_t *search, gboolean reverse)
-{
- struct browse_req *req;
- int err = 0;
-
- if (device->browse)
- return -EBUSY;
-
- if (device->type == DEVICE_TYPE_LE)
- req = browse_primary(device, &err);
- else
- req = browse_sdp(device, search, reverse, &err);
-
- if (req == NULL)
return err;
+ }
if (conn == NULL)
conn = get_dbus_connection();
@@ -1786,7 +1789,7 @@ static gboolean start_discovery(gpointer user_data)
{
struct btd_device *device = user_data;
- device_browse(device, NULL, NULL, NULL, TRUE);
+ device_browse_sdp(device, NULL, NULL, NULL, TRUE);
device->discov_timer = 0;
@@ -2123,7 +2126,7 @@ void device_bonding_complete(struct btd_device *device, uint8_t status)
device->discov_timer = 0;
}
- device_browse(device, bonding->conn, bonding->msg,
+ device_browse_sdp(device, bonding->conn, bonding->msg,
NULL, FALSE);
bonding_request_free(bonding);
diff --git a/src/device.h b/src/device.h
index 86721bf..5dea953 100644
--- a/src/device.h
+++ b/src/device.h
@@ -47,9 +47,12 @@ struct btd_device *device_create(DBusConnection *conn,
const gchar *address, device_type_t type);
void device_set_name(struct btd_device *device, const char *name);
void device_get_name(struct btd_device *device, char *name, size_t len);
+device_type_t device_get_type(struct btd_device *device);
void device_remove(struct btd_device *device, gboolean remove_stored);
gint device_address_cmp(struct btd_device *device, const gchar *address);
-int device_browse(struct btd_device *device, DBusConnection *conn,
+int device_browse_primary(struct btd_device *device, DBusConnection *conn,
+ DBusMessage *msg, gboolean secure);
+int device_browse_sdp(struct btd_device *device, DBusConnection *conn,
DBusMessage *msg, uuid_t *search, gboolean reverse);
void device_probe_drivers(struct btd_device *device, GSList *profiles);
const sdp_record_t *btd_device_get_record(struct btd_device *device,
diff --git a/src/glib-helper.c b/src/glib-helper.c
index 648dd62..01517a3 100644
--- a/src/glib-helper.c
+++ b/src/glib-helper.c
@@ -517,9 +517,11 @@ static void connect_cb(GIOChannel *io, GError *gerr, gpointer user_data)
int bt_discover_primary(const bdaddr_t *src, const bdaddr_t *dst, int psm,
bt_primary_t cb, void *user_data,
+ gboolean secure,
bt_destroy_t destroy)
{
struct gattrib_context *ctxt;
+ BtIOSecLevel sec_level;
GIOChannel *io;
ctxt = g_try_new0(struct gattrib_context, 1);
@@ -532,19 +534,25 @@ int bt_discover_primary(const bdaddr_t *src, const bdaddr_t *dst, int psm,
ctxt->cb = cb;
ctxt->destroy = destroy;
+ if (secure == TRUE)
+ sec_level = BT_IO_SEC_HIGH;
+ else
+ sec_level = BT_IO_SEC_LOW;
+
+
if (psm < 0)
io = bt_io_connect(BT_IO_L2CAP, connect_cb, ctxt, NULL, NULL,
BT_IO_OPT_SOURCE_BDADDR, src,
BT_IO_OPT_DEST_BDADDR, dst,
BT_IO_OPT_CID, GATT_CID,
- BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_LOW,
+ BT_IO_OPT_SEC_LEVEL, sec_level,
BT_IO_OPT_INVALID);
else
io = bt_io_connect(BT_IO_L2CAP, connect_cb, ctxt, NULL, NULL,
BT_IO_OPT_SOURCE_BDADDR, src,
BT_IO_OPT_DEST_BDADDR, dst,
BT_IO_OPT_PSM, psm,
- BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_LOW,
+ BT_IO_OPT_SEC_LEVEL, sec_level,
BT_IO_OPT_INVALID);
if (io == NULL) {
diff --git a/src/glib-helper.h b/src/glib-helper.h
index ad81d7f..25fe276 100644
--- a/src/glib-helper.h
+++ b/src/glib-helper.h
@@ -32,6 +32,7 @@ int bt_cancel_discovery(const bdaddr_t *src, const bdaddr_t *dst);
int bt_discover_primary(const bdaddr_t *src, const bdaddr_t *dst, int psm,
bt_primary_t cb, void *user_data,
+ gboolean secure,
bt_destroy_t destroy);
gchar *bt_uuid2string(uuid_t *uuid);
--
1.7.3.2
^ permalink raw reply related
* Re: [PATCH] Updated TODO list for LE HCI Scan, Advertise and Connect commands.
From: Claudio Takahasi @ 2010-12-23 20:41 UTC (permalink / raw)
To: Sumit Kumar BAJPAI; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <4765B7BC10CB4C488A56C73E15D6FBA31DA368123F@EXDCVYMBSTM005.EQ1STM.local>
Hi Sumit,
On Thu, Dec 23, 2010 at 7:07 AM, Sumit Kumar BAJPAI
<sumitkumar.bajpai@stericsson.com> wrote:
> Updated TODO list for HCI commands for LE that ST-Ericsson plans to
> implement and contribute back.
>
> ---
> TODO | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 93 insertions(+), 0 deletions(-)
>
> diff --git a/TODO b/TODO
> index 49a9e76..e62c6e5 100644
> --- a/TODO
> +++ b/TODO
> @@ -66,6 +66,99 @@ Low Energy
> Priority: Low
> Complexity: C2
>
> +- Implement Set Advertise data via Host interface. This Set Advertise Data is
> + used by advertising device to advertise with some data field. This is via
> + undirected and connectable events. Data field is maximum of 30 octets, and is
> + primarily used for small data advertisement. Scanning device can see in scan
> + results the advertised data as set by the advertising device.
> + See Volume 2, Part E, section 7.8.7 for more information.
> +
> + Priority: Low
> + Complexity: C1
> +
> +- Implement Set Advertise parameters via Host interface. This Set Advertise
> + parameters is used by advertising device to set advertising parameters. The
> + Host shall not issue this command when advertising is enabled in the
> + Controller; if it is the Command Disallowed error code shall be used.
> + See Volume 2, Part E, section 7.8.5 for more information.
> +
> + Priority: Low
> + Complexity: C1
> +
> +- Implement Set Scan Response Data via host interface. This data is set by the
> + advertiser in case it wants to send data only to those devices that are
> + currently actively scanning. This is via undirected and connectable events.
> + Data can be set before or after advertising and can be maximum of 30 octets.
> + See Volume 2, Part E, section 7.8.8 for more information.
> +
> + Priority: Low
> + Complexity: C1
We don't need to expose a method to allow the applications to change
the advertising parameters. The idea is to manage them automatically
based on the registered gatt servers.
Broadcaster Role is out of scope at the moment. Peripheral, we are
planning to start the implementation soon, but first we need to define
the GATT server API.
IMHO we need to align the advertising parameter settings with the
Adapter "Discoverable" property and the registered GATT servers.
Set Scan Response Data: I don't an answer at the moment.
> +
> +- Implement Read Advertise Channel Tx Power via Host interface. This Read
> + Advertise Channel Tx power is used by advertising host to read the transmit
> + power level used for LE advertising channel packets.
> + See Volume 2, Part E, section 7.8.6 for more information.
> +
> + Priority: Low
> + Complexity: C1
Could you please give an usage example?
If I understood correctly we will need a function
hci_le_read_xxx_tx_power() to fill the TX Power Level in the
advertising data, right?
> +
> +- Implement Add Device to White List in LE controller via host interface.
> + This command is used to add a single device to white list stored in the
> + controller. Once the device is in white list it should follow scan and
> + connect rules as stated in advertising filter policy.
> + See Volume 2, Part E, section 7.8.16 for more information.
> +
> + Priority: Low
> + Complexity: C1
> +
> +- Implement Remove Device from White List in LE controller via host interface.
> + This command is used to remove a single device from white list stored in the
> + controller. This command has certain restrictions on its usage. Command
> + complete event is generated on completion.
> + See Volume 2, Part E, section 7.8.17 for more information.
> +
> + Priority: Low
> + Complexity: C1
> +
> +- Implement Clear White List in LE controller via host interface. This command
> + is used to clear the white list stored in the controller. This command has
> + certain restrictions on its usage. This command has no command parameters
> + to be pushed on controller. Command complete event is generated on completion.
> + See Volume 2, Part E, section 7.8.15 for more information.
> +
> + Priority: Low
> + Complexity: C1
> +
> +- Implement Read White List Size in LE controller via host interface. This
> + command is used to read the maximum size of the white list supported by the
> + controller.
> + See Volume 2, Part E, section 7.8.14 for more information.
> +
> + Priority: Low
> + Complexity: C1
Maybe we will need this feature to implement the Register Application
API. Automatic connections are planned, but it can be useful to
reduce/filter the amount of advertising reports.
> +
> +- Implement Read LE buffer Size via host interface. This data is used to read
> + the maximum size of data portion of HCI LE ACL Data Packets sent from the
> + Host to the Controller. The Host will segment the data transmitted to the
> + Controller according to these values, so that the HCI Data Packets will
> + contain data with up to this size. The LE_Read_Buffer_Size command also
> + returns the total number of HCI LE ACL Data Packets that can be stored in
> + the data buffers of the Controller. The LE_Read_Buffer_Size command must be
> + issued by the Host before it sends any data to an LE Controller.
> + See Volume 2, Part E, section 7.8.2 for more information.
> +
> + Priority: Low
> + Complexity: C1
> +
> +- Implement LE Connection Update command via Host interface. The
> + LE_Connection_Update command is used to change the Link Layer connection
> + parameters of a connection. This command shall only be used when the local
> + device's role is Master.
> + See Volume 2, Part E, section 7.8.18 for more information.
> +
> + Priority: Medium
> + Complexity: C1
Is it necessary to notify the userpace or it is a kernel task only?
Please remove it if it is a kernel task.
For the other tasks I suggest to keep them in the TODO file to track
the missing features, no matter if we will use them directly(eg:
hcitool, hciconfig) or in the API/services implementation.
If possible please add the expected deliverable for each task, it will
make easier to other developers to contribute.
Regards.
Claudio
^ permalink raw reply
* Re: [PATCH] Fix spurious DeviceDisappeared signals after name resolution
From: Johan Hedberg @ 2010-12-23 19:09 UTC (permalink / raw)
To: Anderson Lizardo; +Cc: linux-bluetooth
In-Reply-To: <1293125965-11782-1-git-send-email-anderson.lizardo@openbossa.org>
Hi Lizardo,
On Thu, Dec 23, 2010, Anderson Lizardo wrote:
> update_oor_devices() was being called twice, first after a inquiry, then
> after name resolution. This caused the just found devices to be always
> reported as "disappeared" after name resolution.
> ---
> src/adapter.c | 3 ++-
> 1 files changed, 2 insertions(+), 1 deletions(-)
Thanks. Pushed upstream.
Johan
^ permalink raw reply
* [PATCH] Fix spurious DeviceDisappeared signals after name resolution
From: Anderson Lizardo @ 2010-12-23 17:39 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
update_oor_devices() was being called twice, first after a inquiry, then
after name resolution. This caused the just found devices to be always
reported as "disappeared" after name resolution.
---
src/adapter.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index 69d3da0..096d684 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2641,13 +2641,14 @@ void adapter_set_state(struct btd_adapter *adapter, int state)
}
if (discov_active == FALSE) {
- update_oor_devices(adapter);
if (type & DISC_RESOLVNAME) {
if (adapter_resolve_names(adapter) == 0) {
adapter->state |= STATE_RESOLVNAME;
return;
}
}
+
+ update_oor_devices(adapter);
} else if (adapter->disc_sessions && main_opts.discov_interval)
adapter->scheduler_id = g_timeout_add_seconds(
main_opts.discov_interval,
--
1.7.0.4
^ permalink raw reply related
* Re: [RFCv2] Bluetooth: Use non-flushable by default L2CAP data packets
From: Andrei Emeltchenko @ 2010-12-23 15:04 UTC (permalink / raw)
To: Gustavo F. Padovan, Nick Pelly; +Cc: linux-bluetooth
In-Reply-To: <20101223020615.GA26284@vigoh>
Hi Gustavo,
On Thu, Dec 23, 2010 at 4:06 AM, Gustavo F. Padovan
<padovan@profusion.mobi> wrote:
> Hi Andrei,
>
> * Emeltchenko Andrei <Andrei.Emeltchenko.news@gmail.com> [2010-12-16 16:54:26 +0200]:
>
>> From: Andrei Emeltchenko <andrei.emeltchenko@nokia.com>
>>
>> Modification of Nick Pelly <npelly@google.com> patch.
>>
>> With Bluetooth 2.1 ACL packets can be flushable or non-flushable. This commit
>> makes ACL data packets non-flushable by default on compatible chipsets, and
>> adds the BT_FLUSHABLE socket option to explicitly request flushable ACL
>> data packets for a given L2CAP socket. This is useful for A2DP data which can
>> be safely discarded if it can not be delivered within a short time (while
>> other ACL data should not be discarded).
>>
>> Note that making ACL data flushable has no effect unless the automatic flush
>> timeout for that ACL link is changed from its default of 0 (infinite).
>>
>> Default packet types (for compatible chipsets):
>> Frame 34: 13 bytes on wire (104 bits), 13 bytes captured (104 bits)
>> Bluetooth HCI H4
>> Bluetooth HCI ACL Packet
>> .... 0000 0000 0010 = Connection Handle: 0x0002
>> ..00 .... .... .... = PB Flag: First Non-automatically Flushable Packet (0)
>> 00.. .... .... .... = BC Flag: Point-To-Point (0)
>> Data Total Length: 8
>> Bluetooth L2CAP Packet
>>
>> After setting BT_FLUSHABLE
>> (sock.setsockopt(274 /*SOL_BLUETOOTH*/, 8 /* BT_FLUSHABLE */, 1 /* flush */))
>> Frame 34: 13 bytes on wire (104 bits), 13 bytes captured (104 bits)
>> Bluetooth HCI H4
>> Bluetooth HCI ACL Packet
>> .... 0000 0000 0010 = Connection Handle: 0x0002
>> ..10 .... .... .... = PB Flag: First Automatically Flushable Packet (2)
>> 00.. .... .... .... = BC Flag: Point-To-Point (0)
>> Data Total Length: 8
>> Bluetooth L2CAP Packet
>>
>> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@nokia.com>
>> ---
>> include/net/bluetooth/bluetooth.h | 5 ++++
>> include/net/bluetooth/hci.h | 2 +
>> include/net/bluetooth/hci_core.h | 1 +
>> include/net/bluetooth/l2cap.h | 2 +
>> net/bluetooth/hci_core.c | 6 +++-
>> net/bluetooth/l2cap.c | 48 ++++++++++++++++++++++++++++++++++--
>> 6 files changed, 59 insertions(+), 5 deletions(-)
>>
>> diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
>> index 0c5e725..ed7d775 100644
>> --- a/include/net/bluetooth/bluetooth.h
>> +++ b/include/net/bluetooth/bluetooth.h
>> @@ -64,6 +64,11 @@ struct bt_security {
>>
>> #define BT_DEFER_SETUP 7
>>
>> +#define BT_FLUSHABLE 8
>> +
>> +#define BT_FLUSHABLE_OFF 0
>> +#define BT_FLUSHABLE_ON 1
>> +
>> #define BT_INFO(fmt, arg...) printk(KERN_INFO "Bluetooth: " fmt "\n" , ## arg)
>> #define BT_ERR(fmt, arg...) printk(KERN_ERR "%s: " fmt "\n" , __func__ , ## arg)
>> #define BT_DBG(fmt, arg...) pr_debug("%s: " fmt "\n" , __func__ , ## arg)
>> diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
>> index 29a7a8c..333d5cb 100644
>> --- a/include/net/bluetooth/hci.h
>> +++ b/include/net/bluetooth/hci.h
>> @@ -150,6 +150,7 @@ enum {
>> #define EDR_ESCO_MASK (ESCO_2EV3 | ESCO_3EV3 | ESCO_2EV5 | ESCO_3EV5)
>>
>> /* ACL flags */
>> +#define ACL_START_NO_FLUSH 0x00
>> #define ACL_CONT 0x01
>> #define ACL_START 0x02
>> #define ACL_ACTIVE_BCAST 0x04
>> @@ -193,6 +194,7 @@ enum {
>> #define LMP_EDR_ESCO_3M 0x40
>> #define LMP_EDR_3S_ESCO 0x80
>>
>> +#define LMP_NO_FLUSH 0x01
>
> Isn't this 0x40? As stated on Core v4.0 (Volume 2, part C, 3.3 Feature Mask
> Definition)
Yes you are right, I will fix this and other comments.
Regards,
Andrei
>
>> #define LMP_SIMPLE_PAIR 0x08
>>
>> /* Connection modes */
>> diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
>> index 1992fac..9778bc8 100644
>> --- a/include/net/bluetooth/hci_core.h
>> +++ b/include/net/bluetooth/hci_core.h
>> @@ -456,6 +456,7 @@ void hci_conn_del_sysfs(struct hci_conn *conn);
>> #define lmp_sniffsubr_capable(dev) ((dev)->features[5] & LMP_SNIFF_SUBR)
>> #define lmp_esco_capable(dev) ((dev)->features[3] & LMP_ESCO)
>> #define lmp_ssp_capable(dev) ((dev)->features[6] & LMP_SIMPLE_PAIR)
>> +#define lmp_no_flush_capable(dev) ((dev)->features[6] & LMP_NO_FLUSH)
>>
>> /* ----- HCI protocols ----- */
>> struct hci_proto {
>> diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
>> index 7ad25ca..af35711 100644
>> --- a/include/net/bluetooth/l2cap.h
>> +++ b/include/net/bluetooth/l2cap.h
>> @@ -75,6 +75,7 @@ struct l2cap_conninfo {
>> #define L2CAP_LM_TRUSTED 0x0008
>> #define L2CAP_LM_RELIABLE 0x0010
>> #define L2CAP_LM_SECURE 0x0020
>> +#define L2CAP_LM_FLUSHABLE 0x0040
>
> Not using this flag in the code.
>
>>
>> /* L2CAP command codes */
>> #define L2CAP_COMMAND_REJ 0x01
>> @@ -327,6 +328,7 @@ struct l2cap_pinfo {
>> __u8 sec_level;
>> __u8 role_switch;
>> __u8 force_reliable;
>> + __u8 flushable;
>>
>> __u8 conf_req[64];
>> __u8 conf_len;
>> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
>> index 51c61f7..c0d776b 100644
>> --- a/net/bluetooth/hci_core.c
>> +++ b/net/bluetooth/hci_core.c
>> @@ -1380,7 +1380,7 @@ void hci_send_acl(struct hci_conn *conn, struct sk_buff *skb, __u16 flags)
>>
>> skb->dev = (void *) hdev;
>> bt_cb(skb)->pkt_type = HCI_ACLDATA_PKT;
>> - hci_add_acl_hdr(skb, conn->handle, flags | ACL_START);
>> + hci_add_acl_hdr(skb, conn->handle, flags);
>>
>> list = skb_shinfo(skb)->frag_list;
>> if (!list) {
>> @@ -1398,12 +1398,14 @@ void hci_send_acl(struct hci_conn *conn, struct sk_buff *skb, __u16 flags)
>> spin_lock_bh(&conn->data_q.lock);
>>
>> __skb_queue_tail(&conn->data_q, skb);
>
> add an empty line here.
>
>> + flags &= ~ACL_START;
>> + flags |= ACL_CONT;
>> do {
>> skb = list; list = list->next;
>>
>> skb->dev = (void *) hdev;
>> bt_cb(skb)->pkt_type = HCI_ACLDATA_PKT;
>> - hci_add_acl_hdr(skb, conn->handle, flags | ACL_CONT);
>> + hci_add_acl_hdr(skb, conn->handle, flags);
>>
>> BT_DBG("%s frag %p len %d", hdev->name, skb, skb->len);
>>
>> diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
>> index c791fcd..efa60eb 100644
>> --- a/net/bluetooth/l2cap.c
>> +++ b/net/bluetooth/l2cap.c
>> @@ -362,13 +362,19 @@ static inline u8 l2cap_get_ident(struct l2cap_conn *conn)
>> static inline void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *data)
>> {
>> struct sk_buff *skb = l2cap_build_cmd(conn, code, ident, len, data);
>> + u8 flags;
>>
>> BT_DBG("code 0x%2.2x", code);
>>
>> if (!skb)
>> return;
>>
>> - hci_send_acl(conn->hcon, skb, 0);
>> + if (lmp_no_flush_capable(conn->hcon->hdev))
>> + flags = ACL_START_NO_FLUSH;
>> + else
>> + flags = ACL_START;
>> +
>> + hci_send_acl(conn->hcon, skb, flags);
>> }
>>
>> static inline void l2cap_send_sframe(struct l2cap_pinfo *pi, u16 control)
>> @@ -900,6 +906,7 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent)
>> pi->sec_level = l2cap_pi(parent)->sec_level;
>> pi->role_switch = l2cap_pi(parent)->role_switch;
>> pi->force_reliable = l2cap_pi(parent)->force_reliable;
>> + pi->flushable = l2cap_pi(parent)->flushable;
>> } else {
>> pi->imtu = L2CAP_DEFAULT_MTU;
>> pi->omtu = 0;
>> @@ -915,6 +922,7 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent)
>> pi->sec_level = BT_SECURITY_LOW;
>> pi->role_switch = 0;
>> pi->force_reliable = 0;
>> + pi->flushable = BT_FLUSHABLE_OFF;
>
> You need to check for the no_flush feature here, right?
>
>> }
>>
>> /* Default config options */
>> @@ -1450,10 +1458,17 @@ static void l2cap_drop_acked_frames(struct sock *sk)
>> static inline void l2cap_do_send(struct sock *sk, struct sk_buff *skb)
>> {
>> struct l2cap_pinfo *pi = l2cap_pi(sk);
>> + struct hci_conn *hcon = pi->conn->hcon;
>> + u16 flags;
>>
>> BT_DBG("sk %p, skb %p len %d", sk, skb, skb->len);
>>
>> - hci_send_acl(pi->conn->hcon, skb, 0);
>> + if (lmp_no_flush_capable(hcon->hdev) && !l2cap_pi(sk)->flushable)
>> + flags = ACL_START_NO_FLUSH;
>> + else
>> + flags = ACL_START;
>> +
>> + hci_send_acl(hcon, skb, flags);
>
> There is another call to hci_send_acl() in l2cap. It is in
> l2cap_send_sframe(), but I'm still wondering if we shall flush those packets
> or not in the case flushable was set. Now I'm thinking that don't.
>
> Then you need to add the same check in l2cap_send_cmd to l2cap_send_sframe().
>
>> }
>>
>> static void l2cap_streaming_send(struct sock *sk)
>> @@ -2045,6 +2060,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, char __us
>> static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen)
>> {
>> struct sock *sk = sock->sk;
>> + struct hci_conn *hcon = l2cap_pi(sk)->conn->hcon;
>> struct bt_security sec;
>> int len, err = 0;
>> u32 opt;
>> @@ -2098,6 +2114,26 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch
>> bt_sk(sk)->defer_setup = opt;
>> break;
>>
>> + case BT_FLUSHABLE:
>> + if (get_user(opt, (u32 __user *) optval)) {
>> + err = -EFAULT;
>> + break;
>> + }
>> +
>> + if (opt > BT_FLUSHABLE_ON) {
>> + err = -EINVAL;
>> + break;
>> + }
>> +
>> + if (opt == BT_FLUSHABLE_OFF &&
>> + !lmp_no_flush_capable(hcon->hdev)) {
>
> I'm not really happy with !lmp_no_flush... 2 negatives in the same place, but
> that is the feature name. So we can't do too much here. Btw, the "No" in the
> feature name is making my brain hurt. ;)
>
> regards,
>
> --
> Gustavo F. Padovan
> http://profusion.mobi
>
^ permalink raw reply
* Re: [PATCH] PBAP tracker-query update for addr fields
From: Johan Hedberg @ 2010-12-23 12:10 UTC (permalink / raw)
To: Radoslaw Jablonski; +Cc: linux-bluetooth
In-Reply-To: <1293103208-17664-1-git-send-email-ext-jablonski.radoslaw@nokia.com>
Hi Radek,
On Thu, Dec 23, 2010, Radoslaw Jablonski wrote:
> This is needed to display many addresses of the same type
> (WORK/HOME/OTHER) in different rows in pbap pull response.
> Currently in that case all addresses of the same type
> were displayed in the same row.
> ---
> plugins/phonebook-tracker.c | 12 ++++++------
> 1 files changed, 6 insertions(+), 6 deletions(-)
Pushed upstream. Thanks.
Johan
^ permalink raw reply
* [PATCH] PBAP tracker-query update for addr fields
From: Radoslaw Jablonski @ 2010-12-23 11:20 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Radoslaw Jablonski
This is needed to display many addresses of the same type
(WORK/HOME/OTHER) in different rows in pbap pull response.
Currently in that case all addresses of the same type
were displayed in the same row.
---
plugins/phonebook-tracker.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/plugins/phonebook-tracker.c b/plugins/phonebook-tracker.c
index 59221cb..b7acead 100644
--- a/plugins/phonebook-tracker.c
+++ b/plugins/phonebook-tracker.c
@@ -109,7 +109,7 @@
"tracker:coalesce(nco:locality(?aff_addr), \"\"), \";\"," \
"tracker:coalesce(nco:region(?aff_addr), \"\"), \";\"," \
"tracker:coalesce(nco:postalcode(?aff_addr), \"\"), \";\"," \
-"tracker:coalesce(nco:country(?aff_addr), \"\") ),\";\")" \
+"tracker:coalesce(nco:country(?aff_addr), \"\") ),\"\30\")" \
"WHERE {" \
"?_role nco:hasPostalAddress ?aff_addr" \
"}) " \
@@ -191,7 +191,7 @@
"tracker:coalesce(nco:locality(?aff_addr), \"\"), \";\"," \
"tracker:coalesce(nco:region(?aff_addr), \"\"), \";\"," \
"tracker:coalesce(nco:postalcode(?aff_addr), \"\"), \";\"," \
- "tracker:coalesce(nco:country(?aff_addr), \"\") ),\";\")" \
+ "tracker:coalesce(nco:country(?aff_addr), \"\") ),\"\30\")" \
"WHERE {" \
"?_role nco:hasPostalAddress ?aff_addr" \
"}) " \
@@ -337,7 +337,7 @@
"tracker:coalesce(nco:locality(?aff_addr), \"\"), \";\"," \
"tracker:coalesce(nco:region(?aff_addr), \"\"), \";\"," \
"tracker:coalesce(nco:postalcode(?aff_addr), \"\"), \";\"," \
- "tracker:coalesce(nco:country(?aff_addr), \"\") ),\";\")" \
+ "tracker:coalesce(nco:country(?aff_addr), \"\") ),\"\30\")" \
"WHERE {" \
"?_role nco:hasPostalAddress ?aff_addr" \
"}) " \
@@ -482,7 +482,7 @@
"tracker:coalesce(nco:locality(?aff_addr), \"\"), \";\"," \
"tracker:coalesce(nco:region(?aff_addr), \"\"), \";\"," \
"tracker:coalesce(nco:postalcode(?aff_addr), \"\"), \";\"," \
- "tracker:coalesce(nco:country(?aff_addr), \"\") ),\";\")" \
+ "tracker:coalesce(nco:country(?aff_addr), \"\") ),\"\30\")" \
"WHERE {" \
"?_role nco:hasPostalAddress ?aff_addr" \
"}) " \
@@ -621,7 +621,7 @@
"tracker:coalesce(nco:locality(?aff_addr), \"\"), \";\"," \
"tracker:coalesce(nco:region(?aff_addr), \"\"), \";\"," \
"tracker:coalesce(nco:postalcode(?aff_addr), \"\"), \";\"," \
- "tracker:coalesce(nco:country(?aff_addr), \"\") ),\";\")" \
+ "tracker:coalesce(nco:country(?aff_addr), \"\") ),\"\30\")" \
"WHERE {" \
"?_role nco:hasPostalAddress ?aff_addr" \
"}) " \
@@ -813,7 +813,7 @@
"tracker:coalesce(nco:locality(?aff_addr), \"\"), \";\"," \
"tracker:coalesce(nco:region(?aff_addr), \"\"), \";\"," \
"tracker:coalesce(nco:postalcode(?aff_addr), \"\"), \";\"," \
-"tracker:coalesce(nco:country(?aff_addr), \"\") ),\";\")" \
+"tracker:coalesce(nco:country(?aff_addr), \"\") ),\"\30\")" \
"WHERE {" \
"?_role nco:hasPostalAddress ?aff_addr" \
"}) " \
--
1.7.0.4
^ permalink raw reply related
* Re: [PATCH 00/11] mfd and bluetooth: Add CG2900 support
From: Pavan Savoy @ 2010-12-23 10:48 UTC (permalink / raw)
To: Par-Gunnar HJALMDAHL
Cc: Vitaly Wool, Linus Walleij, Alan Cox, Arnd Bergmann, Samuel Ortiz,
Marcel Holtmann, linux-kernel@vger.kernel.org,
linux-bluetooth@vger.kernel.org, Lukasz Rymanowski,
Par-Gunnar Hjalmdahl
In-Reply-To: <AFCDDB4A3EA003429EEF1E7B211FDBBA3348A3A516@EXDCVYMBSTM005.EQ1STM.local>
P-G, Vitaly,
>
> I would say our design would map like this:
> common-hci-module: cg2900_core
> serial, spi, i2c,... : cg2900_uart together with hci_ldisc (for other tra=
nsports it would be different files)
> bt, ti-radio, st-e-radio,...: cg2900_chip together with btcg2900 and othe=
r users per channel (cg2900_char_devices for users in User space)
> So it is not a 1-to-1 mapping for the upper parts. I would draw it like t=
his:
>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 bt =C2=A0 st-e-radio =C2=A0st-e-gps
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| =C2=A0 =C2=A0 =C2=A0 =C2=A0 | =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0+---------+----------+
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ti-xx =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0st-e cg2900...
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 +--=
-------+----------+
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 common-hci-module
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 +---------=
--+-----------+
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | =C2=A0 =
=C2=A0 =C2=A0 =C2=A0| =C2=A0 =C2=A0 =C2=A0 | =C2=A0 =C2=A0 =C2=A0|
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 serial =C2=A0 =C2=
=A0spi =C2=A0 =C2=A0 i2c =C2=A0 =C2=A0...
regarding the architecture above suggested...
Is having the common-hci-module, only way ?
Why is this dependency on bluetooth at all?
for example: today I don't compile my kernel with BT support, but
still want to use
the chip for FM & GPS, It should be possible correct ?
Even in TI case, although the firmware download is HCI-VS way, we
don't use hci_core
to interpret the responses...
instead of common-hci-module, why not create a algo-driver layer 'ala
i2c ? where individual drivers can register their receive handlers for
data interpretation ?
>
> The reason for this difference I've gone through before. Basically there =
are so many special behaviors and needed handling that is individual for ea=
ch chip (like startup and shutdown and in the case of CG2900 flow control o=
ver FM and BT channels for audio commands). If you then look at the users I=
guess it would be possible to have one BT user, but it would have to be mo=
dified to handle vendor specific commands (as btcg2900 does with BT_ENABLE =
command). As Arnd has drawn for FM and GPS the users would be completely in=
dividual since they don't have a standardized =C2=A0interface.
>
> /P-G
>
^ permalink raw reply
* [PATCH] Updated TODO list for LE HCI Scan, Advertise and Connect commands.
From: Sumit Kumar BAJPAI @ 2010-12-23 10:07 UTC (permalink / raw)
To: linux-bluetooth@vger.kernel.org
Updated TODO list for HCI commands for LE that ST-Ericsson plans to
implement and contribute back.
---
TODO | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 93 insertions(+), 0 deletions(-)
diff --git a/TODO b/TODO
index 49a9e76..e62c6e5 100644
--- a/TODO
+++ b/TODO
@@ -66,6 +66,99 @@ Low Energy
Priority: Low
Complexity: C2
+- Implement Set Advertise data via Host interface. This Set Advertise Data is
+ used by advertising device to advertise with some data field. This is via
+ undirected and connectable events. Data field is maximum of 30 octets, and is
+ primarily used for small data advertisement. Scanning device can see in scan
+ results the advertised data as set by the advertising device.
+ See Volume 2, Part E, section 7.8.7 for more information.
+
+ Priority: Low
+ Complexity: C1
+
+- Implement Set Advertise parameters via Host interface. This Set Advertise
+ parameters is used by advertising device to set advertising parameters. The
+ Host shall not issue this command when advertising is enabled in the
+ Controller; if it is the Command Disallowed error code shall be used.
+ See Volume 2, Part E, section 7.8.5 for more information.
+
+ Priority: Low
+ Complexity: C1
+
+- Implement Set Scan Response Data via host interface. This data is set by the
+ advertiser in case it wants to send data only to those devices that are
+ currently actively scanning. This is via undirected and connectable events.
+ Data can be set before or after advertising and can be maximum of 30 octets.
+ See Volume 2, Part E, section 7.8.8 for more information.
+
+ Priority: Low
+ Complexity: C1
+
+- Implement Read Advertise Channel Tx Power via Host interface. This Read
+ Advertise Channel Tx power is used by advertising host to read the transmit
+ power level used for LE advertising channel packets.
+ See Volume 2, Part E, section 7.8.6 for more information.
+
+ Priority: Low
+ Complexity: C1
+
+- Implement Add Device to White List in LE controller via host interface.
+ This command is used to add a single device to white list stored in the
+ controller. Once the device is in white list it should follow scan and
+ connect rules as stated in advertising filter policy.
+ See Volume 2, Part E, section 7.8.16 for more information.
+
+ Priority: Low
+ Complexity: C1
+
+- Implement Remove Device from White List in LE controller via host interface.
+ This command is used to remove a single device from white list stored in the
+ controller. This command has certain restrictions on its usage. Command
+ complete event is generated on completion.
+ See Volume 2, Part E, section 7.8.17 for more information.
+
+ Priority: Low
+ Complexity: C1
+
+- Implement Clear White List in LE controller via host interface. This command
+ is used to clear the white list stored in the controller. This command has
+ certain restrictions on its usage. This command has no command parameters
+ to be pushed on controller. Command complete event is generated on completion.
+ See Volume 2, Part E, section 7.8.15 for more information.
+
+ Priority: Low
+ Complexity: C1
+
+- Implement Read White List Size in LE controller via host interface. This
+ command is used to read the maximum size of the white list supported by the
+ controller.
+ See Volume 2, Part E, section 7.8.14 for more information.
+
+ Priority: Low
+ Complexity: C1
+
+- Implement Read LE buffer Size via host interface. This data is used to read
+ the maximum size of data portion of HCI LE ACL Data Packets sent from the
+ Host to the Controller. The Host will segment the data transmitted to the
+ Controller according to these values, so that the HCI Data Packets will
+ contain data with up to this size. The LE_Read_Buffer_Size command also
+ returns the total number of HCI LE ACL Data Packets that can be stored in
+ the data buffers of the Controller. The LE_Read_Buffer_Size command must be
+ issued by the Host before it sends any data to an LE Controller.
+ See Volume 2, Part E, section 7.8.2 for more information.
+
+ Priority: Low
+ Complexity: C1
+
+- Implement LE Connection Update command via Host interface. The
+ LE_Connection_Update command is used to change the Link Layer connection
+ parameters of a connection. This command shall only be used when the local
+ device's role is Master.
+ See Volume 2, Part E, section 7.8.18 for more information.
+
+ Priority: Medium
+ Complexity: C1
+
ATT/GATT
========
--
1.6.5
^ permalink raw reply related
* Re: [PATCH 18/18] Add a "services" command to test-device
From: Johan Hedberg @ 2010-12-23 8:33 UTC (permalink / raw)
To: Vinicius Costa Gomes; +Cc: linux-bluetooth
In-Reply-To: <1292966800-6264-19-git-send-email-vinicius.gomes@openbossa.org>
Hi Vinicius,
On Tue, Dec 21, 2010, Vinicius Costa Gomes wrote:
> This command adds a way to retrieve the Services property that each
> device has.
> ---
> test/test-device | 13 +++++++++++++
> 1 files changed, 13 insertions(+), 0 deletions(-)
I've finished pushing all the patches in this set to the upstream tree.
Please double check that I didn't miss anything.
Johan
^ permalink raw reply
* Re: [PATCH] Add a way to retrieve ATT primary services
From: Johan Hedberg @ 2010-12-23 8:27 UTC (permalink / raw)
To: Vinicius Costa Gomes; +Cc: linux-bluetooth
In-Reply-To: <1293063673-25058-1-git-send-email-vinicius.gomes@openbossa.org>
Hi Vinicius,
On Wed, Dec 22, 2010, Vinicius Costa Gomes wrote:
> As the primary services were discovered by the core bluetoothd, we need
> a way to export that information.
>
> The service discovery uses the same primary list as the device, there's no
> need to free that list when the discovery finishes. That list will be removed
> when the device is free'd.
> ---
> src/adapter.c | 6 +++---
> src/device.c | 15 +++++++++++++++
> src/device.h | 3 +++
> src/glib-helper.c | 1 -
> 4 files changed, 21 insertions(+), 4 deletions(-)
This one has also been pushed upstream. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH] Add support for creating devices from stored primary services
From: Johan Hedberg @ 2010-12-23 8:24 UTC (permalink / raw)
To: Vinicius Costa Gomes; +Cc: linux-bluetooth
In-Reply-To: <1293063397-24958-1-git-send-email-vinicius.gomes@openbossa.org>
Hi Vinicius,
On Wed, Dec 22, 2010, Vinicius Costa Gomes wrote:
> From what we can retrieve from storage we are able to create the devices
> and probe the device drivers.
> ---
> src/adapter.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 77 insertions(+), 0 deletions(-)
Pushed upstream. Thanks.
Johan
^ permalink raw reply
* [PATCH 2/2] drivers:staging: ti-st: delete old bt_drv driver
From: pavan_savoy @ 2010-12-23 7:23 UTC (permalink / raw)
To: gregkh, linux-kernel; +Cc: padovan, marcel, linux-bluetooth, Pavan Savoy
In-Reply-To: <1293089037-23130-2-git-send-email-pavan_savoy@ti.com>
From: Pavan Savoy <pavan_savoy@ti.com>
point the new v7 driver to build if ST_BT is selected
in Makefile and delete the old bt_drv driver.
Signed-off-by: Pavan Savoy <pavan_savoy@ti.com>
---
drivers/staging/ti-st/Makefile | 2 +-
drivers/staging/ti-st/bt_drv.c | 509 ----------------------------------------
drivers/staging/ti-st/bt_drv.h | 61 -----
3 files changed, 1 insertions(+), 571 deletions(-)
delete mode 100644 drivers/staging/ti-st/bt_drv.c
delete mode 100644 drivers/staging/ti-st/bt_drv.h
diff --git a/drivers/staging/ti-st/Makefile b/drivers/staging/ti-st/Makefile
index 5f11b82..9125462 100644
--- a/drivers/staging/ti-st/Makefile
+++ b/drivers/staging/ti-st/Makefile
@@ -2,4 +2,4 @@
# Makefile for TI's shared transport line discipline
# and its protocol drivers (BT, FM, GPS)
#
-obj-$(CONFIG_ST_BT) += bt_drv.o
+obj-$(CONFIG_ST_BT) += btwilink.o
diff --git a/drivers/staging/ti-st/bt_drv.c b/drivers/staging/ti-st/bt_drv.c
deleted file mode 100644
index 75065bf..0000000
--- a/drivers/staging/ti-st/bt_drv.c
+++ /dev/null
@@ -1,509 +0,0 @@
-/*
- * Texas Instrument's Bluetooth Driver For Shared Transport.
- *
- * Bluetooth Driver acts as interface between HCI CORE and
- * TI Shared Transport Layer.
- *
- * Copyright (C) 2009 Texas Instruments
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-
-#include <net/bluetooth/bluetooth.h>
-#include <net/bluetooth/hci_core.h>
-
-#include <linux/ti_wilink_st.h>
-#include "bt_drv.h"
-
-/* Define this macro to get debug msg */
-#undef DEBUG
-
-#ifdef DEBUG
-#define BT_DRV_DBG(fmt, arg...) printk(KERN_INFO "(btdrv):"fmt"\n" , ## arg)
-#define BTDRV_API_START() printk(KERN_INFO "(btdrv): %s Start\n", \
- __func__)
-#define BTDRV_API_EXIT(errno) printk(KERN_INFO "(btdrv): %s Exit(%d)\n", \
- __func__, errno)
-#else
-#define BT_DRV_DBG(fmt, arg...)
-#define BTDRV_API_START()
-#define BTDRV_API_EXIT(errno)
-#endif
-
-#define BT_DRV_ERR(fmt, arg...) printk(KERN_ERR "(btdrv):"fmt"\n" , ## arg)
-
-static int reset;
-static struct hci_st *hst;
-
-/* Increments HCI counters based on pocket ID (cmd,acl,sco) */
-static inline void hci_st_tx_complete(struct hci_st *hst, int pkt_type)
-{
- struct hci_dev *hdev;
-
- BTDRV_API_START();
-
- hdev = hst->hdev;
-
- /* Update HCI stat counters */
- switch (pkt_type) {
- case HCI_COMMAND_PKT:
- hdev->stat.cmd_tx++;
- break;
-
- case HCI_ACLDATA_PKT:
- hdev->stat.acl_tx++;
- break;
-
- case HCI_SCODATA_PKT:
- hdev->stat.cmd_tx++;
- break;
- }
-
- BTDRV_API_EXIT(0);
-}
-
-/* ------- Interfaces to Shared Transport ------ */
-
-/* Called by ST layer to indicate protocol registration completion
- * status.hci_st_open() function will wait for signal from this
- * API when st_register() function returns ST_PENDING.
- */
-static void hci_st_registration_completion_cb(void *priv_data, char data)
-{
- struct hci_st *lhst = (struct hci_st *)priv_data;
- BTDRV_API_START();
-
- /* hci_st_open() function needs value of 'data' to know
- * the registration status(success/fail),So have a back
- * up of it.
- */
- lhst->streg_cbdata = data;
-
- /* Got a feedback from ST for BT driver registration
- * request.Wackup hci_st_open() function to continue
- * it's open operation.
- */
- complete(&lhst->wait_for_btdrv_reg_completion);
-
- BTDRV_API_EXIT(0);
-}
-
-/* Called by Shared Transport layer when receive data is
- * available */
-static long hci_st_receive(void *priv_data, struct sk_buff *skb)
-{
- int err;
- int len;
- struct hci_st *lhst = (struct hci_st *)priv_data;
-
- BTDRV_API_START();
-
- err = 0;
- len = 0;
-
- if (skb == NULL) {
- BT_DRV_ERR("Invalid SKB received from ST");
- BTDRV_API_EXIT(-EFAULT);
- return -EFAULT;
- }
- if (!lhst) {
- kfree_skb(skb);
- BT_DRV_ERR("Invalid hci_st memory,freeing SKB");
- BTDRV_API_EXIT(-EFAULT);
- return -EFAULT;
- }
- if (!test_bit(BT_DRV_RUNNING, &lhst->flags)) {
- kfree_skb(skb);
- BT_DRV_ERR("Device is not running,freeing SKB");
- BTDRV_API_EXIT(-EINVAL);
- return -EINVAL;
- }
-
- len = skb->len;
- skb->dev = (struct net_device *)lhst->hdev;
-
- /* Forward skb to HCI CORE layer */
- err = hci_recv_frame(skb);
- if (err) {
- kfree_skb(skb);
- BT_DRV_ERR("Unable to push skb to HCI CORE(%d),freeing SKB",
- err);
- BTDRV_API_EXIT(err);
- return err;
- }
- lhst->hdev->stat.byte_rx += len;
-
- BTDRV_API_EXIT(0);
- return 0;
-}
-
-/* ------- Interfaces to HCI layer ------ */
-
-/* Called from HCI core to initialize the device */
-static int hci_st_open(struct hci_dev *hdev)
-{
- static struct st_proto_s hci_st_proto;
- unsigned long timeleft;
- int err;
-
- BTDRV_API_START();
-
- err = 0;
-
- BT_DRV_DBG("%s %p", hdev->name, hdev);
-
- /* Already registered with ST ? */
- if (test_bit(BT_ST_REGISTERED, &hst->flags)) {
- BT_DRV_ERR("Registered with ST already,open called again?");
- BTDRV_API_EXIT(0);
- return 0;
- }
-
- /* Populate BT driver info required by ST */
- memset(&hci_st_proto, 0, sizeof(hci_st_proto));
-
- /* BT driver ID */
- hci_st_proto.type = ST_BT;
-
- /* Receive function which called from ST */
- hci_st_proto.recv = hci_st_receive;
-
- /* Packet match function may used in future */
- hci_st_proto.match_packet = NULL;
-
- /* Callback to be called when registration is pending */
- hci_st_proto.reg_complete_cb = hci_st_registration_completion_cb;
-
- /* This is write function pointer of ST. BT driver will make use of this
- * for sending any packets to chip. ST will assign and give to us, so
- * make it as NULL */
- hci_st_proto.write = NULL;
-
- /* send in the hst to be received at registration complete callback
- * and during st's receive
- */
- hci_st_proto.priv_data = hst;
-
- /* Register with ST layer */
- err = st_register(&hci_st_proto);
- if (err == -EINPROGRESS) {
- /* Prepare wait-for-completion handler data structures.
- * Needed to syncronize this and st_registration_completion_cb()
- * functions.
- */
- init_completion(&hst->wait_for_btdrv_reg_completion);
-
- /* Reset ST registration callback status flag , this value
- * will be updated in hci_st_registration_completion_cb()
- * function whenever it called from ST driver.
- */
- hst->streg_cbdata = -EINPROGRESS;
-
- /* ST is busy with other protocol registration(may be busy with
- * firmware download).So,Wait till the registration callback
- * (passed as a argument to st_register() function) getting
- * called from ST.
- */
- BT_DRV_DBG(" %s waiting for reg completion signal from ST",
- __func__);
-
- timeleft =
- wait_for_completion_timeout
- (&hst->wait_for_btdrv_reg_completion,
- msecs_to_jiffies(BT_REGISTER_TIMEOUT));
- if (!timeleft) {
- BT_DRV_ERR("Timeout(%ld sec),didn't get reg"
- "completion signal from ST",
- BT_REGISTER_TIMEOUT / 1000);
- BTDRV_API_EXIT(-ETIMEDOUT);
- return -ETIMEDOUT;
- }
-
- /* Is ST registration callback called with ERROR value? */
- if (hst->streg_cbdata != 0) {
- BT_DRV_ERR("ST reg completion CB called with invalid"
- "status %d", hst->streg_cbdata);
- BTDRV_API_EXIT(-EAGAIN);
- return -EAGAIN;
- }
- err = 0;
- } else if (err == -1) {
- BT_DRV_ERR("st_register failed %d", err);
- BTDRV_API_EXIT(-EAGAIN);
- return -EAGAIN;
- }
-
- /* Do we have proper ST write function? */
- if (hci_st_proto.write != NULL) {
- /* We need this pointer for sending any Bluetooth pkts */
- hst->st_write = hci_st_proto.write;
- } else {
- BT_DRV_ERR("failed to get ST write func pointer");
-
- /* Undo registration with ST */
- err = st_unregister(ST_BT);
- if (err < 0)
- BT_DRV_ERR("st_unregister failed %d", err);
-
- hst->st_write = NULL;
- BTDRV_API_EXIT(-EAGAIN);
- return -EAGAIN;
- }
-
- /* Registration with ST layer is completed successfully,
- * now chip is ready to accept commands from HCI CORE.
- * Mark HCI Device flag as RUNNING
- */
- set_bit(HCI_RUNNING, &hdev->flags);
-
- /* Registration with ST successful */
- set_bit(BT_ST_REGISTERED, &hst->flags);
-
- BTDRV_API_EXIT(err);
- return err;
-}
-
-/* Close device */
-static int hci_st_close(struct hci_dev *hdev)
-{
- int err;
-
- BTDRV_API_START();
-
- err = 0;
-
- /* Unregister from ST layer */
- if (test_and_clear_bit(BT_ST_REGISTERED, &hst->flags)) {
- err = st_unregister(ST_BT);
- if (err != 0) {
- BT_DRV_ERR("st_unregister failed %d", err);
- BTDRV_API_EXIT(-EBUSY);
- return -EBUSY;
- }
- }
-
- hst->st_write = NULL;
-
- /* ST layer would have moved chip to inactive state.
- * So,clear HCI device RUNNING flag.
- */
- if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags)) {
- BTDRV_API_EXIT(0);
- return 0;
- }
-
- BTDRV_API_EXIT(err);
- return err;
-}
-
-/* Called from HCI CORE , Sends frames to Shared Transport */
-static int hci_st_send_frame(struct sk_buff *skb)
-{
- struct hci_dev *hdev;
- struct hci_st *hst;
- long len;
-
- BTDRV_API_START();
-
- if (skb == NULL) {
- BT_DRV_ERR("Invalid skb received from HCI CORE");
- BTDRV_API_EXIT(-ENOMEM);
- return -ENOMEM;
- }
- hdev = (struct hci_dev *)skb->dev;
- if (!hdev) {
- BT_DRV_ERR("SKB received for invalid HCI Device (hdev=NULL)");
- BTDRV_API_EXIT(-ENODEV);
- return -ENODEV;
- }
- if (!test_bit(HCI_RUNNING, &hdev->flags)) {
- BT_DRV_ERR("Device is not running");
- BTDRV_API_EXIT(-EBUSY);
- return -EBUSY;
- }
-
- hst = (struct hci_st *)hdev->driver_data;
-
- /* Prepend skb with frame type */
- memcpy(skb_push(skb, 1), &bt_cb(skb)->pkt_type, 1);
-
- BT_DRV_DBG(" %s: type %d len %d", hdev->name, bt_cb(skb)->pkt_type,
- skb->len);
-
- /* Insert skb to shared transport layer's transmit queue.
- * Freeing skb memory is taken care in shared transport layer,
- * so don't free skb memory here.
- */
- if (!hst->st_write) {
- kfree_skb(skb);
- BT_DRV_ERR(" Can't write to ST, st_write null?");
- BTDRV_API_EXIT(-EAGAIN);
- return -EAGAIN;
- }
- len = hst->st_write(skb);
- if (len < 0) {
- /* Something went wrong in st write , free skb memory */
- kfree_skb(skb);
- BT_DRV_ERR(" ST write failed (%ld)", len);
- BTDRV_API_EXIT(-EAGAIN);
- return -EAGAIN;
- }
-
- /* ST accepted our skb. So, Go ahead and do rest */
- hdev->stat.byte_tx += len;
- hci_st_tx_complete(hst, bt_cb(skb)->pkt_type);
-
- BTDRV_API_EXIT(0);
- return 0;
-}
-
-static void hci_st_destruct(struct hci_dev *hdev)
-{
- BTDRV_API_START();
-
- if (!hdev) {
- BT_DRV_ERR("Destruct called with invalid HCI Device"
- "(hdev=NULL)");
- BTDRV_API_EXIT(0);
- return;
- }
-
- BT_DRV_DBG("%s", hdev->name);
-
- /* free hci_st memory */
- if (hdev->driver_data != NULL)
- kfree(hdev->driver_data);
-
- BTDRV_API_EXIT(0);
- return;
-}
-
-/* Creates new HCI device */
-static int hci_st_register_dev(struct hci_st *hst)
-{
- struct hci_dev *hdev;
-
- BTDRV_API_START();
-
- /* Initialize and register HCI device */
- hdev = hci_alloc_dev();
- if (!hdev) {
- BT_DRV_ERR("Can't allocate HCI device");
- BTDRV_API_EXIT(-ENOMEM);
- return -ENOMEM;
- }
- BT_DRV_DBG(" HCI device allocated. hdev= %p", hdev);
-
- hst->hdev = hdev;
- hdev->bus = HCI_UART;
- hdev->driver_data = hst;
- hdev->open = hci_st_open;
- hdev->close = hci_st_close;
- hdev->flush = NULL;
- hdev->send = hci_st_send_frame;
- hdev->destruct = hci_st_destruct;
- hdev->owner = THIS_MODULE;
-
- if (reset)
- set_bit(HCI_QUIRK_NO_RESET, &hdev->quirks);
-
- if (hci_register_dev(hdev) < 0) {
- BT_DRV_ERR("Can't register HCI device");
- hci_free_dev(hdev);
- BTDRV_API_EXIT(-ENODEV);
- return -ENODEV;
- }
-
- BT_DRV_DBG(" HCI device registered. hdev= %p", hdev);
- BTDRV_API_EXIT(0);
- return 0;
-}
-
-/* ------- Module Init interface ------ */
-
-static int __init bt_drv_init(void)
-{
- int err;
-
- BTDRV_API_START();
-
- err = 0;
-
- BT_DRV_DBG(" Bluetooth Driver Version %s", VERSION);
-
- /* Allocate local resource memory */
- hst = kzalloc(sizeof(struct hci_st), GFP_KERNEL);
- if (!hst) {
- BT_DRV_ERR("Can't allocate control structure");
- BTDRV_API_EXIT(-ENFILE);
- return -ENFILE;
- }
-
- /* Expose "hciX" device to user space */
- err = hci_st_register_dev(hst);
- if (err) {
- /* Release local resource memory */
- kfree(hst);
-
- BT_DRV_ERR("Unable to expose hci0 device(%d)", err);
- BTDRV_API_EXIT(err);
- return err;
- }
- set_bit(BT_DRV_RUNNING, &hst->flags);
-
- BTDRV_API_EXIT(err);
- return err;
-}
-
-/* ------- Module Exit interface ------ */
-
-static void __exit bt_drv_exit(void)
-{
- BTDRV_API_START();
-
- /* Deallocate local resource's memory */
- if (hst) {
- struct hci_dev *hdev = hst->hdev;
-
- if (hdev == NULL) {
- BT_DRV_ERR("Invalid hdev memory");
- kfree(hst);
- } else {
- hci_st_close(hdev);
- if (test_and_clear_bit(BT_DRV_RUNNING, &hst->flags)) {
- /* Remove HCI device (hciX) created
- * in module init.
- */
- hci_unregister_dev(hdev);
-
- /* Free HCI device memory */
- hci_free_dev(hdev);
- }
- }
- }
- BTDRV_API_EXIT(0);
-}
-
-module_init(bt_drv_init);
-module_exit(bt_drv_exit);
-
-/* ------ Module Info ------ */
-
-module_param(reset, bool, 0644);
-MODULE_PARM_DESC(reset, "Send HCI reset command on initialization");
-MODULE_AUTHOR("Raja Mani <raja_mani@ti.com>");
-MODULE_DESCRIPTION("Bluetooth Driver for TI Shared Transport" VERSION);
-MODULE_VERSION(VERSION);
-MODULE_LICENSE("GPL");
diff --git a/drivers/staging/ti-st/bt_drv.h b/drivers/staging/ti-st/bt_drv.h
deleted file mode 100644
index a0beebe..0000000
--- a/drivers/staging/ti-st/bt_drv.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Texas Instrument's Bluetooth Driver For Shared Transport.
- *
- * Bluetooth Driver acts as interface between HCI CORE and
- * TI Shared Transport Layer.
- *
- * Copyright (C) 2009 Texas Instruments
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-
-#ifndef _BT_DRV_H
-#define _BT_DRV_H
-
-/* Bluetooth Driver Version */
-#define VERSION "1.0"
-
-/* Defines number of seconds to wait for reg completion
- * callback getting called from ST (in case,registration
- * with ST returns PENDING status)
- */
-#define BT_REGISTER_TIMEOUT msecs_to_jiffies(6000) /* 6 sec */
-
-/* BT driver's local status */
-#define BT_DRV_RUNNING 0
-#define BT_ST_REGISTERED 1
-
-/* BT driver operation structure */
-struct hci_st {
-
- /* hci device pointer which binds to bt driver */
- struct hci_dev *hdev;
-
- /* used locally,to maintain various BT driver status */
- unsigned long flags;
-
- /* to hold ST registration callback status */
- char streg_cbdata;
-
- /* write function pointer of ST driver */
- long (*st_write) (struct sk_buff *);
-
- /* Wait on comepletion handler needed to synchronize
- * hci_st_open() and hci_st_registration_completion_cb()
- * functions.*/
- struct completion wait_for_btdrv_reg_completion;
-};
-
-#endif
--
1.6.3.3
^ permalink raw reply related
* [PATCH 1/2] drivers:staging: ti-st: add the v7 btwilink driver
From: pavan_savoy @ 2010-12-23 7:23 UTC (permalink / raw)
To: gregkh, linux-kernel; +Cc: padovan, marcel, linux-bluetooth, Pavan Savoy
In-Reply-To: <1293089037-23130-1-git-send-email-pavan_savoy@ti.com>
From: Pavan Savoy <pavan_savoy@ti.com>
Add the btwilink driver which has undergone 7 revisions
of review. Based on bluetooth maintainer comments, since
there might be some re-work needed on underlying ST driver,
park the driver here.
Signed-off-by: Pavan Savoy <pavan_savoy@ti.com>
---
drivers/staging/ti-st/btwilink.c | 363 ++++++++++++++++++++++++++++++++++++++
1 files changed, 363 insertions(+), 0 deletions(-)
create mode 100644 drivers/staging/ti-st/btwilink.c
diff --git a/drivers/staging/ti-st/btwilink.c b/drivers/staging/ti-st/btwilink.c
new file mode 100644
index 0000000..71e69f8
--- /dev/null
+++ b/drivers/staging/ti-st/btwilink.c
@@ -0,0 +1,363 @@
+/*
+ * Texas Instrument's Bluetooth Driver For Shared Transport.
+ *
+ * Bluetooth Driver acts as interface between HCI core and
+ * TI Shared Transport Layer.
+ *
+ * Copyright (C) 2009-2010 Texas Instruments
+ * Author: Raja Mani <raja_mani@ti.com>
+ * Pavan Savoy <pavan_savoy@ti.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include <linux/platform_device.h>
+#include <net/bluetooth/bluetooth.h>
+#include <net/bluetooth/hci_core.h>
+
+#include <linux/ti_wilink_st.h>
+
+/* Bluetooth Driver Version */
+#define VERSION "1.0"
+
+/* Number of seconds to wait for registration completion
+ * when ST returns PENDING status.
+ */
+#define BT_REGISTER_TIMEOUT 6000 /* 6 sec */
+
+/**
+ * struct ti_st - driver operation structure
+ * @hdev: hci device pointer which binds to bt driver
+ * @reg_status: ST registration callback status
+ * @st_write: write function provided by the ST driver
+ * to be used by the driver during send_frame.
+ * @wait_reg_completion - completion sync between ti_st_open
+ * and ti_st_registration_completion_cb.
+ */
+struct ti_st {
+ struct hci_dev *hdev;
+ char reg_status;
+ long (*st_write) (struct sk_buff *);
+ struct completion wait_reg_completion;
+};
+
+/* Increments HCI counters based on pocket ID (cmd,acl,sco) */
+static inline void ti_st_tx_complete(struct ti_st *hst, int pkt_type)
+{
+ struct hci_dev *hdev = hst->hdev;
+
+ /* Update HCI stat counters */
+ switch (pkt_type) {
+ case HCI_COMMAND_PKT:
+ hdev->stat.cmd_tx++;
+ break;
+
+ case HCI_ACLDATA_PKT:
+ hdev->stat.acl_tx++;
+ break;
+
+ case HCI_SCODATA_PKT:
+ hdev->stat.sco_tx++;
+ break;
+ }
+}
+
+/* ------- Interfaces to Shared Transport ------ */
+
+/* Called by ST layer to indicate protocol registration completion
+ * status.ti_st_open() function will wait for signal from this
+ * API when st_register() function returns ST_PENDING.
+ */
+static void st_registration_completion_cb(void *priv_data, char data)
+{
+ struct ti_st *lhst = priv_data;
+
+ /* Save registration status for use in ti_st_open() */
+ lhst->reg_status = data;
+ /* complete the wait in ti_st_open() */
+ complete(&lhst->wait_reg_completion);
+}
+
+/* Called by Shared Transport layer when receive data is
+ * available */
+static long st_receive(void *priv_data, struct sk_buff *skb)
+{
+ struct ti_st *lhst = priv_data;
+ int err;
+
+ if (!skb)
+ return -EFAULT;
+
+ if (!lhst) {
+ kfree_skb(skb);
+ return -EFAULT;
+ }
+
+ skb->dev = (void *) lhst->hdev;
+
+ /* Forward skb to HCI core layer */
+ err = hci_recv_frame(skb);
+ if (err < 0) {
+ BT_ERR("Unable to push skb to HCI core(%d)", err);
+ return err;
+ }
+
+ lhst->hdev->stat.byte_rx += skb->len;
+
+ return 0;
+}
+
+/* ------- Interfaces to HCI layer ------ */
+/* protocol structure registered with shared transport */
+static struct st_proto_s ti_st_proto = {
+ .type = ST_BT,
+ .recv = st_receive,
+ .reg_complete_cb = st_registration_completion_cb,
+};
+
+/* Called from HCI core to initialize the device */
+static int ti_st_open(struct hci_dev *hdev)
+{
+ unsigned long timeleft;
+ struct ti_st *hst;
+ int err;
+
+ BT_DBG("%s %p", hdev->name, hdev);
+ if (test_and_set_bit(HCI_RUNNING, &hdev->flags)) {
+ BT_ERR("btwilink already opened");
+ return -EBUSY;
+ }
+
+ /* provide contexts for callbacks from ST */
+ hst = hdev->driver_data;
+ ti_st_proto.priv_data = hst;
+
+ err = st_register(&ti_st_proto);
+ if (err == -EINPROGRESS) {
+ /* ST is busy with either protocol registration or firmware
+ * download.
+ */
+ /* Prepare wait-for-completion handler data structures.
+ */
+ init_completion(&hst->wait_reg_completion);
+
+ /* Reset ST registration callback status flag , this value
+ * will be updated in ti_st_registration_completion_cb()
+ * function whenever it called from ST driver.
+ */
+ hst->reg_status = -EINPROGRESS;
+
+ BT_DBG("waiting for registration completion signal from ST");
+ timeleft = wait_for_completion_timeout
+ (&hst->wait_reg_completion,
+ msecs_to_jiffies(BT_REGISTER_TIMEOUT));
+ if (!timeleft) {
+ clear_bit(HCI_RUNNING, &hdev->flags);
+ BT_ERR("Timeout(%d sec),didn't get reg "
+ "completion signal from ST",
+ BT_REGISTER_TIMEOUT / 1000);
+ return -ETIMEDOUT;
+ }
+
+ /* Is ST registration callback called with ERROR status? */
+ if (hst->reg_status != 0) {
+ clear_bit(HCI_RUNNING, &hdev->flags);
+ BT_ERR("ST registration completed with invalid "
+ "status %d", hst->reg_status);
+ return -EAGAIN;
+ }
+ err = 0;
+ } else if (err != 0) {
+ clear_bit(HCI_RUNNING, &hdev->flags);
+ BT_ERR("st_register failed %d", err);
+ return err;
+ }
+
+ /* ti_st_proto.write is filled up by the underlying shared
+ * transport driver upon registration
+ */
+ hst->st_write = ti_st_proto.write;
+ if (!hst->st_write) {
+ BT_ERR("undefined ST write function");
+ clear_bit(HCI_RUNNING, &hdev->flags);
+
+ /* Undo registration with ST */
+ err = st_unregister(ST_BT);
+ if (err)
+ BT_ERR("st_unregister() failed with error %d", err);
+
+ hst->st_write = NULL;
+ return err;
+ }
+
+ return err;
+}
+
+/* Close device */
+static int ti_st_close(struct hci_dev *hdev)
+{
+ int err;
+ struct ti_st *hst = hdev->driver_data;
+
+ if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags))
+ return 0;
+
+ /* continue to unregister from transport */
+ err = st_unregister(ST_BT);
+ if (err)
+ BT_ERR("st_unregister() failed with error %d", err);
+
+ hst->st_write = NULL;
+
+ return err;
+}
+
+static int ti_st_send_frame(struct sk_buff *skb)
+{
+ struct hci_dev *hdev;
+ struct ti_st *hst;
+ long len;
+
+ hdev = (struct hci_dev *)skb->dev;
+
+ if (!test_bit(HCI_RUNNING, &hdev->flags))
+ return -EBUSY;
+
+ hst = hdev->driver_data;
+
+ /* Prepend skb with frame type */
+ memcpy(skb_push(skb, 1), &bt_cb(skb)->pkt_type, 1);
+
+ BT_DBG("%s: type %d len %d", hdev->name, bt_cb(skb)->pkt_type,
+ skb->len);
+
+ /* Insert skb to shared transport layer's transmit queue.
+ * Freeing skb memory is taken care in shared transport layer,
+ * so don't free skb memory here.
+ */
+ len = hst->st_write(skb);
+ if (len < 0) {
+ kfree_skb(skb);
+ BT_ERR("ST write failed (%ld)", len);
+ /* Try Again, would only fail if UART has gone bad */
+ return -EAGAIN;
+ }
+
+ /* ST accepted our skb. So, Go ahead and do rest */
+ hdev->stat.byte_tx += len;
+ ti_st_tx_complete(hst, bt_cb(skb)->pkt_type);
+
+ return 0;
+}
+
+static void ti_st_destruct(struct hci_dev *hdev)
+{
+ BT_DBG("%s", hdev->name);
+ kfree(hdev->driver_data);
+}
+
+static int bt_ti_probe(struct platform_device *pdev)
+{
+ static struct ti_st *hst;
+ struct hci_dev *hdev;
+ int err;
+
+ hst = kzalloc(sizeof(struct ti_st), GFP_KERNEL);
+ if (!hst)
+ return -ENOMEM;
+
+ /* Expose "hciX" device to user space */
+ hdev = hci_alloc_dev();
+ if (!hdev) {
+ kfree(hst);
+ return -ENOMEM;
+ }
+
+ BT_DBG("hdev %p", hdev);
+
+ hst->hdev = hdev;
+ hdev->bus = HCI_UART;
+ hdev->driver_data = hst;
+ hdev->open = ti_st_open;
+ hdev->close = ti_st_close;
+ hdev->flush = NULL;
+ hdev->send = ti_st_send_frame;
+ hdev->destruct = ti_st_destruct;
+ hdev->owner = THIS_MODULE;
+
+ err = hci_register_dev(hdev);
+ if (err < 0) {
+ BT_ERR("Can't register HCI device error %d", err);
+ kfree(hst);
+ hci_free_dev(hdev);
+ return err;
+ }
+
+ BT_DBG("HCI device registered (hdev %p)", hdev);
+
+ dev_set_drvdata(&pdev->dev, hst);
+ return err;
+}
+
+static int bt_ti_remove(struct platform_device *pdev)
+{
+ struct hci_dev *hdev;
+ struct ti_st *hst = dev_get_drvdata(&pdev->dev);
+
+ if (!hst)
+ return -EFAULT;
+
+ hdev = hst->hdev;
+ ti_st_close(hdev);
+ hci_unregister_dev(hdev);
+
+ hci_free_dev(hdev);
+ kfree(hst);
+
+ dev_set_drvdata(&pdev->dev, NULL);
+ return 0;
+}
+
+static struct platform_driver btwilink_driver = {
+ .probe = bt_ti_probe,
+ .remove = bt_ti_remove,
+ .driver = {
+ .name = "btwilink",
+ .owner = THIS_MODULE,
+ },
+};
+
+/* ------- Module Init/Exit interfaces ------ */
+static int __init btwilink_init(void)
+{
+ BT_INFO("Bluetooth Driver for TI WiLink - Version %s", VERSION);
+
+ return platform_driver_register(&btwilink_driver);
+}
+
+static void __exit btwilink_exit(void)
+{
+ platform_driver_unregister(&btwilink_driver);
+}
+
+module_init(btwilink_init);
+module_exit(btwilink_exit);
+
+/* ------ Module Info ------ */
+
+MODULE_AUTHOR("Raja Mani <raja_mani@ti.com>");
+MODULE_DESCRIPTION("Bluetooth Driver for TI Shared Transport" VERSION);
+MODULE_VERSION(VERSION);
+MODULE_LICENSE("GPL");
--
1.6.3.3
^ permalink raw reply related
* [PATCH 0/2] drivers:staging:ti-st: keep updated
From: pavan_savoy @ 2010-12-23 7:23 UTC (permalink / raw)
To: gregkh, linux-kernel; +Cc: padovan, marcel, linux-bluetooth, Pavan Savoy
From: Pavan Savoy <pavan_savoy@ti.com>
Greg,
Happy Holidays.
Re-ordering the patches as you suggested.
1. Adds the new btwilink driver
2. deletes the old driver and points it to new one.
This is all to keep the drivers/staging/ti-st/ directory updated,
and since the btwilink driver has undergone huge modifications,
there was an update required.
So parking the most recent version of driver here, while
underlying TI-ST driver modifications are carried out.
Pavan Savoy (2):
drivers:staging: ti-st: add the v7 btwilink driver
drivers:staging: ti-st: delete old bt_drv driver
drivers/staging/ti-st/Makefile | 2 +-
drivers/staging/ti-st/bt_drv.c | 509 --------------------------------------
drivers/staging/ti-st/bt_drv.h | 61 -----
drivers/staging/ti-st/btwilink.c | 363 +++++++++++++++++++++++++++
4 files changed, 364 insertions(+), 571 deletions(-)
delete mode 100644 drivers/staging/ti-st/bt_drv.c
delete mode 100644 drivers/staging/ti-st/bt_drv.h
create mode 100644 drivers/staging/ti-st/btwilink.c
^ permalink raw reply
* pull request: bluetooth-next-2.6 2010-12-23
From: Gustavo F. Padovan @ 2010-12-23 3:05 UTC (permalink / raw)
To: linville; +Cc: linux-wireless, linux-bluetooth
Hi John,
Here are my last set of patches to 2.6.38. Biggest feature is the new
Bluetooth Management Interface, which intends to replace all HCI raw access
from bluetoothd. That interface is still disabled by default. However you can
enable it via a module parameter.
The other two patches from me is simple fixes in the stack. Tracey's patch is
already in net-next and I only pushed it to solve a merge conflict.
This time I'm using a link to my git tree inside master.kernel.org,
git.kernel.org is really slow today.
Please pull or let me know any problems. Thanks.
The following changes since commit 5c4bc1ce917d93ce8f7dd498fbec6881b3d7743a:
rtlwifi: Fix large packet issue (2010-12-22 15:45:52 -0500)
are available in the git repository at:
master.kernel.org:/pub/scm/linux/kernel/git/padovan/bluetooth-next-2.6.git master
Gustavo F. Padovan (2):
Bluetooth: Don't accept ConfigReq if we aren't in the BT_CONFIG state
Bluetooth: Improve handling of HCI control channel in bind
Johan Hedberg (9):
Bluetooth: Add Bluetooth Management interface definitions
Bluetooth: Add initial Bluetooth Management interface callbacks
Bluetooth: Make hci_send_to_sock usable for management control sockets
Bluetooth: Add error handling for managment command handlers
Bluetooth: Add read_version management command
Bluetooth: Add read_index_list management command
Bluetooth: Add read_info management command
Bluetooth: Add management events for controller addition & removal
Bluetooth: Fix __hci_request synchronization for hci_open_dev
Tracey Dent (1):
Net: bluetooth: Makefile: Remove deprecated kbuild goal definitions
include/net/bluetooth/bluetooth.h | 1 +
include/net/bluetooth/hci.h | 4 +
include/net/bluetooth/hci_core.h | 9 +-
include/net/bluetooth/mgmt.h | 87 +++++++++++
net/bluetooth/Makefile | 2 +-
net/bluetooth/hci_core.c | 17 ++-
net/bluetooth/hci_event.c | 33 +++--
net/bluetooth/hci_sock.c | 52 ++++++-
net/bluetooth/l2cap.c | 8 +-
net/bluetooth/mgmt.c | 308 +++++++++++++++++++++++++++++++++++++
10 files changed, 498 insertions(+), 23 deletions(-)
create mode 100644 include/net/bluetooth/mgmt.h
create mode 100644 net/bluetooth/mgmt.c
--
Gustavo F. Padovan
http://profusion.mobi
^ 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