send custom init code if nececessary

This commit is contained in:
matthias.ringwald 2010-08-05 20:13:02 +00:00
parent 77c915711e
commit 9091920332
2 changed files with 19 additions and 7 deletions

View File

@ -51,6 +51,6 @@ typedef struct {
/** support custom init sequences after RESET command
* @return pointer do next command packet used during init
*/
uint8_t (*next_command)(void *config);
uint8_t * (*next_command)(void *config);
} bt_control_t;

View File

@ -520,24 +520,36 @@ void hci_run(){
// cannot send command yet
return;
}
switch (hci_stack.substate/2){
switch (hci_stack.substate >> 1){
case 0:
hci_send_cmd(&hci_reset);
break;
case 1:
case 1:
// custom initialization
if (hci_stack.control && hci_stack.control->next_command){
uint8_t * cmd = (*hci_stack.control->next_command)(hci_stack.config);
if (cmd) {
int size = 3 + cmd[2];
hci_stack.hci_transport->send_cmd_packet(cmd, size);
break;
}
}
// @NOTE fall through, if no command to send anymore
hci_stack.substate += 2;
case 2:
hci_send_cmd(&hci_read_bd_addr);
break;
case 2:
case 3:
hci_send_cmd(&hci_read_buffer_size);
break;
case 3:
case 4:
// ca. 15 sec
hci_send_cmd(&hci_write_page_timeout, 0x6000);
break;
case 4:
case 5:
hci_send_cmd(&hci_write_scan_enable, 3); // 3 inq scan + page scan
break;
case 5:
case 6:
// done.
hci_stack.state = HCI_STATE_WORKING;
hci_emit_state();