mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-23 19:20:51 +00:00
hci: set link_key_db via hci_set_link_key_db instead of via hci_init().
This commit is contained in:
parent
9d294ab530
commit
2d5e09d6d4
@ -2068,7 +2068,10 @@ int main (int argc, char * const * argv){
|
||||
log_info("version %s, build %s", BTSTACK_VERSION, BTSTACK_DATE);
|
||||
|
||||
// init HCI
|
||||
hci_init(transport, config, btstack_link_key_db);
|
||||
hci_init(transport, config)
|
||||
if (btstack_link_key_db){
|
||||
hci_set_link_key_db(btstack_link_key_db);
|
||||
}
|
||||
if (control){
|
||||
hci_set_control(control);
|
||||
}
|
||||
|
@ -746,7 +746,7 @@ void BTstackManager::setup(void){
|
||||
btstack_run_loop_init(btstack_run_loop_embedded_get_instance());
|
||||
|
||||
const hci_transport_t * transport = hci_transport_h4_instance();
|
||||
hci_init(transport, NULL, NULL);
|
||||
hci_init(transport, NULL);
|
||||
hci_set_chipset(btstack_chipset_em9301_instance());
|
||||
|
||||
if (have_custom_addr){
|
||||
|
@ -98,9 +98,8 @@ int main(void)
|
||||
btstack_run_loop_init(btstack_run_loop_embedded_get_instance());
|
||||
|
||||
// init HCI
|
||||
const hci_transport_t * transport = hci_transport_h4_instance();
|
||||
remote_device_db_t * remote_db = (remote_device_db_t *) &remote_device_db_memory;
|
||||
hci_init(transport, &config, remote_db);
|
||||
hci_init(hci_transport_h4_instance(), &config);
|
||||
hci_set_link_key_db(btstack_link_key_db_memory_instance());
|
||||
hci_set_chipset(btstack_chipset_cc256x_instance());
|
||||
|
||||
// use eHCILL
|
||||
|
@ -91,8 +91,8 @@ int main(int argc, const char * argv[]){
|
||||
hci_dump_open("/tmp/hci_dump.pklg", HCI_DUMP_PACKETLOGGER);
|
||||
|
||||
// init HCI
|
||||
const hci_transport_t * transport = hci_transport_usb_instance();
|
||||
hci_init(transport, NULL, btstack_link_key_db_fs_instance());
|
||||
hci_init(hci_transport_usb_instance(), NULL);
|
||||
hci_set_link_key_db(btstack_link_key_db_fs_instance());
|
||||
|
||||
// handle CTRL-c
|
||||
signal(SIGINT, sigint_handler);
|
||||
|
@ -378,8 +378,9 @@ int main(void){
|
||||
|
||||
// init HCI
|
||||
const hci_transport_t * transport = hci_transport_h4_instance();
|
||||
remote_device_db_t * remote_db = (remote_device_db_t *) &remote_device_db_memory;
|
||||
hci_init(transport, &config, remote_db);
|
||||
remote_device_db_t * link_key_db = (remote_device_db_t *) &remote_device_db_memory;
|
||||
hci_init(transport, &config, link_key_db);
|
||||
hci_set_link_key_db(link_key_db);
|
||||
hci_set_chipset(btstack_chipset_cc256x_instance());
|
||||
|
||||
// use eHCILL
|
||||
|
@ -98,9 +98,8 @@ static void btstack_setup(void){
|
||||
btstack_run_loop_init(btstack_run_loop_embedded_get_instance());
|
||||
|
||||
// init HCI
|
||||
const hci_transport_t * transport = hci_transport_h4_instance();
|
||||
remote_device_db_t * remote_db = (remote_device_db_t *) &remote_device_db_memory;
|
||||
hci_init(transport, &config, remote_db);
|
||||
hci_init(hci_transport_h4_instance, &config);
|
||||
hci_set_link_key_db(btstack_link_key_db_memory_instance);
|
||||
hci_set_chipset(btstack_chipset_cc256x_instance());
|
||||
|
||||
// use eHCILL
|
||||
|
@ -105,9 +105,8 @@ static void btstack_setup(void){
|
||||
btstack_run_loop_init(btstack_run_loop_embedded_get_instance());
|
||||
|
||||
// init HCI
|
||||
const hci_transport_t * transport = hci_transport_h4_instance();
|
||||
remote_device_db_t * remote_db = (remote_device_db_t *) &remote_device_db_memory;
|
||||
hci_init(transport, &config, remote_db);
|
||||
hci_init(hci_transport_h4_instance, &config);
|
||||
hci_set_link_key_db(btstack_link_key_db_memory_instance());
|
||||
hci_set_chipset(btstack_chipset_cc256x_instance());
|
||||
|
||||
// use eHCILL
|
||||
|
@ -226,7 +226,7 @@ void BTSTACK_Initialize ( void )
|
||||
hci_dump_open(NULL, HCI_DUMP_STDOUT);
|
||||
|
||||
const hci_transport_t * transport = hci_transport_h4_instance();
|
||||
hci_init(transport, &config, NULL);
|
||||
hci_init(transport, &config);
|
||||
hci_set_chipset(btstack_chipset_csr_instance());
|
||||
|
||||
// hci_power_control(HCI_POWER_ON);
|
||||
|
@ -162,7 +162,8 @@ int main(int argc, const char * argv[]){
|
||||
// init HCI
|
||||
const hci_transport_t * transport = hci_transport_h4_instance();
|
||||
const btstack_link_key_db_t * link_key_db = btstack_link_key_db_fs_instance();
|
||||
hci_init(transport, (void*) &config, link_key_db);
|
||||
hci_init(transport, (void*) &config);
|
||||
hci_set_link_key_db(link_key_db);
|
||||
|
||||
// register for HCI events
|
||||
hci_event_callback_registration.callback = &hci_event_handler;
|
||||
|
@ -424,9 +424,8 @@ int main(void)
|
||||
btstack_run_loop_init(btstack_run_loop_embedded_get_instance());
|
||||
|
||||
// init HCI
|
||||
const hci_transport_t * transport = hci_transport_h4_instance();
|
||||
remote_device_db_t * remote_db = (remote_device_db_t *) &remote_device_db_memory;
|
||||
hci_init(transport, (void*) &config, remote_db);
|
||||
hci_init(hci_transport_h4_instance(), (void*) &config);
|
||||
hci_set_link_key_db(btstack_link_key_db_memory_instance());
|
||||
hci_set_chipset(btstack_chipset_cc256x_instance());
|
||||
|
||||
// enable eHCILL
|
||||
|
@ -92,9 +92,8 @@ void application_start(void){
|
||||
// hci_dump_open(NULL, HCI_DUMP_STDOUT);
|
||||
|
||||
// init HCI
|
||||
const hci_transport_t * transport = hci_transport_h4_instance();
|
||||
remote_device_db_t * remote_db = (remote_device_db_t *) &remote_device_db_memory;
|
||||
hci_init(transport, (void*) &hci_transport_config_uart, remote_db);
|
||||
hci_init(hci_transport_h4_instance, (void*) &hci_transport_config_uart);
|
||||
hci_set_link_key_db(btstack_link_key_db_memory_instance());
|
||||
hci_set_chipset(btstack_chipset_bcm_instance());
|
||||
|
||||
// use WIFI Mac address + 1 for Bluetooth
|
||||
|
22
src/hci.c
22
src/hci.c
@ -1880,7 +1880,18 @@ static void hci_state_reset(void){
|
||||
hci_stack->le_connection_parameter_range.le_supervision_timeout_max = 3200;
|
||||
}
|
||||
|
||||
void hci_init(const hci_transport_t *transport, const void *config, btstack_link_key_db_t const * link_key_db){
|
||||
/**
|
||||
* @brief Configure Bluetooth hardware control. Has to be called before power on.
|
||||
*/
|
||||
void hci_set_link_key_db(btstack_link_key_db_t const * link_key_db){
|
||||
// store and open remote device db
|
||||
hci_stack->link_key_db = link_key_db;
|
||||
if (hci_stack->link_key_db) {
|
||||
hci_stack->link_key_db->open();
|
||||
}
|
||||
}
|
||||
|
||||
void hci_init(const hci_transport_t *transport, const void *config){
|
||||
|
||||
#ifdef HAVE_MALLOC
|
||||
if (!hci_stack) {
|
||||
@ -1897,15 +1908,6 @@ void hci_init(const hci_transport_t *transport, const void *config, btstack_link
|
||||
// reference to used config
|
||||
hci_stack->config = config;
|
||||
|
||||
// init used hardware control with NULL
|
||||
// init used chipset with NULL
|
||||
|
||||
// store and open remote device db
|
||||
hci_stack->link_key_db = link_key_db;
|
||||
if (hci_stack->link_key_db) {
|
||||
hci_stack->link_key_db->open();
|
||||
}
|
||||
|
||||
// max acl payload size defined in config.h
|
||||
hci_stack->acl_data_packet_length = HCI_ACL_PAYLOAD_SIZE;
|
||||
|
||||
|
@ -696,7 +696,7 @@ void hci_local_bd_addr(bd_addr_t address_buffer);
|
||||
/**
|
||||
* @brief Set up HCI. Needs to be called before any other function.
|
||||
*/
|
||||
void hci_init(const hci_transport_t *transport, const void *config, btstack_link_key_db_t const * btstack_link_key_db);
|
||||
void hci_init(const hci_transport_t *transport, const void *config);
|
||||
|
||||
/**
|
||||
* @brief Configure Bluetooth chipset driver. Has to be called before power on, or right after receiving the local version information.
|
||||
@ -708,6 +708,11 @@ void hci_set_chipset(const btstack_chipset_t *chipset_driver);
|
||||
*/
|
||||
void hci_set_control(const btstack_control_t *hardware_control);
|
||||
|
||||
/**
|
||||
* @brief Configure Bluetooth hardware control. Has to be called before power on.
|
||||
*/
|
||||
void hci_set_link_key_db(btstack_link_key_db_t const * link_key_db);
|
||||
|
||||
/**
|
||||
* @brief Set class of device that will be set during Bluetooth init.
|
||||
*/
|
||||
|
@ -149,7 +149,7 @@ bool nameHasPrefix(const char * name_prefix, uint16_t data_length, uint8_t * dat
|
||||
|
||||
TEST_GROUP(ADParser){
|
||||
void setup(void){
|
||||
hci_init(&dummy_transport, NULL, NULL);
|
||||
hci_init(&dummy_transport, NULL);
|
||||
hci_event_callback_registration.callback = &packet_handler;
|
||||
hci_add_event_handler(&hci_event_callback_registration);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user