Skip to content
Permalink
Browse files

daemon/libusb-intel/windows-winusb-intel: skip power down and hci clo…

…se if firmware wasn't downloaded yet on SIGINT
  • Loading branch information...
mringwal committed Sep 4, 2019
1 parent 228e430 commit 948e8bfe93ba41dcc49e6d7e1c833f141546760f
Showing with 27 additions and 9 deletions.
  1. +10 −2 platform/daemon/src/daemon.c
  2. +9 −3 port/libusb-intel/main.c
  3. +8 −4 port/windows-winusb-intel/main.c
@@ -1759,8 +1759,16 @@ static void daemon_sigint_handler(int param){

log_info(" <= SIGINT received, shutting down..\n");

hci_power_control( HCI_POWER_OFF);
hci_close();
int send_power_off = 1;
#ifdef HAVE_INTEL_USB
// power off and close only if hci was initialized before
send_power_off = intel_firmware_loaded;
#endif

if (send_power_off){
hci_power_control( HCI_POWER_OFF);
hci_close();
}

log_info("Good bye, see you.\n");

@@ -75,6 +75,7 @@ static bd_addr_t local_addr;
static int main_argc;
static const char ** main_argv;
static const hci_transport_t * transport;
static int intel_firmware_loaded;

int btstack_main(int argc, const char * argv[]);

@@ -109,9 +110,12 @@ static void sigint_handler(int param){
// reset anyway
btstack_stdin_reset();

// power down
hci_power_control(HCI_POWER_OFF);
hci_close();
// power off and close only if hci was initialized before
if (intel_firmware_loaded){
hci_power_control( HCI_POWER_OFF);
hci_close();
}

log_info("Good bye, see you.\n");
exit(0);
}
@@ -126,6 +130,8 @@ static void intel_firmware_done(int result){

printf("Done %x\n", result);

intel_firmware_loaded = 1;

// init HCI
hci_init(transport, NULL);

@@ -69,6 +69,7 @@ static btstack_packet_callback_registration_t hci_event_callback_registration;
static int main_argc;
static const char ** main_argv;
static const hci_transport_t * transport;
static int intel_firmware_loaded;

static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
if (packet_type != HCI_EVENT_PACKET) return;
@@ -88,10 +89,11 @@ static void sigint_handler(int param){
// reset anyway
btstack_stdin_reset();

// power down
hci_power_control(HCI_POWER_OFF);
hci_close();
log_info("Good bye, see you.\n");
// power off and close only if hci was initialized before
if (intel_firmware_loaded){
hci_power_control( HCI_POWER_OFF);
hci_close();
}
exit(0);
}

@@ -106,6 +108,8 @@ static void intel_firmware_done(int result){

printf("Done %x\n", result);

intel_firmware_loaded = 1;

// init HCI
hci_init(transport, NULL);

0 comments on commit 948e8bf

Please sign in to comment.
You can’t perform that action at this time.