All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arman Uguray <armansito@chromium.org>
To: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>
Subject: Re: [PATCH BlueZ 4/5] core: device: Add device_is_bonded_for_gatt
Date: Thu, 29 Jan 2015 11:46:34 -0800	[thread overview]
Message-ID: <CAHrH25TvixrEj6L3vWYJcV+4g=QNixYJ+7iaA98f4Ch+STTrgA@mail.gmail.com> (raw)
In-Reply-To: <CABBYNZ+6OCd2tLfSVJt-dUYUc348jTik003jkwc+vFs-uKaS9w@mail.gmail.com>

Hi Luiz,

> On Thu, Jan 29, 2015 at 5:52 AM, Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote:
> Hi Arman,
>
> On Thu, Jan 29, 2015 at 4:11 AM, Arman Uguray <armansito@chromium.org> wrote:
>> Added the device_is_bonded_for_gatt function, which returns true if
>> the bonding state is true for the bearer over which the GATT db was
>> populated. For now, this only returns the LE state but added for
>> better layering, so that future changes to the internal logic can be
>> simply performed here to avoid regressions.
>>
>> Change-Id: I6ebd16a1111aa38645a0a072536f4171d246b931
>> ---
>>  src/device.c | 14 +++++++++++++-
>>  src/device.h |  1 +
>>  2 files changed, 14 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/device.c b/src/device.c
>> index 9cb5acb..2ef2b6a 100644
>> --- a/src/device.c
>> +++ b/src/device.c
>> @@ -506,8 +506,10 @@ static void gatt_client_cleanup(struct btd_device *device)
>>         bt_gatt_client_unref(device->client);
>>         device->client = NULL;
>>
>> -       if (!device->le_state.bonded)
>> +       if (!device_is_bonded_for_gatt(device)) {
>> +               DBG("Device is not bonded, clearing client attribute cache");
>>                 gatt_db_clear(device->db);
>> +       }
>>  }
>>
>>  static void attio_cleanup(struct btd_device *device)
>> @@ -638,6 +640,16 @@ bool device_is_bonded(struct btd_device *device, uint8_t bdaddr_type)
>>         return state->bonded;
>>  }
>>
>> +bool device_is_bonded_for_gatt(struct btd_device *device)
>> +{
>> +       /*
>> +        * TODO: Once we properly support GATT over BR/EDR, we should remember
>> +        * whether the GATT client  database was populated over LE or BR/EDR and
>> +        * check the correct bonding state.
>> +        */
>> +       return device->le_state.bonded;
>> +}
>> +
>>  gboolean device_is_trusted(struct btd_device *device)
>>  {
>>         return device->trusted;
>> diff --git a/src/device.h b/src/device.h
>> index a7fefee..b4aead1 100644
>> --- a/src/device.h
>> +++ b/src/device.h
>> @@ -82,6 +82,7 @@ const char *device_get_path(const struct btd_device *device);
>>  gboolean device_is_temporary(struct btd_device *device);
>>  bool device_is_paired(struct btd_device *device, uint8_t bdaddr_type);
>>  bool device_is_bonded(struct btd_device *device, uint8_t bdaddr_type);
>> +bool device_is_bonded_for_gatt(struct btd_device *device);
>
> Isn't this equivalent to device_is_bonded or perhaps we don't the
> type? I guess it is possible to retrieve in what transport we are
> connected and then check if we it is bonded.
>

It's pretty much the same thing, except it would return the bonding
state based on the transport that did the GATT discovery. I figured it
would be better to have this function in one place so that we only
have one place to change when we properly support GATT over BR/EDR in
the future. Just using device_is_bonded and passing BDADDR_LE_PUBLIC
for the bdaddr works too for now, we just need to remember to update
them later. I'll go ahead and leave this out for now.

>>  gboolean device_is_trusted(struct btd_device *device);
>>  void device_set_paired(struct btd_device *dev, uint8_t bdaddr_type);
>>  void device_set_unpaired(struct btd_device *dev, uint8_t bdaddr_type);
>> --
>> 2.2.0.rc0.207.ga3a616c
>>
>
>
>
> --
> Luiz Augusto von Dentz

Arman

  reply	other threads:[~2015-01-29 19:46 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-29  2:10 [PATCH BlueZ 0/5] core: gatt: Support enabling notifications Arman Uguray
2015-01-29  2:10 ` [PATCH BlueZ 1/5] core: gatt: Implement GattCharacteristic1.StartNotify Arman Uguray
2015-01-29 13:37   ` Luiz Augusto von Dentz
2015-01-29 20:10     ` Arman Uguray
2015-01-29  2:11 ` [PATCH BlueZ 2/5] core: gatt: Implement GattCharacteristic1.StopNotify Arman Uguray
2015-01-29  2:11 ` [PATCH BlueZ 3/5] core: device: Don't check ready in service_removed Arman Uguray
2015-01-29  2:11 ` [PATCH BlueZ 4/5] core: device: Add device_is_bonded_for_gatt Arman Uguray
2015-01-29 13:52   ` Luiz Augusto von Dentz
2015-01-29 19:46     ` Arman Uguray [this message]
2015-01-29  2:11 ` [PATCH BlueZ 5/5] core: gatt: Keep objects over disconnects Arman Uguray
2015-01-29  2:24 ` [PATCH BlueZ 0/5] core: gatt: Support enabling notifications Arman Uguray

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHrH25TvixrEj6L3vWYJcV+4g=QNixYJ+7iaA98f4Ch+STTrgA@mail.gmail.com' \
    --to=armansito@chromium.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.