xref: /btstack/src/hci.c (revision 475c8125ef8bd08f640a384990d9a8403144ebf4)
11f504dbdSmatthias.ringwald /*
21f504dbdSmatthias.ringwald  *  hci.c
31f504dbdSmatthias.ringwald  *
41f504dbdSmatthias.ringwald  *  Created by Matthias Ringwald on 4/29/09.
51f504dbdSmatthias.ringwald  *
61f504dbdSmatthias.ringwald  */
71f504dbdSmatthias.ringwald 
8*475c8125Smatthias.ringwald #include <unistd.h>
9*475c8125Smatthias.ringwald 
101f504dbdSmatthias.ringwald #include "hci.h"
111f504dbdSmatthias.ringwald 
12*475c8125Smatthias.ringwald static hci_transport_t *hci_transport;
13*475c8125Smatthias.ringwald 
14*475c8125Smatthias.ringwald void hci_init(hci_transport_t *transport, void *config){
15*475c8125Smatthias.ringwald 
16*475c8125Smatthias.ringwald     // reference to use transport layer implementation
17*475c8125Smatthias.ringwald     hci_transport = transport;
18*475c8125Smatthias.ringwald 
19*475c8125Smatthias.ringwald     // open unix socket
20*475c8125Smatthias.ringwald 
21*475c8125Smatthias.ringwald     // wait for connections
22*475c8125Smatthias.ringwald 
23*475c8125Smatthias.ringwald     // enter loop
24*475c8125Smatthias.ringwald 
25*475c8125Smatthias.ringwald     // handle events
26*475c8125Smatthias.ringwald }
27*475c8125Smatthias.ringwald 
28*475c8125Smatthias.ringwald int hci_power_control(HCI_POWER_MODE power_mode){
29*475c8125Smatthias.ringwald     return 0;
30*475c8125Smatthias.ringwald }
31*475c8125Smatthias.ringwald 
32*475c8125Smatthias.ringwald int hci_send_cmd(char *buffer, int size){
33*475c8125Smatthias.ringwald     return hci_transport->send_cmd_packet(buffer, size);
34*475c8125Smatthias.ringwald }
35*475c8125Smatthias.ringwald 
36*475c8125Smatthias.ringwald void hci_run(){
37*475c8125Smatthias.ringwald     while (1) {
38*475c8125Smatthias.ringwald         //  construct file descriptor set to wait for
39*475c8125Smatthias.ringwald         //  select
40*475c8125Smatthias.ringwald 
41*475c8125Smatthias.ringwald         // for each ready file in FD - call handle_data
42*475c8125Smatthias.ringwald         sleep(1);
43*475c8125Smatthias.ringwald     }
441f504dbdSmatthias.ringwald }