provide buffer to next_cmd - avoids extra buffer for embedded systems with init scripts

This commit is contained in:
matthias.ringwald 2011-07-28 22:05:38 +00:00
parent 223aafc1c7
commit d62aca9f5d
2 changed files with 15 additions and 13 deletions

View File

@ -48,20 +48,22 @@ typedef enum {
} POWER_NOTIFICATION_t;
typedef struct {
int (*on)(void *config); // <-- turn BT module on and configure
int (*off)(void *config); // <-- turn BT module off
int (*on) (void *config); // <-- turn BT module on and configure
int (*off) (void *config); // <-- turn BT module off
int (*sleep)(void *config); // <-- put BT module to sleep - only to be called after ON
int (*wake)(void *config); // <-- wake BT module from sleep - only to be called after SLEEP
int (*wake) (void *config); // <-- wake BT module from sleep - only to be called after SLEEP
int (*valid)(void *config); // <-- test if hardware can be supported
const char * (*name)(void *config); // <-- return hardware name
const char * (*name) (void *config); // <-- return hardware name
/** support for UART baud rate changes */
/** support for UART baud rate changes - cmd has to be stored in hci_cmd_buffer
* @return have command
*/
int (*baudrate_cmd)(void * config, uint32_t baudrate, uint8_t *hci_cmd_buffer);
/** support custom init sequences after RESET command
* @return pointer do next command packet used during init
/** support custom init sequences after RESET command - cmd has to be stored in hci_cmd_buffer
* @return have command
*/
uint8_t * (*next_command)(void *config);
int (*next_cmd)(void *config, uint8_t * hci_cmd_buffer);
void (*register_for_power_notifications)(void (*cb)(POWER_NOTIFICATION_t event));

View File

@ -956,14 +956,14 @@ void hci_run(){
case 3:
// 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_packet(HCI_COMMAND_DATA_PACKET, cmd, size);
int valid_cmd = (*hci_stack.control->next_command)(hci_stack.config, hci_stack.hci_cmd_buffer);
if (valid_cmd){
int size = 3 + hci_stack.hci_cmd_buffer[2];
hci_stack.hci_transport->send_packet(HCI_COMMAND_DATA_PACKET, hci_stack.hci_cmd_buffer, size);
hci_stack.substate = 4; // more init commands
break;
}
printf("hci_run: init script done\n\r");
log_info("hci_run: init script done\n\r");
}
// otherwise continue
hci_send_cmd(&hci_read_bd_addr);