2 * C Implementation: testovaci
7 * Author: root <root@ubuntu>, (C) 2008
9 * Copyright: See COPYING file that comes with this distribution
14 #include <sys/ioctl.h>
18 #include "hcidriver.h"
29 //inicialization process, obtain adress and name from local controller
30 struct hci_dev_info device,*p_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);
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;
49 memset(array_req,0,(sizeof(cmd_state_request)*MAX_CMD_STATE_REQUEST));
51 if(!p_connection->con_state){ //there is no connection, create it
63 //void call_hci_send_data(unsigned short con_handle, __u8 pb_flag, __u8 b_flag, unsigned short data_lenght)
65 //void call_hci_create_connection(bt_address *dev_adress,unsigned short pkt_type,__u8 sc_mod){//
70 /*void show_all_local_dev(connection_hci *connection, struct hci_dev_info *p_device){
75 bt_device_req_list dlist,*p_dlist;
76 bt_device_req *p_dreq;
79 p_dlist->dev_num=HCI_MAX_DEV;
80 p_dreq=p_dlist->dev_req;
82 if((sock=socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI))<0){
87 if((ioctl(sock, HCIGETDEVLIST, (void *) p_dlist))<0){
88 perror("Can't get device list");
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){
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");
104 printba(&dev_array[i].bdaddr);
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;
113 printf("There is no BT host controler device connected!! \n");