From df9e278041f9d9cf7b91ea2e47525a28ac324d3f Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Wed, 17 Nov 2021 11:37:52 +0100 Subject: [PATCH] hci: run substate machines, esp. halting, before other commands to assert reliable power down --- src/hci.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/src/hci.c b/src/hci.c index 0ba704ded..0fff78ff6 100644 --- a/src/hci.c +++ b/src/hci.c @@ -5084,6 +5084,22 @@ static bool hci_run_general_pending_commands(void){ static void hci_run(void){ + // stack state sub statemachines + hci_connection_t *connection; + switch (hci_stack->state) { + case HCI_STATE_INITIALIZING: + hci_initializing_run(); + break; + case HCI_STATE_HALTING: + hci_halting_run(); + break; + case HCI_STATE_FALLING_ASLEEP: + hci_falling_asleep_run(); + break; + default: + break; + } + bool done; // send continuation fragments first, as they block the prepared packet buffer @@ -5117,24 +5133,7 @@ static void hci_run(void){ #endif // send pending HCI commands - done = hci_run_general_pending_commands(); - if (done) return; - - // stack state sub statemachines - hci_connection_t * connection; - switch (hci_stack->state){ - case HCI_STATE_INITIALIZING: - hci_initializing_run(); - break; - case HCI_STATE_HALTING: - hci_halting_run(); - break; - case HCI_STATE_FALLING_ASLEEP: - hci_falling_asleep_run(); - break; - default: - break; - } + hci_run_general_pending_commands(); } uint8_t hci_send_cmd_packet(uint8_t *packet, int size){