2009-10-29 20:25:42 +00:00
|
|
|
/*
|
2015-02-06 16:19:27 +00:00
|
|
|
* Copyright (C) 2014 BlueKitchen GmbH
|
2009-10-29 20:25:42 +00:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. Neither the name of the copyright holders nor the names of
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
2012-05-07 21:54:09 +00:00
|
|
|
* 4. Any redistribution, use, or modification is done solely for
|
|
|
|
* personal benefit and not for any commercial purpose or for
|
|
|
|
* monetary gain.
|
2009-10-29 20:25:42 +00:00
|
|
|
*
|
2015-02-06 16:19:27 +00:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
|
2009-10-29 20:25:42 +00:00
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
|
|
|
|
* RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
|
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
|
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
|
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
|
|
|
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
2015-02-06 16:19:27 +00:00
|
|
|
* Please inquire about commercial licensing options at
|
|
|
|
* contact@bluekitchen-gmbh.com
|
2012-05-07 21:54:09 +00:00
|
|
|
*
|
2009-10-29 20:25:42 +00:00
|
|
|
*/
|
|
|
|
|
2009-04-29 22:00:24 +00:00
|
|
|
/*
|
|
|
|
* hci_transport.h
|
|
|
|
*
|
2009-05-19 21:49:12 +00:00
|
|
|
* HCI Transport API -- allows BT Daemon to use different transport protcols
|
2009-04-29 22:00:24 +00:00
|
|
|
*
|
|
|
|
* Created by Matthias Ringwald on 4/29/09.
|
|
|
|
*
|
|
|
|
*/
|
2014-01-19 16:30:17 +00:00
|
|
|
#ifndef __HCI_TRANSPORT_H
|
|
|
|
#define __HCI_TRANSPORT_H
|
2009-04-29 22:00:24 +00:00
|
|
|
|
2009-05-08 21:37:54 +00:00
|
|
|
#include <stdint.h>
|
2016-01-20 15:08:39 +01:00
|
|
|
#include "btstack_run_loop.h"
|
2009-05-08 21:37:54 +00:00
|
|
|
|
2010-11-01 17:50:06 +00:00
|
|
|
#if defined __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2015-07-01 15:40:29 +02:00
|
|
|
|
|
|
|
/* API_START */
|
|
|
|
|
2009-07-09 18:49:43 +00:00
|
|
|
/* HCI packet types */
|
2009-04-29 22:00:24 +00:00
|
|
|
typedef struct {
|
|
|
|
int (*open)(void *transport_config);
|
2011-06-06 13:57:15 +00:00
|
|
|
int (*close)(void *transport_config);
|
2010-08-16 17:23:22 +00:00
|
|
|
int (*send_packet)(uint8_t packet_type, uint8_t *packet, int size);
|
2010-07-18 16:14:55 +00:00
|
|
|
void (*register_packet_handler)(void (*handler)(uint8_t packet_type, uint8_t *packet, uint16_t size));
|
2011-06-06 13:57:15 +00:00
|
|
|
const char * (*get_transport_name)(void);
|
2011-06-05 09:54:31 +00:00
|
|
|
// custom extension for UART transport implementations
|
|
|
|
int (*set_baudrate)(uint32_t baudrate);
|
2011-07-12 20:09:07 +00:00
|
|
|
// support async transport layers, e.g. IRQ driven without buffers
|
|
|
|
int (*can_send_packet_now)(uint8_t packet_type);
|
2009-04-29 22:00:24 +00:00
|
|
|
} hci_transport_t;
|
|
|
|
|
2016-01-06 23:02:46 +01:00
|
|
|
typedef enum {
|
|
|
|
HCI_TRANSPORT_CONFIG_UART,
|
|
|
|
HCI_TRANSPORT_CONFIG_USB
|
|
|
|
} hci_transport_config_type_t;
|
|
|
|
|
2009-04-29 22:00:24 +00:00
|
|
|
typedef struct {
|
2016-01-06 23:02:46 +01:00
|
|
|
hci_transport_config_type_t type;
|
|
|
|
} hci_transport_config_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
hci_transport_config_type_t type; // == HCI_TRANSPORT_CONFIG_UART
|
2011-06-05 09:54:31 +00:00
|
|
|
uint32_t baudrate_init; // initial baud rate
|
|
|
|
uint32_t baudrate_main; // = 0: same as initial baudrate
|
2016-01-06 23:02:46 +01:00
|
|
|
int flowcontrol; //
|
|
|
|
const char *device_name;
|
|
|
|
} hci_transport_config_uart_t;
|
2009-04-29 22:00:24 +00:00
|
|
|
|
2010-07-04 14:27:05 +00:00
|
|
|
|
2010-06-04 18:10:12 +00:00
|
|
|
// inline various hci_transport_X.h files
|
2015-07-01 15:40:29 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @brief
|
|
|
|
*/
|
2016-01-21 11:05:09 +01:00
|
|
|
extern hci_transport_t * hci_transport_h4_instance(void);
|
2015-07-01 15:40:29 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @brief
|
|
|
|
*/
|
2011-06-06 13:57:15 +00:00
|
|
|
extern hci_transport_t * hci_transport_usb_instance(void);
|
2010-06-04 18:09:01 +00:00
|
|
|
|
2015-12-22 21:58:01 +01:00
|
|
|
|
2015-07-01 15:40:29 +02:00
|
|
|
/* API_END */
|
2011-08-28 19:10:54 +00:00
|
|
|
|
2010-11-01 17:50:06 +00:00
|
|
|
#if defined __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2010-06-04 18:09:01 +00:00
|
|
|
|
2014-01-19 16:30:17 +00:00
|
|
|
#endif // __HCI_TRANSPORT_H
|