2012-02-28 02:56:43 +08:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* BlueZ - Bluetooth protocol stack for Linux
|
|
|
|
*
|
|
|
|
* Copyright (C) 2011-2012 Intel Corporation
|
|
|
|
* Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org>
|
|
|
|
*
|
|
|
|
*
|
2012-12-17 09:40:46 +08:00
|
|
|
* 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.
|
2012-02-28 02:56:43 +08:00
|
|
|
*
|
2012-12-17 09:40:46 +08:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
2012-02-28 02:56:43 +08:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2012-12-17 09:40:46 +08:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2012-02-28 02:56:43 +08:00
|
|
|
*
|
2012-12-17 09:40:46 +08:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2012-02-28 02:56:43 +08:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdint.h>
|
2013-07-21 08:17:13 +08:00
|
|
|
#include <stdbool.h>
|
2012-02-28 02:56:43 +08:00
|
|
|
|
2012-12-17 09:03:22 +08:00
|
|
|
#define BTDEV_RESPONSE_DEFAULT 0
|
|
|
|
#define BTDEV_RESPONSE_COMMAND_STATUS 1
|
|
|
|
#define BTDEV_RESPONSE_COMMAND_COMPLETE 2
|
|
|
|
|
|
|
|
typedef struct btdev_callback * btdev_callback;
|
|
|
|
|
|
|
|
void btdev_command_response(btdev_callback callback, uint8_t response,
|
|
|
|
uint8_t status, const void *data, uint8_t len);
|
|
|
|
|
|
|
|
#define btdev_command_default(callback) \
|
|
|
|
btdev_command_response(callback, \
|
|
|
|
BTDEV_RESPONSE_DEFAULT, 0x00, NULL, 0);
|
|
|
|
|
|
|
|
#define btdev_command_status(callback, status) \
|
|
|
|
btdev_command_response(callback, \
|
|
|
|
BTDEV_RESPONSE_COMMAND_STATUS, status, NULL, 0);
|
|
|
|
|
|
|
|
#define btdev_command_complete(callback, data, len) \
|
|
|
|
btdev_command_response(callback, \
|
|
|
|
BTDEV_RESPONSE_COMMAND_COMPLETE, 0x00, data, len);
|
|
|
|
|
|
|
|
|
|
|
|
typedef void (*btdev_command_func) (uint16_t opcode,
|
|
|
|
const void *data, uint8_t len,
|
|
|
|
btdev_callback callback, void *user_data);
|
|
|
|
|
2012-02-28 02:56:43 +08:00
|
|
|
typedef void (*btdev_send_func) (const void *data, uint16_t len,
|
|
|
|
void *user_data);
|
|
|
|
|
2013-07-21 08:17:13 +08:00
|
|
|
typedef bool (*btdev_hook_func) (const void *data, uint16_t len,
|
|
|
|
void *user_data);
|
|
|
|
|
2012-10-30 06:01:43 +08:00
|
|
|
enum btdev_type {
|
2013-02-01 04:03:32 +08:00
|
|
|
BTDEV_TYPE_BREDRLE,
|
2012-10-30 06:01:43 +08:00
|
|
|
BTDEV_TYPE_BREDR,
|
2012-10-30 06:12:03 +08:00
|
|
|
BTDEV_TYPE_LE,
|
2012-10-30 06:29:15 +08:00
|
|
|
BTDEV_TYPE_AMP,
|
2012-10-30 06:01:43 +08:00
|
|
|
};
|
|
|
|
|
2013-07-21 08:17:13 +08:00
|
|
|
enum btdev_hook_type {
|
|
|
|
BTDEV_HOOK_PRE_CMD,
|
|
|
|
BTDEV_HOOK_POST_CMD,
|
|
|
|
BTDEV_HOOK_PRE_EVT,
|
|
|
|
BTDEV_HOOK_POST_EVT,
|
|
|
|
};
|
|
|
|
|
2012-02-28 02:56:43 +08:00
|
|
|
struct btdev;
|
|
|
|
|
2012-10-30 06:01:43 +08:00
|
|
|
struct btdev *btdev_create(enum btdev_type type, uint16_t id);
|
2012-02-28 02:56:43 +08:00
|
|
|
void btdev_destroy(struct btdev *btdev);
|
|
|
|
|
2013-04-11 23:24:42 +08:00
|
|
|
const uint8_t *btdev_get_bdaddr(struct btdev *btdev);
|
2013-08-01 17:52:40 +08:00
|
|
|
uint8_t *btdev_get_features(struct btdev *btdev);
|
2012-12-16 06:53:03 +08:00
|
|
|
|
2012-12-17 09:03:22 +08:00
|
|
|
void btdev_set_command_handler(struct btdev *btdev, btdev_command_func handler,
|
|
|
|
void *user_data);
|
|
|
|
|
2012-02-28 02:56:43 +08:00
|
|
|
void btdev_set_send_handler(struct btdev *btdev, btdev_send_func handler,
|
|
|
|
void *user_data);
|
|
|
|
|
|
|
|
void btdev_receive_h4(struct btdev *btdev, const void *data, uint16_t len);
|
2013-07-21 08:17:13 +08:00
|
|
|
|
|
|
|
int btdev_add_hook(struct btdev *btdev, enum btdev_hook_type type,
|
|
|
|
uint16_t opcode, btdev_hook_func handler,
|
|
|
|
void *user_data);
|
2013-07-21 08:17:16 +08:00
|
|
|
|
|
|
|
bool btdev_del_hook(struct btdev *btdev, enum btdev_hook_type type,
|
|
|
|
uint16_t opcode);
|