]> rtime.felk.cvut.cz Git - tiny-bt.git/blobdiff - testf/t2/slavetest.c
Removed files not present and bachelor thesis CD
[tiny-bt.git] / testf / t2 / slavetest.c
diff --git a/testf/t2/slavetest.c b/testf/t2/slavetest.c
deleted file mode 100644 (file)
index 612d501..0000000
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
-*  C Implementation: slavetest
-*
-* Description: 
-*
-*
-* Author: root <root@ubuntu>, (C) 2008
-*
-* Copyright: See COPYING file that comes with this distribution
-*
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-#include <sys/poll.h>
-#include <sys/ioctl.h>
-#include "hcidriver.h"
-#include "hil2cap.h"
-
-incoming_evt evt_array[MAX_CMD_STATE_REQUEST];
-int evt_id;
-int global_index;
-struct hci_filter nnf, oof; // the oldest and newest filters
-
-
-int factorial(int num){
-       if(num==1) return 1;
-       return num*factorial(num-1);
-}
-
-int hci_open_device(int dev_id){
-       struct sockaddr_hci address;
-       int dd;
-
-       if((dd=socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI))<0){
-               perror("socket no created");
-                return dd; //it return -1 when socket isn't created
-       }
-
-       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);
-}
-
-int add_evt_toarray(incoming_evt *p_evt,struct hci_filter *p_pf,int *p_fchanged){ //fcn add the request at the end of array or replace the oldest request
-       int i,sig=0,index=0;
-       incoming_evt the_oldest=evt_array[0];
-
-
-       if(!hci_filter_test_event(p_evt->evt_code,&nnf)){
-               *p_pf=nnf;
-               *p_fchanged=1; 
-               hci_filter_set_event(p_evt->evt_code,&nnf);
-       }
-       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((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;
-               evt_array[index]=*p_evt;
-               global_index=index;     
-       }
-       return 0;
-}
-
-
-void rutine_con_req(void){
-
-
-}
-
-void rutine_cmd_status(void){
-
-
-}
-
-int check_socket(int dd){
-       int len,j;
-       __u8 recbuf[HCI_MAX_EVENT_SIZE],*p_recbuf;
-       
-       while((len=read(dd, recbuf, sizeof(recbuf)))<0){
-                       if(errno == EAGAIN || errno == EINTR)
-                               printf("error in read EAGAIN or EINTR \n");
-                               continue;
-                       perror("Problem with cmd reading \n");
-                       return -1;
-               }
-       
-       if(len){
-               printf("Count of received bytes %d \n ",len);
-               for(j=0;j<len;j++){
-                       printf("%2.2X ",recbuf[j]);     
-               }
-               printf("\n");
-               
-       }
-       else{
-               printf("There is nothing on socket %d \n",dd);
-               return 0;
-       }
-
-return 0;
-}
-
-
-
-
-int main(void){
-
-       incoming_evt new_evt,*p_new_evt=&new_evt;
-       int fchanged=0;
-       socklen_t len;
-       struct hci_filter pf;
-       memset(evt_array,0,(sizeof(incoming_evt)*MAX_EVT_COUNT));
-       evt_id=0;
-       global_index=0;
-       
-       int dd=hci_open_device(0); // only for testig 1 
-       
-       len = sizeof(oof); //the oldest filter
-       if(getsockopt(dd, SOL_HCI, HCI_FILTER, &oof, &len)<0){
-               printf("some problem with getsockopt: %d",dd);
-               return -1;
-       }
-       hci_filter_clear(&nnf);
-       hci_filter_set_ptype(HCI_EVENT_PKT, &nnf);
-       //hci_filter_set_opcode(*(p_req->p_OCF_OGF), &nf);
-
-       p_new_evt->id=evt_id++;
-       p_new_evt->actual_status=PERMANENT;
-       p_new_evt->evt_code = EVT_CMD_STATUS;
-       p_new_evt->p_serv_rutine=&rutine_cmd_status;
-       add_evt_toarray(p_new_evt,&pf,&fchanged);
-               
-       p_new_evt->id=evt_id++;
-       p_new_evt->actual_status=ESTABLISHED;
-       p_new_evt->evt_code = EVT_CONN_REQUEST;
-       p_new_evt->p_serv_rutine=&rutine_con_req;
-       add_evt_toarray(p_new_evt,&pf,&fchanged);
-               
-       while(1){
-
-               if(fchanged){
-                       if(setsockopt(dd, SOL_HCI, HCI_FILTER, &nnf, sizeof(nnf))<0){
-                       printf("some problem with setsockopt: %d",dd);
-                       return -1;
-                       }
-                       fchanged=0;
-               }
-               if(check_socket(dd)<0){
-                       printf("problem with sock checking \n");
-                       setsockopt(dd, SOL_HCI, HCI_FILTER, &pf, sizeof(pf));
-                       break;
-               }
-               
-               printf("I doing something %d \n",factorial(100));
-                               
-
-       }
-       setsockopt(dd, SOL_HCI, HCI_FILTER, &oof, sizeof(oof));
-       hci_close_dev(dd);
-
-return 0;
-}