added callback for Bluetooth hardware error

This commit is contained in:
Matthias Ringwald 2015-05-18 21:13:28 +02:00
parent 57fe2af8bc
commit d23838ec66
2 changed files with 20 additions and 1 deletions

View File

@ -1504,7 +1504,9 @@ static void event_handler(uint8_t *packet, int size){
break;
case HCI_EVENT_HARDWARE_ERROR:
if(hci_stack->control && hci_stack->control->hw_error){
if (hci_stack->hardware_error_callback){
(*hci_stack->hardware_error_callback)();
} else if(hci_stack->control && hci_stack->control->hw_error){
(*hci_stack->control->hw_error)();
} else {
// if no special requests, just reboot stack
@ -2915,6 +2917,14 @@ le_command_status_t gap_disconnect(hci_con_handle_t handle){
return BLE_PERIPHERAL_OK;
}
/**
* @brief Set callback for Bluetooth Hardware Error
*/
void hci_set_hardware_error_callback(void (*fn)(void)){
hci_stack->hardware_error_callback = fn;
}
void hci_disconnect_all(void){
linked_list_iterator_t it;
linked_list_iterator_init(&it, &hci_stack->connections);

View File

@ -679,6 +679,9 @@ typedef struct {
bd_addr_t custom_bd_addr;
uint8_t custom_bd_addr_set;
// hardware error handler
void (*hardware_error_callback)(void);
} hci_stack_t;
/**
@ -854,6 +857,12 @@ void hci_ssp_set_auto_accept(int auto_accept);
* @brief Get addr type and address used in advertisement packets.
*/
void hci_le_advertisement_address(uint8_t * addr_type, bd_addr_t addr);
/**
* @brief Set callback for Bluetooth Hardware Error
*/
void hci_set_hardware_error_callback(void (*fn)(void));
/* API_END */
#if defined __cplusplus