Linux bluetooth development
 help / color / mirror / Atom feed
From: Andrei Emeltchenko <andrei.emeltchenko.news@gmail.com>
To: Marcel Holtmann <marcel@holtmann.org>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCHv3 07/15] android: Create HAL API header skeleton
Date: Thu, 10 Oct 2013 15:29:14 +0300	[thread overview]
Message-ID: <20131010122911.GJ23879@aemeltch-MOBL1> (raw)
In-Reply-To: <69ADBAAE-9261-4C56-9779-5708DE897CBA@holtmann.org>

On Wed, Oct 09, 2013 at 09:34:17PM +0200, Marcel Holtmann wrote:
> Hi Andrei,
> 
> > Header describes the protocol between Android HAL threads and BlueZ
> > daemon.
> > ---
> > android/hal_msg.h |  255 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 255 insertions(+)
> > create mode 100644 android/hal_msg.h
> > 
> > diff --git a/android/hal_msg.h b/android/hal_msg.h
> > new file mode 100644
> > index 0000000..c6bc883
> > --- /dev/null
> > +++ b/android/hal_msg.h
> > @@ -0,0 +1,255 @@
> > +/*
> > + *
> > + *  BlueZ - Bluetooth protocol stack for Linux
> > + *
> > + *  Copyright (C) 2013  Intel Corporation. All rights reserved.
> > + *
> > + *
> > + *  This library is free software; you can redistribute it and/or
> > + *  modify it under the terms of the GNU Lesser General Public
> > + *  License as published by the Free Software Foundation; either
> > + *  version 2.1 of the License, or (at your option) any later version.
> > + *
> > + *  This library is distributed in the hope that it will be useful,
> > + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> > + *  Lesser General Public License for more details.
> > + *
> > + *  You should have received a copy of the GNU Lesser General Public
> > + *  License along with this library; if not, write to the Free Software
> > + *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> > + *
> > + */
> > +
> > +#ifndef __packed
> > +#define __packed __attribute__((packed))
> > +#endif

you want different style from lib/mgmt.h ?

> 
> nowhere in the code we are using __packed. That is more a kernel thing. Just use the gcc style directly.
> 
> > +
> > +typedef struct {
> > +	uint8_t b[6];
> > +} __packed __bdaddr_t;
> 
> Just use a uint8_t bdaddr[6] instead.
> 
> > +
> > +struct hal_msg_hdr {
> > +	uint8_t service_id;
> > +	uint8_t opcode;
> > +	uint16_t len;
> > +	uint8_t payload[0];
> 
> I would not include the payload[0] here.

I know that the current approach is to magically add to pointer header
size, but doesn't it looks better?

> 
> > +} __packed;
> > +
> > +#define HAL_SERVICE_ID_CORE		0
> > +#define HAL_SERVICE_ID_BLUETOOTH	1
> > +#define HAL_SERVICE_ID_SOCK		2
> > +#define HAL_SERVICE_ID_HIDHOST		3
> > +#define HAL_SERVICE_ID_PAN		4
> > +#define HAL_SERVICE_ID_HANDSFREE	5
> > +#define HAL_SERVICE_ID_AD2P		6
> > +#define HAL_SERVICE_ID_HEALTH		7
> > +#define HAL_SERVICE_ID_AVRCP		8
> > +#define HAL_SERVICE_ID_GATT		9
> > +
> > +/* Core Service */
> > +
> > +#define HAL_MSG_OP_ERROR		0x00
> > +struct hal_msg_rp_error {
> > +	uint8_t status;
> > +} __packed;
> 
> using RSP, rsp, CMD, cmd, EVT and EVT seems to be clearer I think.

So I want to be sure that I understand this right:

hal_msg_rp_error => hal_msg_rsp_error

hal_msg_cp_register_module => hal_msg_cmd_register_module

this would be different from lib/mgmt.h

> > +
> > +#define HAL_MSG_OP_REGISTER_MODULE	0x01
> > +struct hal_msg_cp_register_module {
> > +	uint8_t service_id;
> > +} __packed;
> > +struct hal_msg_rp_register_module {
> > +	uint8_t service_id;
> > +} __packed;
> > +
> > +#define HAL_MSG_OP_UNREGISTER_MODULE	0x02
> > +struct hal_msg_cp_unregister_module {
> > +	uint8_t service_id;
> > +} __packed;
> > +
> > +/* Bluetooth Core HAL API */
> > +
> > +#define HAL_MSG_OP_BT_ENABLE		0x01
> > +
> > +#define HAL_MSG_OP_BT_DISABLE		0x02
> > +
> > +#define HAL_MSG_OP_BT_GET_ADAPTER_PROPS	0x03
> > +
> > +#define HAL_MSG_OP_BT_GET_ADAPTER_PROP	0x04
> > +struct hal_msg_cp_bt_get_adapter_prop {
> > +	uint8_t type;
> > +} __packed;
> > +
> > +#define HAL_MSG_OP_BT_SET_ADAPTER_PROP	0x05
> > +struct hal_msg_cp_bt_set_adapter_prop {
> > +	uint8_t type;
> > +	uint16_t len;
> > +	uint8_t val[0];
> > +} __packed;
> > +
> > +#define HAL_MSG_OP_BT_GET_REMOTE_DEVICE_PROPS	0x06
> > +struct hal_msg_cp_bt_get_remote_device_props {
> > +	__bdaddr_t bdaddr;
> > +} __packed;
> > +
> > +#define HAL_MSG_OP_BT_GET_REMOTE_DEVICE_PROP	0x07
> > +struct hal_msg_cp_bt_get_remote_device_prop {
> > +	__bdaddr_t bdaddr;
> > +	uint8_t type;
> > +} __packed;
> > +
> > +#define HAL_MSG_OP_BT_SET_REMOTE_DEVICE_PROP	0x08
> > +struct hal_msg_cp_bt_set_remote_device_prop {
> > +	__bdaddr_t bdaddr;
> > +	uint8_t type;
> > +	uint16_t len;
> 
> Lets make these all align properly.

Align with tabs? So this will be very different from lib/mgmt.h ?

Best regards 
Andrei Emeltchenko 
 

  reply	other threads:[~2013-10-10 12:29 UTC|newest]

Thread overview: 91+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-07  7:38 [PATCHv1 00/15] Basic code for Android BlueZ Andrei Emeltchenko
2013-10-07  7:38 ` [PATCHv1 01/15] android: Supress missing initializers warnings Andrei Emeltchenko
2013-10-07  7:38 ` [PATCHv1 02/15] android: Add Adapter Bluetooth HAL template Andrei Emeltchenko
2013-10-07  7:38 ` [PATCHv1 03/15] android: Add Socket " Andrei Emeltchenko
2013-10-07  7:38 ` [PATCHv1 04/15] android: Enable Socket interface Andrei Emeltchenko
2013-10-07  7:38 ` [PATCHv1 05/15] android: Start Android Bluetooth daemon Andrei Emeltchenko
2013-10-07 12:09   ` Szymon Janc
2013-10-07  7:38 ` [PATCHv1 06/15] android: Add basic mgmt initialization sequence Andrei Emeltchenko
2013-10-07  7:38 ` [PATCHv1 07/15] android: Create HAL API header skeleton Andrei Emeltchenko
2013-10-07  7:38 ` [PATCHv1 08/15] android: Add adapter and device struct for BlueZ daemon Andrei Emeltchenko
2013-10-07  7:38 ` [PATCHv1 09/15] android: Add Android Makefile for libbluetooth Andrei Emeltchenko
2013-10-07  7:38 ` [PATCHv1 10/15] android: sdp: Reuse BlueZ SDP server in Android Andrei Emeltchenko
2013-10-07  7:38 ` [PATCHv1 11/15] android: Add cap to bind to port < 1024 Andrei Emeltchenko
2013-10-07 12:14   ` Szymon Janc
2013-10-07  7:38 ` [PATCHv1 12/15] android: Implement read_info_complete callback Andrei Emeltchenko
2013-10-07 12:26   ` Andrei Emeltchenko
2013-10-07  7:38 ` [PATCHv1 13/15] android: Handle mgmt changed events Andrei Emeltchenko
2013-10-07  7:38 ` [PATCHv1 14/15] android: Add makefile for hciconfig Andrei Emeltchenko
2013-10-07  7:38 ` [PATCHv1 15/15] android: Add makefile for hcitool Andrei Emeltchenko
2013-10-08 10:33 ` [PATCHv2 00/15] Basic code for Android BlueZ Andrei Emeltchenko
2013-10-08 10:33   ` [PATCHv2 01/15] android: Supress missing initializers warnings Andrei Emeltchenko
2013-10-08 10:33   ` [PATCHv2 02/15] android: Add Adapter Bluetooth HAL template Andrei Emeltchenko
2013-10-08 10:33   ` [PATCHv2 03/15] android: Add Socket " Andrei Emeltchenko
2013-10-08 10:33   ` [PATCHv2 04/15] android: Enable Socket interface Andrei Emeltchenko
2013-10-08 10:33   ` [PATCHv2 05/15] android: Start Android Bluetooth daemon Andrei Emeltchenko
2013-10-08 10:33   ` [PATCHv2 06/15] android: Add basic mgmt initialization sequence Andrei Emeltchenko
2013-10-08 10:33   ` [PATCHv2 07/15] android: Create HAL API header skeleton Andrei Emeltchenko
2013-10-08 10:33   ` [PATCHv2 08/15] android: Add adapter and device struct for BlueZ daemon Andrei Emeltchenko
2013-10-08 10:33   ` [PATCHv2 09/15] android: Add Android Makefile for libbluetooth Andrei Emeltchenko
2013-10-08 10:33   ` [PATCHv2 10/15] android: sdp: Reuse BlueZ SDP server in Android Andrei Emeltchenko
2013-10-08 10:33   ` [PATCHv2 11/15] android: Add cap to bind to port < 1024 Andrei Emeltchenko
2013-10-08 10:33   ` [PATCHv2 12/15] android: Implement read_info_complete callback Andrei Emeltchenko
2013-10-08 10:33   ` [PATCHv2 13/15] android: Handle mgmt changed events Andrei Emeltchenko
2013-10-08 10:33   ` [PATCHv2 14/15] android: Add makefile for hciconfig Andrei Emeltchenko
2013-10-08 10:33   ` [PATCHv2 15/15] android: Add makefile for hcitool Andrei Emeltchenko
2013-10-08 14:51 ` [PATCHv3 00/15] Basic code for Android BlueZ Andrei Emeltchenko
2013-10-08 14:51   ` [PATCHv3 01/15] android: Supress missing initializers warnings Andrei Emeltchenko
2013-10-09 19:11     ` Marcel Holtmann
2013-10-09 22:55       ` Lucas De Marchi
2013-10-10  6:58       ` Andrei Emeltchenko
2013-10-10  7:35         ` Marcel Holtmann
2013-10-10  8:07           ` Andrei Emeltchenko
2013-10-10  8:10             ` Marcel Holtmann
2013-10-10  8:16               ` Andrei Emeltchenko
2013-10-08 14:51   ` [PATCHv3 02/15] android: Add Adapter Bluetooth HAL template Andrei Emeltchenko
2013-10-08 14:51   ` [PATCHv3 03/15] android: Add Socket " Andrei Emeltchenko
2013-10-09 19:14     ` Marcel Holtmann
2013-10-10  6:56       ` Andrei Emeltchenko
2013-10-10  7:33         ` Marcel Holtmann
2013-10-08 14:51   ` [PATCHv3 04/15] android: Enable Socket interface Andrei Emeltchenko
2013-10-09 19:15     ` Marcel Holtmann
2013-10-08 14:51   ` [PATCHv3 05/15] android: Start Android Bluetooth daemon Andrei Emeltchenko
2013-10-09 19:19     ` Marcel Holtmann
2013-10-08 14:51   ` [PATCHv3 06/15] android: Add basic mgmt initialization sequence Andrei Emeltchenko
2013-10-09 19:30     ` Marcel Holtmann
2013-10-10  9:59       ` Andrei Emeltchenko
2013-10-10 12:38         ` Marcel Holtmann
2013-10-08 14:51   ` [PATCHv3 07/15] android: Create HAL API header skeleton Andrei Emeltchenko
2013-10-09 19:34     ` Marcel Holtmann
2013-10-10 12:29       ` Andrei Emeltchenko [this message]
2013-10-10 12:35         ` Marcel Holtmann
2013-10-10 12:48           ` Andrei Emeltchenko
2013-10-10 13:02             ` Marcel Holtmann
2013-10-08 14:51   ` [PATCHv3 08/15] android: Add adapter and device struct for BlueZ daemon Andrei Emeltchenko
2013-10-09 19:39     ` Marcel Holtmann
2013-10-10 12:36       ` Andrei Emeltchenko
2013-10-10 12:40         ` Marcel Holtmann
2013-10-10  9:07     ` Marcin Kraglak
2013-10-10 12:30       ` Andrei Emeltchenko
2013-10-10 13:18         ` Marcin Kraglak
2013-10-10 13:27           ` Andrei Emeltchenko
2013-10-08 14:51   ` [PATCHv3 09/15] android: Add Android Makefile for libbluetooth Andrei Emeltchenko
2013-10-09 19:43     ` Marcel Holtmann
2013-10-10 12:43       ` Andrei Emeltchenko
2013-10-10 12:45         ` Marcel Holtmann
2013-10-10 12:52           ` Andrei Emeltchenko
2013-10-08 14:51   ` [PATCHv3 10/15] android: sdp: Reuse BlueZ SDP server in Android Andrei Emeltchenko
2013-10-09 19:45     ` Marcel Holtmann
2013-10-08 14:51   ` [PATCHv3 11/15] android: Add cap to bind to port < 1024 Andrei Emeltchenko
2013-10-09 19:48     ` Marcel Holtmann
2013-10-10 13:01       ` Andrei Emeltchenko
2013-10-08 14:51   ` [PATCHv3 12/15] android: Implement read_info_complete callback Andrei Emeltchenko
2013-10-09 19:54     ` Marcel Holtmann
2013-10-08 14:51   ` [PATCHv3 13/15] android: Handle mgmt changed events Andrei Emeltchenko
2013-10-09 19:58     ` Marcel Holtmann
2013-10-08 14:51   ` [PATCHv3 14/15] android: Add makefile for hciconfig Andrei Emeltchenko
2013-10-09 19:59     ` Marcel Holtmann
2013-10-14 11:51       ` Andrei Emeltchenko
2013-10-14 12:06         ` Marcel Holtmann
2013-10-14 13:39           ` Michal Labedzki
2013-10-08 14:51   ` [PATCHv3 15/15] android: Add makefile for hcitool Andrei Emeltchenko

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=20131010122911.GJ23879@aemeltch-MOBL1 \
    --to=andrei.emeltchenko.news@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=marcel@holtmann.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