Linux-Bluetooth Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH BlueZ] profile: Add exception from being claimed internally
@ 2020-07-15 22:28 Sonny Sasaka
  2020-07-15 22:39 ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 8+ messages in thread
From: Sonny Sasaka @ 2020-07-15 22:28 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Sonny Sasaka

This adds a flag to give exception to profiles that are considered safe
to be both handled internally and externally via GATT API. Currently
this includes the battery profile.

---
 profiles/battery/battery.c | 1 +
 src/device.c               | 2 +-
 src/profile.h              | 5 +++++
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/profiles/battery/battery.c b/profiles/battery/battery.c
index 4da4355a1..20aa47727 100644
--- a/profiles/battery/battery.c
+++ b/profiles/battery/battery.c
@@ -354,6 +354,7 @@ static struct btd_profile batt_profile = {
 	.device_remove	= batt_remove,
 	.accept		= batt_accept,
 	.disconnect	= batt_disconnect,
+	.claim_service_exception = true,
 };
 
 static int batt_init(void)
diff --git a/src/device.c b/src/device.c
index 0deee2707..cfa52461f 100644
--- a/src/device.c
+++ b/src/device.c
@@ -3818,7 +3818,7 @@ done:
 	profile = btd_service_get_profile(service);
 
 	/* Claim attributes of internal profiles */
-	if (!profile->external) {
+	if (!profile->external && !profile->claim_service_exception) {
 		/* Mark the service as claimed by the existing profile. */
 		gatt_db_service_set_claimed(attr, true);
 	}
diff --git a/src/profile.h b/src/profile.h
index 4448a2a6d..25e83381b 100644
--- a/src/profile.h
+++ b/src/profile.h
@@ -36,6 +36,11 @@ struct btd_profile {
 
 	bool auto_connect;
 	bool external;
+	/* Some profiles are considered safe to be handled internally and also
+	 * be exposed in the GATT API. This flag give such profiles exception
+	 * from being claimed internally.
+	 */
+	bool claim_service_exception;
 
 	int (*device_probe) (struct btd_service *service);
 	void (*device_remove) (struct btd_service *service);
-- 
2.26.2


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH BlueZ] profile: Add exception from being claimed internally
  2020-07-15 22:28 [PATCH BlueZ] profile: Add exception from being claimed internally Sonny Sasaka
@ 2020-07-15 22:39 ` Luiz Augusto von Dentz
  2020-07-15 22:47   ` [PATCH BlueZ v2] profile: Add exception to battery profile for external access Sonny Sasaka
  2020-07-15 22:49   ` [PATCH BlueZ] profile: Add exception from being claimed internally Sonny Sasaka
  0 siblings, 2 replies; 8+ messages in thread
From: Luiz Augusto von Dentz @ 2020-07-15 22:39 UTC (permalink / raw)
  To: Sonny Sasaka; +Cc: linux-bluetooth

Hi Sonny,

On Wed, Jul 15, 2020 at 3:32 PM Sonny Sasaka <sonnysasaka@chromium.org> wrote:
>
> This adds a flag to give exception to profiles that are considered safe
> to be both handled internally and externally via GATT API. Currently
> this includes the battery profile.
>
> ---
>  profiles/battery/battery.c | 1 +
>  src/device.c               | 2 +-
>  src/profile.h              | 5 +++++
>  3 files changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/profiles/battery/battery.c b/profiles/battery/battery.c
> index 4da4355a1..20aa47727 100644
> --- a/profiles/battery/battery.c
> +++ b/profiles/battery/battery.c
> @@ -354,6 +354,7 @@ static struct btd_profile batt_profile = {
>         .device_remove  = batt_remove,
>         .accept         = batt_accept,
>         .disconnect     = batt_disconnect,
> +       .claim_service_exception = true,
>  };
>
>  static int batt_init(void)
> diff --git a/src/device.c b/src/device.c
> index 0deee2707..cfa52461f 100644
> --- a/src/device.c
> +++ b/src/device.c
> @@ -3818,7 +3818,7 @@ done:
>         profile = btd_service_get_profile(service);
>
>         /* Claim attributes of internal profiles */
> -       if (!profile->external) {
> +       if (!profile->external && !profile->claim_service_exception) {

The external field was added exactly to allow it to be used externally.

>                 /* Mark the service as claimed by the existing profile. */
>                 gatt_db_service_set_claimed(attr, true);
>         }
> diff --git a/src/profile.h b/src/profile.h
> index 4448a2a6d..25e83381b 100644
> --- a/src/profile.h
> +++ b/src/profile.h
> @@ -36,6 +36,11 @@ struct btd_profile {
>
>         bool auto_connect;
>         bool external;
> +       /* Some profiles are considered safe to be handled internally and also
> +        * be exposed in the GATT API. This flag give such profiles exception
> +        * from being claimed internally.
> +        */
> +       bool claim_service_exception;
>
>         int (*device_probe) (struct btd_service *service);
>         void (*device_remove) (struct btd_service *service);
> --
> 2.26.2
>


-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH BlueZ v2] profile: Add exception to battery profile for external access
  2020-07-15 22:39 ` Luiz Augusto von Dentz
@ 2020-07-15 22:47   ` Sonny Sasaka
  2020-07-17 20:13     ` Sonny Sasaka
  2020-07-15 22:49   ` [PATCH BlueZ] profile: Add exception from being claimed internally Sonny Sasaka
  1 sibling, 1 reply; 8+ messages in thread
From: Sonny Sasaka @ 2020-07-15 22:47 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Sonny Sasaka

This gives exception to battery profile to be shared both internally and
externally.

---
 profiles/battery/battery.c | 1 +
 src/profile.h              | 4 ++++
 2 files changed, 5 insertions(+)

diff --git a/profiles/battery/battery.c b/profiles/battery/battery.c
index 4da4355a1..c9a1af4b9 100644
--- a/profiles/battery/battery.c
+++ b/profiles/battery/battery.c
@@ -354,6 +354,7 @@ static struct btd_profile batt_profile = {
 	.device_remove	= batt_remove,
 	.accept		= batt_accept,
 	.disconnect	= batt_disconnect,
+	.external	= true,
 };
 
 static int batt_init(void)
diff --git a/src/profile.h b/src/profile.h
index 4448a2a6d..95523e50a 100644
--- a/src/profile.h
+++ b/src/profile.h
@@ -35,6 +35,10 @@ struct btd_profile {
 	const char *remote_uuid;
 
 	bool auto_connect;
+	/* Some profiles are considered safe to be handled internally and also
+	 * be exposed in the GATT API. This flag give such profiles exception
+	 * from being claimed internally.
+	 */
 	bool external;
 
 	int (*device_probe) (struct btd_service *service);
-- 
2.26.2


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH BlueZ] profile: Add exception from being claimed internally
  2020-07-15 22:39 ` Luiz Augusto von Dentz
  2020-07-15 22:47   ` [PATCH BlueZ v2] profile: Add exception to battery profile for external access Sonny Sasaka
@ 2020-07-15 22:49   ` Sonny Sasaka
  1 sibling, 0 replies; 8+ messages in thread
From: Sonny Sasaka @ 2020-07-15 22:49 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hi Luiz,

On Wed, Jul 15, 2020 at 3:40 PM Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
>
> Hi Sonny,
>
> On Wed, Jul 15, 2020 at 3:32 PM Sonny Sasaka <sonnysasaka@chromium.org> wrote:
> >
> > This adds a flag to give exception to profiles that are considered safe
> > to be both handled internally and externally via GATT API. Currently
> > this includes the battery profile.
> >
> > ---
> >  profiles/battery/battery.c | 1 +
> >  src/device.c               | 2 +-
> >  src/profile.h              | 5 +++++
> >  3 files changed, 7 insertions(+), 1 deletion(-)
> >
> > diff --git a/profiles/battery/battery.c b/profiles/battery/battery.c
> > index 4da4355a1..20aa47727 100644
> > --- a/profiles/battery/battery.c
> > +++ b/profiles/battery/battery.c
> > @@ -354,6 +354,7 @@ static struct btd_profile batt_profile = {
> >         .device_remove  = batt_remove,
> >         .accept         = batt_accept,
> >         .disconnect     = batt_disconnect,
> > +       .claim_service_exception = true,
> >  };
> >
> >  static int batt_init(void)
> > diff --git a/src/device.c b/src/device.c
> > index 0deee2707..cfa52461f 100644
> > --- a/src/device.c
> > +++ b/src/device.c
> > @@ -3818,7 +3818,7 @@ done:
> >         profile = btd_service_get_profile(service);
> >
> >         /* Claim attributes of internal profiles */
> > -       if (!profile->external) {
> > +       if (!profile->external && !profile->claim_service_exception) {
>
> The external field was added exactly to allow it to be used externally.
Oh, I was misled by the field name, I thought it's to mark profiles
which are not handled internally. I have sent another patch also
clarifying the field with a comment.
>
> >                 /* Mark the service as claimed by the existing profile. */
> >                 gatt_db_service_set_claimed(attr, true);
> >         }
> > diff --git a/src/profile.h b/src/profile.h
> > index 4448a2a6d..25e83381b 100644
> > --- a/src/profile.h
> > +++ b/src/profile.h
> > @@ -36,6 +36,11 @@ struct btd_profile {
> >
> >         bool auto_connect;
> >         bool external;
> > +       /* Some profiles are considered safe to be handled internally and also
> > +        * be exposed in the GATT API. This flag give such profiles exception
> > +        * from being claimed internally.
> > +        */
> > +       bool claim_service_exception;
> >
> >         int (*device_probe) (struct btd_service *service);
> >         void (*device_remove) (struct btd_service *service);
> > --
> > 2.26.2
> >
>
>
> --
> Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH BlueZ v2] profile: Add exception to battery profile for external access
  2020-07-15 22:47   ` [PATCH BlueZ v2] profile: Add exception to battery profile for external access Sonny Sasaka
@ 2020-07-17 20:13     ` Sonny Sasaka
  2020-07-17 20:33       ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 8+ messages in thread
From: Sonny Sasaka @ 2020-07-17 20:13 UTC (permalink / raw)
  To: BlueZ

Friendly ping on this simple patch.

On Wed, Jul 15, 2020 at 3:47 PM Sonny Sasaka <sonnysasaka@chromium.org> wrote:
>
> This gives exception to battery profile to be shared both internally and
> externally.
>
> ---
>  profiles/battery/battery.c | 1 +
>  src/profile.h              | 4 ++++
>  2 files changed, 5 insertions(+)
>
> diff --git a/profiles/battery/battery.c b/profiles/battery/battery.c
> index 4da4355a1..c9a1af4b9 100644
> --- a/profiles/battery/battery.c
> +++ b/profiles/battery/battery.c
> @@ -354,6 +354,7 @@ static struct btd_profile batt_profile = {
>         .device_remove  = batt_remove,
>         .accept         = batt_accept,
>         .disconnect     = batt_disconnect,
> +       .external       = true,
>  };
>
>  static int batt_init(void)
> diff --git a/src/profile.h b/src/profile.h
> index 4448a2a6d..95523e50a 100644
> --- a/src/profile.h
> +++ b/src/profile.h
> @@ -35,6 +35,10 @@ struct btd_profile {
>         const char *remote_uuid;
>
>         bool auto_connect;
> +       /* Some profiles are considered safe to be handled internally and also
> +        * be exposed in the GATT API. This flag give such profiles exception
> +        * from being claimed internally.
> +        */
>         bool external;
>
>         int (*device_probe) (struct btd_service *service);
> --
> 2.26.2
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH BlueZ v2] profile: Add exception to battery profile for external access
  2020-07-17 20:13     ` Sonny Sasaka
@ 2020-07-17 20:33       ` Luiz Augusto von Dentz
  2020-07-17 20:38         ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 8+ messages in thread
From: Luiz Augusto von Dentz @ 2020-07-17 20:33 UTC (permalink / raw)
  To: Sonny Sasaka; +Cc: BlueZ

Hi Sonny,

On Fri, Jul 17, 2020 at 1:17 PM Sonny Sasaka <sonnysasaka@chromium.org> wrote:
>
> Friendly ping on this simple patch.
>
> On Wed, Jul 15, 2020 at 3:47 PM Sonny Sasaka <sonnysasaka@chromium.org> wrote:
> >
> > This gives exception to battery profile to be shared both internally and
> > externally.
> >
> > ---
> >  profiles/battery/battery.c | 1 +
> >  src/profile.h              | 4 ++++
> >  2 files changed, 5 insertions(+)
> >
> > diff --git a/profiles/battery/battery.c b/profiles/battery/battery.c
> > index 4da4355a1..c9a1af4b9 100644
> > --- a/profiles/battery/battery.c
> > +++ b/profiles/battery/battery.c
> > @@ -354,6 +354,7 @@ static struct btd_profile batt_profile = {
> >         .device_remove  = batt_remove,
> >         .accept         = batt_accept,
> >         .disconnect     = batt_disconnect,
> > +       .external       = true,
> >  };
> >
> >  static int batt_init(void)
> > diff --git a/src/profile.h b/src/profile.h
> > index 4448a2a6d..95523e50a 100644
> > --- a/src/profile.h
> > +++ b/src/profile.h
> > @@ -35,6 +35,10 @@ struct btd_profile {
> >         const char *remote_uuid;
> >
> >         bool auto_connect;
> > +       /* Some profiles are considered safe to be handled internally and also
> > +        * be exposed in the GATT API. This flag give such profiles exception
> > +        * from being claimed internally.
> > +        */
> >         bool external;
> >
> >         int (*device_probe) (struct btd_service *service);
> > --
> > 2.26.2
> >

I've might have forgotten to announce it on the mailing list but this
has been applied for a while:

commit 0509a4a217256ac46020b957a6532dc150729748 (HEAD -> master)
Author: Sonny Sasaka <sonnysasaka@chromium.org>
Date:   Wed Jul 15 15:47:40 2020 -0700

    profile: Add exception to battery profile for external access

    This gives exception to battery profile to be shared both internally and
    externally.


-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH BlueZ v2] profile: Add exception to battery profile for external access
  2020-07-17 20:33       ` Luiz Augusto von Dentz
@ 2020-07-17 20:38         ` Luiz Augusto von Dentz
  2020-07-17 21:36           ` Sonny Sasaka
  0 siblings, 1 reply; 8+ messages in thread
From: Luiz Augusto von Dentz @ 2020-07-17 20:38 UTC (permalink / raw)
  To: Sonny Sasaka; +Cc: BlueZ

Hi Sonny,

On Fri, Jul 17, 2020 at 1:33 PM Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
>
> Hi Sonny,
>
> On Fri, Jul 17, 2020 at 1:17 PM Sonny Sasaka <sonnysasaka@chromium.org> wrote:
> >
> > Friendly ping on this simple patch.
> >
> > On Wed, Jul 15, 2020 at 3:47 PM Sonny Sasaka <sonnysasaka@chromium.org> wrote:
> > >
> > > This gives exception to battery profile to be shared both internally and
> > > externally.
> > >
> > > ---
> > >  profiles/battery/battery.c | 1 +
> > >  src/profile.h              | 4 ++++
> > >  2 files changed, 5 insertions(+)
> > >
> > > diff --git a/profiles/battery/battery.c b/profiles/battery/battery.c
> > > index 4da4355a1..c9a1af4b9 100644
> > > --- a/profiles/battery/battery.c
> > > +++ b/profiles/battery/battery.c
> > > @@ -354,6 +354,7 @@ static struct btd_profile batt_profile = {
> > >         .device_remove  = batt_remove,
> > >         .accept         = batt_accept,
> > >         .disconnect     = batt_disconnect,
> > > +       .external       = true,
> > >  };
> > >
> > >  static int batt_init(void)
> > > diff --git a/src/profile.h b/src/profile.h
> > > index 4448a2a6d..95523e50a 100644
> > > --- a/src/profile.h
> > > +++ b/src/profile.h
> > > @@ -35,6 +35,10 @@ struct btd_profile {
> > >         const char *remote_uuid;
> > >
> > >         bool auto_connect;
> > > +       /* Some profiles are considered safe to be handled internally and also
> > > +        * be exposed in the GATT API. This flag give such profiles exception
> > > +        * from being claimed internally.
> > > +        */
> > >         bool external;
> > >
> > >         int (*device_probe) (struct btd_service *service);
> > > --
> > > 2.26.2
> > >
>
> I've might have forgotten to announce it on the mailing list but this
> has been applied for a while:
>
> commit 0509a4a217256ac46020b957a6532dc150729748 (HEAD -> master)
> Author: Sonny Sasaka <sonnysasaka@chromium.org>
> Date:   Wed Jul 15 15:47:40 2020 -0700
>
>     profile: Add exception to battery profile for external access
>
>     This gives exception to battery profile to be shared both internally and
>     externally.

Nevermind, it was just in my local tree for some reason, now I've applied it.

-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH BlueZ v2] profile: Add exception to battery profile for external access
  2020-07-17 20:38         ` Luiz Augusto von Dentz
@ 2020-07-17 21:36           ` Sonny Sasaka
  0 siblings, 0 replies; 8+ messages in thread
From: Sonny Sasaka @ 2020-07-17 21:36 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: BlueZ

Thanks, Luiz.

On Fri, Jul 17, 2020 at 1:38 PM Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
>
> Hi Sonny,
>
> On Fri, Jul 17, 2020 at 1:33 PM Luiz Augusto von Dentz
> <luiz.dentz@gmail.com> wrote:
> >
> > Hi Sonny,
> >
> > On Fri, Jul 17, 2020 at 1:17 PM Sonny Sasaka <sonnysasaka@chromium.org> wrote:
> > >
> > > Friendly ping on this simple patch.
> > >
> > > On Wed, Jul 15, 2020 at 3:47 PM Sonny Sasaka <sonnysasaka@chromium.org> wrote:
> > > >
> > > > This gives exception to battery profile to be shared both internally and
> > > > externally.
> > > >
> > > > ---
> > > >  profiles/battery/battery.c | 1 +
> > > >  src/profile.h              | 4 ++++
> > > >  2 files changed, 5 insertions(+)
> > > >
> > > > diff --git a/profiles/battery/battery.c b/profiles/battery/battery.c
> > > > index 4da4355a1..c9a1af4b9 100644
> > > > --- a/profiles/battery/battery.c
> > > > +++ b/profiles/battery/battery.c
> > > > @@ -354,6 +354,7 @@ static struct btd_profile batt_profile = {
> > > >         .device_remove  = batt_remove,
> > > >         .accept         = batt_accept,
> > > >         .disconnect     = batt_disconnect,
> > > > +       .external       = true,
> > > >  };
> > > >
> > > >  static int batt_init(void)
> > > > diff --git a/src/profile.h b/src/profile.h
> > > > index 4448a2a6d..95523e50a 100644
> > > > --- a/src/profile.h
> > > > +++ b/src/profile.h
> > > > @@ -35,6 +35,10 @@ struct btd_profile {
> > > >         const char *remote_uuid;
> > > >
> > > >         bool auto_connect;
> > > > +       /* Some profiles are considered safe to be handled internally and also
> > > > +        * be exposed in the GATT API. This flag give such profiles exception
> > > > +        * from being claimed internally.
> > > > +        */
> > > >         bool external;
> > > >
> > > >         int (*device_probe) (struct btd_service *service);
> > > > --
> > > > 2.26.2
> > > >
> >
> > I've might have forgotten to announce it on the mailing list but this
> > has been applied for a while:
> >
> > commit 0509a4a217256ac46020b957a6532dc150729748 (HEAD -> master)
> > Author: Sonny Sasaka <sonnysasaka@chromium.org>
> > Date:   Wed Jul 15 15:47:40 2020 -0700
> >
> >     profile: Add exception to battery profile for external access
> >
> >     This gives exception to battery profile to be shared both internally and
> >     externally.
>
> Nevermind, it was just in my local tree for some reason, now I've applied it.
>
> --
> Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, back to index

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-15 22:28 [PATCH BlueZ] profile: Add exception from being claimed internally Sonny Sasaka
2020-07-15 22:39 ` Luiz Augusto von Dentz
2020-07-15 22:47   ` [PATCH BlueZ v2] profile: Add exception to battery profile for external access Sonny Sasaka
2020-07-17 20:13     ` Sonny Sasaka
2020-07-17 20:33       ` Luiz Augusto von Dentz
2020-07-17 20:38         ` Luiz Augusto von Dentz
2020-07-17 21:36           ` Sonny Sasaka
2020-07-15 22:49   ` [PATCH BlueZ] profile: Add exception from being claimed internally Sonny Sasaka

Linux-Bluetooth Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-bluetooth/0 linux-bluetooth/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-bluetooth linux-bluetooth/ https://lore.kernel.org/linux-bluetooth \
		linux-bluetooth@vger.kernel.org
	public-inbox-index linux-bluetooth

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-bluetooth


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git