From 4a924fdcae4493b082295b76511d448456c5e36a Mon Sep 17 00:00:00 2001 From: Kiran Kelageri Date: Tue, 4 Aug 2015 15:46:33 -0700 Subject: Bluetooth: Enable SSR. Enabling SSR feature. Change-Id: I26eab5b3a10ac7823ff5e9f2adc3bc187939c87e --- hci/src/hci_layer.c | 19 ++++++++++++++++++- hci/src/vendor.c | 8 ++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) (limited to 'hci/src') diff --git a/hci/src/hci_layer.c b/hci/src/hci_layer.c index 5138ce6e1..0d1c62b92 100644 --- a/hci/src/hci_layer.c +++ b/hci/src/hci_layer.c @@ -44,6 +44,7 @@ #include "packet_fragmenter.h" #include "osi/include/reactor.h" #include "vendor.h" +#include "bt_target.h" // TODO(zachoverflow): remove this hack extern #include @@ -162,6 +163,8 @@ static bool filter_incoming_event(BT_HDR *packet); static serial_data_type_t event_to_data_type(uint16_t event); static waiting_command_t *get_waiting_command(command_opcode_t opcode); +void ssr_cleanup (void); + // Module lifecycle functions static future_t *start_up(void) { @@ -517,7 +520,8 @@ static void command_timed_out(UNUSED_ATTR void *context) { } LOG_ERROR("%s restarting the bluetooth process.", __func__); - usleep(10000); + ssr_cleanup(); + usleep(20000); kill(getpid(), SIGKILL); } @@ -690,6 +694,18 @@ intercepted:; return true; } +/** SSR cleanup is used in HW reset cases +** which would close all the client channels +** and turns off the chip*/ +void ssr_cleanup (void) { + LOG_INFO("%s", __func__); + if (vendor != NULL) { + vendor->ssr_cleanup(); + } else { + LOG_ERROR("%s: vendor is NULL", __func__); + } +} + // Callback for the fragmenter to dispatch up a completely reassembled packet static void dispatch_reassembled(BT_HDR *packet) { // Events should already have been dispatched before this point @@ -758,6 +774,7 @@ static void init_layer_interface() { interface.transmit_command = transmit_command; interface.transmit_command_futured = transmit_command_futured; interface.transmit_downward = transmit_downward; + interface.ssr_cleanup = ssr_cleanup; interface_created = true; } } diff --git a/hci/src/vendor.c b/hci/src/vendor.c index 2e220e4a7..ccc0003d5 100644 --- a/hci/src/vendor.c +++ b/hci/src/vendor.c @@ -89,6 +89,13 @@ static void vendor_close(void) { lib_interface = NULL; lib_handle = NULL; } +void vendor_ssrcleanup(void) { + if (lib_interface) + lib_interface->ssr_cleanup(); + else + LOG_ERROR("%s lib_interface is NULL", __func__); + +} static int send_command(vendor_opcode_t opcode, void *param) { assert(lib_interface != NULL); @@ -204,6 +211,7 @@ static const vendor_t interface = { send_command, send_async_command, set_callback, + vendor_ssrcleanup }; const vendor_t *vendor_get_interface() { -- cgit v1.2.3