* [PATCH v3] Remove unneeded variable
From: Anderson Lizardo @ 2010-12-21 12:02 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1292885388-21703-1-git-send-email-claudio.takahasi@openbossa.org>
From: Claudio Takahasi <claudio.takahasi@openbossa.org>
---
src/glib-helper.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/glib-helper.c b/src/glib-helper.c
index 0233eb7..bf39a83 100644
--- a/src/glib-helper.c
+++ b/src/glib-helper.c
@@ -514,7 +514,6 @@ int bt_discover_primary(const bdaddr_t *src, const bdaddr_t *dst, int psm,
{
struct gattrib_context *ctxt;
GIOChannel *io;
- GError *gerr = NULL;
ctxt = g_try_new0(struct gattrib_context, 1);
if (ctxt == NULL)
@@ -527,14 +526,14 @@ int bt_discover_primary(const bdaddr_t *src, const bdaddr_t *dst, int psm,
ctxt->destroy = destroy;
if (psm < 0)
- io = bt_io_connect(BT_IO_L2CAP, connect_cb, ctxt, NULL, &gerr,
+ 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_INVALID);
else
- io = bt_io_connect(BT_IO_L2CAP, connect_cb, ctxt, NULL, &gerr,
+ 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,
--
1.7.0.4
^ permalink raw reply related
* Re: problem to disconnect with bluez-test
From: Johan Hedberg @ 2010-12-21 9:24 UTC (permalink / raw)
To: Goubert, TonyX; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <6E42A1B4DD2F7B4D80A1F26BB498BF9F8C9BD2CAB2@irsmsx501.ger.corp.intel.com>
Hi Tony,
On Tue, Dec 21, 2010, Goubert, TonyX wrote:
> I have paired a handset with a laptop by using 'simple-agent'
> bluez-test script BUT I can't disconnect it when I use the bluez
> stack.
I suppose you mean you can't disconnect it using the test scripts that
come with BlueZ (since I'm sure you *can* disconnect it with BlueZ as
long as you use the D-Bus interface directly).
> I can remove it (./test-device remove xx:xx:xx:xx:xx:xx) but I
> want to be able to connect/disconnect/connect...
The Device.Disconnect method is indeed something that should be added to
the test-device script. I just went ahead and pushed a patch for it
upstream.
> [root@localhost test]# ./test-device disconnect xx:xx:xx:xx:xx:xx
> Unknown command
This command should work with latest git now.
Johan
^ permalink raw reply
* problem to disconnect with bluez-test
From: Goubert, TonyX @ 2010-12-21 8:53 UTC (permalink / raw)
To: linux-bluetooth@vger.kernel.org
Hi all,
I use bluez-4.76.2.6 i586.rpm and bluez-test-4.76.2.6.i586.rpm in order to discover, connect, ...
Link : repo.meego.com/MeeGo/builds/trunk/1.1.80.10.20101214.1/core/repos/ia32/packages/i586/
I have paired a handset with a laptop by using 'simple-agent' bluez-test script
BUT I can't disconnect it when I use the bluez stack.
I can remove it (./test-device remove xx:xx:xx:xx:xx:xx) but I want to be able to connect/disconnect/connect...
Is there a command?
Some handset traces:
[root@localhost test]# ./list-devices
[ /org/bluez/369/hci0/dev_xx_xx_xx_xx_xx_xx ]
Name = tllab54
Paired = 1
Adapter = /org/bluez/369/hci0
Alias = tllab54
Connected = 1
UUIDs = 0x110a 0x110c 0x110e 0x1112 0x1115 0x1116 0x1117 0x111f
Address = xx:xx:xx:xx:xx:xx
Services = dbus.Array([], signature=dbus.Signature('o'), variant_level=1)
Class = 0x000000
Trusted = 0
Blocked = 0
[root@localhost test]# ./test-device disconnect xx:xx:xx:xx:xx:xx
Unknown command
[root@localhost test]# ./test-input disconnect xx:xx:xx:xx:xx:xx
Traceback (most recent call last):
File "./test-input", line 42, in <module>
input.Disconnect()
File "/usr/lib/python2.6/site-packages/dbus/proxies.py", line 68, in __call__
return self._proxy_method(*args, **keywords)
File "/usr/lib/python2.6/site-packages/dbus/proxies.py", line 140, in __call__
**keywords)
File "/usr/lib/python2.6/site-packages/dbus/connection.py", line 630, in call_blocking
message, timeout)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownMethod: Method "Disconnect" wt
BR
--
Tony Goubert
tonyx.goubert@intel.com
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris,
92196 Meudon Cedex, France
Registration Number: 302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
^ permalink raw reply
* Re: [PATCH v2 3/3] More CodingStyle in lib and tools
From: Johan Hedberg @ 2010-12-21 8:52 UTC (permalink / raw)
To: Michal Labedzki; +Cc: linux-bluetooth
In-Reply-To: <1292920489-29040-1-git-send-email-michal.labedzki@tieto.com>
Hi Michal,
On Tue, Dec 21, 2010, Michal Labedzki wrote:
> ---
> lib/hci.c | 65 ++++++++++++++++++++++++++------------
> tools/hciconfig.c | 89 ++++++++++++++++++++++++++++++++++-------------------
> tools/hcitool.c | 20 ++++++------
> 3 files changed, 111 insertions(+), 63 deletions(-)
Thanks. This patch has been pushed upstream.
Johan
^ permalink raw reply
* Re: [PATCH v2 1/3] Filter device name in hciconfig.
From: Johan Hedberg @ 2010-12-21 8:49 UTC (permalink / raw)
To: Michal Labedzki; +Cc: linux-bluetooth
In-Reply-To: <1292920258-28989-1-git-send-email-michal.labedzki@tieto.com>
Hi Michal,
On Tue, Dec 21, 2010, Michal Labedzki wrote:
> No anymore work someting like "hciconfig tty1", "hciconfig qfg1" or
> "hciconfig hci1hg" as "hci1".
> ---
> lib/hci.c | 12 +++++++++++-
> tools/hciconfig.c | 30 +++++++++++++++++++++++++++++-
> 2 files changed, 40 insertions(+), 2 deletions(-)
This doesn't compile for me:
lib/hci.c: In function 'is_number':
lib/hci.c:60: error: implicit declaration of function 'isdigit'
Did you actually compile using ./boostrap-configure? Always do that
before submitting patches. It'll enable some extra checks and convert
all warnings to errors so you don't miss them by mistake.
"man isdigit" tells me that <ctype.h> should be included to use the
funciton.
Also, your commit message doesn't match the patch content. The patch
also changes hci_devid which is in no way specific to hciconfig whereas
your commit message implies that the patch is specific to hciconfig.
Feel free to split this into two separate patches with appropriate
commit messages.
Johan
^ permalink raw reply
* Re: [PATCH v3 2/5] Change CreatePairedDevice to support LE devices
From: Johan Hedberg @ 2010-12-21 8:42 UTC (permalink / raw)
To: Sheldon Demario; +Cc: linux-bluetooth
In-Reply-To: <1292889434-3773-1-git-send-email-sheldon.demario@openbossa.org>
Hi Sheldon,
On Mon, Dec 20, 2010, Sheldon Demario wrote:
> +static struct btd_device *create_device_internal(DBusConnection *conn,
> + struct btd_adapter *adapter,
> + const gchar *address,
> + gboolean secure, 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 (!secure && type == DEVICE_TYPE_LE &&
> + !event_is_connectable(dev->evt_type)) {
I think you got something mixed up here. I asked you to change the
sec_level_high variable occurences to secure. Here you've gone and
changed the force variable to secure (something that I didn't request).
I.e. please use "force" like before (since that describes its purpose
within the create_device_internal function more intuitively) and change
the following:
> +int device_browse_primary(struct btd_device *device, DBusConnection *conn,
> + DBusMessage *msg, gboolean sec_level_high)
> +int device_browse_primary(struct btd_device *device, DBusConnection *conn,
> + DBusMessage *msg, gboolean sec_level_high);
> int bt_discover_primary(const bdaddr_t *src, const bdaddr_t *dst, int psm,
> bt_primary_t cb, void *user_data,
> + gboolean sec_level_high,
> bt_destroy_t destroy)
> int bt_discover_primary(const bdaddr_t *src, const bdaddr_t *dst, int psm,
> bt_primary_t cb, void *user_data,
> + gboolean sec_level_high,
> bt_destroy_t destroy);
Johan
^ permalink raw reply
* [PATCH v2 3/3] More CodingStyle in lib and tools
From: Michal Labedzki @ 2010-12-21 8:34 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Michal Labedzki
In-Reply-To: <20101220153817.GB14575@jh-x301>
---
lib/hci.c | 65 ++++++++++++++++++++++++++------------
tools/hciconfig.c | 89 ++++++++++++++++++++++++++++++++++-------------------
tools/hcitool.c | 20 ++++++------
3 files changed, 111 insertions(+), 63 deletions(-)
diff --git a/lib/hci.c b/lib/hci.c
index 1d33e0e..29b053e 100644
--- a/lib/hci.c
+++ b/lib/hci.c
@@ -138,7 +138,8 @@ static int hci_str2uint(hci_map *map, char *str, unsigned int *val)
while ((t = strsep(&ptr, ","))) {
for (m = map; m->str; m++) {
if (!strcasecmp(m->str,t)) {
- *val = (unsigned int) m->val; set = 1;
+ *val = (unsigned int) m->val;
+ set = 1;
break;
}
}
@@ -781,7 +782,8 @@ char *lmp_featurestostr(uint8_t *features, char *pref, int width)
while (m->str) {
if (m->val & features[i])
- size += strlen(m->str) + (pref ? strlen(pref) : 0) + 1;
+ size += strlen(m->str) +
+ (pref ? strlen(pref) : 0) + 1;
m++;
}
}
@@ -803,7 +805,8 @@ char *lmp_featurestostr(uint8_t *features, char *pref, int width)
while (m->str) {
if (m->val & features[i]) {
if (strlen(off) + strlen(m->str) > maxwidth) {
- ptr += sprintf(ptr, "\n%s", pref ? pref : "");
+ ptr += sprintf(ptr, "\n%s",
+ pref ? pref : "");
off = ptr;
}
ptr += sprintf(ptr, "%s ", m->str);
@@ -816,8 +819,8 @@ char *lmp_featurestostr(uint8_t *features, char *pref, int width)
}
/* HCI functions that do not require open device */
-
-int hci_for_each_dev(int flag, int (*func)(int dd, int dev_id, long arg), long arg)
+int hci_for_each_dev(int flag, int (*func)(int dd, int dev_id, long arg),
+ long arg)
{
struct hci_dev_list_req *dl;
struct hci_dev_req *dr;
@@ -951,7 +954,8 @@ int hci_devba(int dev_id, bdaddr_t *bdaddr)
return 0;
}
-int hci_inquiry(int dev_id, int len, int nrsp, const uint8_t *lap, inquiry_info **ii, long flags)
+int hci_inquiry(int dev_id, int len, int nrsp, const uint8_t *lap,
+ inquiry_info **ii, long flags)
{
struct hci_inquiry_req *ir;
uint8_t num_rsp = nrsp;
@@ -1138,7 +1142,8 @@ int hci_send_req(int dd, struct hci_request *r, int to)
}
to -= 10;
- if (to < 0) to = 0;
+ if (to < 0)
+ to = 0;
}
@@ -1231,7 +1236,9 @@ done:
return 0;
}
-int hci_create_connection(int dd, const bdaddr_t *bdaddr, uint16_t ptype, uint16_t clkoffset, uint8_t rswitch, uint16_t *handle, int to)
+int hci_create_connection(int dd, const bdaddr_t *bdaddr, uint16_t ptype,
+ uint16_t clkoffset, uint8_t rswitch,
+ uint16_t *handle, int to)
{
evt_conn_complete rp;
create_conn_cp cp;
@@ -1338,7 +1345,10 @@ int hci_write_local_name(int dd, const char *name, int to)
return 0;
}
-int hci_read_remote_name_with_clock_offset(int dd, const bdaddr_t *bdaddr, uint8_t pscan_rep_mode, uint16_t clkoffset, int len, char *name, int to)
+int hci_read_remote_name_with_clock_offset(int dd, const bdaddr_t *bdaddr,
+ uint8_t pscan_rep_mode,
+ uint16_t clkoffset,
+ int len, char *name, int to)
{
evt_remote_name_req_complete rn;
remote_name_req_cp cp;
@@ -1371,9 +1381,11 @@ int hci_read_remote_name_with_clock_offset(int dd, const bdaddr_t *bdaddr, uint8
return 0;
}
-int hci_read_remote_name(int dd, const bdaddr_t *bdaddr, int len, char *name, int to)
+int hci_read_remote_name(int dd, const bdaddr_t *bdaddr, int len, char *name,
+ int to)
{
- return hci_read_remote_name_with_clock_offset(dd, bdaddr, 0x02, 0x0000, len, name, to);
+ return hci_read_remote_name_with_clock_offset(dd, bdaddr, 0x02, 0x0000,
+ len, name, to);
}
int hci_read_remote_name_cancel(int dd, const bdaddr_t *bdaddr, int to)
@@ -1396,7 +1408,8 @@ int hci_read_remote_name_cancel(int dd, const bdaddr_t *bdaddr, int to)
return 0;
}
-int hci_read_remote_version(int dd, uint16_t handle, struct hci_version *ver, int to)
+int hci_read_remote_version(int dd, uint16_t handle, struct hci_version *ver,
+ int to)
{
evt_read_remote_version_complete rp;
read_remote_version_cp cp;
@@ -1460,7 +1473,9 @@ int hci_read_remote_features(int dd, uint16_t handle, uint8_t *features, int to)
return 0;
}
-int hci_read_remote_ext_features(int dd, uint16_t handle, uint8_t page, uint8_t *max_page, uint8_t *features, int to)
+int hci_read_remote_ext_features(int dd, uint16_t handle, uint8_t page,
+ uint8_t *max_page, uint8_t *features,
+ int to)
{
evt_read_remote_ext_features_complete rp;
read_remote_ext_features_cp cp;
@@ -1603,7 +1618,8 @@ int hci_read_local_features(int dd, uint8_t *features, int to)
return 0;
}
-int hci_read_local_ext_features(int dd, uint8_t page, uint8_t *max_page, uint8_t *features, int to)
+int hci_read_local_ext_features(int dd, uint8_t page, uint8_t *max_page,
+ uint8_t *features, int to)
{
read_local_ext_features_cp cp;
read_local_ext_features_rp rp;
@@ -1944,7 +1960,8 @@ int hci_switch_role(int dd, bdaddr_t *bdaddr, uint8_t role, int to)
return 0;
}
-int hci_park_mode(int dd, uint16_t handle, uint16_t max_interval, uint16_t min_interval, int to)
+int hci_park_mode(int dd, uint16_t handle, uint16_t max_interval,
+ uint16_t min_interval, int to)
{
park_mode_cp cp;
evt_mode_change rp;
@@ -2342,7 +2359,8 @@ int hci_write_inquiry_transmit_power_level(int dd, int8_t level, int to)
return 0;
}
-int hci_read_transmit_power_level(int dd, uint16_t handle, uint8_t type, int8_t *level, int to)
+int hci_read_transmit_power_level(int dd, uint16_t handle, uint8_t type,
+ int8_t *level, int to)
{
read_transmit_power_level_cp cp;
read_transmit_power_level_rp rp;
@@ -2426,7 +2444,8 @@ int hci_write_link_policy(int dd, uint16_t handle, uint16_t policy, int to)
return 0;
}
-int hci_read_link_supervision_timeout(int dd, uint16_t handle, uint16_t *timeout, int to)
+int hci_read_link_supervision_timeout(int dd, uint16_t handle,
+ uint16_t *timeout, int to)
{
read_link_supervision_timeout_rp rp;
struct hci_request rq;
@@ -2451,7 +2470,8 @@ int hci_read_link_supervision_timeout(int dd, uint16_t handle, uint16_t *timeout
return 0;
}
-int hci_write_link_supervision_timeout(int dd, uint16_t handle, uint16_t timeout, int to)
+int hci_write_link_supervision_timeout(int dd, uint16_t handle,
+ uint16_t timeout, int to)
{
write_link_supervision_timeout_cp cp;
write_link_supervision_timeout_rp rp;
@@ -2508,7 +2528,8 @@ int hci_set_afh_classification(int dd, uint8_t *map, int to)
return 0;
}
-int hci_read_link_quality(int dd, uint16_t handle, uint8_t *link_quality, int to)
+int hci_read_link_quality(int dd, uint16_t handle, uint8_t *link_quality,
+ int to)
{
read_link_quality_rp rp;
struct hci_request rq;
@@ -2558,7 +2579,8 @@ int hci_read_rssi(int dd, uint16_t handle, int8_t *rssi, int to)
return 0;
}
-int hci_read_afh_map(int dd, uint16_t handle, uint8_t *mode, uint8_t *map, int to)
+int hci_read_afh_map(int dd, uint16_t handle, uint8_t *mode, uint8_t *map,
+ int to)
{
read_afh_map_rp rp;
struct hci_request rq;
@@ -2584,7 +2606,8 @@ int hci_read_afh_map(int dd, uint16_t handle, uint8_t *mode, uint8_t *map, int t
return 0;
}
-int hci_read_clock(int dd, uint16_t handle, uint8_t which, uint32_t *clock, uint16_t *accuracy, int to)
+int hci_read_clock(int dd, uint16_t handle, uint8_t which, uint32_t *clock,
+ uint16_t *accuracy, int to)
{
read_clock_cp cp;
read_clock_rp rp;
diff --git a/tools/hciconfig.c b/tools/hciconfig.c
index 6d2d1a5..0148ab5 100644
--- a/tools/hciconfig.c
+++ b/tools/hciconfig.c
@@ -57,7 +57,8 @@ static void print_dev_list(int ctl, int flags)
struct hci_dev_req *dr;
int i;
- if (!(dl = malloc(HCI_MAX_DEV * sizeof(struct hci_dev_req) + sizeof(uint16_t)))) {
+ if (!(dl = malloc(HCI_MAX_DEV * sizeof(struct hci_dev_req) +
+ sizeof(uint16_t)))) {
perror("Can't allocate memory");
exit(1);
}
@@ -501,7 +502,7 @@ static char *get_minor_device_name(int major, int minor)
case 0: /* misc */
return "";
case 1: /* computer */
- switch(minor) {
+ switch (minor) {
case 0:
return "Uncategorized";
case 1:
@@ -519,7 +520,7 @@ static char *get_minor_device_name(int major, int minor)
}
break;
case 2: /* phone */
- switch(minor) {
+ switch (minor) {
case 0:
return "Uncategorized";
case 1:
@@ -539,7 +540,7 @@ static char *get_minor_device_name(int major, int minor)
case 3: /* lan access */
if (minor == 0)
return "Uncategorized";
- switch(minor / 8) {
+ switch (minor / 8) {
case 0:
return "Fully available";
case 1:
@@ -559,7 +560,7 @@ static char *get_minor_device_name(int major, int minor)
}
break;
case 4: /* audio/video */
- switch(minor) {
+ switch (minor) {
case 0:
return "Uncategorized";
case 1:
@@ -603,7 +604,7 @@ static char *get_minor_device_name(int major, int minor)
cls_str[0] = '\0';
- switch(minor & 48) {
+ switch (minor & 48) {
case 16:
strncpy(cls_str, "Keyboard", sizeof(cls_str));
break;
@@ -614,10 +615,10 @@ static char *get_minor_device_name(int major, int minor)
strncpy(cls_str, "Combo keyboard/pointing device", sizeof(cls_str));
break;
}
- if((minor & 15) && (strlen(cls_str) > 0))
+ if ((minor & 15) && (strlen(cls_str) > 0))
strcat(cls_str, "/");
- switch(minor & 15) {
+ switch (minor & 15) {
case 0:
break;
case 1:
@@ -642,7 +643,7 @@ static char *get_minor_device_name(int major, int minor)
strncat(cls_str, "(reserved)", sizeof(cls_str) - strlen(cls_str));
break;
}
- if(strlen(cls_str) > 0)
+ if (strlen(cls_str) > 0)
return cls_str;
}
case 6: /* imaging */
@@ -656,7 +657,7 @@ static char *get_minor_device_name(int major, int minor)
return "Printer";
break;
case 7: /* wearable */
- switch(minor) {
+ switch (minor) {
case 1:
return "Wrist Watch";
case 2:
@@ -670,7 +671,7 @@ static char *get_minor_device_name(int major, int minor)
}
break;
case 8: /* toy */
- switch(minor) {
+ switch (minor) {
case 1:
return "Robot";
case 2:
@@ -754,10 +755,24 @@ static void cmd_class(int ctl, int hdev, char *opt)
static void cmd_voice(int ctl, int hdev, char *opt)
{
- static char *icf[] = { "Linear", "u-Law", "A-Law", "Reserved" };
- static char *idf[] = { "1's complement", "2's complement", "Sign-Magnitude", "Reserved" };
- static char *iss[] = { "8 bit", "16 bit" };
- static char *acf[] = { "CVSD", "u-Law", "A-Law", "Reserved" };
+ static char *icf[] = { "Linear",
+ "u-Law",
+ "A-Law",
+ "Reserved" };
+
+ static char *idf[] = { "1's complement",
+ "2's complement",
+ "Sign-Magnitude",
+ "Reserved" };
+
+ static char *iss[] = { "8 bit",
+ "16 bit" };
+
+ static char *acf[] = { "CVSD",
+ "u-Law",
+ "A-Law",
+ "Reserved" };
+
int s = hci_open_dev(hdev);
if (s < 0) {
@@ -787,15 +802,19 @@ static void cmd_voice(int ctl, int hdev, char *opt)
((vs & 0x03fc) == 0x0060) ? " (Default Condition)" : "");
printf("\tInput Coding: %s\n", icf[ic]);
printf("\tInput Data Format: %s\n", idf[(vs & 0xc0) >> 6]);
+
if (!ic) {
- printf("\tInput Sample Size: %s\n", iss[(vs & 0x20) >> 5]);
- printf("\t# of bits padding at MSB: %d\n", (vs & 0x1c) >> 2);
+ printf("\tInput Sample Size: %s\n",
+ iss[(vs & 0x20) >> 5]);
+ printf("\t# of bits padding at MSB: %d\n",
+ (vs & 0x1c) >> 2);
}
printf("\tAir Coding Format: %s\n", acf[vs & 0x03]);
}
}
-static int get_link_key(const bdaddr_t *local, const bdaddr_t *peer, uint8_t *key)
+static int get_link_key(const bdaddr_t *local, const bdaddr_t *peer,
+ uint8_t *key)
{
char filename[PATH_MAX + 1], addr[18], tmp[3], *str;
int i;
@@ -1356,8 +1375,10 @@ static void cmd_page_parms(int ctl, int hdev, char *opt)
window = btohs(rp.window);
interval = btohs(rp.interval);
- printf("\tPage interval: %u slots (%.2f ms), window: %u slots (%.2f ms)\n",
- interval, (float)interval * 0.625, window, (float)window * 0.625);
+ printf("\tPage interval: %u slots (%.2f ms), "
+ "window: %u slots (%.2f ms)\n",
+ interval, (float)interval * 0.625,
+ window, (float)window * 0.625);
}
}
@@ -1441,7 +1462,7 @@ static void cmd_afh_mode(int ctl, int hdev, char *opt)
if (hci_write_afh_mode(dd, mode, 2000) < 0) {
fprintf(stderr, "Can't set AFH mode on hci%d: %s (%d)\n",
- hdev, strerror(errno), errno);
+ hdev, strerror(errno), errno);
exit(1);
}
} else {
@@ -1449,7 +1470,7 @@ static void cmd_afh_mode(int ctl, int hdev, char *opt)
if (hci_read_afh_mode(dd, &mode, 1000) < 0) {
fprintf(stderr, "Can't read AFH mode on hci%d: %s (%d)\n",
- hdev, strerror(errno), errno);
+ hdev, strerror(errno), errno);
exit(1);
}
@@ -1474,7 +1495,7 @@ static void cmd_ssp_mode(int ctl, int hdev, char *opt)
if (hci_write_simple_pairing_mode(dd, mode, 2000) < 0) {
fprintf(stderr, "Can't set Simple Pairing mode on hci%d: %s (%d)\n",
- hdev, strerror(errno), errno);
+ hdev, strerror(errno), errno);
exit(1);
}
} else {
@@ -1482,12 +1503,13 @@ static void cmd_ssp_mode(int ctl, int hdev, char *opt)
if (hci_read_simple_pairing_mode(dd, &mode, 1000) < 0) {
fprintf(stderr, "Can't read Simple Pairing mode on hci%d: %s (%d)\n",
- hdev, strerror(errno), errno);
+ hdev, strerror(errno), errno);
exit(1);
}
print_dev_hdr(&di);
- printf("\tSimple Pairing mode: %s\n", mode == 1 ? "Enabled" : "Disabled");
+ printf("\tSimple Pairing mode: %s\n",
+ mode == 1 ? "Enabled" : "Disabled");
}
}
@@ -1505,7 +1527,8 @@ static void print_rev_ericsson(int dd)
rq.rlen = sizeof(buf);
if (hci_send_req(dd, &rq, 1000) < 0) {
- printf("\nCan't read revision info: %s (%d)\n", strerror(errno), errno);
+ printf("\nCan't read revision info: %s (%d)\n",
+ strerror(errno), errno);
return;
}
@@ -1551,7 +1574,8 @@ static void print_rev_digianswer(int dd)
rq.rlen = sizeof(buf);
if (hci_send_req(dd, &rq, 1000) < 0) {
- printf("\nCan't read revision info: %s (%d)\n", strerror(errno), errno);
+ printf("\nCan't read revision info: %s (%d)\n",
+ strerror(errno), errno);
return;
}
@@ -1560,7 +1584,8 @@ static void print_rev_digianswer(int dd)
static void print_rev_broadcom(uint16_t hci_rev, uint16_t lmp_subver)
{
- printf("\tFirmware %d.%d / %d\n", hci_rev & 0xff, lmp_subver >> 8, lmp_subver & 0xff);
+ printf("\tFirmware %d.%d / %d\n",
+ hci_rev & 0xff, lmp_subver >> 8, lmp_subver & 0xff);
}
static void print_rev_avm(uint16_t hci_rev, uint16_t lmp_subver)
@@ -1807,7 +1832,7 @@ static void usage(void)
"\thciconfig\n"
"\thciconfig [-a] hciX [command ...]\n");
printf("Commands:\n");
- for (i=0; command[i].cmd; i++)
+ for (i = 0; command[i].cmd; i++)
printf("\t%-10s %-8s\t%s\n", command[i].cmd,
command[i].opt ? command[i].opt : " ",
command[i].doc);
@@ -1821,10 +1846,10 @@ static struct option main_options[] = {
int main(int argc, char *argv[])
{
- int opt, ctl, i, cmd=0;
+ int opt, ctl, i, cmd = 0;
- while ((opt=getopt_long(argc, argv, "ah", main_options, NULL)) != -1) {
- switch(opt) {
+ while ((opt = getopt_long(argc, argv, "ah", main_options, NULL)) != -1) {
+ switch (opt) {
case 'a':
all = 1;
break;
diff --git a/tools/hcitool.c b/tools/hcitool.c
index 847bf1b..d50adaf 100644
--- a/tools/hcitool.c
+++ b/tools/hcitool.c
@@ -197,7 +197,7 @@ static char *get_minor_device_name(int major, int minor)
case 0: /* misc */
return "";
case 1: /* computer */
- switch(minor) {
+ switch (minor) {
case 0:
return "Uncategorized";
case 1:
@@ -215,7 +215,7 @@ static char *get_minor_device_name(int major, int minor)
}
break;
case 2: /* phone */
- switch(minor) {
+ switch (minor) {
case 0:
return "Uncategorized";
case 1:
@@ -235,7 +235,7 @@ static char *get_minor_device_name(int major, int minor)
case 3: /* lan access */
if (minor == 0)
return "Uncategorized";
- switch(minor / 8) {
+ switch (minor / 8) {
case 0:
return "Fully available";
case 1:
@@ -255,7 +255,7 @@ static char *get_minor_device_name(int major, int minor)
}
break;
case 4: /* audio/video */
- switch(minor) {
+ switch (minor) {
case 0:
return "Uncategorized";
case 1:
@@ -297,7 +297,7 @@ static char *get_minor_device_name(int major, int minor)
case 5: /* peripheral */ {
static char cls_str[48]; cls_str[0] = 0;
- switch(minor & 48) {
+ switch (minor & 48) {
case 16:
strncpy(cls_str, "Keyboard", sizeof(cls_str));
break;
@@ -308,10 +308,10 @@ static char *get_minor_device_name(int major, int minor)
strncpy(cls_str, "Combo keyboard/pointing device", sizeof(cls_str));
break;
}
- if((minor & 15) && (strlen(cls_str) > 0))
+ if ((minor & 15) && (strlen(cls_str) > 0))
strcat(cls_str, "/");
- switch(minor & 15) {
+ switch (minor & 15) {
case 0:
break;
case 1:
@@ -336,7 +336,7 @@ static char *get_minor_device_name(int major, int minor)
strncat(cls_str, "(reserved)", sizeof(cls_str) - strlen(cls_str));
break;
}
- if(strlen(cls_str) > 0)
+ if (strlen(cls_str) > 0)
return cls_str;
}
case 6: /* imaging */
@@ -350,7 +350,7 @@ static char *get_minor_device_name(int major, int minor)
return "Printer";
break;
case 7: /* wearable */
- switch(minor) {
+ switch (minor) {
case 1:
return "Wrist Watch";
case 2:
@@ -364,7 +364,7 @@ static char *get_minor_device_name(int major, int minor)
}
break;
case 8: /* toy */
- switch(minor) {
+ switch (minor) {
case 1:
return "Robot";
case 2:
--
1.7.0.4
^ permalink raw reply related
* [PATCH v2 1/3] Filter device name in hciconfig.
From: Michal Labedzki @ 2010-12-21 8:30 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Michal Labedzki
In-Reply-To: <1292840029-27770-2-git-send-email-michal.labedzki@tieto.com>
No anymore work someting like "hciconfig tty1", "hciconfig qfg1" or
"hciconfig hci1hg" as "hci1".
---
lib/hci.c | 12 +++++++++++-
tools/hciconfig.c | 30 +++++++++++++++++++++++++++++-
2 files changed, 40 insertions(+), 2 deletions(-)
diff --git a/lib/hci.c b/lib/hci.c
index 3304daa..1d33e0e 100644
--- a/lib/hci.c
+++ b/lib/hci.c
@@ -54,6 +54,16 @@ typedef struct {
unsigned int val;
} hci_map;
+static int is_number(const char *c)
+{
+ while (*c) {
+ if (!isdigit(*c))
+ return 0;
+ ++c;
+ }
+ return 1;
+}
+
static char *hci_bit2str(hci_map *m, unsigned int val)
{
char *str = malloc(120);
@@ -889,7 +899,7 @@ int hci_devid(const char *str)
bdaddr_t ba;
int id = -1;
- if (!strncmp(str, "hci", 3) && strlen(str) >= 4) {
+ if (!strncmp(str, "hci", 3) && strlen(str) >= 4 && is_number(str + 3)) {
id = atoi(str + 3);
if (hci_devba(id, &ba) < 0)
return -1;
diff --git a/tools/hciconfig.c b/tools/hciconfig.c
index 995aca1..6d2d1a5 100644
--- a/tools/hciconfig.c
+++ b/tools/hciconfig.c
@@ -1721,6 +1721,33 @@ static void print_dev_info(int ctl, struct hci_dev_info *di)
printf("\n");
}
+static int is_number(const char *c)
+{
+ while (*c) {
+ if (!isdigit(*c))
+ return 0;
+ ++c;
+ }
+ return 1;
+}
+
+static int dev_name_filter(char *dev_name)
+{
+ int ret;
+
+ if ((strlen(dev_name) >= 4) && (!strncmp(dev_name, "hci", 3)) &&
+ (is_number(dev_name + 3)))
+ ret = atoi(dev_name + 3);
+ else if (is_number(dev_name))
+ ret = atoi(dev_name);
+ else {
+ fprintf(stderr, "No valid device name\n");
+ exit(1);
+ }
+
+ return ret;
+}
+
static struct {
char *cmd;
void (*func)(int ctl, int hdev, char *opt);
@@ -1824,7 +1851,8 @@ int main(int argc, char *argv[])
exit(0);
}
- di.dev_id = atoi(argv[0] + 3);
+ di.dev_id = dev_name_filter(argv[0]);
+
argc--; argv++;
if (ioctl(ctl, HCIGETDEVINFO, (void *) &di)) {
--
1.7.0.4
^ permalink raw reply related
* bluetooth for vendor special command and event
From: Challen Zhou @ 2010-12-21 8:09 UTC (permalink / raw)
To: linux-bluetooth@vger.kernel.org
In-Reply-To: <1292886362-19755-1-git-send-email-sheldon.demario@openbossa.org>
Hi,all,
I want to add a control interface for BT control other device(bt and the device on single chip),
Thus , I need to add some special HCI command and Event, but when I view the code
in kernel, but find that it do not provide this interface or function. Anybody have any idea on this?
BRS
Challen zhou
^ permalink raw reply
* [PATCH v3 2/5] Change CreatePairedDevice to support LE devices
From: Sheldon Demario @ 2010-12-20 23:57 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Sheldon Demario
In-Reply-To: <20101220225909.GA6365@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 cf3566d..c0fe4c0 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -1510,15 +1510,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 secure, 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 (!secure && 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)
@@ -1535,41 +1568,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)
@@ -1594,6 +1622,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,
@@ -1618,12 +1647,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 bef8e71..33b09eb 100644
--- a/src/device.c
+++ b/src/device.c
@@ -583,7 +583,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 {
@@ -594,7 +594,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;
}
@@ -985,6 +985,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];
@@ -1537,41 +1542,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 sec_level_high)
{
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,
+ sec_level_high, 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);
@@ -1586,34 +1612,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();
@@ -1716,7 +1719,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;
@@ -2053,7 +2056,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 74b968c..947de95 100644
--- a/src/device.h
+++ b/src/device.h
@@ -46,9 +46,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 sec_level_high);
+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 c440e60..6ab288a 100644
--- a/src/glib-helper.c
+++ b/src/glib-helper.c
@@ -520,9 +520,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 sec_level_high,
bt_destroy_t destroy)
{
struct gattrib_context *ctxt;
+ BtIOSecLevel sec_level;
GIOChannel *io;
GError *gerr = NULL;
@@ -536,19 +538,25 @@ int bt_discover_primary(const bdaddr_t *src, const bdaddr_t *dst, int psm,
ctxt->cb = cb;
ctxt->destroy = destroy;
+ if (sec_level_high == 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, &gerr,
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, &gerr,
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 10718bb..9cac915 100644
--- a/src/glib-helper.h
+++ b/src/glib-helper.h
@@ -35,6 +35,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 sec_level_high,
bt_destroy_t destroy);
gchar *bt_uuid2string(uuid_t *uuid);
--
1.7.3.2
^ permalink raw reply related
* Re: [PATCH] Remove bt_discover_services function from glib-helper
From: Johan Hedberg @ 2010-12-20 23:10 UTC (permalink / raw)
To: Sheldon Demario; +Cc: linux-bluetooth
In-Reply-To: <1292886362-19755-1-git-send-email-sheldon.demario@openbossa.org>
Hi Sheldon,
On Mon, Dec 20, 2010, Sheldon Demario wrote:
> There is no reference in the code for this function. SDP discovery in
> the bluetoothd core and plugins are now using bt_search_service only.
> ---
> src/glib-helper.c | 10 ----------
> src/glib-helper.h | 3 ---
> 2 files changed, 0 insertions(+), 13 deletions(-)
Pushed upstream. Thanks.
Johan
^ permalink raw reply
* [PATCH] Remove bt_discover_services function from glib-helper
From: Sheldon Demario @ 2010-12-20 23:06 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Sheldon Demario
There is no reference in the code for this function. SDP discovery in
the bluetoothd core and plugins are now using bt_search_service only.
---
src/glib-helper.c | 10 ----------
src/glib-helper.h | 3 ---
2 files changed, 0 insertions(+), 13 deletions(-)
diff --git a/src/glib-helper.c b/src/glib-helper.c
index aa7f2c7..ec016a8 100644
--- a/src/glib-helper.c
+++ b/src/glib-helper.c
@@ -363,16 +363,6 @@ int bt_search_service(const bdaddr_t *src, const bdaddr_t *dst,
return 0;
}
-int bt_discover_services(const bdaddr_t *src, const bdaddr_t *dst,
- bt_callback_t cb, void *user_data, bt_destroy_t destroy)
-{
- uuid_t uuid;
-
- sdp_uuid16_create(&uuid, PUBLIC_BROWSE_GROUP);
-
- return bt_search_service(src, dst, &uuid, cb, user_data, destroy);
-}
-
static gint find_by_bdaddr(gconstpointer data, gconstpointer user_data)
{
const struct search_context *ctxt = data, *search = user_data;
diff --git a/src/glib-helper.h b/src/glib-helper.h
index 9cac915..a191be0 100644
--- a/src/glib-helper.h
+++ b/src/glib-helper.h
@@ -25,9 +25,6 @@ typedef void (*bt_callback_t) (sdp_list_t *recs, int err, gpointer user_data);
typedef void (*bt_primary_t) (GSList *l, int err, gpointer user_data);
typedef void (*bt_destroy_t) (gpointer user_data);
-int bt_discover_services(const bdaddr_t *src, const bdaddr_t *dst,
- bt_callback_t cb, void *user_data, bt_destroy_t destroy);
-
int bt_search_service(const bdaddr_t *src, const bdaddr_t *dst,
uuid_t *uuid, bt_callback_t cb, void *user_data,
bt_destroy_t destroy);
--
1.7.3.2
^ permalink raw reply related
* Re: [PATCH v2 5/5] Remove unneeded variable
From: Johan Hedberg @ 2010-12-20 23:02 UTC (permalink / raw)
To: Claudio Takahasi; +Cc: linux-bluetooth
In-Reply-To: <1292885388-21703-1-git-send-email-claudio.takahasi@openbossa.org>
Hi Claudio,
On Mon, Dec 20, 2010, Claudio Takahasi wrote:
> ---
> src/glib-helper.c | 5 ++---
> 1 files changed, 2 insertions(+), 3 deletions(-)
This patch seems fine but it doesn't apply (probably due to me not
applying v2 2/5).
Johan
^ permalink raw reply
* Re: [PATCH v2 4/5] Fix missing reply when create device is cancelled
From: Johan Hedberg @ 2010-12-20 23:00 UTC (permalink / raw)
To: Claudio Takahasi; +Cc: linux-bluetooth
In-Reply-To: <1292885255-21662-1-git-send-email-claudio.takahasi@openbossa.org>
Hi Claudio,
On Mon, Dec 20, 2010, Claudio Takahasi wrote:
> When CancelDeviceCreation is called or when the device is removed for
> any reason, the reply for the pending CreateDevice is not sent.
> ---
> src/device.c | 8 ++++++--
> 1 files changed, 6 insertions(+), 2 deletions(-)
Pushed upstream. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH v2 2/5] Change CreatePairedDevice to support LE devices
From: Johan Hedberg @ 2010-12-20 22:59 UTC (permalink / raw)
To: Claudio Takahasi; +Cc: linux-bluetooth, Sheldon Demario
In-Reply-To: <1292885021-21619-1-git-send-email-claudio.takahasi@openbossa.org>
Hi,
> +static struct btd_device *create_common(DBusConnection *conn,
I don't really like this name since it doesn't explain what the function
does in any way except that it creates "something". Could you call it
e.g. __create_device() or create_device_internal()?
> + if (type == DEVICE_TYPE_LE && !event_is_connectable(dev->evt_type)) {
> + if (force)
> + goto create;
> +
> + if (err)
> + *err = -ENOTCONN;
> +
> + return NULL;
> + }
> +
> +create:
You could avoid the label and goto by simply adding if (!force && type...
to the beginning of the if-statement.
> +int device_browse_primary(struct btd_device *device, DBusConnection *conn,
> + DBusMessage *msg, gboolean sec_level_high)
Could you call the gboolean parameter just "secure"?
Johan
^ permalink raw reply
* [PATCH v2 5/5] Remove unneeded variable
From: Claudio Takahasi @ 2010-12-20 22:49 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1292442852-26457-5-git-send-email-claudio.takahasi@openbossa.org>
---
src/glib-helper.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/glib-helper.c b/src/glib-helper.c
index 6ab288a..aa7f2c7 100644
--- a/src/glib-helper.c
+++ b/src/glib-helper.c
@@ -526,7 +526,6 @@ int bt_discover_primary(const bdaddr_t *src, const bdaddr_t *dst, int psm,
struct gattrib_context *ctxt;
BtIOSecLevel sec_level;
GIOChannel *io;
- GError *gerr = NULL;
ctxt = g_try_new0(struct gattrib_context, 1);
if (ctxt == NULL)
@@ -545,14 +544,14 @@ int bt_discover_primary(const bdaddr_t *src, const bdaddr_t *dst, int psm,
if (psm < 0)
- io = bt_io_connect(BT_IO_L2CAP, connect_cb, ctxt, NULL, &gerr,
+ 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, sec_level,
BT_IO_OPT_INVALID);
else
- io = bt_io_connect(BT_IO_L2CAP, connect_cb, ctxt, NULL, &gerr,
+ 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,
--
1.7.3.3
^ permalink raw reply related
* [PATCH v2 4/5] Fix missing reply when create device is cancelled
From: Claudio Takahasi @ 2010-12-20 22:47 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1292442852-26457-4-git-send-email-claudio.takahasi@openbossa.org>
When CancelDeviceCreation is called or when the device is removed for
any reason, the reply for the pending CreateDevice is not sent.
---
src/device.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/device.c b/src/device.c
index 33b09eb..b7c7ddf 100644
--- a/src/device.c
+++ b/src/device.c
@@ -727,8 +727,10 @@ void device_request_disconnect(struct btd_device *device, DBusMessage *msg)
if (device->bonding)
bonding_request_cancel(device->bonding);
- if (device->browse)
+ if (device->browse) {
+ discover_services_reply(device->browse, -ECANCELED, NULL);
browse_request_cancel(device->browse);
+ }
if (msg)
device->disconnects = g_slist_append(device->disconnects,
@@ -1040,8 +1042,10 @@ void device_remove(struct btd_device *device, gboolean remove_stored)
if (device->bonding)
device_cancel_bonding(device, HCI_OE_USER_ENDED_CONNECTION);
- if (device->browse)
+ if (device->browse) {
+ discover_services_reply(device->browse, -ECANCELED, NULL);
browse_request_cancel(device->browse);
+ }
if (device->handle)
do_disconnect(device);
--
1.7.3.3
^ permalink raw reply related
* Re: [PATCH 3/5] Return an error if adapter_create_device fails
From: Claudio Takahasi @ 2010-12-20 22:45 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1292442852-26457-3-git-send-email-claudio.takahasi@openbossa.org>
Hi Johan,
On Wed, Dec 15, 2010 at 4:54 PM, Claudio Takahasi
<claudio.takahasi@openbossa.org> wrote:
> This function can fail if the device object is already registered or if
> the system doesn't have enough memory. Issue detected due wrong device
> object reference counting that doesn't unregister the D-Bus object path
> when the device is removed.
> ---
> src/adapter.c | 6 ++++--
> 1 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/src/adapter.c b/src/adapter.c
> index c1fddce..f71d063 100644
> --- a/src/adapter.c
> +++ b/src/adapter.c
> @@ -1595,7 +1595,8 @@ static DBusMessage *create_device(DBusConnection *conn,
>
> device = adapter_create_device(conn, adapter, address, type);
> if (!device)
> - return NULL;
> + return btd_error_failed(msg,
> + "Unable to create a new device object");
>
> if (type == DEVICE_TYPE_LE && !event_is_connectable(dev->evt_type)) {
> /* Device is not connectable */
> @@ -1693,7 +1694,8 @@ static DBusMessage *create_paired_device(DBusConnection *conn,
>
> device = adapter_create_device(conn, adapter, address, type);
> if (!device)
> - return NULL;
> + return btd_error_failed(msg,
> + "Unable to create a new device object");
> } else
> type = device_get_type(device);
>
> --
> 1.7.3.3
>
>
This patch is not necessary anymore. Please ignore it!
Claudio
^ permalink raw reply
* Re: [PATCH 1/2] Move EIR flags definitions to adapter.c
From: Johan Hedberg @ 2010-12-20 22:43 UTC (permalink / raw)
To: Bruna Moreira; +Cc: linux-bluetooth
In-Reply-To: <1292869005-12391-1-git-send-email-bruna.moreira@openbossa.org>
Hi Bruna,
On Mon, Dec 20, 2010, Bruna Moreira wrote:
> ---
> src/adapter.c | 9 +++++++++
> src/sdpd.h | 9 ---------
> 2 files changed, 9 insertions(+), 9 deletions(-)
Both patches have been pushed upstream. Thanks. In the future, please
put some content to the commit message body for any non-trivial patches.
You could at least have a sentence or two about *why* the patches are
needed.
Johan
^ permalink raw reply
* [PATCH v2 2/5] Change CreatePairedDevice to support LE devices
From: Claudio Takahasi @ 2010-12-20 22:43 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Sheldon Demario
In-Reply-To: <20101216210111.GA25720@jh-x301>
From: Sheldon Demario <sheldon.demario@openbossa.org>
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 | 104 +++++++++++++++++++++++++++++++++++++----------------
src/device.c | 89 +++++++++++++++++++++++----------------------
src/device.h | 5 ++-
src/glib-helper.c | 12 +++++-
src/glib-helper.h | 1 +
5 files changed, 134 insertions(+), 77 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index cf3566d..047473b 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -1510,15 +1510,51 @@ static gboolean event_is_connectable(uint8_t type)
}
}
+static struct btd_device *create_common(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 (type == DEVICE_TYPE_LE && !event_is_connectable(dev->evt_type)) {
+ if (force)
+ goto create;
+
+ if (err)
+ *err = -ENOTCONN;
+
+ return NULL;
+ }
+
+create:
+ 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)
@@ -1535,41 +1571,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_common(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)
@@ -1594,6 +1625,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,
@@ -1618,12 +1650,22 @@ 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_common(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 bef8e71..33b09eb 100644
--- a/src/device.c
+++ b/src/device.c
@@ -583,7 +583,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 {
@@ -594,7 +594,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;
}
@@ -985,6 +985,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];
@@ -1537,41 +1542,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 sec_level_high)
{
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,
+ sec_level_high, 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);
@@ -1586,34 +1612,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();
@@ -1716,7 +1719,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;
@@ -2053,7 +2056,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 74b968c..947de95 100644
--- a/src/device.h
+++ b/src/device.h
@@ -46,9 +46,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 sec_level_high);
+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 c440e60..6ab288a 100644
--- a/src/glib-helper.c
+++ b/src/glib-helper.c
@@ -520,9 +520,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 sec_level_high,
bt_destroy_t destroy)
{
struct gattrib_context *ctxt;
+ BtIOSecLevel sec_level;
GIOChannel *io;
GError *gerr = NULL;
@@ -536,19 +538,25 @@ int bt_discover_primary(const bdaddr_t *src, const bdaddr_t *dst, int psm,
ctxt->cb = cb;
ctxt->destroy = destroy;
+ if (sec_level_high == 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, &gerr,
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, &gerr,
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 10718bb..9cac915 100644
--- a/src/glib-helper.h
+++ b/src/glib-helper.h
@@ -35,6 +35,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 sec_level_high,
bt_destroy_t destroy);
gchar *bt_uuid2string(uuid_t *uuid);
--
1.7.3.3
^ permalink raw reply related
* Re: [PATCH 1/2] Move EIR flags definitions to adapter.c
From: Bruna Moreira @ 2010-12-20 20:10 UTC (permalink / raw)
To: Gustavo F. Padovan; +Cc: linux-bluetooth
In-Reply-To: <20101220185421.GA553@vigoh>
Hi Gustavo,
On Mon, Dec 20, 2010 at 2:54 PM, Gustavo F. Padovan
<padovan@profusion.mobi> wrote:
> Hi Bruna,
>
> * Bruna Moreira <bruna.moreira@openbossa.org> [2010-12-20 14:16:44 -0400]:
>
>> ---
>> src/adapter.c | 9 +++++++++
>> src/sdpd.h | 9 ---------
>> 2 files changed, 9 insertions(+), 9 deletions(-)
>
> What's the point on moving this? I supposed you were using these macros in the
> following patch but you're not.
>
It is only a cleanup patch. These macros are used just in adapter.c.
This patch is not related with the next one.
BR,
--
Bruna Moreira
Instituto Nokia de Tecnologia (INdT)
Manaus - Brazil
^ permalink raw reply
* Re: [PATCH 1/2] Move EIR flags definitions to adapter.c
From: Gustavo F. Padovan @ 2010-12-20 18:54 UTC (permalink / raw)
To: Bruna Moreira; +Cc: linux-bluetooth
In-Reply-To: <1292869005-12391-1-git-send-email-bruna.moreira@openbossa.org>
Hi Bruna,
* Bruna Moreira <bruna.moreira@openbossa.org> [2010-12-20 14:16:44 -0400]:
> ---
> src/adapter.c | 9 +++++++++
> src/sdpd.h | 9 ---------
> 2 files changed, 9 insertions(+), 9 deletions(-)
What's the point on moving this? I supposed you were using these macros in the
following patch but you're not.
--
Gustavo F. Padovan
http://profusion.mobi
^ permalink raw reply
* [PATCH 2/2] Remove le_advertising_info struct from adapter.c
From: Bruna Moreira @ 2010-12-20 18:16 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Bruna Moreira
In-Reply-To: <1292869005-12391-1-git-send-email-bruna.moreira@openbossa.org>
---
src/adapter.c | 13 ++++---------
src/adapter.h | 6 +++---
src/event.c | 6 +++++-
3 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index db3649f..5cdf4c2 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2763,23 +2763,18 @@ static void remove_same_uuid(gpointer data, gpointer user_data)
}
void adapter_update_device_from_info(struct btd_adapter *adapter,
- le_advertising_info *info,
- char *name, GSList *services,
- uint8_t flags)
+ bdaddr_t bdaddr, int8_t rssi,
+ uint8_t evt_type, char *name,
+ GSList *services, uint8_t flags)
{
struct remote_dev_info *dev;
- bdaddr_t bdaddr;
gboolean new_dev;
- int8_t rssi;
-
- rssi = *(info->data + info->length);
- bdaddr = info->bdaddr;
dev = get_found_dev(adapter, &bdaddr, &new_dev);
if (new_dev) {
dev->le = TRUE;
- dev->evt_type = info->evt_type;
+ dev->evt_type = evt_type;
} else if (dev->rssi == rssi)
return;
diff --git a/src/adapter.h b/src/adapter.h
index a390088..039c30b 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -136,9 +136,9 @@ int adapter_get_discover_type(struct btd_adapter *adapter);
struct remote_dev_info *adapter_search_found_devices(struct btd_adapter *adapter,
struct remote_dev_info *match);
void adapter_update_device_from_info(struct btd_adapter *adapter,
- le_advertising_info *info,
- char *name, GSList *services,
- uint8_t flags);
+ bdaddr_t bdaddr, int8_t rssi,
+ uint8_t evt_type, char *name,
+ GSList *services, uint8_t flags);
void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
int8_t rssi, uint32_t class, const char *name,
const char *alias, gboolean legacy,
diff --git a/src/event.c b/src/event.c
index 3603643..55a83c2 100644
--- a/src/event.c
+++ b/src/event.c
@@ -435,6 +435,7 @@ void btd_event_advertising_report(bdaddr_t *local, le_advertising_info *info)
{
struct btd_adapter *adapter;
struct eir_data eir_data;
+ int8_t rssi;
int err;
adapter = manager_find_adapter(local);
@@ -450,7 +451,10 @@ void btd_event_advertising_report(bdaddr_t *local, le_advertising_info *info)
error("Error parsing advertising data: %s (%d)",
strerror(-err), -err);
- adapter_update_device_from_info(adapter, info, eir_data.name,
+ rssi = *(info->data + info->length);
+
+ adapter_update_device_from_info(adapter, info->bdaddr, rssi,
+ info->evt_type, eir_data.name,
eir_data.services, eir_data.flags);
}
--
1.7.0.4
^ permalink raw reply related
* [PATCH 1/2] Move EIR flags definitions to adapter.c
From: Bruna Moreira @ 2010-12-20 18:16 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Bruna Moreira
---
src/adapter.c | 9 +++++++++
src/sdpd.h | 9 ---------
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index 669a0ac..db3649f 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -56,6 +56,15 @@
#include "agent.h"
#include "storage.h"
+/* Flags Descriptions */
+#define EIR_LIM_DISC 0x01 /* LE Limited Discoverable Mode */
+#define EIR_GEN_DISC 0x02 /* LE General Discoverable Mode */
+#define EIR_BREDR_UNSUP 0x04 /* BR/EDR Not Supported */
+#define EIR_SIM_CONTROLLER 0x08 /* Simultaneous LE and BR/EDR to Same
+ Device Capable (Controller) */
+#define EIR_SIM_HOST 0x10 /* Simultaneous LE and BR/EDR to Same
+ Device Capable (Host) */
+
#define ADV_TYPE_IND 0x00
#define ADV_TYPE_DIRECT_IND 0x01
diff --git a/src/sdpd.h b/src/sdpd.h
index 98e5b20..dc7a256 100644
--- a/src/sdpd.h
+++ b/src/sdpd.h
@@ -48,15 +48,6 @@
#define EIR_TX_POWER 0x0A /* transmit power level */
#define EIR_DEVICE_ID 0x10 /* device ID */
-/* Flags Descriptions */
-#define EIR_LIM_DISC 0x01 /* LE Limited Discoverable Mode */
-#define EIR_GEN_DISC 0x02 /* LE General Discoverable Mode */
-#define EIR_BREDR_UNSUP 0x04 /* BR/EDR Not Supported */
-#define EIR_SIM_CONTROLLER 0x08 /* Simultaneous LE and BR/EDR to Same
- Device Capable (Controller) */
-#define EIR_SIM_HOST 0x10 /* Simultaneous LE and BR/EDR to Same
- Device Capable (Host) */
-
typedef struct request {
bdaddr_t device;
bdaddr_t bdaddr;
--
1.7.0.4
^ permalink raw reply related
* Re: [PATCH 2/3] Fix tools UI to avoid program launch mistakes.
From: Johan Hedberg @ 2010-12-20 15:41 UTC (permalink / raw)
To: Michal Labedzki; +Cc: linux-bluetooth
In-Reply-To: <1292840029-27770-3-git-send-email-michal.labedzki@tieto.com>
Hi Michal,
On Mon, Dec 20, 2010, Michal Labedzki wrote:
> hciconfig: warrning user on unknown commands
> hcitool: return error on unknown command in hcitool
> fix length size in comparision to avoid ambiguity commands
> check if command number of arguments is correct
> ---
> tools/hciconfig.c | 10 ++-
> tools/hcitool.c | 201 ++++++++++++++++------------------------------------
> 2 files changed, 70 insertions(+), 141 deletions(-)
This patch has been pushed upstream. Thanks.
Johan
^ 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