hci: re-add local version information callback for dynamic chipset configuration

This commit is contained in:
Matthias Ringwald 2016-03-22 22:15:59 +01:00
parent 369c1a52d1
commit a6ddbcb91c
3 changed files with 24 additions and 10 deletions

View File

@ -75,8 +75,6 @@ static hci_transport_config_uart_t config = {
NULL,
};
static btstack_packet_callback_registration_t hci_event_callback_registration;
static void sigint_handler(int param){
#ifndef _WIN32
@ -101,11 +99,7 @@ static void using_921600_baud(void){
config.baudrate_main = 921600;
}
static void hci_event_handler(uint8_t packet_type, uint16_t channel, uint8_t * packet, uint16_t size){
if (packet_type != HCI_EVENT_PACKET) return;
if (!HCI_EVENT_IS_COMMAND_COMPLETE(packet, hci_read_local_version_information)) return;
static void local_version_information_callback(uint8_t * packet){
printf("Local version information:\n");
uint16_t hci_version = little_endian_read_16(packet, 4);
uint16_t hci_revision = little_endian_read_16(packet, 6);
@ -165,9 +159,8 @@ int main(int argc, const char * argv[]){
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;
hci_add_event_handler(&hci_event_callback_registration);
// setup dynamic chipset driver setup
hci_set_local_version_information_callback(&local_version_information_callback);
// handle CTRL-c
signal(SIGINT, sigint_handler);

View File

@ -1399,6 +1399,10 @@ static void event_handler(uint8_t *packet, int size){
hci_stack->manufacturer = little_endian_read_16(packet, 10);
// hci_stack->lmp_subversion = little_endian_read_16(packet, 12);
log_info("Manufacturer: 0x%04x", hci_stack->manufacturer);
// notify app
if (hci_stack->local_version_information_callback){
hci_stack->local_version_information_callback(packet);
}
}
if (HCI_EVENT_IS_COMMAND_COMPLETE(packet, hci_read_local_supported_commands)){
hci_stack->local_supported_commands[0] =
@ -3553,6 +3557,14 @@ void hci_set_hardware_error_callback(void (*fn)(void)){
hci_stack->hardware_error_callback = fn;
}
/**
* @brief Set callback for local information from Bluetooth controller right after HCI Reset
* @note Can be used to select chipset driver dynamically during startup
*/
void hci_set_local_version_information_callback(void (*fn)(uint8_t * local_version_information)){
hci_stack->local_version_information_callback = fn;
}
void hci_disconnect_all(void){
btstack_linked_list_iterator_t it;
btstack_linked_list_iterator_init(&it, &hci_stack->connections);

View File

@ -546,6 +546,9 @@ typedef struct {
/* callbacks for events */
btstack_linked_list_t event_handlers;
// local version information callback
void (*local_version_information_callback)(uint8_t * local_version_information);
// hardware error callback
void (*hardware_error_callback)(void);
@ -697,6 +700,12 @@ void hci_set_class_of_device(uint32_t class_of_device);
*/
void hci_set_hardware_error_callback(void (*fn)(void));
/**
* @brief Set callback for local information from Bluetooth controller right after HCI Reset
* @note Can be used to select chipset driver dynamically during startup
*/
void hci_set_local_version_information_callback(void (*fn)(uint8_t * local_version_information));
/**
* @brief Set Public BD ADDR - passed on to Bluetooth chipset during init if supported in bt_control_h
*/