#include <string.h>
#include <errno.h>
#include <unistd.h>
+#include <stdint.h>
+#include <fcntl.h>
#include <sys/poll.h>
#include <sys/ioctl.h>
#include "hcidriver.h"
+
/************************** hci command functions**************************/
int call_hci_inquiry_cmd(int dd, void *p_addressarray,__u16 *p_ocf_ogf){
inquiry_cp cmdp,*p_cmdp=&cmdp;
}
+int call_hci_accept_conn_req_cmd(int dd, bt_address *p_address, __u16 *p_ocf_ogf){
+ accept_conn_req_cp cmdp, *p_cmdp=&cmdp;
+ hci_request req,*p_req=&req;
+
+ p_cmdp->bdaddr=*p_address;
+ p_cmdp->role=0x01;
+ memset(p_req,0,sizeof(req));
+ p_req->p_OCF_OGF=p_ocf_ogf;
+ p_req->p_cmdp=p_cmdp;
+ p_req->cmdp_len=ACCEPT_CONN_REQ_CP_SIZE;
+
+ if(hci_send_command(dd,p_req)<0){
+ printf("problem with command sending\n");
+ return -1;
+ }
+ return 0;
+}
+
/*******************************HCI main functions ********************************/
return dd;
}
+int hci_open_device_nonblock(int dev_id){
+ struct sockaddr_hci address;
+ int dd;
+ int oldflag;
+
+ if((dd=socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI))<0){
+ perror("socket no created");
+ return dd; //it return -1 when socket isn't created
+ }
+
+ oldflag=fcntl(dd, F_GETFL, 0);
+ if(fcntl(dd, F_SETFL, oldflag | O_NONBLOCK) < 0){
+ printf("problem with socket flag setting");
+ return -1;
+ }
+
+ memset(&address,0,sizeof(address));
+ address.hci_family=AF_BLUETOOTH;
+ address.hci_dev=dev_id;
+ if(bind(dd,(struct sockaddr *) &address, sizeof(address))<0){
+ perror("Socket not binded to hci device");
+ close(dd);
+ return -1;
+ }
+
+ return dd;
+}
+
int hci_close_dev(int dd){
return close(dd);
}