]> rtime.felk.cvut.cz Git - tiny-bt.git/blob - src2/hil2cap.h
new version
[tiny-bt.git] / src2 / hil2cap.h
1 //
2 // C++ Interface: hil2cap
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 #ifndef __HIL2CAP
13 #define __HIL2CAP
14
15 #include"hcidriver.h"
16 #include<asm/types.h>
17 #include<sys/socket.h>
18 #include<errno.h>
19
20
21 typedef enum{
22         DISCONNECT = 0,
23         CONNECT= 1
24 }connection_state;
25
26 typedef enum{
27         FREE = 0,
28         ESTABLISHED = 1,
29         PERMANENT = 2,
30         DONE = 3
31 }req_state;
32
33 typedef enum{
34         LINUX = 0,
35         UART = 1
36 }hw_connection_type;
37
38 #define MAX_CMD_STATE_REQUEST 0x0F
39 #define MAX_EVT_COUNT   128
40
41 typedef struct{
42         __u8 actual_status;
43         __u8 id;
44         __u16 req_opcode;
45         __u8 evt_code;//codes of expected ansver event,command status event will be accepted everytime
46         void (*p_serv_rutine)(void); 
47
48 } __attribute__((packed)) cmd_state_request;
49
50 typedef struct{
51         __u8 actual_status;
52         __u16 id;
53         __u8 evt_type;
54         __u16 req_opcode;
55         int (*p_callback)(void *p_arg, void *p_recbuf);
56         void *p_data;
57 } __attribute__((packed)) expect_evt;
58
59 typedef struct{
60         __u16 con_id;
61         __u8 con_state;
62         struct hci_dev_info master;
63         struct hci_dev_info slave;
64         uint16_t handle;
65         int socket_fd;
66 }connection_hci;
67
68 typedef struct{
69         hw_connection_type type;
70         __u16 dev_identif; // like a device descriptor
71         hci_dev_info dev;
72 }bt_device;
73
74
75 typedef struct{
76         bt_address *p_address;
77         void (*callback_app_read_bd_addr)(bt_address *p_address);
78 }read_bd_addr_data;
79
80 typedef struct{
81         char    *p_name;
82         void (*callback_app_read_local_name)(char *p_name);
83 }read_local_name_data;
84
85 typedef struct{
86         bt_address *p_address;
87         void (*callback_app_inquiry_RSSI)(bt_address *p_address);
88 }inquiry_RSSI_data;
89
90 typedef struct{
91         __u16   *p_handle;
92         //bt_address    *p_address; // address of device whoo iniciated this connection
93         void (*callback_app_connection_complete)(__u16 *p_handle, bt_address *p_address);
94 }connection_complete_data;
95
96
97 extern int create_master_connection(connection_hci *p_connection);
98 extern int show_all_local_dev(struct hci_dev_info *master);
99 extern int show_all_remote_dev(struct hci_dev_info *master, bt_address *p_remadrar,int *p_remd_count);
100
101 extern int l2cap_call_cmd(__u16 ocf_ogf,int dd, void *p_param);
102
103 extern int req_fcn_add(cmd_state_request *p_req);
104 extern void req_fcn_remove(void);
105
106 extern void *rutine_catch_bd_addr(void *arg);
107
108
109
110
111 #endif