* [PATCH] Change OPUSH sdp record when use sdptool for GOEP v2.0.
From: nami @ 2011-05-18 9:27 UTC (permalink / raw)
To: linux-bluetooth; +Cc: nami
---
lib/sdp.h | 5 +++++
tools/sdptool.c | 11 ++++++++++-
2 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/lib/sdp.h b/lib/sdp.h
index 5f7d271..bb217a5 100644
--- a/lib/sdp.h
+++ b/lib/sdp.h
@@ -312,6 +312,11 @@ extern "C" {
#define SDP_ATTR_HID_BOOT_DEVICE 0x020e
/*
+ * GoepL2capPsm attribute is added on GOEP v2.0 and later
+ */
+ #define SDP_ATTR_GOEP_L2CAP_PSM 0x0200
+
+/*
* These identifiers are based on the SDP spec stating that
* "base attribute id of the primary (universal) language must be 0x0100"
*
diff --git a/tools/sdptool.c b/tools/sdptool.c
index 140a46a..1b2117a 100644
--- a/tools/sdptool.c
+++ b/tools/sdptool.c
@@ -1752,6 +1752,8 @@ static int add_opush(sdp_session_t *session, svc_info_t *si)
uint8_t dtd = SDP_UINT8;
sdp_data_t *sflist;
int ret = 0;
+ uint16_t psm = si->psm ? si->psm : 0x1015;
+ sdp_data_t *l2cappsm;
memset(&record, 0, sizeof(sdp_record_t));
record.handle = si->handle;
@@ -1765,7 +1767,9 @@ static int add_opush(sdp_session_t *session, svc_info_t *si)
sdp_set_service_classes(&record, svclass_id);
sdp_uuid16_create(&profile[0].uuid, OBEX_OBJPUSH_PROFILE_ID);
- profile[0].version = 0x0100;
+ /* The profile version number in the BluetoothProfileDescriptorList attribute
+ shall be incremented for GOEPv2.0 and later. */
+ profile[0].version = 0x0102;
pfseq = sdp_list_append(0, profile);
sdp_set_profile_descs(&record, pfseq);
@@ -1795,6 +1799,10 @@ static int add_opush(sdp_session_t *session, svc_info_t *si)
sdp_set_info_attr(&record, "OBEX Object Push", 0, 0);
+ /* The SDP records shall include the GoepL2capPsm attribute for GOEPv2.0 and later. */
+ l2cappsm = sdp_data_alloc (SDP_UINT16, &psm);
+ sdp_attr_add (&record, SDP_ATTR_GOEP_L2CAP_PSM, l2cappsm);
+
if (sdp_device_record_register(session, &interface, &record, SDP_RECORD_PERSIST) < 0) {
printf("Service Record registration failed\n");
ret = -1;
@@ -1805,6 +1813,7 @@ static int add_opush(sdp_session_t *session, svc_info_t *si)
end:
sdp_data_free(channel);
+ sdp_data_free(l2cappsm);
sdp_list_free(proto[0], 0);
sdp_list_free(proto[1], 0);
sdp_list_free(proto[2], 0);
--
1.7.1
^ permalink raw reply related
* [PATCH v2] Fix incorrect number of expected columns in a response to NEW_MISSED_CALLS_LIST
From: Slawomir Bochenski @ 2011-05-18 9:17 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Slawomir Bochenski
In-Reply-To: <1305710013-31563-1-git-send-email-lkslawek@gmail.com>
This fixes error "GLIB CRITICAL ** Tracker -
tracker_db_cursor_get_value_type: assertion `column < n_columns' failed"
occurring when pulling phone book or doing listing for missed calls. The
number of expected columns in reply to NEW_MISSED_CALLS_LIST query was
incorrectly set to PULL_QUERY_COL_AMOUNT (23) but the query actually
returns 3 columns.
---
Just a little modification of a commit message.
plugins/phonebook-tracker.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/plugins/phonebook-tracker.c b/plugins/phonebook-tracker.c
index 9431d8a..8da8b80 100644
--- a/plugins/phonebook-tracker.c
+++ b/plugins/phonebook-tracker.c
@@ -49,6 +49,7 @@
#define ADDR_FIELD_AMOUNT 7
#define PULL_QUERY_COL_AMOUNT 23
#define COUNT_QUERY_COL_AMOUNT 1
+#define NEW_MISSED_CALLS_COL_AMOUNT 3
#define COL_PHONE_AFF 0 /* work/home phone numbers */
#define COL_FULL_NAME 1
@@ -2029,7 +2030,7 @@ int phonebook_pull_read(void *request)
if (g_strcmp0(data->req_name, "/telecom/mch.vcf") == 0) {
query = NEW_MISSED_CALLS_LIST;
- col_amount = PULL_QUERY_COL_AMOUNT;
+ col_amount = NEW_MISSED_CALLS_COL_AMOUNT;
pull_cb = pull_newmissedcalls;
} else if (data->params->maxlistcount == 0) {
query = name2count_query(data->req_name);
--
1.7.4.1
^ permalink raw reply related
* [PATCH] Fix incorrect number of expected columns in a response to NEW_MISSED_CALLS_LIST
From: Slawomir Bochenski @ 2011-05-18 9:13 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Slawomir Bochenski
This fixes error "GLIB CRITICAL ** Tracker -
tracker_db_cursor_get_value_type: assertion `column < n_columns' failed"
occurring when pulling phone book or doing listing for missed calls. The
number of expected columns in reply to NEW_MISSED_CALLS_LIST query was
incorrectly set PULL_QUERY_CALL_AMOUNT (23) but the query actually
returns 3 columns.
---
plugins/phonebook-tracker.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/plugins/phonebook-tracker.c b/plugins/phonebook-tracker.c
index 9431d8a..8da8b80 100644
--- a/plugins/phonebook-tracker.c
+++ b/plugins/phonebook-tracker.c
@@ -49,6 +49,7 @@
#define ADDR_FIELD_AMOUNT 7
#define PULL_QUERY_COL_AMOUNT 23
#define COUNT_QUERY_COL_AMOUNT 1
+#define NEW_MISSED_CALLS_COL_AMOUNT 3
#define COL_PHONE_AFF 0 /* work/home phone numbers */
#define COL_FULL_NAME 1
@@ -2029,7 +2030,7 @@ int phonebook_pull_read(void *request)
if (g_strcmp0(data->req_name, "/telecom/mch.vcf") == 0) {
query = NEW_MISSED_CALLS_LIST;
- col_amount = PULL_QUERY_COL_AMOUNT;
+ col_amount = NEW_MISSED_CALLS_COL_AMOUNT;
pull_cb = pull_newmissedcalls;
} else if (data->params->maxlistcount == 0) {
query = name2count_query(data->req_name);
--
1.7.4.1
^ permalink raw reply related
* bluez patch : Modify OPUSH sdp record when use sdptool for GOEP v2.0
From: hui li @ 2011-05-18 9:03 UTC (permalink / raw)
To: linux-bluetooth
Cc: haijun.liu, steven.li, ruiyi.zhang, yang.wu, costa.yao, nami.li
Hi, all
Since GOEP v2.0 has some changes in sdp record, I`d like to add the
two changes in bluez for backwards compatibility with GOEP v1.x:
• The profile version number in the BluetoothProfileDescriptorList
attribute shall be incremented to match the version number of the
enhanced profile specification. If earlier versions of the profile do
not include this SDP attribute it shall be included in revised
versions.
• The SDP records shall include the GoepL2capPsm attribute.
The upper text references Generic Object Exchange Profile v2.0.
The GoepL2capPsm attribute value can be found in Bluetooth SIG
Assigned Numbers – Service Discovery, and this value is 0x0200.
My patch only define GoepL2capPsm and change OPUSH sdp record in
sdptool. I didn`t assign a new variable in svc_info_t struct to
indicate the new l2cap psm value, I used its original psm member to
indicate l2cap psm value.
Also, I didn`t found OPUSH l2cap psm default value in Bluetooth SIG
Assigned Numbers or its spec, so I just choose 0x1015 as its default
value.
I will send my patch later.
Best wishes.
Nami
^ permalink raw reply
* [PATCH v2 2/2] Fix empty parameter list in usage() declaration
From: Szymon Janc @ 2011-05-18 6:42 UTC (permalink / raw)
To: linux-bluetooth; +Cc: par-gunnar.p.hjalmdahl, Szymon Janc
In-Reply-To: <1305700967-13217-1-git-send-email-szymon.janc@tieto.com>
---
sbc/sbctester.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/sbc/sbctester.c b/sbc/sbctester.c
index b1e3608..c08c22a 100644
--- a/sbc/sbctester.c
+++ b/sbc/sbctester.c
@@ -245,7 +245,7 @@ static int check_absolute_diff(SNDFILE * sndref, SF_INFO * infosref,
return verdict;
}
-static void usage()
+static void usage(void)
{
printf("SBC conformance test ver %s\n", VERSION);
printf("Copyright (c) 2007-2010 Marcel Holtmann\n");
--
on behalf of ST-Ericsson
^ permalink raw reply related
* [PATCH v2 1/2] Fix empty parameter list in functions declarations
From: Szymon Janc @ 2011-05-18 6:42 UTC (permalink / raw)
To: linux-bluetooth; +Cc: par-gunnar.p.hjalmdahl, Szymon Janc
---
lib/sdp.c | 2 +-
src/log.c | 2 +-
src/log.h | 2 +-
src/sdpd-database.c | 2 +-
test/avtest.c | 2 +-
tools/avinfo.c | 2 +-
6 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/lib/sdp.c b/lib/sdp.c
index 2425b1e..a48ee14 100644
--- a/lib/sdp.c
+++ b/lib/sdp.c
@@ -3111,7 +3111,7 @@ int sdp_record_update(sdp_session_t *session, const sdp_record_t *rec)
return sdp_device_record_update(session, BDADDR_ANY, rec);
}
-sdp_record_t *sdp_record_alloc()
+sdp_record_t *sdp_record_alloc(void)
{
sdp_record_t *rec = malloc(sizeof(sdp_record_t));
diff --git a/src/log.c b/src/log.c
index 494ff5d..6fbbba9 100644
--- a/src/log.c
+++ b/src/log.c
@@ -86,7 +86,7 @@ static gboolean is_enabled(struct btd_debug_desc *desc)
return 0;
}
-void __btd_toggle_debug()
+void __btd_toggle_debug(void)
{
struct btd_debug_desc *desc;
diff --git a/src/log.h b/src/log.h
index 14e9bfd..78bbdd8 100644
--- a/src/log.h
+++ b/src/log.h
@@ -28,7 +28,7 @@ void btd_debug(const char *format, ...) __attribute__((format(printf, 1, 2)));
void __btd_log_init(const char *debug, int detach);
void __btd_log_cleanup(void);
-void __btd_toggle_debug();
+void __btd_toggle_debug(void);
struct btd_debug_desc {
const char *file;
diff --git a/src/sdpd-database.c b/src/sdpd-database.c
index 08f542f..dd492bf 100644
--- a/src/sdpd-database.c
+++ b/src/sdpd-database.c
@@ -90,7 +90,7 @@ static void access_free(void *p)
/*
* Reset the service repository by deleting its contents
*/
-void sdp_svcdb_reset()
+void sdp_svcdb_reset(void)
{
sdp_list_free(service_db, (sdp_free_func_t) sdp_record_free);
sdp_list_free(access_db, access_free);
diff --git a/test/avtest.c b/test/avtest.c
index 168326f..541b3cd 100644
--- a/test/avtest.c
+++ b/test/avtest.c
@@ -714,7 +714,7 @@ static void do_avctp_send(int sk, int invalid)
dump_avctp_header(hdr);
}
-static void usage()
+static void usage(void)
{
printf("avtest - Audio/Video testing ver %s\n", VERSION);
printf("Usage:\n"
diff --git a/tools/avinfo.c b/tools/avinfo.c
index 7f76c03..63b0da6 100644
--- a/tools/avinfo.c
+++ b/tools/avinfo.c
@@ -604,7 +604,7 @@ static int l2cap_connect(bdaddr_t *src, bdaddr_t *dst)
return sk;
}
-static void usage()
+static void usage(void)
{
printf("avinfo - Audio/Video Info Tool ver %s\n", VERSION);
printf("Usage:\n"
--
on behalf of ST-Ericsson
^ permalink raw reply related
* GSOC Introduction
From: Jakub Adamek @ 2011-05-17 23:01 UTC (permalink / raw)
To: linux-bluetooth
Hi,
my name is Jakub Adamek. I study at the Jagiellonian University in Krakow,
Poland. My project for GSOC is to implement the Basic Imaging Profile in obexd.
Thus far I've read the BIP specification and implementation guidelines and
a large part of the existing code. BIP has some needs that aren't provided by the
existing code, so I'm currently working out the best way to adapt it to be able to use
it.
Coding will ensue as of 23.05, slowly at first due to university work,
but will gain full speed around 15.06 with the end of my classes.
Cheers,
Jakub Adamek
^ permalink raw reply
* Re: [PATCH 02/12] Bluetooth: LE advertising cache
From: Gustavo F. Padovan @ 2011-05-17 18:43 UTC (permalink / raw)
To: Andre Guedes; +Cc: linux-bluetooth
In-Reply-To: <BANLkTikDg2B0-=TyLAg4AriupRZEsr9OqA@mail.gmail.com>
* Andre Guedes <andre.guedes@openbossa.org> [2011-05-17 15:22:31 -0300]:
> Hi Gustavo,
>
> On Fri, May 13, 2011 at 4:33 PM, Gustavo F. Padovan
> <padovan@profusion.mobi> wrote:
> > Hi Andre,
> >
> > * Andre Guedes <andre.guedes@openbossa.org> [2011-05-06 14:05:11 -0300]:
> >
> >> This patch implements the LE advertising cache. It stores sensitive
> >> information (bdaddr and bdaddr_type so far) gathered from LE
> >> advertising report events.
> >>
> >> Only advertising entries from connectables devices are added to the
> >> cache.
> >>
> >> Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
> >> ---
> >> include/net/bluetooth/hci_core.h | 13 +++++++
> >> net/bluetooth/hci_core.c | 74 ++++++++++++++++++++++++++++++++++++++
> >> 2 files changed, 87 insertions(+), 0 deletions(-)
> >>
> >> diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
> >> index 14cc324..65135f8 100644
> >> --- a/include/net/bluetooth/hci_core.h
> >> +++ b/include/net/bluetooth/hci_core.h
> >> @@ -89,6 +89,12 @@ struct oob_data {
> >> u8 randomizer[16];
> >> };
> >>
> >> +struct adv_entry {
> >> + struct list_head list;
> >> + bdaddr_t bdaddr;
> >> + u8 bdaddr_type;
> >> +};
> >> +
> >> #define NUM_REASSEMBLY 4
> >> struct hci_dev {
> >> struct list_head list;
> >> @@ -181,6 +187,8 @@ struct hci_dev {
> >>
> >> struct list_head remote_oob_data;
> >>
> >> + struct list_head adv_entries;
> >> +
> >> struct hci_dev_stats stat;
> >>
> >> struct sk_buff_head driver_init;
> >> @@ -526,6 +534,11 @@ int hci_add_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *hash,
> >> u8 *randomizer);
> >> int hci_remove_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr);
> >>
> >> +int hci_adv_entries_clear(struct hci_dev *hdev);
> >> +struct adv_entry *hci_find_adv_entry(struct hci_dev *hdev, bdaddr_t *bdaddr);
> >> +int hci_add_adv_entry(struct hci_dev *hdev,
> >> + struct hci_ev_le_advertising_info *ev);
> >
> > Rename this to hci_adv_add_entry()
> >
>
> 'adv_entry' is the element of the list. So, to follow the standard IMO
> we should keep the name hci_add_adv_entry(). See others functions
> like hci_add_link_key() and hci_add_remote_oob_data().
Fair enough. Keep it hci_add_adv_entry()
--
Gustavo F. Padovan
http://profusion.mobi
^ permalink raw reply
* [PATCH v4 12/12] Drop variable EIR length
From: Claudio Takahasi @ 2011-05-17 18:26 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Bruna Moreira
In-Reply-To: <1305579001-3019-12-git-send-email-claudio.takahasi@openbossa.org>
From: Bruna Moreira <bruna.moreira@openbossa.org>
The functions eir_parse() and adapter_update_found_devices() now
assume that the EIR buffer has always 240 octets. For advertising
reports, the advertising data is stored on a buffer with 240 bytes,
padded with zeroes.
---
plugins/hciops.c | 13 +++++++++----
src/adapter.c | 6 +++---
src/adapter.h | 4 ++--
src/eir.c | 8 ++++----
src/eir.h | 2 +-
src/event.c | 3 +--
6 files changed, 20 insertions(+), 16 deletions(-)
diff --git a/plugins/hciops.c b/plugins/hciops.c
index 65ad4f3..9b1225c 100644
--- a/plugins/hciops.c
+++ b/plugins/hciops.c
@@ -2171,7 +2171,7 @@ static inline void le_advertising_report(int index, evt_le_meta_event *meta)
{
struct dev_info *dev = &devs[index];
le_advertising_info *info;
- uint8_t num_reports, rssi;
+ uint8_t num_reports, rssi, eir[HCI_MAX_EIR_LENGTH];
const uint8_t RSSI_SIZE = 1;
num_reports = meta->data[0];
@@ -2179,8 +2179,10 @@ static inline void le_advertising_report(int index, evt_le_meta_event *meta)
info = (le_advertising_info *) &meta->data[1];
rssi = *(info->data + info->length);
- btd_event_device_found(&dev->bdaddr, &info->bdaddr, 0, rssi,
- info->data);
+ memset(eir, 0, sizeof(eir));
+ memcpy(eir, info->data, info->length);
+
+ btd_event_device_found(&dev->bdaddr, &info->bdaddr, 0, rssi, eir);
num_reports--;
@@ -2189,8 +2191,11 @@ static inline void le_advertising_report(int index, evt_le_meta_event *meta)
RSSI_SIZE);
rssi = *(info->data + info->length);
+ memset(eir, 0, sizeof(eir));
+ memcpy(eir, info->data, info->length);
+
btd_event_device_found(&dev->bdaddr, &info->bdaddr, 0, rssi,
- info->data);
+ eir);
}
}
diff --git a/src/adapter.c b/src/adapter.c
index e8fa8e0..8a4fef3 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2994,8 +2994,8 @@ static char *read_stored_data(bdaddr_t *local, bdaddr_t *peer, const char *file)
}
void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
- uint32_t class, int8_t rssi,
- uint8_t *data, size_t eir_size)
+ uint32_t class, int8_t rssi,
+ uint8_t *data)
{
struct remote_dev_info *dev, match;
struct eir_data eir_data;
@@ -3005,7 +3005,7 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
int err;
memset(&eir_data, 0, sizeof(eir_data));
- err = eir_parse(&eir_data, data, HCI_MAX_EIR_LENGTH);
+ err = eir_parse(&eir_data, data);
if (err < 0) {
error("Error parsing EIR data: %s (%d)", strerror(-err), -err);
return;
diff --git a/src/adapter.h b/src/adapter.h
index 4c07e92..3526849 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -109,8 +109,8 @@ 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_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
- uint32_t class, int8_t rssi,
- uint8_t *data, size_t eir_size);
+ uint32_t class, int8_t rssi,
+ uint8_t *data);
int adapter_remove_found_device(struct btd_adapter *adapter, bdaddr_t *bdaddr);
void adapter_emit_device_found(struct btd_adapter *adapter,
struct remote_dev_info *dev);
diff --git a/src/eir.c b/src/eir.c
index 7dfc444..01b6ac5 100644
--- a/src/eir.c
+++ b/src/eir.c
@@ -52,7 +52,7 @@ void eir_data_free(struct eir_data *eir)
g_free(eir->name);
}
-int eir_parse(struct eir_data *eir, uint8_t *eir_data, size_t eir_length)
+int eir_parse(struct eir_data *eir, uint8_t *eir_data)
{
uint16_t len = 0;
size_t total;
@@ -69,10 +69,10 @@ int eir_parse(struct eir_data *eir, uint8_t *eir_data, size_t eir_length)
eir->flags = -1;
/* No EIR data to parse */
- if (eir_data == NULL || eir_length == 0)
+ if (eir_data == NULL)
return 0;
- while (len < eir_length - 1) {
+ while (len < HCI_MAX_EIR_LENGTH - 1) {
uint8_t field_len = eir_data[0];
/* Check for the end of EIR */
@@ -115,7 +115,7 @@ int eir_parse(struct eir_data *eir, uint8_t *eir_data, size_t eir_length)
}
/* Bail out if got incorrect length */
- if (len > eir_length)
+ if (len > HCI_MAX_EIR_LENGTH)
return -EINVAL;
total = uuid16_count + uuid32_count + uuid128_count;
diff --git a/src/eir.h b/src/eir.h
index ea38570..d225973 100644
--- a/src/eir.h
+++ b/src/eir.h
@@ -35,7 +35,7 @@ struct eir_data {
};
void eir_data_free(struct eir_data *eir);
-int eir_parse(struct eir_data *eir, uint8_t *eir_data, size_t eir_length);
+int eir_parse(struct eir_data *eir, uint8_t *eir_data);
void eir_create(const char *name, int8_t tx_power, uint16_t did_vendor,
uint16_t did_product, uint16_t did_version,
GSList *uuids, uint8_t *data);
diff --git a/src/event.c b/src/event.c
index e28afa3..2643a87 100644
--- a/src/event.c
+++ b/src/event.c
@@ -320,8 +320,7 @@ void btd_event_device_found(bdaddr_t *local, bdaddr_t *peer, uint32_t class,
if (data)
write_remote_eir(local, peer, data);
- adapter_update_found_devices(adapter, peer, class, rssi,
- data, HCI_MAX_EIR_LENGTH);
+ adapter_update_found_devices(adapter, peer, class, rssi, data);
}
void btd_event_set_legacy_pairing(bdaddr_t *local, bdaddr_t *peer,
--
1.7.5.rc3
^ permalink raw reply related
* [PATCH v4 11/12] Replace EIR_DATA_LENGTH with HCI_MAX_EIR_LENGTH
From: Claudio Takahasi @ 2011-05-17 18:26 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Bruna Moreira
In-Reply-To: <1305579001-3019-11-git-send-email-claudio.takahasi@openbossa.org>
From: Bruna Moreira <bruna.moreira@openbossa.org>
Both defines have the same value (240) and meaning.
---
src/adapter.c | 2 +-
src/eir.c | 9 +++++----
src/eir.h | 2 --
src/event.c | 2 +-
4 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index ff2b484..e8fa8e0 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -3005,7 +3005,7 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
int err;
memset(&eir_data, 0, sizeof(eir_data));
- err = eir_parse(&eir_data, data, EIR_DATA_LENGTH);
+ err = eir_parse(&eir_data, data, HCI_MAX_EIR_LENGTH);
if (err < 0) {
error("Error parsing EIR data: %s (%d)", strerror(-err), -err);
return;
diff --git a/src/eir.c b/src/eir.c
index 2fbd919..7dfc444 100644
--- a/src/eir.c
+++ b/src/eir.c
@@ -27,6 +27,7 @@
#include <glib.h>
#include <bluetooth/bluetooth.h>
+#include <bluetooth/hci.h>
#include <bluetooth/sdp.h>
#include "glib-helper.h"
@@ -184,7 +185,7 @@ static void eir_generate_uuid128(GSList *list, uint8_t *ptr, uint16_t *eir_len)
continue;
/* Stop if not enough space to put next UUID128 */
- if ((len + 2 + SIZEOF_UUID128) > EIR_DATA_LENGTH) {
+ if ((len + 2 + SIZEOF_UUID128) > HCI_MAX_EIR_LENGTH) {
truncated = TRUE;
break;
}
@@ -229,7 +230,7 @@ void eir_create(const char *name, int8_t tx_power, uint16_t did_vendor,
GSList *l;
uint8_t *ptr = data;
uint16_t eir_len = 0;
- uint16_t uuid16[EIR_DATA_LENGTH / 2];
+ uint16_t uuid16[HCI_MAX_EIR_LENGTH / 2];
int i, uuid_count = 0;
gboolean truncated = FALSE;
size_t name_len;
@@ -289,7 +290,7 @@ void eir_create(const char *name, int8_t tx_power, uint16_t did_vendor,
continue;
/* Stop if not enough space to put next UUID16 */
- if ((eir_len + 2 + sizeof(uint16_t)) > EIR_DATA_LENGTH) {
+ if ((eir_len + 2 + sizeof(uint16_t)) > HCI_MAX_EIR_LENGTH) {
truncated = TRUE;
break;
}
@@ -322,6 +323,6 @@ void eir_create(const char *name, int8_t tx_power, uint16_t did_vendor,
}
/* Group all UUID128 types */
- if (eir_len <= EIR_DATA_LENGTH - 2)
+ if (eir_len <= HCI_MAX_EIR_LENGTH - 2)
eir_generate_uuid128(uuids, ptr, &eir_len);
}
diff --git a/src/eir.h b/src/eir.h
index aacd16a..ea38570 100644
--- a/src/eir.h
+++ b/src/eir.h
@@ -22,8 +22,6 @@
*
*/
-#define EIR_DATA_LENGTH 240
-
struct uuid_info {
uuid_t uuid;
uint8_t svc_hint;
diff --git a/src/event.c b/src/event.c
index 3ee8802..e28afa3 100644
--- a/src/event.c
+++ b/src/event.c
@@ -321,7 +321,7 @@ void btd_event_device_found(bdaddr_t *local, bdaddr_t *peer, uint32_t class,
write_remote_eir(local, peer, data);
adapter_update_found_devices(adapter, peer, class, rssi,
- data, EIR_DATA_LENGTH);
+ data, HCI_MAX_EIR_LENGTH);
}
void btd_event_set_legacy_pairing(bdaddr_t *local, bdaddr_t *peer,
--
1.7.5.rc3
^ permalink raw reply related
* [PATCH v4 10/12] Cleanup inserting new device found entry
From: Claudio Takahasi @ 2011-05-17 18:26 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1305579001-3019-10-git-send-email-claudio.takahasi@openbossa.org>
---
src/adapter.c | 97 +++++++++++++++++++++++++++-----------------------------
1 files changed, 47 insertions(+), 50 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index 1a49fb0..ff2b484 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2914,29 +2914,24 @@ void adapter_emit_device_found(struct btd_adapter *adapter,
g_free(alias);
}
-static struct remote_dev_info *get_found_dev(struct btd_adapter *adapter,
- const bdaddr_t *bdaddr,
- gboolean *new_dev)
+static struct remote_dev_info *found_device_new(const bdaddr_t *bdaddr,
+ gboolean le, const char *name,
+ const char *alias, uint32_t class,
+ gboolean legacy, name_status_t status,
+ int flags)
{
- struct remote_dev_info *dev, match;
+ struct remote_dev_info *dev;
- memset(&match, 0, sizeof(struct remote_dev_info));
- bacpy(&match.bdaddr, bdaddr);
- match.name_status = NAME_ANY;
-
- dev = adapter_search_found_devices(adapter, &match);
- if (dev) {
- *new_dev = FALSE;
- /* Out of range list update */
- adapter->oor_devices = g_slist_remove(adapter->oor_devices,
- dev);
- } else {
- *new_dev = TRUE;
- dev = g_new0(struct remote_dev_info, 1);
- bacpy(&dev->bdaddr, bdaddr);
- adapter->found_devices = g_slist_prepend(adapter->found_devices,
- dev);
- }
+ dev = g_new0(struct remote_dev_info, 1);
+ bacpy(&dev->bdaddr, bdaddr);
+ dev->le = le;
+ dev->name = g_strdup(name);
+ dev->alias = g_strdup(alias);
+ dev->class = class;
+ dev->legacy = legacy;
+ dev->name_status = status;
+ if (flags >= 0)
+ dev->flags = flags;
return dev;
}
@@ -3002,11 +2997,11 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
uint32_t class, int8_t rssi,
uint8_t *data, size_t eir_size)
{
- struct remote_dev_info *dev;
+ struct remote_dev_info *dev, match;
struct eir_data eir_data;
- char *name;
- gboolean new_dev, legacy, le;
- name_status_t name_status = NAME_NOT_REQUIRED;
+ char *alias, *name;
+ gboolean legacy, le;
+ name_status_t name_status;
int err;
memset(&eir_data, 0, sizeof(eir_data));
@@ -3019,6 +3014,25 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
if (eir_data.name != NULL && eir_data.name_complete)
write_device_name(&adapter->bdaddr, bdaddr, eir_data.name);
+ /* Device already seen in the discovery session ? */
+ memset(&match, 0, sizeof(struct remote_dev_info));
+ bacpy(&match.bdaddr, bdaddr);
+ match.name_status = NAME_ANY;
+
+ dev = adapter_search_found_devices(adapter, &match);
+ if (dev) {
+ adapter->oor_devices = g_slist_remove(adapter->oor_devices,
+ dev);
+ if (dev->rssi != rssi)
+ goto done;
+
+ eir_data_free(&eir_data);
+
+ return;
+ }
+
+ /* New device in the discovery session */
+
name = read_stored_data(&adapter->bdaddr, bdaddr, "names");
if (eir_data.flags < 0) {
@@ -3036,34 +3050,19 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
} else {
le = TRUE;
legacy = FALSE;
+ name_status = NAME_NOT_REQUIRED;
}
- dev = get_found_dev(adapter, bdaddr, &new_dev);
-
- if (new_dev) {
- const char *dev_name = (name ? name : eir_data.name);
- char *alias;
+ alias = read_stored_data(&adapter->bdaddr, bdaddr, "aliases");
- if (dev_name)
- dev->name = g_strdup(dev_name);
-
- alias = read_stored_data(&adapter->bdaddr, bdaddr, "aliases");
- if (alias) {
- dev->alias = g_strdup(alias);
- free(alias);
- }
-
- dev->le = FALSE;
- dev->class = class;
- dev->legacy = legacy;
- dev->name_status = name_status;
+ dev = found_device_new(bdaddr, le, name, alias, class, legacy,
+ name_status, eir_data.flags);
+ free(name);
+ free(alias);
- if (eir_data.flags >= 0)
- dev->flags = eir_data.flags;
-
- } else if (dev->rssi == rssi)
- goto done;
+ adapter->found_devices = g_slist_prepend(adapter->found_devices, dev);
+done:
dev->rssi = rssi;
adapter->found_devices = g_slist_sort(adapter->found_devices,
@@ -3074,8 +3073,6 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
adapter_emit_device_found(adapter, dev);
-done:
- free(name);
eir_data_free(&eir_data);
}
--
1.7.5.rc3
^ permalink raw reply related
* [PATCH v4 09/12] Change the order to write/read the remote's name
From: Claudio Takahasi @ 2011-05-17 18:26 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1305579001-3019-9-git-send-email-claudio.takahasi@openbossa.org>
When discovering, write the EIR "complete" name first before to read
the name. Only names retrieved from EIR "complete" name and HCI Remote
Name Request Complete event are stored. This patch doesn't change the
final result: the value of the name sent in the signal.
---
src/adapter.c | 19 +++++--------------
1 files changed, 5 insertions(+), 14 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index 9afb0d4..1a49fb0 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -3007,7 +3007,6 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
char *name;
gboolean new_dev, legacy, le;
name_status_t name_status = NAME_NOT_REQUIRED;
- const char *dev_name;
int err;
memset(&eir_data, 0, sizeof(eir_data));
@@ -3017,6 +3016,9 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
return;
}
+ if (eir_data.name != NULL && eir_data.name_complete)
+ write_device_name(&adapter->bdaddr, bdaddr, eir_data.name);
+
name = read_stored_data(&adapter->bdaddr, bdaddr, "names");
if (eir_data.flags < 0) {
@@ -3036,23 +3038,12 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
legacy = FALSE;
}
- /* Complete EIR names are always used. Shortened EIR names are only
- * used if there is no name already in storage. */
- dev_name = name;
- if (eir_data.name != NULL) {
- if (eir_data.name_complete) {
- write_device_name(&adapter->bdaddr, bdaddr,
- eir_data.name);
- name_status = NAME_NOT_REQUIRED;
- dev_name = eir_data.name;
- } else if (name == NULL)
- dev_name = eir_data.name;
- }
-
dev = get_found_dev(adapter, bdaddr, &new_dev);
if (new_dev) {
+ const char *dev_name = (name ? name : eir_data.name);
char *alias;
+
if (dev_name)
dev->name = g_strdup(dev_name);
--
1.7.5.rc3
^ permalink raw reply related
* [PATCH v4 08/12] Remove btd_event_advertising_report
From: Claudio Takahasi @ 2011-05-17 18:26 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Bruna Moreira
In-Reply-To: <1305579001-3019-8-git-send-email-claudio.takahasi@openbossa.org>
From: Bruna Moreira <bruna.moreira@openbossa.org>
Advertises should be notified using btd_event_device_found function
to keep the compatibility with mgmtops plugin.
---
plugins/hciops.c | 13 ++++++++++---
src/event.c | 17 -----------------
src/event.h | 1 -
3 files changed, 10 insertions(+), 21 deletions(-)
diff --git a/plugins/hciops.c b/plugins/hciops.c
index 07643a1..65ad4f3 100644
--- a/plugins/hciops.c
+++ b/plugins/hciops.c
@@ -2171,19 +2171,26 @@ static inline void le_advertising_report(int index, evt_le_meta_event *meta)
{
struct dev_info *dev = &devs[index];
le_advertising_info *info;
- uint8_t num_reports;
+ uint8_t num_reports, rssi;
const uint8_t RSSI_SIZE = 1;
num_reports = meta->data[0];
info = (le_advertising_info *) &meta->data[1];
- btd_event_advertising_report(&dev->bdaddr, info);
+ rssi = *(info->data + info->length);
+
+ btd_event_device_found(&dev->bdaddr, &info->bdaddr, 0, rssi,
+ info->data);
+
num_reports--;
while (num_reports--) {
info = (le_advertising_info *) (info->data + info->length +
RSSI_SIZE);
- btd_event_advertising_report(&dev->bdaddr, info);
+ rssi = *(info->data + info->length);
+
+ btd_event_device_found(&dev->bdaddr, &info->bdaddr, 0, rssi,
+ info->data);
}
}
diff --git a/src/event.c b/src/event.c
index 115b285..3ee8802 100644
--- a/src/event.c
+++ b/src/event.c
@@ -281,23 +281,6 @@ void btd_event_simple_pairing_complete(bdaddr_t *local, bdaddr_t *peer,
device_simple_pairing_complete(device, status);
}
-void btd_event_advertising_report(bdaddr_t *local, le_advertising_info *info)
-{
- struct btd_adapter *adapter;
- int8_t rssi;
-
- adapter = manager_find_adapter(local);
- if (adapter == NULL) {
- error("No matching adapter found");
- return;
- }
-
- rssi = *(info->data + info->length);
-
- adapter_update_found_devices(adapter, &info->bdaddr, 0, rssi,
- info->data, info->length);
-}
-
static void update_lastseen(bdaddr_t *sba, bdaddr_t *dba)
{
time_t t;
diff --git a/src/event.h b/src/event.h
index 005d8a7..22c199e 100644
--- a/src/event.h
+++ b/src/event.h
@@ -23,7 +23,6 @@
*/
int btd_event_request_pin(bdaddr_t *sba, bdaddr_t *dba);
-void btd_event_advertising_report(bdaddr_t *local, le_advertising_info *info);
void btd_event_device_found(bdaddr_t *local, bdaddr_t *peer, uint32_t class,
int8_t rssi, uint8_t *data);
void btd_event_set_legacy_pairing(bdaddr_t *local, bdaddr_t *peer, gboolean legacy);
--
1.7.5.rc3
^ permalink raw reply related
* [PATCH v4 07/12] Fix memory leak of EIR data
From: Claudio Takahasi @ 2011-05-17 18:26 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1305579001-3019-7-git-send-email-claudio.takahasi@openbossa.org>
---
src/adapter.c | 1 +
src/eir.c | 7 +++++++
src/eir.h | 1 +
3 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index c053d6c..9afb0d4 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -3085,6 +3085,7 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
done:
free(name);
+ eir_data_free(&eir_data);
}
int adapter_remove_found_device(struct btd_adapter *adapter, bdaddr_t *bdaddr)
diff --git a/src/eir.c b/src/eir.c
index d827c7e..2fbd919 100644
--- a/src/eir.c
+++ b/src/eir.c
@@ -44,6 +44,13 @@
#define EIR_TX_POWER 0x0A /* transmit power level */
#define EIR_DEVICE_ID 0x10 /* device ID */
+void eir_data_free(struct eir_data *eir)
+{
+ g_slist_foreach(eir->services, (GFunc) g_free, NULL);
+ g_slist_free(eir->services);
+ g_free(eir->name);
+}
+
int eir_parse(struct eir_data *eir, uint8_t *eir_data, size_t eir_length)
{
uint16_t len = 0;
diff --git a/src/eir.h b/src/eir.h
index c7699eb..aacd16a 100644
--- a/src/eir.h
+++ b/src/eir.h
@@ -36,6 +36,7 @@ struct eir_data {
gboolean name_complete;
};
+void eir_data_free(struct eir_data *eir);
int eir_parse(struct eir_data *eir, uint8_t *eir_data, size_t eir_length);
void eir_create(const char *name, int8_t tx_power, uint16_t did_vendor,
uint16_t did_product, uint16_t did_version,
--
1.7.5.rc3
^ permalink raw reply related
* [PATCH v4 06/12] Unify inquiry results and advertises
From: Claudio Takahasi @ 2011-05-17 18:25 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1305579001-3019-6-git-send-email-claudio.takahasi@openbossa.org>
Adapter needs to have only one method to allow discovery results
integration for both interfaces: hciops and mgmtops. This patch
moves the code related to advertises parsing to the same function
that handles inquiry results.
---
src/adapter.c | 69 +++++++++++++++++++--------------------------------------
src/adapter.h | 7 +----
src/event.c | 25 +++-----------------
3 files changed, 29 insertions(+), 72 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index 1f535e1..c053d6c 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2966,42 +2966,6 @@ static void dev_prepend_uuid(gpointer data, gpointer user_data)
dev->services = g_slist_prepend(dev->services, g_strdup(new_uuid));
}
-void adapter_update_device_from_info(struct btd_adapter *adapter,
- bdaddr_t bdaddr, int8_t rssi,
- const char *name, GSList *services,
- int flags)
-{
- struct remote_dev_info *dev;
- gboolean new_dev;
-
- dev = get_found_dev(adapter, &bdaddr, &new_dev);
-
- if (new_dev)
- dev->le = TRUE;
- else if (dev->rssi == rssi)
- return;
-
- dev->rssi = rssi;
-
- adapter->found_devices = g_slist_sort(adapter->found_devices,
- (GCompareFunc) dev_rssi_cmp);
-
- g_slist_foreach(services, remove_same_uuid, dev);
- g_slist_foreach(services, dev_prepend_uuid, dev);
-
- if (flags >= 0)
- dev->flags = flags;
-
- if (name) {
- g_free(dev->name);
- dev->name = g_strdup(name);
- }
-
- /* FIXME: check if other information was changed before emitting the
- * signal */
- adapter_emit_device_found(adapter, dev);
-}
-
static gboolean pairing_is_legacy(bdaddr_t *local, bdaddr_t *peer,
gboolean eir, gboolean name)
{
@@ -3035,13 +2999,14 @@ static char *read_stored_data(bdaddr_t *local, bdaddr_t *peer, const char *file)
}
void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
- uint32_t class, int8_t rssi, uint8_t *data)
+ uint32_t class, int8_t rssi,
+ uint8_t *data, size_t eir_size)
{
struct remote_dev_info *dev;
struct eir_data eir_data;
char *name;
- gboolean new_dev, legacy;
- name_status_t name_status;
+ gboolean new_dev, legacy, le;
+ name_status_t name_status = NAME_NOT_REQUIRED;
const char *dev_name;
int err;
@@ -3054,14 +3019,22 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
name = read_stored_data(&adapter->bdaddr, bdaddr, "names");
- legacy = pairing_is_legacy(&adapter->bdaddr, bdaddr,
- data ? TRUE : FALSE, name ? TRUE : FALSE);
+ if (eir_data.flags < 0) {
+ le = FALSE;
- if (!name && main_opts.name_resolv &&
- adapter_has_discov_sessions(adapter))
- name_status = NAME_REQUIRED;
- else
- name_status = NAME_NOT_REQUIRED;
+ legacy = pairing_is_legacy(&adapter->bdaddr, bdaddr,
+ data ? TRUE : FALSE,
+ name ? TRUE : FALSE);
+
+ if (!name && main_opts.name_resolv &&
+ adapter_has_discov_sessions(adapter))
+ name_status = NAME_REQUIRED;
+ else
+ name_status = NAME_NOT_REQUIRED;
+ } else {
+ le = TRUE;
+ legacy = FALSE;
+ }
/* Complete EIR names are always used. Shortened EIR names are only
* used if there is no name already in storage. */
@@ -3093,6 +3066,10 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
dev->class = class;
dev->legacy = legacy;
dev->name_status = name_status;
+
+ if (eir_data.flags >= 0)
+ dev->flags = eir_data.flags;
+
} else if (dev->rssi == rssi)
goto done;
diff --git a/src/adapter.h b/src/adapter.h
index 4785d5c..4c07e92 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -108,12 +108,9 @@ int adapter_get_state(struct btd_adapter *adapter);
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,
- bdaddr_t bdaddr, int8_t rssi,
- const char *name, GSList *services,
- int flags);
void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
- uint32_t class, int8_t rssi, uint8_t *data);
+ uint32_t class, int8_t rssi,
+ uint8_t *data, size_t eir_size);
int adapter_remove_found_device(struct btd_adapter *adapter, bdaddr_t *bdaddr);
void adapter_emit_device_found(struct btd_adapter *adapter,
struct remote_dev_info *dev);
diff --git a/src/event.c b/src/event.c
index 2c893f0..115b285 100644
--- a/src/event.c
+++ b/src/event.c
@@ -281,19 +281,10 @@ void btd_event_simple_pairing_complete(bdaddr_t *local, bdaddr_t *peer,
device_simple_pairing_complete(device, status);
}
-static void free_eir_data(struct eir_data *eir)
-{
- g_slist_foreach(eir->services, (GFunc) g_free, NULL);
- g_slist_free(eir->services);
- g_free(eir->name);
-}
-
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);
if (adapter == NULL) {
@@ -301,19 +292,10 @@ void btd_event_advertising_report(bdaddr_t *local, le_advertising_info *info)
return;
}
- memset(&eir_data, 0, sizeof(eir_data));
- err = eir_parse(&eir_data, info->data, info->length);
- if (err < 0)
- error("Error parsing advertising data: %s (%d)",
- strerror(-err), -err);
-
rssi = *(info->data + info->length);
- adapter_update_device_from_info(adapter, info->bdaddr, rssi,
- eir_data.name, eir_data.services,
- eir_data.flags);
-
- free_eir_data(&eir_data);
+ adapter_update_found_devices(adapter, &info->bdaddr, 0, rssi,
+ info->data, info->length);
}
static void update_lastseen(bdaddr_t *sba, bdaddr_t *dba)
@@ -355,7 +337,8 @@ void btd_event_device_found(bdaddr_t *local, bdaddr_t *peer, uint32_t class,
if (data)
write_remote_eir(local, peer, data);
- adapter_update_found_devices(adapter, peer, class, rssi, data);
+ adapter_update_found_devices(adapter, peer, class, rssi,
+ data, EIR_DATA_LENGTH);
}
void btd_event_set_legacy_pairing(bdaddr_t *local, bdaddr_t *peer,
--
1.7.5.rc3
^ permalink raw reply related
* [PATCH v4 05/12] Don't resolve name if the name is in the storage
From: Claudio Takahasi @ 2011-05-17 18:25 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1305579001-3019-5-git-send-email-claudio.takahasi@openbossa.org>
---
src/adapter.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index 7cc725c..1f535e1 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -3052,17 +3052,17 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
return;
}
- /* the inquiry result can be triggered by NON D-Bus client */
- if (main_opts.name_resolv && adapter_has_discov_sessions(adapter))
- name_status = NAME_REQUIRED;
- else
- name_status = NAME_NOT_REQUIRED;
-
name = read_stored_data(&adapter->bdaddr, bdaddr, "names");
legacy = pairing_is_legacy(&adapter->bdaddr, bdaddr,
data ? TRUE : FALSE, name ? TRUE : FALSE);
+ if (!name && main_opts.name_resolv &&
+ adapter_has_discov_sessions(adapter))
+ name_status = NAME_REQUIRED;
+ else
+ name_status = NAME_NOT_REQUIRED;
+
/* Complete EIR names are always used. Shortened EIR names are only
* used if there is no name already in storage. */
dev_name = name;
--
1.7.5.rc3
^ permalink raw reply related
* [PATCH v4 04/12] Cleanup read name and alias from storage
From: Claudio Takahasi @ 2011-05-17 18:25 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1305579001-3019-4-git-send-email-claudio.takahasi@openbossa.org>
---
src/adapter.c | 35 +++++++++++++++++++++++------------
1 files changed, 23 insertions(+), 12 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index d4e1121..7cc725c 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -3022,13 +3022,24 @@ static gboolean pairing_is_legacy(bdaddr_t *local, bdaddr_t *peer,
return TRUE;
}
+static char *read_stored_data(bdaddr_t *local, bdaddr_t *peer, const char *file)
+{
+ char local_addr[18], peer_addr[18], filename[PATH_MAX + 1];
+
+ ba2str(local, local_addr);
+ ba2str(peer, peer_addr);
+
+ create_name(filename, PATH_MAX, STORAGEDIR, local_addr, file);
+
+ return textfile_get(filename, peer_addr);
+}
+
void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
uint32_t class, int8_t rssi, uint8_t *data)
{
- char local_addr[18], peer_addr[18], filename[PATH_MAX + 1];
struct remote_dev_info *dev;
struct eir_data eir_data;
- char *alias, *name;
+ char *name;
gboolean new_dev, legacy;
name_status_t name_status;
const char *dev_name;
@@ -3047,14 +3058,7 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
else
name_status = NAME_NOT_REQUIRED;
- ba2str(&adapter->bdaddr, local_addr);
- ba2str(bdaddr, peer_addr);
-
- create_name(filename, PATH_MAX, STORAGEDIR, local_addr, "aliases");
- alias = textfile_get(filename, peer_addr);
-
- create_name(filename, PATH_MAX, STORAGEDIR, local_addr, "names");
- name = textfile_get(filename, peer_addr);
+ name = read_stored_data(&adapter->bdaddr, bdaddr, "names");
legacy = pairing_is_legacy(&adapter->bdaddr, bdaddr,
data ? TRUE : FALSE, name ? TRUE : FALSE);
@@ -3075,18 +3079,22 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
dev = get_found_dev(adapter, bdaddr, &new_dev);
if (new_dev) {
+ char *alias;
if (dev_name)
dev->name = g_strdup(dev_name);
- if (alias)
+ alias = read_stored_data(&adapter->bdaddr, bdaddr, "aliases");
+ if (alias) {
dev->alias = g_strdup(alias);
+ free(alias);
+ }
dev->le = FALSE;
dev->class = class;
dev->legacy = legacy;
dev->name_status = name_status;
} else if (dev->rssi == rssi)
- return;
+ goto done;
dev->rssi = rssi;
@@ -3097,6 +3105,9 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
g_slist_foreach(eir_data.services, dev_prepend_uuid, dev);
adapter_emit_device_found(adapter, dev);
+
+done:
+ free(name);
}
int adapter_remove_found_device(struct btd_adapter *adapter, bdaddr_t *bdaddr)
--
1.7.5.rc3
^ permalink raw reply related
* [PATCH v4 03/12] Move legacy verification to a new function
From: Claudio Takahasi @ 2011-05-17 18:25 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <20110517161326.GA20885@dell.ice.intel.com>
---
src/adapter.c | 35 ++++++++++++++++++++++-------------
1 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index 3188974..d4e1121 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -3002,6 +3002,26 @@ void adapter_update_device_from_info(struct btd_adapter *adapter,
adapter_emit_device_found(adapter, dev);
}
+static gboolean pairing_is_legacy(bdaddr_t *local, bdaddr_t *peer,
+ gboolean eir, gboolean name)
+{
+ unsigned char features[8];
+
+ if (eir)
+ return FALSE;
+
+ if (name == FALSE)
+ return TRUE;
+
+ if (read_remote_features(local, peer, NULL, features) < 0)
+ return TRUE;
+
+ if (features[0] & 0x01)
+ return FALSE;
+ else
+ return TRUE;
+}
+
void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
uint32_t class, int8_t rssi, uint8_t *data)
{
@@ -3011,7 +3031,6 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
char *alias, *name;
gboolean new_dev, legacy;
name_status_t name_status;
- unsigned char features[8];
const char *dev_name;
int err;
@@ -3037,18 +3056,8 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
create_name(filename, PATH_MAX, STORAGEDIR, local_addr, "names");
name = textfile_get(filename, peer_addr);
- if (data)
- legacy = FALSE;
- else if (name == NULL)
- legacy = TRUE;
- else if (read_remote_features(&adapter->bdaddr, bdaddr, NULL,
- features) == 0) {
- if (features[0] & 0x01)
- legacy = FALSE;
- else
- legacy = TRUE;
- } else
- legacy = TRUE;
+ legacy = pairing_is_legacy(&adapter->bdaddr, bdaddr,
+ data ? TRUE : FALSE, name ? TRUE : FALSE);
/* Complete EIR names are always used. Shortened EIR names are only
* used if there is no name already in storage. */
--
1.7.5.rc3
^ permalink raw reply related
* Re: [PATCH 02/12] Bluetooth: LE advertising cache
From: Andre Guedes @ 2011-05-17 18:22 UTC (permalink / raw)
To: Andre Guedes, linux-bluetooth
In-Reply-To: <20110513193326.GB5403@joana>
Hi Gustavo,
On Fri, May 13, 2011 at 4:33 PM, Gustavo F. Padovan
<padovan@profusion.mobi> wrote:
> Hi Andre,
>
> * Andre Guedes <andre.guedes@openbossa.org> [2011-05-06 14:05:11 -0300]:
>
>> This patch implements the LE advertising cache. It stores sensitive
>> information (bdaddr and bdaddr_type so far) gathered from LE
>> advertising report events.
>>
>> Only advertising entries from connectables devices are added to the
>> cache.
>>
>> Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
>> ---
>> include/net/bluetooth/hci_core.h | 13 +++++++
>> net/bluetooth/hci_core.c | 74 ++++++++++++++++++++++++++++++++++++++
>> 2 files changed, 87 insertions(+), 0 deletions(-)
>>
>> diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
>> index 14cc324..65135f8 100644
>> --- a/include/net/bluetooth/hci_core.h
>> +++ b/include/net/bluetooth/hci_core.h
>> @@ -89,6 +89,12 @@ struct oob_data {
>> u8 randomizer[16];
>> };
>>
>> +struct adv_entry {
>> + struct list_head list;
>> + bdaddr_t bdaddr;
>> + u8 bdaddr_type;
>> +};
>> +
>> #define NUM_REASSEMBLY 4
>> struct hci_dev {
>> struct list_head list;
>> @@ -181,6 +187,8 @@ struct hci_dev {
>>
>> struct list_head remote_oob_data;
>>
>> + struct list_head adv_entries;
>> +
>> struct hci_dev_stats stat;
>>
>> struct sk_buff_head driver_init;
>> @@ -526,6 +534,11 @@ int hci_add_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *hash,
>> u8 *randomizer);
>> int hci_remove_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr);
>>
>> +int hci_adv_entries_clear(struct hci_dev *hdev);
>> +struct adv_entry *hci_find_adv_entry(struct hci_dev *hdev, bdaddr_t *bdaddr);
>> +int hci_add_adv_entry(struct hci_dev *hdev,
>> + struct hci_ev_le_advertising_info *ev);
>
> Rename this to hci_adv_add_entry()
>
'adv_entry' is the element of the list. So, to follow the standard IMO
we should keep the name hci_add_adv_entry(). See others functions
like hci_add_link_key() and hci_add_remote_oob_data().
>> +
>> void hci_del_off_timer(struct hci_dev *hdev);
>>
>> void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb);
>> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
>> index b6bda3f..0ba3c39 100644
>> --- a/net/bluetooth/hci_core.c
>> +++ b/net/bluetooth/hci_core.c
>> @@ -1204,6 +1204,77 @@ int hci_add_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *hash,
>> return 0;
>> }
>>
>> +int hci_adv_entries_clear(struct hci_dev *hdev)
>> +{
>> + struct list_head *p, *n;
>> +
>> + list_for_each_safe(p, n, &hdev->adv_entries) {
>
> list_for_each_entry_safe() here.
>
>> + struct adv_entry *entry;
>> +
>> + entry = list_entry(p, struct adv_entry, list);
>> +
>> + list_del(p);
>> + kfree(entry);
>> + }
>> +
>> + BT_DBG("%s adv cache cleared", hdev->name);
>> +
>> + return 0;
>> +}
>> +
>> +struct adv_entry *hci_find_adv_entry(struct hci_dev *hdev, bdaddr_t *bdaddr)
>> +{
>> + struct list_head *p;
>> +
>> + list_for_each(p, &hdev->adv_entries) {
>
> list_for_each_entry() here.
>
>> + struct adv_entry *entry;
>> +
>> + entry = list_entry(p, struct adv_entry, list);
>> +
>> + if (bacmp(bdaddr, &entry->bdaddr) == 0)
>> + return entry;
>> + }
>> +
>> + return NULL;
>> +}
>> +
>> +static inline int is_connectable_adv(u8 evt_type)
>> +{
>> + if (evt_type == ADV_IND || evt_type == ADV_DIRECT_IND)
>> + return 1;
>> +
>> + return 0;
>
> You use this function just in one place, get rid of it.
>
Yes, this function is used just in one place. It was created to
improve code's readability since
if (is_connectable_adv())
do_something()
means much more than
if (evt_type == ADV_IND || evt_type == ADV_DIRECT_IND)
do_something()
>> +}
>> +
>> +int hci_add_adv_entry(struct hci_dev *hdev,
>> + struct hci_ev_le_advertising_info *ev)
>> +{
>> + struct adv_entry *entry;
>> +
>> + if (!is_connectable_adv(ev->evt_type))
>> + return -EINVAL;
>> +
>> + entry = hci_find_adv_entry(hdev, &ev->bdaddr);
>> + /* Only new entries should be added to adv_entries. So, if
>> + * bdaddr was found, don't add it. */
>> + if (entry)
>> + return 0;
>
> if (hci_find_adv_entry())
> return 0;
>
> --
> Gustavo F. Padovan
> http://profusion.mobi
>
BR,
Andre Guedes.
^ permalink raw reply
* Re: [PATCH] mgmt: fix DBG string format
From: Johan Hedberg @ 2011-05-17 17:56 UTC (permalink / raw)
To: Frédéric Danis; +Cc: linux-bluetooth
In-Reply-To: <1305623078-15115-1-git-send-email-frederic.danis@linux.intel.com>
Hi Frédéric,
On Tue, May 17, 2011, Frédéric Danis wrote:
> ---
> plugins/mgmtops.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
Applied. Thanks.
Johan
^ permalink raw reply
* Re: Does any one recognise this protocol? is it RF_COMM
From: James Steele @ 2011-05-17 17:30 UTC (permalink / raw)
To: Alan; +Cc: linux-bluetooth
In-Reply-To: <201105171715.47064.alanbluetooth@aiaware.com>
On 17 May 2011 12:45, Alan <alanbluetooth@aiaware.com> wrote:
>
> What protocol is this? Can it be RF_COMM ?
It looks like it is RFCOMM yes (at least it looks sane from my mental parser).
> Im pretty sure the 2b 20 20 00 is
> Protocol: “Core_V4.0.pdf” Figure 5.2: HCI ACL Data Packet p429
> and 1c 00 8c 00
> is L2CAP [size and channel ID].
Yes
> Does anyone recognise a protocol runnign on L2CAP that looks like this
>
> 09 ef 3f Data 40 for inbound packets and
> 0b ff 2f 00 Data 86 for outbound packets
Yes - it's RFCOMM
> Note there are binary differences in both the L2CAP and RFCOMM parts.
> Most worrying to me is the missing 0.
I assume you mean the "extra" 00 in the "outbound packet" you
mentioned above? If so then don't worry, that is the "credits" field
when RFCOMM is operating with credit based flow control - it's present
when the poll bit (0x10) is set in the control field for a UIH
(control field = 0xef).
> Any idea why the differences or where there is a reasonable document on what
> those RF_COMM bytes mean.
The RFCOMM specification gives a basic introduction, but the headers
can be quite gnarly since they are quite "packed" and there are quite
a few extension bits (with their frame structure changing properties.)
The RFCOMM specification does have the simple frame structure
overview for the regular frames (Figure 5.1) and credit based flow
control frames (Figure 6.1) though .
Otherwise TS 07.10 - you can find it on 3GPP.
James
^ permalink raw reply
* Re: [PATCH v3 03/12] Move legacy verification to a new function
From: Johan Hedberg @ 2011-05-17 16:13 UTC (permalink / raw)
To: Claudio Takahasi; +Cc: linux-bluetooth
In-Reply-To: <1305579001-3019-3-git-send-email-claudio.takahasi@openbossa.org>
Hi Claudio,
On Mon, May 16, 2011, Claudio Takahasi wrote:
> ---
> src/adapter.c | 40 ++++++++++++++++++++++++++++------------
> 1 files changed, 28 insertions(+), 12 deletions(-)
>
> diff --git a/src/adapter.c b/src/adapter.c
> index 3188974..6f85abf 100644
> --- a/src/adapter.c
> +++ b/src/adapter.c
> @@ -3002,6 +3002,31 @@ void adapter_update_device_from_info(struct btd_adapter *adapter,
> adapter_emit_device_found(adapter, dev);
> }
>
> +static int pairing_is_legacy(bdaddr_t *local, bdaddr_t *peer, gboolean eir,
> + gboolean name, gboolean *legacy)
> +{
The first two patches in this set have been pushed upstream, however
could you consider the following change to this one: since you just
assume legacy == TRUE if the storage read fails, why not just make this
pairing_is_legacy function return a gboolean instead of returning the
value by reference? (it's look cleaner, especially considering the name
of the function)
Johan
^ permalink raw reply
* Re: [PATCH v2] Adjust SPARQL queries to the changes in call history
From: Johan Hedberg @ 2011-05-17 15:51 UTC (permalink / raw)
To: Slawomir Bochenski; +Cc: linux-bluetooth
In-Reply-To: <1305025781-21893-1-git-send-email-lkslawek@gmail.com>
Hi Slawek,
On Tue, May 10, 2011, Slawomir Bochenski wrote:
> Currently nmo:Call resources put to the Tracker by commhistory do not use
> the same nco:PhoneNumber as the one bound to the nco:PersonContact. This
> patch introduces matching contacts by actual phone number, thus returning
> proper contact data regardless of this commhistory change.
> ---
> In the previous version backslashes at the ends of lines were incorrectly
> aligned.
> plugins/phonebook-tracker.c | 74 ++++++++++++++++++++++++++++++------------
> 1 files changed, 53 insertions(+), 21 deletions(-)
Pushed upstream. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH 03/12] Bluetooth: Protect 'adv_entries' with a RW lock
From: Andre Guedes @ 2011-05-17 14:39 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <1305163474.15916.166.camel@aeonflux>
Hi Marcel,
On Wed, May 11, 2011 at 10:24 PM, Marcel Holtmann <marcel@holtmann.org> wro=
te:
> Hi Andre,
>
>> This patch adds a RW lock to protect concurrent operations on
>> adv_entries list.
>>
>> Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
>> ---
>> =A0include/net/bluetooth/hci_core.h | =A0 =A01 +
>> =A0net/bluetooth/hci_core.c =A0 =A0 =A0 =A0 | =A0 21 +++++++++++++++++--=
--
>> =A02 files changed, 18 insertions(+), 4 deletions(-)
>>
>> diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hc=
i_core.h
>> index 65135f8..2ceeadf 100644
>> --- a/include/net/bluetooth/hci_core.h
>> +++ b/include/net/bluetooth/hci_core.h
>> @@ -188,6 +188,7 @@ struct hci_dev {
>> =A0 =A0 =A0 struct list_head =A0 =A0 =A0 =A0remote_oob_data;
>>
>> =A0 =A0 =A0 struct list_head =A0 =A0 =A0 =A0adv_entries;
>> + =A0 =A0 rwlock_t =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0adv_entries_lock;
>
> we might wanna consider just using spinlocks and not rwlocks. Also can
> you please look into using RCU.
>
> Regards
>
> Marcel
>
>
>
Ok. I will use hci_dev_lock and friends to protect adv_entries.
This is the approach already used to protect uuids, link_keys,
remote_oob_data lists.
About RCU, I see the point in using it, but since reading operations
in adv_entries are not _extremely_ requested, IMO, we'll not have
much performance gain here. Anyway, the changes to use RCU
are straightforward. So, let me know if you wanna try RCU to
protect the advertising cache.
BR,
Andre Guedes.
^ permalink raw reply
* Re: HCI data payload not getting through when using BlueZ
From: Eponymous - @ 2011-05-17 12:45 UTC (permalink / raw)
To: Anderson Lizardo; +Cc: linux-bluetooth
In-Reply-To: <BANLkTin1wGOa2=_9qHhYmmTbLs_E2xUHXw@mail.gmail.com>
lsusb:
Bus 001 Device 041: ID 0a12:0001 Cambridge Silicon Radio, Ltd
Bluetooth Dongle (HCI mode)
Bus 001 Device 040: ID 0a12:0001 Cambridge Silicon Radio, Ltd
Bluetooth Dongle (HCI mode)
These are definitely plain USB devices. There is no /dev/ttyUSBxx like
you would get with the FTDI USB->Serial converters.
I've checked over dmesg and the messages (of which there are many
since I have eight of these devices) says they are USB.
I don't want to become sidetracked from the issue though. Is there
anyway to debug this issue without using l2test or any other
upperlayers program? The issue I have seen was at the HCI level
remember so I'm thinking introducing the upperlayers is going to make
things unnecessarily complicated.
Cheers.
On Tue, May 17, 2011 at 12:50 PM, Anderson Lizardo
<anderson.lizardo@openbossa.org> wrote:
> Hi,
>
> On Tue, May 17, 2011 at 3:13 AM, Eponymous - <the.epon@gmail.com> wrote:
>> The chips are CSR Bluecores. In order to get upperlayers access rather
>> than HCI over USB you have to configure a key in the firmware.
>>
>> As soon as I enable upperlayers access the devices disappear from hciconfig.
>
> As I said, there are various development/prototype devices out there
> that use UART (usually CDC ACM or FTDI over USB) transport instead of
> "plain" USB. If you post the relevant lines from "dmesg" and "lsusb"
> somewhere (after you configure the firmware key), we might be able to
> identify the transport.
>
> For UART, you need to use hciattach on a e.g. /dev/ttyUSBX device
> created when plugging the device.
>
> HTH,
> --
> Anderson Lizardo
> Instituto Nokia de Tecnologia - INdT
> Manaus - Brazil
>
^ 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