]> rtime.felk.cvut.cz Git - tiny-bt.git/blob - testf/t2/slavetest.c
part of master l2cap functions was implemented. Master initiate connection. Next...
[tiny-bt.git] / testf / t2 / slavetest.c
1 /*
2 *  C Implementation: slavetest
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
13 #include <stdio.h>
14 #include <stdlib.h>
15 #include <math.h>
16 #include <string.h>
17 #include <errno.h>
18 #include <unistd.h>
19 #include <sys/poll.h>
20 #include <sys/ioctl.h>
21 #include "hcidriver.h"
22
23 cmd_state_request array_req[MAX_CMD_STATE_REQUEST];
24 int cmd_req_id;
25 int global_index;
26
27 int req_fcn_add(cmd_state_request *p_req){ //fcn add the request at the end of array or replace the oldest request
28         int i,sig=0,index=0;
29         cmd_state_request the_oldest=array_req[0];
30         
31         for(i=0;i<MAX_CMD_STATE_REQUEST;i++){
32                 if((array_req[i].actual_status)==0 || array_req[i].actual_status==3 ){
33                         array_req[i]=*p_req;
34                         sig=1;
35                         global_index=i;
36                         break;
37                 }
38                 if((array_req[i].id) < the_oldest.id){ //the smallest id (oldest request) will stay here
39                         the_oldest = array_req[i];
40                         index=i;
41                         
42                 }
43         }
44         if(!sig){
45                 //return -1;
46                 array_req[index]=*p_req;
47                 global_index=index;     
48         }
49         return 0;
50 }
51
52 void rutine_con_req(void *arg){
53
54
55 }
56
57
58
59
60 int main(void){
61
62         cmd_state_request new_req,*p_new_req=&new_req;
63         memset(array_req,0,(sizeof(cmd_state_request)*MAX_CMD_STATE_REQUEST));
64         cmd_req_id=0;
65         global_index=0;
66         
67         p_new_req->id=cmd_req_id++;
68         //p_new_req->req_opcode = ocf_ogf;
69         p_new_req->evt_code = EVT_CONN_REQUEST;
70         p_new_req->p_serv_rutine=&rutine_con_req;       
71         
72         
73
74         while(1){
75                 
76
77         }
78
79 return 0;
80 }