mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-23 19:20:51 +00:00
hci_trasport: add type to hci transport config, update all ports
This commit is contained in:
parent
f89ed3dce5
commit
9796ebea28
@ -279,13 +279,6 @@ static const bt_control_t bt_control_cc256x = {
|
||||
NULL, // set_bd_addr_cmd
|
||||
};
|
||||
|
||||
static const hci_uart_config_t hci_uart_config_cc256x = {
|
||||
NULL,
|
||||
115200,
|
||||
1000000,
|
||||
0
|
||||
};
|
||||
|
||||
// MARK: public API
|
||||
|
||||
void bt_control_cc256x_enable_ehcill(int on){
|
||||
@ -302,7 +295,3 @@ void bt_control_cc256x_set_power(int16_t power_in_dB){
|
||||
bt_control_t *bt_control_cc256x_instance(void){
|
||||
return (bt_control_t*) &bt_control_cc256x;
|
||||
}
|
||||
|
||||
hci_uart_config_t *hci_uart_config_cc256x_instance(void){
|
||||
return (hci_uart_config_t*) &hci_uart_config_cc256x;
|
||||
}
|
||||
|
@ -57,8 +57,6 @@ void bt_control_cc256x_set_power(int16_t power_in_dB);
|
||||
void bt_control_cc256x_enable_ehcill(int on);
|
||||
int bt_control_cc256x_ehcill_enabled(void);
|
||||
|
||||
hci_uart_config_t *hci_uart_config_cc256x_instance(void);
|
||||
|
||||
#if defined __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -74,7 +74,7 @@ static int bt_control_csr_on(void *config){
|
||||
}
|
||||
|
||||
// set requested baud rate
|
||||
static void bt_control_csr_update_command(hci_uart_config_t *config, uint8_t *hci_cmd_buffer){
|
||||
static void bt_control_csr_update_command(hci_transport_config_uart_t *config, uint8_t *hci_cmd_buffer){
|
||||
uint16_t varid = READ_BT_16(hci_cmd_buffer, 10);
|
||||
if (varid != 0x7003) return;
|
||||
uint16_t key = READ_BT_16(hci_cmd_buffer, 14);
|
||||
@ -104,7 +104,7 @@ static int bt_control_csr_next_cmd(void *config, uint8_t *hci_cmd_buffer){
|
||||
memcpy(&hci_cmd_buffer[3], (uint8_t *) &init_script[init_script_offset], payload_len);
|
||||
|
||||
// support for on-the-fly configuration updates
|
||||
bt_control_csr_update_command((hci_uart_config_t*)config, hci_cmd_buffer);
|
||||
bt_control_csr_update_command((hci_transport_config_uart_t*)config, hci_cmd_buffer);
|
||||
|
||||
init_script_offset += payload_len;
|
||||
|
||||
@ -134,13 +134,6 @@ static const bt_control_t bt_control_csr = {
|
||||
NULL, // set_bd_addr_cmd
|
||||
};
|
||||
|
||||
static const hci_uart_config_t hci_uart_config_csr = {
|
||||
NULL,
|
||||
115200,
|
||||
0, // 1000000,
|
||||
0
|
||||
};
|
||||
|
||||
// MARK: public API
|
||||
void bt_control_csr_set_power(int16_t power_in_dB){
|
||||
}
|
||||
@ -148,7 +141,3 @@ void bt_control_csr_set_power(int16_t power_in_dB){
|
||||
bt_control_t *bt_control_csr_instance(void){
|
||||
return (bt_control_t*) &bt_control_csr;
|
||||
}
|
||||
|
||||
hci_uart_config_t *hci_uart_config_csr_instance(void){
|
||||
return (hci_uart_config_t*) &hci_uart_config_csr;
|
||||
}
|
||||
|
@ -54,7 +54,6 @@ extern "C" {
|
||||
|
||||
bt_control_t * bt_control_csr_instance(void);
|
||||
void bt_control_csr_set_power(int16_t power_in_dB);
|
||||
hci_uart_config_t *hci_uart_config_csr_instance(void);
|
||||
|
||||
#if defined __cplusplus
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ static client_state_t * client_for_connection(connection_t *connection);
|
||||
|
||||
// MARK: globals
|
||||
static hci_transport_t * transport;
|
||||
static hci_uart_config_t config;
|
||||
static hci_transport_config_uart_t hci_transport_config_uart;
|
||||
static timer_source_t timeout;
|
||||
static uint8_t timeout_active = 0;
|
||||
static int power_management_sleep = 0;
|
||||
@ -1943,16 +1943,18 @@ int main (int argc, char * const * argv){
|
||||
#endif
|
||||
|
||||
bt_control_t * control = NULL;
|
||||
|
||||
void * config;
|
||||
|
||||
#ifdef HAVE_TRANSPORT_H4
|
||||
config.device_name = UART_DEVICE;
|
||||
config.baudrate_init = UART_SPEED;
|
||||
config.baudrate_main = 0;
|
||||
config.flowcontrol = 1;
|
||||
hci_transport_config_uart.type = HCI_TRANSPORT_CONFIG_UART;
|
||||
hci_transport_config_uart.baudrate_init = UART_SPEED;
|
||||
hci_transport_config_uart.baudrate_main = 0;
|
||||
hci_transport_config_uart.flowcontrol = 1;
|
||||
hci_transport_config_uart.device_name = UART_DEVICE;
|
||||
#if defined(USE_BLUETOOL) && defined(USE_POWERMANAGEMENT)
|
||||
if (bt_control_iphone_power_management_supported()){
|
||||
// use default (max) UART baudrate over netraph interface
|
||||
config.baudrate_init = 0;
|
||||
// use default (max) UART baudrate over netgraph interface
|
||||
hci_transport_config_uart.baudrate_init = 0;
|
||||
transport = hci_transport_h4_iphone_instance();
|
||||
} else {
|
||||
transport = hci_transport_h4_instance();
|
||||
@ -1960,6 +1962,7 @@ int main (int argc, char * const * argv){
|
||||
#else
|
||||
transport = hci_transport_h4_instance();
|
||||
#endif
|
||||
config = &hci_transport_config_uart;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TRANSPORT_USB
|
||||
@ -2007,7 +2010,7 @@ int main (int argc, char * const * argv){
|
||||
log_info("version %s, build %s", BTSTACK_VERSION, BTSTACK_DATE);
|
||||
|
||||
// init HCI
|
||||
hci_init(transport, &config, control, remote_device_db);
|
||||
hci_init(transport, config, control, remote_device_db);
|
||||
|
||||
#ifdef USE_BLUETOOL
|
||||
// iPhone doesn't use SSP yet as there's no UI for it yet and auto accept is not an option
|
||||
|
@ -63,7 +63,7 @@
|
||||
|
||||
static int h4_process(struct data_source *ds);
|
||||
static void dummy_handler(uint8_t packet_type, uint8_t *packet, uint16_t size);
|
||||
static hci_uart_config_t *hci_uart_config;
|
||||
static hci_transport_config_uart_t *hci_transport_config_uart;
|
||||
|
||||
typedef enum {
|
||||
H4_W4_PACKET_TYPE,
|
||||
@ -133,13 +133,13 @@ static int h4_set_baudrate(uint32_t baudrate){
|
||||
}
|
||||
|
||||
static int h4_open(void *transport_config){
|
||||
hci_uart_config = (hci_uart_config_t*) transport_config;
|
||||
hci_transport_config_uart = (hci_transport_config_uart_t*) transport_config;
|
||||
struct termios toptions;
|
||||
int flags = O_RDWR | O_NOCTTY | O_NONBLOCK;
|
||||
int fd = open(hci_uart_config->device_name, flags);
|
||||
int fd = open(hci_transport_config_uart->device_name, flags);
|
||||
if (fd == -1) {
|
||||
perror("init_serialport: Unable to open port ");
|
||||
perror(hci_uart_config->device_name);
|
||||
perror(hci_transport_config_uart->device_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -154,7 +154,7 @@ static int h4_open(void *transport_config){
|
||||
toptions.c_cflag &= ~CSTOPB;
|
||||
toptions.c_cflag |= CS8;
|
||||
|
||||
if (hci_uart_config->flowcontrol) {
|
||||
if (hci_transport_config_uart->flowcontrol) {
|
||||
// with flow control
|
||||
toptions.c_cflag |= CRTSCTS;
|
||||
} else {
|
||||
@ -183,7 +183,7 @@ static int h4_open(void *transport_config){
|
||||
run_loop_add_data_source(hci_transport_h4->ds);
|
||||
|
||||
// also set baudrate
|
||||
if (h4_set_baudrate(hci_uart_config->baudrate_init) < 0){
|
||||
if (h4_set_baudrate(hci_transport_config_uart->baudrate_init) < 0){
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -81,18 +81,18 @@ static hci_transport_h5_t * hci_transport_h5 = NULL;
|
||||
|
||||
static int h5_process(struct data_source *ds);
|
||||
static void dummy_handler(uint8_t packet_type, uint8_t *packet, int size);
|
||||
static hci_uart_config_t *hci_uart_config;
|
||||
static hci_transport_config_uart_t *hci_transport_config_uart;
|
||||
|
||||
static void (*packet_handler)(uint8_t packet_type, uint8_t *packet, int size) = dummy_handler;
|
||||
|
||||
// prototypes
|
||||
static int h5_open(void *transport_config){
|
||||
hci_uart_config = (hci_uart_config_t*) transport_config;
|
||||
hci_transport_config_uart = (hci_transport_config_uart_t*) transport_config;
|
||||
struct termios toptions;
|
||||
int fd = open(hci_uart_config->device_name, O_RDWR | O_NOCTTY | O_NDELAY);
|
||||
int fd = open(hci_transport_config_uart->device_name, O_RDWR | O_NOCTTY | O_NDELAY);
|
||||
if (fd == -1) {
|
||||
perror("init_serialport: Unable to open port ");
|
||||
perror(hci_uart_config->device_name);
|
||||
perror(hci_transport_config_uart->device_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -100,8 +100,8 @@ static int h5_open(void *transport_config){
|
||||
perror("init_serialport: Couldn't get term attributes");
|
||||
return -1;
|
||||
}
|
||||
speed_t brate = hci_uart_config->baudrate; // let you override switch below if needed
|
||||
switch(hci_uart_config->baudrate) {
|
||||
speed_t brate = hci_transport_config_uart->baudrate; // let you override switch below if needed
|
||||
switch(hci_transport_config_uart->baudrate) {
|
||||
case 57600: brate=B57600; break;
|
||||
case 115200: brate=B115200; break;
|
||||
#ifdef B230400
|
||||
@ -123,7 +123,7 @@ static int h5_open(void *transport_config){
|
||||
toptions.c_cflag &= ~CSIZE;
|
||||
toptions.c_cflag |= CS8;
|
||||
|
||||
if (hci_uart_config->flowcontrol) {
|
||||
if (hci_transport_config_uart->flowcontrol) {
|
||||
// with flow control
|
||||
toptions.c_cflag |= CRTSCTS;
|
||||
} else {
|
||||
|
@ -724,9 +724,6 @@ void BTstackManager::setPublicBdAddr(bd_addr_t addr){
|
||||
memcpy(public_bd_addr, addr ,6);
|
||||
}
|
||||
|
||||
// static hci_uart_config_t config;
|
||||
|
||||
|
||||
void bluetooth_hardware_error(){
|
||||
printf("Bluetooth Hardware Error event. Restarting...\n\n\n");
|
||||
#ifdef __AVR__
|
||||
|
@ -65,6 +65,14 @@
|
||||
|
||||
int btstack_main(int argc, const char * argv[]);
|
||||
|
||||
static hci_transport_config_uart_t config = {
|
||||
HCI_TRANSPORT_CONFIG_UART,
|
||||
115200,
|
||||
1000000, // main baudrate
|
||||
1, // flow control
|
||||
NULL,
|
||||
};
|
||||
|
||||
// main
|
||||
int main(void)
|
||||
{
|
||||
@ -92,9 +100,8 @@ int main(void)
|
||||
// init HCI
|
||||
hci_transport_t * transport = hci_transport_h4_dma_instance();
|
||||
bt_control_t * control = bt_control_cc256x_instance();
|
||||
hci_uart_config_t * config = hci_uart_config_cc256x_instance();
|
||||
remote_device_db_t * remote_db = (remote_device_db_t *) &remote_device_db_memory;
|
||||
hci_init(transport, config, control, remote_db);
|
||||
hci_init(transport, &config, control, remote_db);
|
||||
|
||||
// use eHCILL
|
||||
bt_control_cc256x_enable_ehcill(1);
|
||||
|
@ -448,13 +448,13 @@ static void iphone_write_configscript(int fd, int baudrate){
|
||||
}
|
||||
|
||||
static int iphone_on (void *transport_config){
|
||||
// hci_uart_config->baudrate_init == 0, if using native speed
|
||||
// hci_transport_config_uart->baudrate_init == 0, if using native speed
|
||||
|
||||
log_info("iphone_on: entered\n");
|
||||
|
||||
int err = 0;
|
||||
|
||||
hci_uart_config_t * hci_uart_config = (hci_uart_config_t*) transport_config;
|
||||
hci_transport_config_uart_t * hci_transport_config_uart = (hci_transport_config_uart_t*) transport_config;
|
||||
|
||||
// get local-mac-addr and transport-speed from IORegistry
|
||||
ioregistry_get_info();
|
||||
@ -508,23 +508,23 @@ static int iphone_on (void *transport_config){
|
||||
}
|
||||
|
||||
// quick test if Bluetooth UART can be opened - and try to start cleanly
|
||||
int fd = open(hci_uart_config->device_name, O_RDWR | O_NOCTTY | O_NDELAY);
|
||||
int fd = open(hci_transport_config_uart->device_name, O_RDWR | O_NOCTTY | O_NDELAY);
|
||||
if (fd > 0) {
|
||||
// everything's fine
|
||||
close(fd);
|
||||
} else {
|
||||
// no way!
|
||||
log_error( "bt_control.c:iphone_on(): Failed to open '%s', trying killall %s\n", hci_uart_config->device_name, bluetool);
|
||||
log_error( "bt_control.c:iphone_on(): Failed to open '%s', trying killall %s\n", hci_transport_config_uart->device_name, bluetool);
|
||||
system("killall -9 BlueToolH4");
|
||||
system("killall -9 BlueTool");
|
||||
sleep(3);
|
||||
|
||||
// try again
|
||||
fd = open(hci_uart_config->device_name, O_RDWR | O_NOCTTY | O_NDELAY);
|
||||
fd = open(hci_transport_config_uart->device_name, O_RDWR | O_NOCTTY | O_NDELAY);
|
||||
if (fd > 0){
|
||||
close(fd);
|
||||
} else {
|
||||
log_error( "bt_control.c:iphone_on(): Failed to open '%s' again, trying killall BTServer and killall %s\n", hci_uart_config->device_name, bluetool);
|
||||
log_error( "bt_control.c:iphone_on(): Failed to open '%s' again, trying killall BTServer and killall %s\n", hci_transport_config_uart->device_name, bluetool);
|
||||
system("killall -9 BTServer");
|
||||
system("killall -9 BlueToolH4");
|
||||
system("killall -9 BlueTool");
|
||||
@ -547,10 +547,10 @@ static int iphone_on (void *transport_config){
|
||||
|
||||
if (os4x) {
|
||||
// 4.x - send custom config
|
||||
iphone_write_configscript(output, hci_uart_config->baudrate_init);
|
||||
iphone_write_configscript(output, hci_transport_config_uart->baudrate_init);
|
||||
} else {
|
||||
// 3.x - modify original script on the fly
|
||||
iphone_write_initscript(output, hci_uart_config->baudrate_init);
|
||||
iphone_write_initscript(output, hci_transport_config_uart->baudrate_init);
|
||||
}
|
||||
|
||||
// log output
|
||||
@ -577,8 +577,8 @@ static int iphone_on (void *transport_config){
|
||||
power_management_active = bt_control_iphone_power_management_supported();
|
||||
|
||||
// if baud == 0, we're using system default: set in transport config
|
||||
if (hci_uart_config->baudrate_init == 0) {
|
||||
hci_uart_config->baudrate_init = transport_speed;
|
||||
if (hci_transport_config_uart->baudrate_init == 0) {
|
||||
hci_transport_config_uart->baudrate_init = transport_speed;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -84,7 +84,7 @@
|
||||
|
||||
static int h4_process(struct data_source *ds);
|
||||
static void dummy_handler(uint8_t packet_type, uint8_t *packet, uint16_t size);
|
||||
static hci_uart_config_t *hci_uart_config;
|
||||
static hci_transport_config_uart_t *hci_transport_config_uart;
|
||||
|
||||
static void h4_enforce_wake_on(void);
|
||||
static void h4_enforce_wake_off(void);
|
||||
@ -134,7 +134,7 @@ static uint8_t hci_packet[1+HCI_PACKET_BUFFER_SIZE]; // packet type + max(acl he
|
||||
|
||||
static int h4_open(void *transport_config)
|
||||
{
|
||||
hci_uart_config = (hci_uart_config_t *) transport_config;
|
||||
hci_transport_config_uart = (hci_transport_config_uart_t *) transport_config;
|
||||
|
||||
int fd = socket(PF_NETGRAPH, SOCK_STREAM, NG_CONTROL);
|
||||
log_info("h4_open: open socket(%u, %u, %u) %d", PF_NETGRAPH, SOCK_STREAM, NG_CONTROL, fd);
|
||||
@ -188,7 +188,7 @@ static int h4_open(void *transport_config)
|
||||
|
||||
// make raw and set speed
|
||||
cfmakeraw(&toptions);
|
||||
speed_t brate = (speed_t) hci_uart_config->baudrate_init;
|
||||
speed_t brate = (speed_t) hci_transport_config_uart->baudrate_init;
|
||||
cfsetspeed(&toptions, brate);
|
||||
toptions.c_iflag |= IGNPAR;
|
||||
toptions.c_cflag = 0x00038b00;
|
||||
|
@ -92,7 +92,7 @@ int main(int argc, const char * argv[]){
|
||||
|
||||
// init HCI
|
||||
hci_transport_t * transport = hci_transport_usb_instance();
|
||||
hci_uart_config_t * config = NULL;
|
||||
void * config = NULL;
|
||||
bt_control_t * control = NULL;
|
||||
remote_device_db_t * remote_db = (remote_device_db_t *) &remote_device_db_fs;
|
||||
|
||||
|
@ -342,6 +342,14 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
||||
}
|
||||
}
|
||||
|
||||
static hci_transport_config_uart_t config = {
|
||||
HCI_TRANSPORT_CONFIG_UART,
|
||||
115200,
|
||||
1000000, // main baudrate
|
||||
1, // flow control
|
||||
NULL,
|
||||
};
|
||||
|
||||
int main(void){
|
||||
|
||||
// stop watchdog timer
|
||||
@ -369,9 +377,8 @@ int main(void){
|
||||
// init HCI
|
||||
hci_transport_t * transport = hci_transport_h4_dma_instance();
|
||||
bt_control_t * control = bt_control_cc256x_instance();
|
||||
hci_uart_config_t * config = hci_uart_config_cc256x_instance();
|
||||
remote_device_db_t * remote_db = (remote_device_db_t *) &remote_device_db_memory;
|
||||
hci_init(transport, config, control, remote_db);
|
||||
hci_init(transport, &config, control, remote_db);
|
||||
|
||||
// use eHCILL
|
||||
bt_control_cc256x_enable_ehcill(1);
|
||||
|
@ -84,6 +84,14 @@ static void hw_setup(void){
|
||||
__enable_interrupt();
|
||||
}
|
||||
|
||||
static hci_transport_config_uart_t config = {
|
||||
HCI_TRANSPORT_CONFIG_UART,
|
||||
115200,
|
||||
1000000, // main baudrate
|
||||
1, // flow control
|
||||
NULL,
|
||||
};
|
||||
|
||||
static void btstack_setup(void){
|
||||
/// GET STARTED with BTstack ///
|
||||
btstack_memory_init();
|
||||
@ -92,9 +100,8 @@ static void btstack_setup(void){
|
||||
// init HCI
|
||||
hci_transport_t * transport = hci_transport_h4_dma_instance();
|
||||
bt_control_t * control = bt_control_cc256x_instance();
|
||||
hci_uart_config_t * config = hci_uart_config_cc256x_instance();
|
||||
remote_device_db_t * remote_db = (remote_device_db_t *) &remote_device_db_memory;
|
||||
hci_init(transport, config, control, remote_db);
|
||||
hci_init(transport, &config, control, remote_db);
|
||||
|
||||
// use eHCILL
|
||||
bt_control_cc256x_enable_ehcill(1);
|
||||
|
@ -88,6 +88,14 @@ static void hw_setup(void){
|
||||
__enable_interrupt();
|
||||
}
|
||||
|
||||
static hci_transport_config_uart_t config = {
|
||||
HCI_TRANSPORT_CONFIG_UART,
|
||||
115200,
|
||||
1000000, // main baudrate
|
||||
1, // flow control
|
||||
NULL,
|
||||
};
|
||||
|
||||
static void btstack_setup(void){
|
||||
|
||||
hci_dump_open(NULL, HCI_DUMP_STDOUT);
|
||||
@ -99,9 +107,8 @@ static void btstack_setup(void){
|
||||
// init HCI
|
||||
hci_transport_t * transport = hci_transport_h4_dma_instance();
|
||||
bt_control_t * control = bt_control_cc256x_instance();
|
||||
hci_uart_config_t * config = hci_uart_config_cc256x_instance();
|
||||
remote_device_db_t * remote_db = (remote_device_db_t *) &remote_device_db_memory;
|
||||
hci_init(transport, config, control, remote_db);
|
||||
hci_init(transport, &config, control, remote_db);
|
||||
|
||||
// use eHCILL
|
||||
// bt_control_cc256x_enable_ehcill(1);
|
||||
|
@ -207,13 +207,15 @@ void hal_uart_dma_receive_block(uint8_t *data, uint16_t size){
|
||||
}
|
||||
|
||||
///
|
||||
static const hci_uart_config_t hci_uart_config_csr = {
|
||||
NULL,
|
||||
static hci_transport_config_uart_t config = {
|
||||
HCI_TRANSPORT_CONFIG_UART,
|
||||
115200,
|
||||
0, // 1000000,
|
||||
0
|
||||
0, // main baudrate
|
||||
1, // flow control
|
||||
NULL,
|
||||
};
|
||||
|
||||
|
||||
void BTSTACK_Initialize ( void )
|
||||
{
|
||||
printf("\n\nBTstack_Initialize()\n");
|
||||
@ -225,7 +227,7 @@ void BTSTACK_Initialize ( void )
|
||||
|
||||
hci_transport_t * transport = hci_transport_h4_dma_instance();
|
||||
bt_control_t * control = bt_control_csr_instance();
|
||||
hci_init(transport, (void*) &hci_uart_config_csr, control, NULL);
|
||||
hci_init(transport, &config, control, NULL);
|
||||
|
||||
// hci_power_control(HCI_POWER_ON);
|
||||
btstack_main(0, NULL);
|
||||
|
@ -50,6 +50,7 @@
|
||||
#include "btstack-config.h"
|
||||
|
||||
#include "run_loop.h"
|
||||
#include "run_loop_posix.h"
|
||||
|
||||
#include "debug.h"
|
||||
#include "btstack_memory.h"
|
||||
@ -61,9 +62,13 @@
|
||||
|
||||
int btstack_main(int argc, const char * argv[]);
|
||||
|
||||
static hci_uart_config_t hci_uart_config_cc256x = {
|
||||
NULL,
|
||||
|
||||
static hci_transport_config_uart_t config = {
|
||||
HCI_TRANSPORT_CONFIG_UART,
|
||||
115200,
|
||||
0, // main baudrate
|
||||
1, // flow control
|
||||
NULL,
|
||||
};
|
||||
|
||||
static void sigint_handler(int param){
|
||||
@ -96,14 +101,14 @@ int main(int argc, const char * argv[]){
|
||||
hci_dump_open("/tmp/hci_dump.pklg", HCI_DUMP_PACKETLOGGER);
|
||||
|
||||
// pick serial port
|
||||
hci_uart_config_cc256x.device_name = "/dev/tty.usbserial-AD025KU2";
|
||||
config.device_name = "/dev/tty.usbserial-AD025KU2";
|
||||
|
||||
// init HCI
|
||||
hci_transport_t * transport = hci_transport_h4_instance();
|
||||
bt_control_t * control = bt_control_cc256x_instance();
|
||||
remote_device_db_t * remote_db = (remote_device_db_t *) &remote_device_db_fs;
|
||||
|
||||
hci_init(transport, (void*) &hci_uart_config_cc256x, control, remote_db);
|
||||
hci_init(transport, &config, control, remote_db);
|
||||
|
||||
// handle CTRL-c
|
||||
signal(SIGINT, sigint_handler);
|
||||
|
@ -54,13 +54,17 @@
|
||||
#include "hci.h"
|
||||
#include "hci_dump.h"
|
||||
#include "run_loop.h"
|
||||
#include "run_loop_posix.h"
|
||||
#include "stdin_support.h"
|
||||
|
||||
int btstack_main(int argc, const char * argv[]);
|
||||
|
||||
static hci_uart_config_t hci_uart_config_generic = {
|
||||
NULL,
|
||||
static hci_transport_config_uart_t config = {
|
||||
HCI_TRANSPORT_CONFIG_UART,
|
||||
115200,
|
||||
0, // main baudrate
|
||||
1, // flow control
|
||||
NULL,
|
||||
};
|
||||
|
||||
static void sigint_handler(int param){
|
||||
@ -93,13 +97,13 @@ int main(int argc, const char * argv[]){
|
||||
hci_dump_open("/tmp/hci_dump.pklg", HCI_DUMP_PACKETLOGGER);
|
||||
|
||||
// pick serial port
|
||||
hci_uart_config_generic.device_name = "/dev/tty.usbmodem1413";
|
||||
config.device_name = "/dev/tty.usbmodem1413";
|
||||
|
||||
// init HCI
|
||||
hci_transport_t * transport = hci_transport_h4_instance();
|
||||
remote_device_db_t * remote_db = (remote_device_db_t *) &remote_device_db_fs;
|
||||
|
||||
hci_init(transport, (void*) &hci_uart_config_generic, NULL, remote_db);
|
||||
hci_init(transport, (void*) &config, NULL, remote_db);
|
||||
|
||||
// handle CTRL-c
|
||||
signal(SIGINT, sigint_handler);
|
||||
|
@ -50,6 +50,7 @@
|
||||
#include "btstack-config.h"
|
||||
|
||||
#include "run_loop.h"
|
||||
#include "run_loop_posix.h"
|
||||
|
||||
#include "debug.h"
|
||||
#include "btstack_memory.h"
|
||||
@ -60,10 +61,12 @@
|
||||
|
||||
int btstack_main(int argc, const char * argv[]);
|
||||
|
||||
static hci_uart_config_t hci_uart_config_cc256x = {
|
||||
NULL,
|
||||
static hci_transport_config_uart_t config = {
|
||||
HCI_TRANSPORT_CONFIG_UART,
|
||||
115200,
|
||||
0, // main baudrate: set to higher standard values if needed e.g. 460800
|
||||
0, // main baudrate
|
||||
1, // flow control
|
||||
NULL,
|
||||
};
|
||||
|
||||
static void sigint_handler(int param){
|
||||
@ -96,14 +99,14 @@ int main(int argc, const char * argv[]){
|
||||
hci_dump_open("/tmp/hci_dump.pklg", HCI_DUMP_PACKETLOGGER);
|
||||
|
||||
// pick serial port
|
||||
hci_uart_config_cc256x.device_name = "/dev/tty.usbserial-AD025KU2";
|
||||
config.device_name = "/dev/tty.usbserial-AD025KU2";
|
||||
|
||||
// init HCI
|
||||
hci_transport_t * transport = hci_transport_h4_instance();
|
||||
bt_control_t * control = bt_control_stlc2500d_instance();
|
||||
remote_device_db_t * remote_db = (remote_device_db_t *) &remote_device_db_fs;
|
||||
|
||||
hci_init(transport, (void*) &hci_uart_config_cc256x, control, remote_db);
|
||||
hci_init(transport, (void*) &config, control, remote_db);
|
||||
|
||||
// handle CTRL-c
|
||||
signal(SIGINT, sigint_handler);
|
||||
|
@ -50,6 +50,7 @@
|
||||
#include "btstack-config.h"
|
||||
|
||||
#include "run_loop.h"
|
||||
#include "run_loop_posix.h"
|
||||
|
||||
#include "debug.h"
|
||||
#include "btstack_memory.h"
|
||||
@ -61,9 +62,12 @@
|
||||
|
||||
int btstack_main(int argc, const char * argv[]);
|
||||
|
||||
static hci_uart_config_t hci_uart_config_cc256x = {
|
||||
NULL,
|
||||
static hci_transport_config_uart_t config = {
|
||||
HCI_TRANSPORT_CONFIG_UART,
|
||||
115200,
|
||||
0, // main baudrate
|
||||
1, // flow control
|
||||
NULL,
|
||||
};
|
||||
|
||||
static void sigint_handler(int param){
|
||||
@ -96,14 +100,14 @@ int main(int argc, const char * argv[]){
|
||||
hci_dump_open("/tmp/hci_dump.pklg", HCI_DUMP_PACKETLOGGER);
|
||||
|
||||
// pick serial port
|
||||
hci_uart_config_cc256x.device_name = "/dev/tty.usbserial-AD025KU2";
|
||||
config.device_name = "/dev/tty.usbserial-AD025KU2";
|
||||
|
||||
// init HCI
|
||||
hci_transport_t * transport = hci_transport_h4_instance();
|
||||
bt_control_t * control = bt_control_cc256x_instance();
|
||||
remote_device_db_t * remote_db = (remote_device_db_t *) &remote_device_db_fs;
|
||||
|
||||
hci_init(transport, (void*) &hci_uart_config_cc256x, control, remote_db);
|
||||
hci_init(transport, (void*) &config, control, remote_db);
|
||||
|
||||
// handle CTRL-c
|
||||
signal(SIGINT, sigint_handler);
|
||||
|
@ -403,11 +403,12 @@ static void bluetooth_power_cycle(void){
|
||||
|
||||
// after HCI Reset, use 115200. Then increase baud reate to 468000.
|
||||
// (on nucleo board without external crystall, running at 8 Mhz, 1 mbps was not possible)
|
||||
static const hci_uart_config_t hci_uart_config_cc256x = {
|
||||
NULL,
|
||||
static const hci_transport_config_uart_t config = {
|
||||
HCI_TRANSPORT_CONFIG_UART,
|
||||
115200,
|
||||
460800,
|
||||
0
|
||||
1,
|
||||
NULL
|
||||
};
|
||||
|
||||
int main(void)
|
||||
@ -426,7 +427,7 @@ int main(void)
|
||||
hci_transport_t * transport = hci_transport_h4_dma_instance();
|
||||
bt_control_t * control = bt_control_cc256x_instance();
|
||||
remote_device_db_t * remote_db = (remote_device_db_t *) &remote_device_db_memory;
|
||||
hci_init(transport, (void*) &hci_uart_config_cc256x, control, remote_db);
|
||||
hci_init(transport, (void*) &config, control, remote_db);
|
||||
|
||||
// enable eHCILL
|
||||
bt_control_cc256x_enable_ehcill(1);
|
||||
|
@ -48,11 +48,12 @@
|
||||
// see generated_mac_address.txt - "macaddr=02:0A:F7:3d:76:be"
|
||||
static const char * wifi_mac_address = NVRAM_GENERATED_MAC_ADDRESS;
|
||||
|
||||
static const hci_uart_config_t hci_uart_config = {
|
||||
NULL,
|
||||
static const hci_transport_config_uart_t hci_transport_config_uart = {
|
||||
HCI_TRANSPORT_CONFIG_UART,
|
||||
115200,
|
||||
3000000,
|
||||
0
|
||||
1,
|
||||
NULL,
|
||||
};
|
||||
|
||||
extern int btstack_main(void);
|
||||
@ -94,7 +95,7 @@ void application_start(void){
|
||||
hci_transport_t * transport = hci_transport_h4_wiced_instance();
|
||||
bt_control_t * control = bt_control_bcm_instance();
|
||||
remote_device_db_t * remote_db = (remote_device_db_t *) &remote_device_db_memory;
|
||||
hci_init(transport, (void*) &hci_uart_config, control, remote_db);
|
||||
hci_init(transport, (void*) &hci_transport_config_uart, control, remote_db);
|
||||
|
||||
// use WIFI Mac address + 1 for Bluetooth
|
||||
bd_addr_t dummy = { 1,2,3,4,5,6};
|
||||
|
@ -846,7 +846,7 @@ void le_handle_advertisement_report(uint8_t *packet, int size){
|
||||
|
||||
static uint32_t hci_transport_uart_get_main_baud_rate(void){
|
||||
if (!hci_stack->config) return 0;
|
||||
uint32_t baud_rate = ((hci_uart_config_t *)hci_stack->config)->baudrate_main;
|
||||
uint32_t baud_rate = ((hci_transport_config_uart_t *)hci_stack->config)->baudrate_main;
|
||||
// Limit baud rate for Broadcom chipsets to 3 mbps
|
||||
if (hci_stack->manufacturer == COMPANY_ID_BROADCOM_CORPORATION && baud_rate > 3000000){
|
||||
baud_rate = 3000000;
|
||||
@ -974,9 +974,9 @@ static void hci_initializing_run(void){
|
||||
&& hci_stack->control
|
||||
&& hci_stack->control->baudrate_cmd
|
||||
&& hci_stack->hci_transport->set_baudrate
|
||||
&& ((hci_uart_config_t *)hci_stack->config)->baudrate_main;
|
||||
&& ((hci_transport_config_uart_t *)hci_stack->config)->baudrate_main;
|
||||
if (need_baud_change) {
|
||||
uint32_t baud_rate = ((hci_uart_config_t *)hci_stack->config)->baudrate_init;
|
||||
uint32_t baud_rate = ((hci_transport_config_uart_t *)hci_stack->config)->baudrate_init;
|
||||
log_info("Local baud rate change to %"PRIu32" after init script", baud_rate);
|
||||
hci_stack->hci_transport->set_baudrate(baud_rate);
|
||||
}
|
||||
@ -1119,7 +1119,7 @@ static void hci_initializing_event_handler(uint8_t * packet, uint16_t size){
|
||||
&& hci_stack->control
|
||||
&& hci_stack->control->baudrate_cmd
|
||||
&& hci_stack->hci_transport->set_baudrate
|
||||
&& ((hci_uart_config_t *)hci_stack->config)->baudrate_main;
|
||||
&& ((hci_transport_config_uart_t *)hci_stack->config)->baudrate_main;
|
||||
|
||||
int need_addr_change = hci_stack->custom_bd_addr_set
|
||||
&& hci_stack->control
|
||||
|
@ -68,12 +68,22 @@ typedef struct {
|
||||
int (*can_send_packet_now)(uint8_t packet_type);
|
||||
} hci_transport_t;
|
||||
|
||||
typedef enum {
|
||||
HCI_TRANSPORT_CONFIG_UART,
|
||||
HCI_TRANSPORT_CONFIG_USB
|
||||
} hci_transport_config_type_t;
|
||||
|
||||
typedef struct {
|
||||
const char *device_name;
|
||||
hci_transport_config_type_t type;
|
||||
} hci_transport_config_t;
|
||||
|
||||
typedef struct {
|
||||
hci_transport_config_type_t type; // == HCI_TRANSPORT_CONFIG_UART
|
||||
uint32_t baudrate_init; // initial baud rate
|
||||
uint32_t baudrate_main; // = 0: same as initial baudrate
|
||||
int flowcontrol; //
|
||||
} hci_uart_config_t;
|
||||
int flowcontrol; //
|
||||
const char *device_name;
|
||||
} hci_transport_config_uart_t;
|
||||
|
||||
|
||||
// inline various hci_transport_X.h files
|
||||
|
@ -22,7 +22,7 @@ COMMON = \
|
||||
hci_dump.c \
|
||||
le_device_db_memory.c \
|
||||
memory_pool.c \
|
||||
mock.c
|
||||
mock.c \
|
||||
utils.c \
|
||||
|
||||
|
||||
|
@ -939,17 +939,6 @@ static int get_oob_data_callback(uint8_t addres_type, bd_addr_t addr, uint8_t *
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if defined(HAVE_UART_CSR) || defined(HAVE_UART_CC256x)
|
||||
static hci_uart_config_t hci_uart_config = {
|
||||
// "/dev/tty.usbserial-A40081HW",
|
||||
"/dev/tty.usbserial-AD025KU2",
|
||||
115200,
|
||||
0, // 1000000,
|
||||
1
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
int btstack_main(int argc, const char * argv[]);
|
||||
int btstack_main(int argc, const char * argv[]){
|
||||
|
||||
|
@ -14,6 +14,8 @@
|
||||
#include "CppUTest/TestHarness.h"
|
||||
#include "CppUTest/CommandLineTestRunner.h"
|
||||
|
||||
#include "run_loop_posix.h"
|
||||
|
||||
#include "hci_cmds.h"
|
||||
#include "utils.h"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user