]> rtime.felk.cvut.cz Git - tiny-bt.git/blob - src/hil2cap.c
87885b5a3736f7ec0d82fb79007cbe395b9fdf29
[tiny-bt.git] / src / hil2cap.c
1 /*
2 *  C Implementation: testovaci
3 *
4 * Description: 
5 *
6 *
7 * Author: root <root@ubuntu>, (C) 2008
8 *
9 * Copyright: See COPYING file that comes with this distribution
10 *
11 */
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <sys/ioctl.h>
15 #include <errno.h>
16 #include <stdint.h>
17 #include "hil2cap.h"
18 #include "hcidriver.h"
19
20
21
22 extern int errno;
23
24 int main(void)
25 {       dev_lap lap;
26         lap.byte[0]=0x00;
27         lap.byte[1]=0x55;
28         lap.byte[2]=0x12;
29         //inicialization process, obtain adress and name from local controller
30         struct hci_dev_info device,*p_device;
31         p_device=&device;
32         connection_hci connection,*p_connection;
33         p_connection=&connection;
34         p_connection->con_state=DISCONNECTED;
35         //show_all_local_dev(p_connection,p_device);
36         
37         
38 return 0;
39 }
40
41
42
43 int create_master_connection(void){//establish connection and send a coutn of bytes every x second
44         cmd_state_request array_req[MAX_CMD_STATE_REQUEST]; //array of open request which are in waiting state for appropriate event or answer
45         connection_hci connection,*p_connection=&connection;
46         p_connection->con_id=0;
47         p_connection->con_state=DISCONNECTED;
48         
49         memset(array_req,0,(sizeof(cmd_state_request)*MAX_CMD_STATE_REQUEST));
50         while(1){
51                 if(!p_connection->con_state){ //there is no connection, create it
52                         
53                 }
54
55
56
57         }
58         
59
60 }
61
62
63 //void call_hci_send_data(unsigned short con_handle, __u8 pb_flag, __u8 b_flag, unsigned short data_lenght)
64
65 //void call_hci_create_connection(bt_address *dev_adress,unsigned short pkt_type,__u8 sc_mod){//
66
67 //}
68
69 //Socket functions
70 /*void show_all_local_dev(connection_hci *connection, struct hci_dev_info *p_device){
71         int errr=0;
72         int sock,i;
73         int timeout=1000;
74         
75         bt_device_req_list dlist,*p_dlist;
76         bt_device_req *p_dreq;
77
78         p_dlist=&dlist;
79         p_dlist->dev_num=HCI_MAX_DEV;
80         p_dreq=p_dlist->dev_req;
81         
82         if((sock=socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI))<0){ 
83                 perror("socket");
84                 errr=1;
85         }
86         
87         if((ioctl(sock, HCIGETDEVLIST, (void *) p_dlist))<0){
88                 perror("Can't get device list");
89                 errr=2;
90         }
91         if(p_dlist->dev_num >1 && errr == 0){
92                 bt_device dev_array[p_dlist->dev_num];
93                 for(i=0;i<p_dlist->dev_num;i++){
94                 dev_array[i].dev_id=(p_dreq+i)->dev_id;
95                 if(ioctl(sock, HCIGETDEVINFO, (void *) &dev_array[i])<0){
96                         printf("No info");
97                         continue;
98                 }
99                 int dd=hci_open_device(dev_array[i].dev_id);
100                 if(call_hci_read_bd_addr_cmd(dd,&dev_array[i].bdaddr, timeout)< 0){
101                         printf("Error in call hci bd addr cnd");
102                         exit(0);
103                 }
104                 printba(&dev_array[i].bdaddr);
105                 }
106         }
107         else{
108                 switch(errr){
109                         case 1: printf("Error: %d,%d",errr,errno);break;
110                         case 2: printf("Error: %d,%d",errr,errno);break;
111                         //case 3: printf("Error in call hci bd addr cnd");break;
112                 }
113                 printf("There is no BT host controler device connected!! \n");
114                 exit(0);
115         }
116                 
117 } */
118         
119         
120