]> rtime.felk.cvut.cz Git - tiny-bt.git/blob - src2/tiny_bt_hci_core.h
Better coding style and evt_array is setted on zeros in init function
[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 <asm/types.h>
16 #include <sys/socket.h>
17 #include <errno.h>
18 #include "tiny_bt_hci_cmd.h"
19
20 #define MAX_CMD_STATE_REQUEST 0x0F
21 #define MAX_EVT_COUNT   128
22
23 typedef enum{
24         DISCONNECT = 0,
25         CONNECT= 1
26 } connection_state;
27
28 typedef enum{
29         FREE = 0,
30         ESTABLISHED = 1,
31         PERMANENT = 2,
32         DONE = 3
33 } req_state;
34
35 typedef struct{
36         __u8 actual_status;
37         __u8 id;
38         __u16 req_opcode;
39         __u8 evt_code; /*codes of expected ansver event,command status event will be accepted everytime*/
40         void (*p_serv_rutine)(void); 
41 } __attribute__((packed)) cmd_state_request;
42
43 typedef struct{
44         __u8 actual_status;
45         __u16 id;
46         __u8 evt_type;
47         __u16 req_opcode;
48         void (*p_callback)(void *p_arg, void *p_recbuf);
49         void *p_data;
50 } __attribute__((packed)) expect_evt;
51
52 typedef struct{
53         __u16 con_id;
54         __u8 con_state;
55         struct hci_dev_info master;
56         struct hci_dev_info slave;
57         uint16_t handle;
58         int socket_fd;
59 } connection_hci;
60
61 typedef struct{
62         bt_address *p_address;
63         void (*callback_app_read_bd_addr)(bt_address *p_address);
64 } read_bd_addr_data;
65
66 typedef struct{
67         char    *p_name;
68         void (*callback_app_read_local_name)(char *p_name);
69 } read_local_name_data;
70
71 typedef struct{
72         bt_address *p_address;
73         void (*callback_app_inquiry_RSSI)(bt_address *p_address);
74 } inquiry_RSSI_data;
75
76 typedef struct{
77         void (*callback_app_inquiry_complete)(void);
78 } inquiry_complete_data;
79
80 typedef struct{
81         bt_address *p_address;
82         void (*callback_app_connection_request)(bt_address *p_address);
83 } connection_request_data;
84
85 typedef struct{
86         __u16   *p_handle;
87         //bt_address    *p_address; // address of device whoo iniciated this connection
88         void (*callback_app_connection_complete)(__u16 *p_handle);
89 } connection_complete_data;
90
91 typedef struct{
92         __u16 *p_handle;
93         __u8 *p_reason;
94         void (*callback_app_disconnect)(__u16 *p_handle, __u8 *p_reason);
95 } disconnect_data;
96
97 extern void add_evt_toarray(expect_evt *p_evt);
98 extern int look_up_inarray(__u8 evt_type, __u16 opcode);
99 extern int tiny_bt_init(__u8 dev_id);
100 extern int tiny_bt_process();
101 extern int tiny_bt_read_bd_addr(bt_address *p_dest, void(*callback_app_read_bd_addr)(bt_address *p_address));
102 extern int tiny_bt_read_local_name(char *p_name, void(*callback_app_read_local_name)(char *p_name));
103 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));
104 extern void tiny_bt_inquiry_register_again(bt_address *p_dest_addr, void(*callback_app_inquiry_RSSI)(bt_address *p_address));
105 extern int tiny_bt_connect(bt_address *p_dest_addr, __u16 *p_handle, void( *callback_app_connection_complete)(__u16 *p_handle));
106 extern void tiny_bt_wait_for_connection(bt_address *p_dest_addr, void(*callback_app_conection_request)(bt_address *p_address));
107 extern int tiny_bt_accept_connection(bt_address *p_dest_addr,__u16 *p_handle, void(*callback_app_connection_complete)(__u16 *p_handle));
108 extern void tiny_bt_disconnect_register(void(*callback_app_disconnect)(__u16 *p_handle, __u8 *p_reason));
109 extern int tiny_bt_disconnect(__u16 *p_handle, void(*callback_app_disconnect)(__u16 *p_handle, __u8 *p_reason));
110 extern int tiny_bt_send_data(char *p_data, __u16 lenght, __u16 *p_chandle);
111
112 #endif