mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-27 06:35:20 +00:00
hci: re-add local version information callback for dynamic chipset configuration
This commit is contained in:
parent
369c1a52d1
commit
a6ddbcb91c
@ -75,8 +75,6 @@ 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
|
||||||
@ -101,11 +99,7 @@ static void using_921600_baud(void){
|
|||||||
config.baudrate_main = 921600;
|
config.baudrate_main = 921600;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hci_event_handler(uint8_t packet_type, uint16_t channel, uint8_t * packet, uint16_t size){
|
static void local_version_information_callback(uint8_t * packet){
|
||||||
|
|
||||||
if (packet_type != HCI_EVENT_PACKET) return;
|
|
||||||
if (!HCI_EVENT_IS_COMMAND_COMPLETE(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);
|
||||||
@ -165,9 +159,8 @@ int main(int argc, const char * argv[]){
|
|||||||
hci_init(transport, (void*) &config);
|
hci_init(transport, (void*) &config);
|
||||||
hci_set_link_key_db(link_key_db);
|
hci_set_link_key_db(link_key_db);
|
||||||
|
|
||||||
// register for HCI events
|
// setup dynamic chipset driver setup
|
||||||
hci_event_callback_registration.callback = &hci_event_handler;
|
hci_set_local_version_information_callback(&local_version_information_callback);
|
||||||
hci_add_event_handler(&hci_event_callback_registration);
|
|
||||||
|
|
||||||
// handle CTRL-c
|
// handle CTRL-c
|
||||||
signal(SIGINT, sigint_handler);
|
signal(SIGINT, sigint_handler);
|
||||||
|
12
src/hci.c
12
src/hci.c
@ -1399,6 +1399,10 @@ 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 (HCI_EVENT_IS_COMMAND_COMPLETE(packet, hci_read_local_supported_commands)){
|
if (HCI_EVENT_IS_COMMAND_COMPLETE(packet, hci_read_local_supported_commands)){
|
||||||
hci_stack->local_supported_commands[0] =
|
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;
|
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);
|
||||||
|
@ -546,6 +546,9 @@ typedef struct {
|
|||||||
/* callbacks for events */
|
/* callbacks for events */
|
||||||
btstack_linked_list_t event_handlers;
|
btstack_linked_list_t event_handlers;
|
||||||
|
|
||||||
|
// local version information callback
|
||||||
|
void (*local_version_information_callback)(uint8_t * local_version_information);
|
||||||
|
|
||||||
// hardware error callback
|
// hardware error callback
|
||||||
void (*hardware_error_callback)(void);
|
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));
|
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
|
* @brief Set Public BD ADDR - passed on to Bluetooth chipset during init if supported in bt_control_h
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user