Linux bluetooth development
 help / color / mirror / Atom feed
From: Andrei Emeltchenko <Andrei.Emeltchenko.news@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCHv4 01/11] android: Create HAL API header skeleton
Date: Wed, 16 Oct 2013 17:36:28 +0300	[thread overview]
Message-ID: <1381934198-7955-2-git-send-email-Andrei.Emeltchenko.news@gmail.com> (raw)
In-Reply-To: <1381934198-7955-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Header describes the protocol between Android HAL threads and BlueZ
daemon. The header is added to host build and not to Android since
it is smart enough to include it automatically.
---
 Makefile.android  |    5 +-
 android/hal-msg.h |  246 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 250 insertions(+), 1 deletion(-)
 create mode 100644 android/hal-msg.h

diff --git a/Makefile.android b/Makefile.android
index 3ceefd8..02f3341 100644
--- a/Makefile.android
+++ b/Makefile.android
@@ -1,7 +1,10 @@
 if ANDROID
 noinst_PROGRAMS += android/bluetoothd
 
-android_bluetoothd_SOURCES = android/main.c src/log.c
+android_bluetoothd_SOURCES =	android/main.c \
+				src/log.c \
+				android/hal-msg.h
+
 android_bluetoothd_LDADD = @GLIB_LIBS@
 endif
 
diff --git a/android/hal-msg.h b/android/hal-msg.h
new file mode 100644
index 0000000..4c5ca69
--- /dev/null
+++ b/android/hal-msg.h
@@ -0,0 +1,246 @@
+/*
+ *
+ *  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
+ *
+ */
+
+struct hal_msg_hdr {
+	uint8_t service_id;
+	uint8_t opcode;
+	uint16_t len;
+} __attribute__((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_rsp_error {
+	uint8_t status;
+} __attribute__((packed));
+
+#define HAL_MSG_OP_REGISTER_MODULE	0x01
+struct hal_msg_cmd_register_module {
+	uint8_t service_id;
+} __attribute__((packed));
+struct hal_msg_rsp_register_module {
+	uint8_t service_id;
+} __attribute__((packed));
+
+#define HAL_MSG_OP_UNREGISTER_MODULE	0x02
+struct hal_msg_cmd_unregister_module {
+	uint8_t service_id;
+} __attribute__((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_cmd_bt_get_adapter_prop {
+	uint8_t type;
+} __attribute__((packed));
+
+#define HAL_MSG_OP_BT_SET_ADAPTER_PROP	0x05
+struct hal_msg_cmd_bt_set_adapter_prop {
+	uint8_t  type;
+	uint16_t len;
+	uint8_t  val[0];
+} __attribute__((packed));
+
+#define HAL_MSG_OP_BT_GET_REMOTE_DEVICE_PROPS	0x06
+struct hal_msg_cmd_bt_get_remote_device_props {
+	uint8_t bdaddr[6];
+} __attribute__((packed));
+
+#define HAL_MSG_OP_BT_GET_REMOTE_DEVICE_PROP	0x07
+struct hal_msg_cmd_bt_get_remote_device_prop {
+	uint8_t bdaddr[6];
+	uint8_t type;
+} __attribute__((packed));
+
+#define HAL_MSG_OP_BT_SET_REMOTE_DEVICE_PROP	0x08
+struct hal_msg_cmd_bt_set_remote_device_prop {
+	uint8_t  bdaddr[6];
+	uint8_t  type;
+	uint16_t len;
+	uint8_t  val[0];
+} __attribute__((packed));
+
+#define HAL_MSG_OP_BT_GET_REMOTE_SERVICE_REC	0x09
+struct hal_msg_cmd_bt_get_remote_service_rec {
+	uint8_t bdaddr[6];
+	uint8_t uuid[16];
+} __attribute__((packed));
+
+#define HAL_MSG_OP_BT_GET_REMOTE_SERVICE	0x0a
+struct hal_msg_cmd_bt_get_remote_service {
+	uint8_t bdaddr[6];
+} __attribute__((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_cmd_bt_create_bond {
+	uint8_t bdaddr[6];
+} __attribute__((packed));
+
+#define HAL_MSG_OP_BT_REMOVE_BOND	0x0d
+struct hal_msg_cmd_bt_remove_bond {
+	uint8_t bdaddr[6];
+} __attribute__((packed));
+
+#define HAL_MSG_OP_BT_CANCEL_BOND	0x0f
+struct hal_msg_cmd_bt_cancel_bond {
+	uint8_t bdaddr[6];
+} __attribute__((packed));
+
+#define HAL_MSG_OP_BT_PIN_REPLY		0x10
+struct hal_msg_cmd_bt_pin_reply {
+	uint8_t bdaddr[6];
+	uint8_t accept;
+	uint8_t pin_len;
+	uint8_t pin_code[16];
+} __attribute__((packed));
+
+#define HAL_MSG_OP_BT_SSP_REPLY		0x11
+struct hal_msg_cmd_bt_ssp_reply {
+	uint8_t  bdaddr[6];
+	uint8_t  ssp_variant;
+	uint8_t  accept;
+	uint32_t passkey;
+} __attribute__((packed));
+
+#define HAL_MSG_OP_BT_DUT_MODE_CONF	0x12
+struct hal_msg_cmd_bt_dut_mode_conf {
+	uint8_t enable;
+} __attribute__((packed));
+
+#define HAL_MSG_OP_BT_DUT_MODE_SEND	0x13
+struct hal_msg_cmd_bt_dut_mode_send {
+	uint16_t opcode;
+	uint8_t  len;
+	uint8_t  data[0];
+} __attribute__((packed));
+
+#define HAL_MSG_OP_BT_LE_TEST_MODE	0x14
+struct hal_msg_cmd_bt_le_test_mode {
+	uint16_t opcode;
+	uint8_t  len;
+	uint8_t  data[0];
+} __attribute__((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;
+} __attribute__((packed));
+
+#define HAL_MSG_EV_BT_ADAPTER_PROPS_CHANGED	0x82
+struct hal_property {
+	uint8_t  type;
+	uint16_t len;
+	uint8_t  val[0];
+} __attribute__((packed));
+struct hal_msg_ev_bt_adapter_props_changed {
+	uint8_t              status;
+	uint8_t              num_props;
+	struct  hal_property props[0];
+} __attribute__((packed));
+
+#define HAL_MSG_EV_BT_REMOTE_DEVICE_PROPS	0x83
+struct hal_msg_ev_bt_remote_device_props {
+	uint8_t             status;
+	uint8_t             bdaddr[6];
+	uint8_t             num_props;
+	struct hal_property props[0];
+} __attribute__((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];
+} __attribute__((packed));
+
+#define HAL_MSG_EV_BT_DISCOVERY_STATE_CHANGED	0x85
+struct hal_msg_ev_bt_discovery_state_changed {
+	uint8_t state;
+} __attribute__((packed));
+
+#define HAL_MSG_EV_BT_PIN_REQUEST		0x86
+struct hal_msg_ev_bt_pin_request {
+	uint8_t bdaddr[6];
+	uint8_t name[249 - 1];
+	uint8_t class_of_dev[3];
+} __attribute__((packed));
+
+#define HAL_MSG_EV_BT_SSP_REQUEST		0x87
+struct hal_msg_ev_bt_ssp_request {
+	uint8_t  bdaddr[6];
+	uint8_t  name[249 - 1];
+	uint8_t  class_of_dev[3];
+	uint8_t  pairing_variant;
+	uint32_t passkey;
+} __attribute__((packed));
+
+#define HAL_MSG_EV_BT_BOND_STATE_CHANGED	0x88
+struct hal_msg_ev_bt_bond_state_changed {
+	uint8_t status;
+	uint8_t bdaddr[6];
+	uint8_t state;
+} __attribute__((packed));
+
+#define HAL_MSG_EV_BT_ACL_STATE_CHANGED		0x89
+struct hal_msg_ev_bt_acl_state_changed {
+	uint8_t status;
+	uint8_t bdaddr[6];
+	uint8_t state;
+} __attribute__((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];
+} __attribute__((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;
+} __attribute__((packed));
-- 
1.7.10.4


  reply	other threads:[~2013-10-16 14:36 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-15 10:36 [PATCHv1 0/5] Initial Android BlueZ patches Andrei Emeltchenko
2013-10-15 10:36 ` [PATCHv1 1/5] android: Create HAL API header skeleton Andrei Emeltchenko
2013-10-15 10:37 ` [PATCHv1 2/5] android: Add basic mgmt initialization sequence Andrei Emeltchenko
2013-10-15 10:37 ` [PATCHv1 3/5] android: Add adapter and device struct for BlueZ daemon Andrei Emeltchenko
2013-10-15 10:37 ` [PATCHv1 4/5] android: sdp: Reuse BlueZ SDP server in Android Andrei Emeltchenko
2013-10-15 10:37 ` [PATCHv1 5/5] android: Add cap to bind to port < 1024 Andrei Emeltchenko
2013-10-16  8:46 ` [PATCHv2 0/6] Android BlueZ patches, second chunk Andrei Emeltchenko
2013-10-16  8:46   ` [PATCHv2 1/6] sdp: Check that correct packet received in recv Andrei Emeltchenko
2013-10-16 10:21     ` Johan Hedberg
2013-10-16  8:46   ` [PATCHv2 2/6] android: Create HAL API header skeleton Andrei Emeltchenko
2013-10-16 10:23     ` Johan Hedberg
2013-10-16  8:46   ` [PATCHv2 3/6] android: Add basic mgmt initialization sequence Andrei Emeltchenko
2013-10-16 10:28     ` Johan Hedberg
2013-10-16 12:03     ` Szymon Janc
2013-10-16 12:24       ` Andrei Emeltchenko
2013-10-16  8:46   ` [PATCHv2 4/6] android: Add adapter and device struct for BlueZ daemon Andrei Emeltchenko
2013-10-16 10:31     ` Johan Hedberg
2013-10-16  8:46   ` [PATCHv2 5/6] android: sdp: Reuse BlueZ SDP server in Android Andrei Emeltchenko
2013-10-16  8:46   ` [PATCHv2 6/6] android: Add cap to bind to port < 1024 Andrei Emeltchenko
2013-10-16 14:08 ` [PATCHv3 00/11] Android BlueZ patches, second chunk Andrei Emeltchenko
2013-10-16 14:08   ` [PATCHv3 01/11] android: Create HAL API header skeleton Andrei Emeltchenko
2013-10-16 14:08   ` [PATCHv3 02/11] android: Add basic mgmt initialization sequence Andrei Emeltchenko
2013-10-16 14:08   ` [PATCHv3 03/11] android: Add adapter and device struct for BlueZ daemon Andrei Emeltchenko
2013-10-16 14:08   ` [PATCHv3 04/11] android: sdp: Reuse BlueZ SDP server in Android Andrei Emeltchenko
2013-10-16 14:08   ` [PATCHv3 05/11] android: Add cap to bind to port < 1024 Andrei Emeltchenko
2013-10-16 14:08   ` [PATCHv3 06/11] android: Implement read_info_complete callback Andrei Emeltchenko
2013-10-16 14:08   ` [PATCHv3 07/11] android: Use kernel style to initialize struct fields Andrei Emeltchenko
2013-10-16 14:08   ` [PATCHv3 08/11] android: Rename hal_bluetooth.c to hal-bluetooth.c Andrei Emeltchenko
2013-10-16 14:08   ` [PATCHv3 09/11] android: Rename hal_bt_sock.c to hal-bt-sock.c Andrei Emeltchenko
2013-10-16 14:08   ` [PATCHv3 10/11] android: Add HID Host skeleton Andrei Emeltchenko
2013-10-16 14:08   ` [PATCHv3 11/11] android: Add PAN skeleton Andrei Emeltchenko
2013-10-16 14:36 ` [PATCHv4 00/11] Android BlueZ patches, second chunk Andrei Emeltchenko
2013-10-16 14:36   ` Andrei Emeltchenko [this message]
2013-10-16 14:36   ` [PATCHv4 02/11] android: Add basic mgmt initialization sequence Andrei Emeltchenko
2013-10-16 14:36   ` [PATCHv4 03/11] android: Add adapter and device struct for BlueZ daemon Andrei Emeltchenko
2013-10-16 14:36   ` [PATCHv4 04/11] android: sdp: Reuse BlueZ SDP server in Android Andrei Emeltchenko
2013-10-16 15:48     ` Johan Hedberg
2013-10-16 14:36   ` [PATCHv4 05/11] android: Add cap to bind to port < 1024 Andrei Emeltchenko
2013-10-16 15:44     ` Johan Hedberg
2013-10-16 14:36   ` [PATCHv4 06/11] android: Implement read_info_complete callback Andrei Emeltchenko
2013-10-16 15:47     ` Johan Hedberg
2013-10-16 14:36   ` [PATCHv4 07/11] android: Use kernel style to initialize struct fields Andrei Emeltchenko
2013-10-16 14:36   ` [PATCHv4 08/11] android: Rename hal_bluetooth.c to hal-bluetooth.c Andrei Emeltchenko
2013-10-16 14:36   ` [PATCHv4 09/11] android: Rename hal_bt_sock.c to hal-bt-sock.c Andrei Emeltchenko
2013-10-16 14:36   ` [PATCHv4 10/11] android: Add HID Host skeleton Andrei Emeltchenko
2013-10-16 14:36   ` [PATCHv4 11/11] android: Add PAN skeleton Andrei Emeltchenko
2013-10-17  8:26 ` [PATCHv5 0/7] Android BlueZ patches, second chunk Andrei Emeltchenko
2013-10-17  8:26   ` [PATCHv5 1/7] android: Add capabilities and set userid Andrei Emeltchenko
2013-10-17 11:20     ` Johan Hedberg
2013-10-17 11:26       ` Andrei Emeltchenko
2013-10-17  8:26   ` [PATCHv5 2/7] android: Implement read_info_complete callback Andrei Emeltchenko
2013-10-17 11:53     ` Johan Hedberg
2013-10-17  8:26   ` [PATCHv5 3/7] android: Use kernel style to initialize struct fields Andrei Emeltchenko
2013-10-17  9:04     ` Marcel Holtmann
2013-10-17  8:26   ` [PATCHv5 4/7] android: Rename hal_bluetooth.c to hal-bluetooth.c Andrei Emeltchenko
2013-10-17  8:26   ` [PATCHv5 5/7] android: Rename hal_bt_sock.c to hal-bt-sock.c Andrei Emeltchenko
2013-10-17  8:26   ` [PATCHv5 6/7] android: Add HID Host skeleton Andrei Emeltchenko
2013-10-17  8:26   ` [PATCHv5 7/7] android: Add PAN skeleton Andrei Emeltchenko
2013-10-18 11:36   ` [PATCHv5 0/7] Android BlueZ patches, second chunk Johan Hedberg

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=1381934198-7955-2-git-send-email-Andrei.Emeltchenko.news@gmail.com \
    --to=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