Linux bluetooth development
 help / color / mirror / Atom feed
From: Szymon Janc <szymon.janc@tieto.com>
To: Andrei Emeltchenko <Andrei.Emeltchenko.news@gmail.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [RFCv2 06/14] android: Create HAL API header skeleton
Date: Thu, 03 Oct 2013 16:07:08 +0200	[thread overview]
Message-ID: <4501039.OZxtA2WV21@uw000953> (raw)
In-Reply-To: <1380639799-25790-7-git-send-email-Andrei.Emeltchenko.news@gmail.com>

Hi Andrei,

> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> 
> Header describes the protocol between Android HAL threads and BlueZ
> daemon.
> ---
>  android/hal_msg.h |  260 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 260 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..2d4436a
> --- /dev/null
> +++ b/android/hal_msg.h
> @@ -0,0 +1,260 @@
> +/*
> + *
> + *  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
> +
> +typedef struct {
> +	uint8_t b[6];
> +} __packed __bdaddr_t;
> +
> +struct hal_msg_hdr {
> +	uint8_t service_id;
> +	uint8_t opcode;
> +	uint16_t len;
> +	uint8_t payload[0];
> +} __packed;
> +
> +#define HAL_SERVICE_ID_CORE		0
> +#define HAL_SERVICE_ID_BLUETOOTH	1

SOCK (id 2) is missing here

> +#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 */
> +
> +struct hal_msg_rsp {
> +	struct hal_msg_hdr hdr;
> +	uint8_t status;
> +} __packed;

Non-error response to request has no status field, just header.

> +
> +#define HAL_MSG_OP_ERROR		0x00
> +struct hal_msg_rp_error {
> +	uint8_t status;
> +} __packed;
> +
> +#define HAL_MSG_OP_REGISTER_MODULE	0x02

Should be 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	0x03

Should be 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;
> +	uint8_t val[0];
> +} __packed;
> +
> +#define HAL_MSG_OP_BT_GET_REMOTE_SERVICE_REC	0x09
> +struct hal_msg_cp_bt_get_remote_service_rec {
> +	__bdaddr_t bdaddr;
> +	uint8_t uuid[16];
> +} __packed;
> +
> +#define HAL_MSG_OP_BT_GET_REMOTE_SERVICE	0x0a
> +struct hal_msg_cp_bt_get_remote_service {
> +	__bdaddr_t bdaddr;
> +} __packed;
> +
> +#define HAL_MSG_OP_BT_START_DISCOVERY	0x0b
> +
> +#define HAL_MSG_OP_BT_CANCEL_DISCOVERY	0x0c
> +
> +#define HAL_MSG_OP_BT_CREATE_BOND	0x0d
> +struct hal_msg_cp_bt_create_bond {
> +	__bdaddr_t bdaddr;
> +} __packed;
> +
> +#define HAL_MSG_OP_BT_REMOVE_BOND	0x0d
> +struct hal_msg_cp_bt_remove_bond {
> +	__bdaddr_t bdaddr;
> +} __packed;
> +
> +#define HAL_MSG_OP_BT_CANCEL_BOND	0x0f
> +struct hal_msg_cp_bt_cancel_bond {
> +	__bdaddr_t bdaddr;
> +} __packed;
> +
> +#define HAL_MSG_OP_BT_PIN_REPLY		0x10
> +struct hal_msg_cp_bt_pin_reply {
> +	__bdaddr_t bdaddr;
> +	uint8_t accept;
> +	uint8_t pin_len;
> +	uint8_t pin_code[16];
> +} __packed;
> +
> +#define HAL_MSG_OP_BT_SSP_REPLY		0x11
> +struct hal_msg_cp_bt_ssp_reply {
> +	__bdaddr_t bdaddr;
> +	uint8_t ssp_variant;
> +	uint8_t accept;
> +	uint32_t passkey;
> +} __packed;
> +
> +#define HAL_MSG_OP_BT_DUT_MODE_CONF	0x12
> +struct hal_msg_cp_bt_dut_mode_conf {
> +	uint8_t enable;
> +} __packed;
> +
> +#define HAL_MSG_OP_BT_DUT_MODE_SEND	0x13
> +struct hal_msg_cp_bt_dut_mode_send {
> +	uint16_t opcode;
> +	uint8_t len;
> +	uint8_t data[0];
> +} __packed;
> +
> +#define HAL_MSG_OP_BT_LE_TEST_MODE	0x14
> +struct hal_msg_cp_bt_le_test_mode {
> +	uint16_t opcode;
> +	uint8_t len;
> +	uint8_t data[0];
> +} __packed;
> +
> +/* Notifications and confirmations */
> +
> +#define HAL_MSG_EV_BT_ERROR			0x80
> +
> +#define HAL_MSG_EV_BT_ADAPTER_STATE_CHANGED	0x81
> +struct hal_msg_ev_bt_adapter_state_changed {
> +	uint8_t state;
> +} __packed;
> +
> +#define HAL_MSG_EV_BT_ADAPTER_PROPS_CHANGED	0x82
> +struct hal_property {
> +	uint8_t type;
> +	uint16_t len;
> +	uint8_t val[0];
> +} __packed;
> +struct hal_msg_ev_bt_adapter_props_changed {
> +	uint8_t status;
> +	uint8_t num_props;
> +	struct hal_property props[0];
> +} __packed;
> +
> +#define HAL_MSG_EV_BT_REMOTE_DEVICE_PROPS	0x83
> +struct hal_msg_ev_bt_remote_device_props {
> +	uint8_t status;
> +	__bdaddr_t bdaddr;
> +	uint8_t num_props;
> +	struct hal_property props[0];
> +} __packed;
> +
> +#define HAL_MSG_EV_BT_DEVICE_FOUND		0x84
> +struct hal_msg_ev_bt_device_found {
> +	uint8_t num_props;
> +	struct hal_property props[0];
> +} __packed;
> +
> +#define HAL_MSG_EV_BT_DISCOVERY_STATE_CHANGED	0x85
> +struct hal_msg_ev_bt_discovery_state_changed {
> +	uint8_t state;
> +} __packed;
> +
> +#define HAL_MSG_EV_BT_PIN_REQUEST		0x86
> +struct hal_msg_ev_bt_pin_request {
> +	__bdaddr_t bdaddr;
> +	uint8_t name[249 - 1];
> +	uint8_t class_of_dev[3];
> +} __packed;
> +
> +#define HAL_MSG_EV_BT_SSP_REQUEST		0x87
> +struct hal_msg_ev_bt_ssp_request {
> +	__bdaddr_t bdaddr;
> +	uint8_t name[249 - 1];
> +	uint8_t class_of_dev[3];
> +	uint8_t pairing_variant;
> +	uint32_t passkey;
> +} __packed;
> +
> +#define HAL_MSG_EV_BT_BOND_STATE_CHANGED	0x88
> +struct hal_msg_ev_bt_bond_state_changed {
> +	uint8_t status;
> +	__bdaddr_t bdaddr;
> +	uint8_t state;
> +} __packed;
> +
> +#define HAL_MSG_EV_BT_ACL_STATE_CHANGED		0x89
> +struct hal_msg_ev_bt_acl_state_changed {
> +	uint8_t status;
> +	__bdaddr_t bdaddr;
> +	uint8_t state;
> +} __packed;
> +
> +#define HAL_MSG_EV_BT_DUT_MODE_RECEIVE		0x8a
> +struct hal_msg_ev_bt_dut_mode_receive {
> +	uint16_t opcode;
> +	uint8_t len;
> +	uint8_t data[0];
> +} __packed;
> +
> +#define HAL_MSG_EV_BT_LE_TEST_MODE		0x8b
> +struct hal_msg_ev_bt_le_test_mode {
> +	uint8_t status;
> +	uint16_t num_packets;
> +} __packed;
> 

-- 
BR
Szymon Janc


  reply	other threads:[~2013-10-03 14:07 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-01 15:03 [RFCv2 00/14] Basic code for Android BlueZ Andrei Emeltchenko
2013-10-01 15:03 ` [RFCv2 01/14] android: Add Adapter Bluetooth HAL template Andrei Emeltchenko
2013-10-01 15:03 ` [RFCv2 02/14] android: Add Socket " Andrei Emeltchenko
2013-10-01 15:03 ` [RFCv2 03/14] android: Enable Socket interface Andrei Emeltchenko
2013-10-01 15:03 ` [RFCv2 04/14] android: Start Android Bluetooth daemon Andrei Emeltchenko
2013-10-01 15:03 ` [RFCv2 05/14] android: Add basic mgmt initialization sequence Andrei Emeltchenko
2013-10-01 15:03 ` [RFCv2 06/14] android: Create HAL API header skeleton Andrei Emeltchenko
2013-10-03 14:07   ` Szymon Janc [this message]
2013-10-04  7:16     ` Andrei Emeltchenko
2013-10-01 15:03 ` [RFCv2 07/14] android: Add adapter and device struct for BlueZ daemon Andrei Emeltchenko
2013-10-01 15:03 ` [RFCv2 08/14] android: Add Android Makefile for libbluetooth Andrei Emeltchenko
2013-10-01 15:03 ` [RFCv2 09/14] android: sdp: Reuse BlueZ SDP server in Android Andrei Emeltchenko
2013-10-03 11:23   ` Szymon Janc
2013-10-03 11:35     ` Andrei Emeltchenko
2013-10-03 11:47       ` Szymon Janc
2013-10-01 15:03 ` [RFCv2 10/14] android: Add cap to bind to port < 1024 Andrei Emeltchenko
2013-10-01 15:03 ` [RFCv2 11/14] android: Implement read_info_complete callback Andrei Emeltchenko
2013-10-01 15:03 ` [RFCv2 12/14] android: Handle mgmt changed events Andrei Emeltchenko
2013-10-01 15:03 ` [RFCv2 13/14] android: Add makefile for hciconfig Andrei Emeltchenko
2013-10-01 15:03 ` [RFCv2 14/14] 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=4501039.OZxtA2WV21@uw000953 \
    --to=szymon.janc@tieto.com \
    --cc=Andrei.Emeltchenko.news@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