linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrzej Kaczmarek <andrzej.kaczmarek@tieto.com>
To: <linux-bluetooth@vger.kernel.org>
Cc: Johan Hedberg <johan.hedberg@gmail.com>
Subject: Re: [PATCH v2 01/20] cyclingspeed: Add CSC profile plugin skeleton
Date: Mon, 3 Dec 2012 10:09:26 +0100	[thread overview]
Message-ID: <50BC6C46.2020607@tieto.com> (raw)
In-Reply-To: <20121115093126.GA4414@x220>

Hi Johan,

On 11/15/2012 10:31 AM, Johan Hedberg wrote:
> Hi Andrzej,
>
> On Mon, Nov 05, 2012, Andrzej Kaczmarek wrote:
>> This patch adds stub profile driver plugin for CSC profile.
>> ---
>>   Makefile.am                          |   9 +-
>>   lib/uuid.h                           |   2 +
>>   profiles/cyclingspeed/cyclingspeed.c | 163 +++++++++++++++++++++++++++++++++++
>>   profiles/cyclingspeed/cyclingspeed.h |  26 ++++++
>>   profiles/cyclingspeed/main.c         |  53 ++++++++++++
>>   profiles/cyclingspeed/manager.c      |  79 +++++++++++++++++
>>   profiles/cyclingspeed/manager.h      |  24 ++++++
>>   7 files changed, 354 insertions(+), 2 deletions(-)
>>   create mode 100644 profiles/cyclingspeed/cyclingspeed.c
>>   create mode 100644 profiles/cyclingspeed/cyclingspeed.h
>>   create mode 100644 profiles/cyclingspeed/main.c
>>   create mode 100644 profiles/cyclingspeed/manager.c
>>   create mode 100644 profiles/cyclingspeed/manager.h
>
> You'll need to rebase these against latest git since this one doesn't
> apply cleanly (due to Makefile.am) and doesn't compile either (due to
> main_opts.gatt_enabled having been removed).

Sure, will do.

>> +struct csc_adapter {
>> +	struct btd_adapter	*adapter;
>> +	GSList			*devices;	/* list of registered devices */
>> +};
>> +
>> +struct csc {
>> +	struct btd_device	*dev;
>> +	struct csc_adapter	*cadapter;
>> +};
>
> I'm a bit worried that we've failed to create proper internal GATT APIs
> if they require this kind of per-profile tracking of devices and
> adapters. You can already get a list of btd_device from btd_adapter and
> the btd_adapter from a btd_device. Profiles should only need to track a
> very minimal amount of context.

Probably would be good to have some kind of API to attach profile 
specific data for particular device and/or adapter so we can get rid of 
duplicated code across plugins and just use one already existing list. 
Not sure how this could look like at the moment though.

>> +++ b/profiles/cyclingspeed/main.c
>> @@ -0,0 +1,53 @@

<snip>

>> +static int cyclingspeed_init(void)
>> +{
>> +	if (!main_opts.gatt_enabled) {
>> +		DBG("GATT is disabled");
>> +		return -ENOTSUP;
>> +	}
>> +
>> +	return cyclingspeed_manager_init();
>> +}
>> +
>> +static void cyclingspeed_exit(void)
>> +{
>> +	cyclingspeed_manager_exit();
>> +}
>> +
>> +BLUETOOTH_PLUGIN_DEFINE(cyclingspeed, VERSION,
>> +					BLUETOOTH_PLUGIN_PRIORITY_DEFAULT,
>> +					cyclingspeed_init, cyclingspeed_exit)
>
> If this is all the main.c file does seems like it should be merged into
> manager.c or even cyclingspeed.c.
>
>> +++ b/profiles/cyclingspeed/manager.c
>> @@ -0,0 +1,79 @@

<snip>

>> +
>> +static struct btd_profile cscp_profile = {
>> +	.name		= "Cycling Speed and Cadence GATT Driver",
>> +	.remote_uuids	= BTD_UUIDS(CYCLING_SC_UUID),
>> +
>> +	.adapter_probe	= csc_adapter_probe,
>> +	.adapter_remove	= csc_adapter_remove,
>> +
>> +	.device_probe	= csc_device_probe,
>> +	.device_remove	= csc_device_remove,
>> +};
>> +
>> +int cyclingspeed_manager_init(void)
>> +{
>> +	return btd_profile_register(&cscp_profile);
>> +}
>> +
>> +void cyclingspeed_manager_exit(void)
>> +{
>> +	btd_profile_unregister(&cscp_profile);
>> +}
>
> Are these functions ever going to do anything else than make single
> Vcalls into cyclingspeed.c? If not it seems to me like all this should
> be merged into that file.
>
> Btw, I do realize that other profiles might have similar brain dead
> design but that's not a good enough excuse to keep replicating the bad
> design. Instead the other profiles should be fixed.

Probably I'll just merge all this code into single cyclingspeed.c since 
all code in main.c and manager.c are just dumb calls and I don't see any 
need to extend them in future.

I'll try to send new patchset later today.

BR,
Andrzej

  reply	other threads:[~2012-12-03  9:09 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-05  8:54 [PATCH v2 00/20] CSCP plugin Andrzej Kaczmarek
2012-11-05  8:54 ` [PATCH v2 01/20] cyclingspeed: Add CSC profile plugin skeleton Andrzej Kaczmarek
2012-11-15  9:31   ` Johan Hedberg
2012-12-03  9:09     ` Andrzej Kaczmarek [this message]
2012-11-05  8:54 ` [PATCH v2 02/20] cyclingspeed: Add attio callbacks Andrzej Kaczmarek
2012-11-05  8:54 ` [PATCH v2 03/20] cyclingspeed: Discover CSCS characteristics Andrzej Kaczmarek
2012-11-05  8:54 ` [PATCH v2 04/20] cyclingspeed: Discover characteristics CCC Andrzej Kaczmarek
2012-11-05  8:54 ` [PATCH v2 05/20] cyclingspeed: Read CSC Feature characteristic value Andrzej Kaczmarek
2012-11-05  8:54 ` [PATCH v2 06/20] cyclingspeed: Read Sensor Location " Andrzej Kaczmarek
2012-11-05  8:54 ` [PATCH v2 07/20] cyclingspeed: Add CyclingSpeedManager interface Andrzej Kaczmarek
2012-11-05  8:54 ` [PATCH v2 08/20] cyclingspeed: Add support to enable measurement notifications Andrzej Kaczmarek
2012-11-05  8:54 ` [PATCH v2 09/20] cyclingspeed: Process " Andrzej Kaczmarek
2012-11-05  8:54 ` [PATCH v2 10/20] cyclingspeed: Add DBus.Properties for org.bluez.CyclingSpeed interface Andrzej Kaczmarek
2012-11-05  8:54 ` [PATCH v2 11/20] cyclingspeed: Add stub to use SC Control Point Andrzej Kaczmarek
2012-11-14  0:31   ` Lucas De Marchi
2012-11-05  8:54 ` [PATCH v2 12/20] cyclingspeed: Add support for Request Supported Sensor Locations Andrzej Kaczmarek
2012-11-05  8:54 ` [PATCH v2 13/20] cyclingspeed: Add support for Update Sensor Location Andrzej Kaczmarek
2012-11-05  8:54 ` [PATCH v2 14/20] cyclingspeed: Add support for Set Cumulative Value Andrzej Kaczmarek
2012-11-05  8:55 ` [PATCH v2 15/20] core: Add CyclingSpeedWatcher interface to default policy Andrzej Kaczmarek
2012-11-05  8:55 ` [PATCH v2 16/20] doc: Remove Get-/SetProperties from CSC API document Andrzej Kaczmarek
2012-11-05  8:55 ` [PATCH v2 17/20] doc: Rename cycling API to cyclingspeed Andrzej Kaczmarek
2012-11-05  8:55 ` [PATCH v2 18/20] build: Add CSCP API document to EXTRA_DIST Andrzej Kaczmarek
2012-11-05  8:55 ` [PATCH v2 19/20] test: Add cyclingspeed test script Andrzej Kaczmarek
2012-11-05  8:55 ` [PATCH v2 20/20] test: Enable speed and cadence calculation in test-cyclingspeed Andrzej Kaczmarek
2012-11-14  0:35 ` [PATCH v2 00/20] CSCP plugin Lucas De Marchi

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=50BC6C46.2020607@tieto.com \
    --to=andrzej.kaczmarek@tieto.com \
    --cc=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).