* [PATCH v2] android/bluetooth: Fix discovering new devices
@ 2014-01-16 13:35 Szymon Janc
2014-01-16 13:50 ` Johan Hedberg
0 siblings, 1 reply; 3+ messages in thread
From: Szymon Janc @ 2014-01-16 13:35 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
Device found events should be send also for known devices if this is
new discovery session. Otherwise Android will ignore those devices.
---
V2: report bonded devices in same way as non-bonded
android/bluetooth.c | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
diff --git a/android/bluetooth.c b/android/bluetooth.c
index f1e5458..b235cbd 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -90,6 +90,8 @@ struct device {
uint32_t timestamp;
GSList *uuids;
+
+ bool found; /* if device is found in current discovery session */
};
struct browse_req {
@@ -903,6 +905,13 @@ static void user_passkey_notify_callback(uint16_t index, uint16_t length,
send_ssp_request(&ev->addr.bdaddr, HAL_SSP_VARIANT_NOTIF, ev->passkey);
}
+static void clear_device_found(gpointer data, gpointer user_data)
+{
+ struct device *dev = data;
+
+ dev->found = false;
+}
+
static void mgmt_discovering_event(uint16_t index, uint16_t length,
const void *param, void *user_data)
{
@@ -924,10 +933,12 @@ static void mgmt_discovering_event(uint16_t index, uint16_t length,
DBG("new discovering state %u", ev->discovering);
- if (adapter.discovering)
+ if (adapter.discovering) {
cp.state = HAL_DISCOVERY_STATE_STARTED;
- else
+ } else {
+ g_slist_foreach(devices, clear_device_found, NULL);
cp.state = HAL_DISCOVERY_STATE_STOPPED;
+ }
ipc_send_notif(HAL_SERVICE_ID_BLUETOOTH,
HAL_EV_DISCOVERY_STATE_CHANGED, sizeof(cp), &cp);
@@ -983,12 +994,15 @@ static void update_found_device(const bdaddr_t *bdaddr, uint8_t bdaddr_type,
eir_parse(&eir, data, data_len);
dev = find_device(bdaddr);
- if (!dev) {
+ if (!dev || !dev->found) {
struct hal_ev_device_found *ev = (void *) buf;
bdaddr_t android_bdaddr;
uint8_t android_type;
- dev = create_device(bdaddr, bdaddr_type);
+ if (!dev)
+ dev = create_device(bdaddr, bdaddr_type);
+
+ dev->found = true;
size += sizeof(*ev);
--
1.8.3.2
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v2] android/bluetooth: Fix discovering new devices
2014-01-16 13:35 [PATCH v2] android/bluetooth: Fix discovering new devices Szymon Janc
@ 2014-01-16 13:50 ` Johan Hedberg
2014-01-16 14:50 ` Szymon Janc
0 siblings, 1 reply; 3+ messages in thread
From: Johan Hedberg @ 2014-01-16 13:50 UTC (permalink / raw)
To: Szymon Janc; +Cc: linux-bluetooth
Hi Szymon,
On Thu, Jan 16, 2014, Szymon Janc wrote:
> @@ -983,12 +994,15 @@ static void update_found_device(const bdaddr_t *bdaddr, uint8_t bdaddr_type,
> eir_parse(&eir, data, data_len);
>
> dev = find_device(bdaddr);
> - if (!dev) {
> + if (!dev || !dev->found) {
I think this would still deserve a code comment here explaining why
dev->found is important. Other than that the patch is fine, so feel free
to push it yourself once you've added the comment.
Johan
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2] android/bluetooth: Fix discovering new devices
2014-01-16 13:50 ` Johan Hedberg
@ 2014-01-16 14:50 ` Szymon Janc
0 siblings, 0 replies; 3+ messages in thread
From: Szymon Janc @ 2014-01-16 14:50 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
Hi,
On Thursday 16 of January 2014 15:50:32 Johan Hedberg wrote:
> Hi Szymon,
>
> On Thu, Jan 16, 2014, Szymon Janc wrote:
> > @@ -983,12 +994,15 @@ static void update_found_device(const bdaddr_t *bdaddr, uint8_t bdaddr_type,
> > eir_parse(&eir, data, data_len);
> >
> > dev = find_device(bdaddr);
> > - if (!dev) {
> > + if (!dev || !dev->found) {
>
> I think this would still deserve a code comment here explaining why
> dev->found is important. Other than that the patch is fine, so feel free
> to push it yourself once you've added the comment.
Pushed.
--
Best regards,
Szymon Janc
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-01-16 14:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-16 13:35 [PATCH v2] android/bluetooth: Fix discovering new devices Szymon Janc
2014-01-16 13:50 ` Johan Hedberg
2014-01-16 14:50 ` Szymon Janc
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox