mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-16 17:42:51 +00:00
extracted hci_power_transition_to_initializing, reset reserved hci when transition to initializing
This commit is contained in:
parent
a93597fce0
commit
44935e4085
29
src/hci.c
29
src/hci.c
@ -1025,6 +1025,9 @@ void hci_state_reset(){
|
|||||||
// hci_stack->connectable = 0;
|
// hci_stack->connectable = 0;
|
||||||
// hci_stack->bondable = 1;
|
// hci_stack->bondable = 1;
|
||||||
|
|
||||||
|
// buffer is free
|
||||||
|
hci_stack->hci_packet_buffer_reserved = 0;
|
||||||
|
|
||||||
// no pending cmds
|
// no pending cmds
|
||||||
hci_stack->decline_reason = 0;
|
hci_stack->decline_reason = 0;
|
||||||
hci_stack->new_scan_enable_value = 0xff;
|
hci_stack->new_scan_enable_value = 0xff;
|
||||||
@ -1211,6 +1214,13 @@ static int hci_power_control_wake(void){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void hci_power_transition_to_initializing(void){
|
||||||
|
// set up state machine
|
||||||
|
hci_stack->num_cmd_packets = 1; // assume that one cmd can be sent
|
||||||
|
hci_stack->hci_packet_buffer_reserved = 0;
|
||||||
|
hci_stack->state = HCI_STATE_INITIALIZING;
|
||||||
|
hci_stack->substate = 0;
|
||||||
|
}
|
||||||
|
|
||||||
int hci_power_control(HCI_POWER_MODE power_mode){
|
int hci_power_control(HCI_POWER_MODE power_mode){
|
||||||
|
|
||||||
@ -1227,10 +1237,7 @@ int hci_power_control(HCI_POWER_MODE power_mode){
|
|||||||
log_error("hci_power_control_on() error %u", err);
|
log_error("hci_power_control_on() error %u", err);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
// set up state machine
|
hci_power_transition_to_initializing();
|
||||||
hci_stack->num_cmd_packets = 1; // assume that one cmd can be sent
|
|
||||||
hci_stack->state = HCI_STATE_INITIALIZING;
|
|
||||||
hci_stack->substate = 0;
|
|
||||||
break;
|
break;
|
||||||
case HCI_POWER_OFF:
|
case HCI_POWER_OFF:
|
||||||
// do nothing
|
// do nothing
|
||||||
@ -1277,9 +1284,7 @@ int hci_power_control(HCI_POWER_MODE power_mode){
|
|||||||
case HCI_STATE_HALTING:
|
case HCI_STATE_HALTING:
|
||||||
switch (power_mode){
|
switch (power_mode){
|
||||||
case HCI_POWER_ON:
|
case HCI_POWER_ON:
|
||||||
// set up state machine
|
hci_power_transition_to_initializing();
|
||||||
hci_stack->state = HCI_STATE_INITIALIZING;
|
|
||||||
hci_stack->substate = 0;
|
|
||||||
break;
|
break;
|
||||||
case HCI_POWER_OFF:
|
case HCI_POWER_OFF:
|
||||||
// do nothing
|
// do nothing
|
||||||
@ -1304,10 +1309,7 @@ int hci_power_control(HCI_POWER_MODE power_mode){
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
// set up state machine
|
hci_power_transition_to_initializing();
|
||||||
hci_stack->num_cmd_packets = 1; // assume that one cmd can be sent
|
|
||||||
hci_stack->state = HCI_STATE_INITIALIZING;
|
|
||||||
hci_stack->substate = 0;
|
|
||||||
break;
|
break;
|
||||||
case HCI_POWER_OFF:
|
case HCI_POWER_OFF:
|
||||||
// see hci_run
|
// see hci_run
|
||||||
@ -1334,10 +1336,7 @@ int hci_power_control(HCI_POWER_MODE power_mode){
|
|||||||
#endif
|
#endif
|
||||||
err = hci_power_control_wake();
|
err = hci_power_control_wake();
|
||||||
if (err) return err;
|
if (err) return err;
|
||||||
// set up state machine
|
hci_power_transition_to_initializing();
|
||||||
hci_stack->num_cmd_packets = 1; // assume that one cmd can be sent
|
|
||||||
hci_stack->state = HCI_STATE_INITIALIZING;
|
|
||||||
hci_stack->substate = 0;
|
|
||||||
break;
|
break;
|
||||||
case HCI_POWER_OFF:
|
case HCI_POWER_OFF:
|
||||||
hci_stack->state = HCI_STATE_HALTING;
|
hci_stack->state = HCI_STATE_HALTING;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user