hci: remove callback for local information - use hci_add_event_handler instead

This commit is contained in:
Matthias Ringwald 2016-02-04 18:06:14 +01:00
parent b6e96f1452
commit 54b584ff87
4 changed files with 18 additions and 33 deletions

View File

@ -4,9 +4,9 @@ BTSTACK_ROOT = ../..
CORE += main.c stdin_support.c
COMMON += \
hci_transport_h4_posix.c \
hci_transport_h4_posix.c \
btstack_run_loop_posix.c \
remote_device_db_fs.c \
btstack_link_key_db_fs.c \
CORE += \
bluetooth_init_cc2564B_1.2_BT_Spec_4.1.c \

View File

@ -49,12 +49,13 @@
#include "btstack_config.h"
#include "btstack_memory.h"
#include "btstack_debug.h"
#include "hci.h"
#include "hci_dump.h"
#include "btstack_link_key_db_fs.h"
#include "btstack_memory.h"
#include "btstack_run_loop.h"
#include "btstack_run_loop_posix.h"
#include "hci.h"
#include "hci_dump.h"
#include "stdin_support.h"
#include "btstack_chipset_bcm.h"
@ -74,6 +75,8 @@ 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
@ -98,7 +101,11 @@ static void using_921600_baud(void){
config.baudrate_main = 921600;
}
static void local_version_information_callback(uint8_t * packet){
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 (!COMMAND_COMPLETE_EVENT(packet, hci_read_local_version_information)) return;
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);
@ -154,11 +161,12 @@ int main(int argc, const char * argv[]){
// init HCI
const 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*) &config, remote_db);
const btstack_link_key_db_t * link_key_db = btstack_link_key_db_fs_instance();
hci_init(transport, (void*) &config, link_key_db);
// setup dynamic chipset driver setup
hci_set_local_version_information_callback(&local_version_information_callback);
// register for HCI events
hci_event_callback_registration.callback = &hci_event_handler;
hci_add_event_handler(&hci_event_callback_registration);
// handle CTRL-c
signal(SIGINT, sigint_handler);

View File

@ -1368,11 +1368,6 @@ 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 (COMMAND_COMPLETE_EVENT(packet, hci_read_local_supported_commands)){
hci_stack->local_supported_commands[0] =
@ -3510,15 +3505,6 @@ 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

@ -644,9 +644,6 @@ typedef struct {
// hardware error callback
void (*hardware_error_callback)(void);
// local version information callback
void (*local_version_information_callback)(uint8_t * local_version_information);
} hci_stack_t;
/**
@ -848,12 +845,6 @@ void hci_le_advertisement_address(uint8_t * addr_type, bd_addr_t addr);
*/
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 Configure Voice Setting for use with SCO data in HSP/HFP
*/