]> rtime.felk.cvut.cz Git - tiny-bt.git/blob - src2/tiny_bt_hci_core.h
7203fff09a18200fe9b10997f3986f1b9e4fff1e
[tiny-bt.git] / src2 / tiny_bt_hci_core.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 __TINI_BT_HCI_CORE
13 #define __TINI_BT_HCI_CORE
14
15 #include"tiny_bt_hci_cmd.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 #define MAX_CMD_STATE_REQUEST 0x0F
34 #define MAX_EVT_COUNT   128
35
36 typedef struct{
37         __u8 actual_status;
38         __u8 id;
39         __u16 req_opcode;
40         __u8 evt_code;//codes of expected ansver event,command status event will be accepted everytime
41         void (*p_serv_rutine)(void); 
42
43 } __attribute__((packed)) cmd_state_request;
44
45 typedef struct{
46         __u8 actual_status;
47         __u16 id;
48         __u8 evt_type;
49         __u16 req_opcode;
50         void (*p_callback)(void *p_arg, void *p_recbuf);
51         void *p_data;
52 } __attribute__((packed)) expect_evt;
53
54 typedef struct{
55         __u16 con_id;
56         __u8 con_state;
57         struct hci_dev_info master;
58         struct hci_dev_info slave;
59         uint16_t handle;
60         int socket_fd;
61 }connection_hci;
62
63
64 typedef struct{
65         bt_address *p_address;
66         void (*callback_app_read_bd_addr)(bt_address *p_address);
67 }read_bd_addr_data;
68
69 typedef struct{
70         char    *p_name;
71         void (*callback_app_read_local_name)(char *p_name);
72 }read_local_name_data;
73
74 typedef struct{
75         bt_address *p_address;
76         void (*callback_app_inquiry_RSSI)(bt_address *p_address);
77 }inquiry_RSSI_data;
78
79 typedef struct{
80         void (*callback_app_inquiry_complete)(void);
81 }inquiry_complete_data;
82
83 typedef struct{
84         __u16   *p_handle;
85         //bt_address    *p_address; // address of device whoo iniciated this connection
86         void (*callback_app_connection_complete)(__u16 *p_handle);
87 }connection_complete_data;
88
89 extern void add_evt_toarray(expect_evt *p_evt);
90 extern int look_up_inarray(__u8 evt_type, __u16 opcode);
91 extern int tiny_bt_init(__u8 dev_id);
92 extern int tiny_bt_process();
93 extern int tiny_bt_read_bd_addr(bt_address *p_dest, void(*callback_app_read_bd_addr)(bt_address *p_address));
94 extern int tiny_bt_read_local_name(char *p_name, void(*callback_app_read_local_name)(char *p_name));
95 extern int tiny_bt_inquiry(bt_address *p_dest_addr, void(*callback_app_inquiry_RSSI)(bt_address *p_address), void(*callback_app_inquiry_complete)(void));
96 extern void tiny_bt_inquiry_register_again(bt_address *p_dest_addr, void(*callback_app_inquiry_RSSI)(bt_address *p_address));
97 extern int tiny_bt_connect(bt_address *p_dest_addr, __u16 *p_handle, void( *callback_app_connection_complete)(__u16 *p_handle));
98 extern int tiny_bt_wait_for_connection();
99
100 #endif