add hci_read_bd_addr, don't turn on BT in hci_init(), add temp hack to get socket data

This commit is contained in:
matthias.ringwald 2009-06-07 15:45:31 +00:00
parent e1d15a27d1
commit 68d92d036b
4 changed files with 22 additions and 7 deletions

View File

@ -15,6 +15,7 @@
#define OPCODE(ogf, ocf) (ocf | ogf << 10)
#define OGF_LINK_CONTROL 0x01
#define OGF_CONTROLLER_BASEBAND 0x03
#define OGF_INFORMATIONAL_PARAMETERS 0x04
hci_cmd_t hci_inquiry = {
OPCODE(OGF_LINK_CONTROL, 0x01), "311"
@ -54,6 +55,11 @@ hci_cmd_t hci_host_buffer_size = {
// Host_ACL_Data_Packet_Length:, Host_Synchronous_Data_Packet_Length:, Host_Total_Num_ACL_Data_Packets:, Host_Total_Num_Synchronous_Data_Packets:
};
hci_cmd_t hci_read_bd_addr = {
OPCODE(OGF_INFORMATIONAL_PARAMETERS, 0x09), ""
// no params
};
// the stack is here
static hci_stack_t hci_stack;
@ -214,9 +220,6 @@ void hci_init(hci_transport_t *transport, void *config, bt_control_t *control){
// register packet handlers with transport
transport->register_event_packet_handler( event_handler);
transport->register_acl_packet_handler( acl_handler);
// turn on
hci_power_control(HCI_POWER_ON);
}
int hci_power_control(HCI_POWER_MODE power_mode){
@ -241,6 +244,10 @@ int hci_power_control(HCI_POWER_MODE power_mode){
// power off
hci_stack.control->off(hci_stack.config);
}
// trigger next/first action
hci_run();
return 0;
}

View File

@ -174,6 +174,7 @@ int hci_send_acl_packet(uint8_t *packet, int size);
// helper
extern void bt_store_16(uint8_t *buffer, uint16_t pos, uint16_t value);
extern void bt_store_32(uint8_t *buffer, uint16_t pos, uint32_t value);
extern void bt_flip_addr(bd_addr_t dest, bd_addr_t src);
extern hci_cmd_t hci_inquiry;
extern hci_cmd_t hci_link_key_request_negative_reply;
@ -183,4 +184,5 @@ extern hci_cmd_t hci_create_connection;
extern hci_cmd_t hci_host_buffer_size;
extern hci_cmd_t hci_write_authentication_enable;
extern hci_cmd_t hci_write_page_timeout;
extern hci_cmd_t hci_read_bd_addr;

View File

@ -155,8 +155,8 @@ int main (int argc, const char * argv[]) {
// init L2CAP
l2cap_init();
// trigger first hci action
hci_run();
// turn on
hci_power_control(HCI_POWER_ON);
// create server
data_source_t *socket_server = socket_server_create_tcp(1919);

View File

@ -16,4 +16,10 @@ data_source_t * socket_server_create_tcp(int port);
/**
* create socket data_source for unix domain socket
*/
data_source_t * socket_server_create_unix(char *path);
data_source_t * socket_server_create_unix(char *path);
/**
* register data available callback
* @todo: hack callback to allow data reception - replace with better architecture
*/
void socket_server_register_process_callback( int (*process_callback)(struct data_source *ds, int ready) );