mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-01 04:20:33 +00:00
hci: remove callback for local information - use hci_add_event_handler instead
This commit is contained in:
parent
b6e96f1452
commit
54b584ff87
@ -6,7 +6,7 @@ CORE += main.c stdin_support.c
|
|||||||
COMMON += \
|
COMMON += \
|
||||||
hci_transport_h4_posix.c \
|
hci_transport_h4_posix.c \
|
||||||
btstack_run_loop_posix.c \
|
btstack_run_loop_posix.c \
|
||||||
remote_device_db_fs.c \
|
btstack_link_key_db_fs.c \
|
||||||
|
|
||||||
CORE += \
|
CORE += \
|
||||||
bluetooth_init_cc2564B_1.2_BT_Spec_4.1.c \
|
bluetooth_init_cc2564B_1.2_BT_Spec_4.1.c \
|
||||||
|
@ -49,12 +49,13 @@
|
|||||||
|
|
||||||
#include "btstack_config.h"
|
#include "btstack_config.h"
|
||||||
|
|
||||||
#include "btstack_memory.h"
|
|
||||||
#include "btstack_debug.h"
|
#include "btstack_debug.h"
|
||||||
#include "hci.h"
|
#include "btstack_link_key_db_fs.h"
|
||||||
#include "hci_dump.h"
|
#include "btstack_memory.h"
|
||||||
#include "btstack_run_loop.h"
|
#include "btstack_run_loop.h"
|
||||||
#include "btstack_run_loop_posix.h"
|
#include "btstack_run_loop_posix.h"
|
||||||
|
#include "hci.h"
|
||||||
|
#include "hci_dump.h"
|
||||||
#include "stdin_support.h"
|
#include "stdin_support.h"
|
||||||
|
|
||||||
#include "btstack_chipset_bcm.h"
|
#include "btstack_chipset_bcm.h"
|
||||||
@ -74,6 +75,8 @@ static hci_transport_config_uart_t config = {
|
|||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static btstack_packet_callback_registration_t hci_event_callback_registration;
|
||||||
|
|
||||||
static void sigint_handler(int param){
|
static void sigint_handler(int param){
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
@ -98,7 +101,11 @@ static void using_921600_baud(void){
|
|||||||
config.baudrate_main = 921600;
|
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");
|
printf("Local version information:\n");
|
||||||
uint16_t hci_version = little_endian_read_16(packet, 4);
|
uint16_t hci_version = little_endian_read_16(packet, 4);
|
||||||
uint16_t hci_revision = little_endian_read_16(packet, 6);
|
uint16_t hci_revision = little_endian_read_16(packet, 6);
|
||||||
@ -154,11 +161,12 @@ int main(int argc, const char * argv[]){
|
|||||||
|
|
||||||
// init HCI
|
// init HCI
|
||||||
const hci_transport_t * transport = hci_transport_h4_instance();
|
const hci_transport_t * transport = hci_transport_h4_instance();
|
||||||
remote_device_db_t * remote_db = (remote_device_db_t *) &remote_device_db_fs;
|
const btstack_link_key_db_t * link_key_db = btstack_link_key_db_fs_instance();
|
||||||
hci_init(transport, (void*) &config, remote_db);
|
hci_init(transport, (void*) &config, link_key_db);
|
||||||
|
|
||||||
// setup dynamic chipset driver setup
|
// register for HCI events
|
||||||
hci_set_local_version_information_callback(&local_version_information_callback);
|
hci_event_callback_registration.callback = &hci_event_handler;
|
||||||
|
hci_add_event_handler(&hci_event_callback_registration);
|
||||||
|
|
||||||
// handle CTRL-c
|
// handle CTRL-c
|
||||||
signal(SIGINT, sigint_handler);
|
signal(SIGINT, sigint_handler);
|
||||||
|
14
src/hci.c
14
src/hci.c
@ -1368,11 +1368,6 @@ static void event_handler(uint8_t *packet, int size){
|
|||||||
hci_stack->manufacturer = little_endian_read_16(packet, 10);
|
hci_stack->manufacturer = little_endian_read_16(packet, 10);
|
||||||
// hci_stack->lmp_subversion = little_endian_read_16(packet, 12);
|
// hci_stack->lmp_subversion = little_endian_read_16(packet, 12);
|
||||||
log_info("Manufacturer: 0x%04x", hci_stack->manufacturer);
|
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)){
|
if (COMMAND_COMPLETE_EVENT(packet, hci_read_local_supported_commands)){
|
||||||
hci_stack->local_supported_commands[0] =
|
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;
|
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){
|
void hci_disconnect_all(void){
|
||||||
btstack_linked_list_iterator_t it;
|
btstack_linked_list_iterator_t it;
|
||||||
btstack_linked_list_iterator_init(&it, &hci_stack->connections);
|
btstack_linked_list_iterator_init(&it, &hci_stack->connections);
|
||||||
|
@ -644,9 +644,6 @@ typedef struct {
|
|||||||
// hardware error callback
|
// hardware error callback
|
||||||
void (*hardware_error_callback)(void);
|
void (*hardware_error_callback)(void);
|
||||||
|
|
||||||
// local version information callback
|
|
||||||
void (*local_version_information_callback)(uint8_t * local_version_information);
|
|
||||||
|
|
||||||
} hci_stack_t;
|
} 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));
|
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
|
* @brief Configure Voice Setting for use with SCO data in HSP/HFP
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user