bt_address remote_bd_addr_array[HCI_MAX_DEV];
memset(remote_bd_addr_array,0,(sizeof(bt_address)*HCI_MAX_DEV));
connection_hci connection,*p_connection=&connection;
+ bt_address prefered;
int remd_count,i;
cmd_req_id=0;
global_index=0;
printba(&remote_bd_addr_array[i]);
}
p_connection->master=master;
- p_connection->slave.bdaddr=remote_bd_addr_array[0];
-
+ //p_connection->slave.bdaddr=remote_bd_addr_array[0];
+ fill_add(&prefered,0xE1,0x03,0x24,0x63,0x89,0x22);
+ p_connection->slave.bdaddr=prefered;
if(create_master_connection(p_connection)<0){
printf("connection error");
return -1;
#include <sys/ioctl.h>
#include "hcidriver.h"
-cmd_state_request array_req[MAX_CMD_STATE_REQUEST];
-int cmd_req_id;
+incoming_evt evt_array[MAX_CMD_STATE_REQUEST];
+int evt_id;
int global_index;
-int req_fcn_add(cmd_state_request *p_req){ //fcn add the request at the end of array or replace the oldest request
+int add_evt_toarray(incoming_evt *p_evt){ //fcn add the request at the end of array or replace the oldest request
int i,sig=0,index=0;
- cmd_state_request the_oldest=array_req[0];
+ incoming_evt the_oldest=evt_array[0];
- for(i=0;i<MAX_CMD_STATE_REQUEST;i++){
- if((array_req[i].actual_status)==0 || array_req[i].actual_status==3 ){
- array_req[i]=*p_req;
+ for(i=0;i<MAX_EVT_COUNT;i++){
+ if((evt_array[i].actual_status)==0 || evt_array[i].actual_status==3 ){
+ evt_array[i]=*p_evt;
sig=1;
global_index=i;
break;
}
- if((array_req[i].id) < the_oldest.id){ //the smallest id (oldest request) will stay here
- the_oldest = array_req[i];
+ if((evt_array[i].id) < the_oldest.id){ //the smallest id (oldest request) will stay here
+ the_oldest = evt_array[i];
index=i;
}
}
if(!sig){
//return -1;
- array_req[index]=*p_req;
+ evt_array[index]=*p_req;
global_index=index;
}
return 0;
}
+void rutine_cmd_status(void *arg){
+
+
+}
+
+int check_socket(int *p_dd){
+
+
+return 0;
+}
+
int main(void){
- cmd_state_request new_req,*p_new_req=&new_req;
- memset(array_req,0,(sizeof(cmd_state_request)*MAX_CMD_STATE_REQUEST));
- cmd_req_id=0;
+ incoming_evt new_evt,*p_new_evt=&new_evt;
+ struct hci_filter nf, of;
+ int len;
+ memset(evt_array,0,(sizeof(incoming_evt)*MAX_EVT_COUNT));
+ evt_id=0;
global_index=0;
- p_new_req->id=cmd_req_id++;
- //p_new_req->req_opcode = ocf_ogf;
- p_new_req->evt_code = EVT_CONN_REQUEST;
- p_new_req->p_serv_rutine=&rutine_con_req;
+ p_new_evt->id=evt_id++;
+ p_new_evt->actual_status=PERMANENT;
+ p_new_req->evt_code = EVT_CMD_STATUS;
+ p_new_req->p_serv_rutine=&rutine_cmd_status;
+ int dd=hci_open_device(1); // only for testig 1
+ add_evt_toarray(p_new_evt);
+ p_new_evt->id=evt_id++;
+ p_new_evt->actual_status=ESTABLISHED;
+ p_new_req->evt_code = EVT_CONN_REQUEST;
+ p_new_req->p_serv_rutine=&rutine_con_req;
+
+ len = sizeof(of);
+ if(getsockopt(dd, SOL_HCI, HCI_FILTER, &of, &len)<0){
+ printf("some problem with getsockopt: %d",dd);
+ return -1;
+ }
+ hci_filter_clear(&nf);
+ hci_filter_set_ptype(HCI_EVENT_PKT, &nf);
+ hci_filter_set_event(EVT_CMD_STATUS, &nf);
+ //hci_filter_set_event(EVT_INQUIRY_RESULT_WITH_RSSI, &nf);
+ //hci_filter_set_event(p_req->event, &nf);
+ //hci_filter_set_opcode(*(p_req->p_OCF_OGF), &nf);
+
+ if(setsockopt(dd, SOL_HCI, HCI_FILTER, &nf, sizeof(nf))<0){
+ printf("some problem with setsockopt: %d",dd);
+ return -1;
+ }
+
while(1){
+ if(check_socket(dd)<0){
+ printf("problem with sock checking \n");
+ break;
+ }
+
}
+ setsockopt(dd, SOL_HCI, HCI_FILTER, &of, sizeof(of));
+ hci_close_dev(dd);
return 0;
}