2 // C++ Interface: hcidriver
4 // Description: my idea , embeded system will be in waiting state. For this role it will be slave. Master it is a main computer or phone.
7 // Author: root <root@ubuntu>, (C) 2008
9 // Copyright: See COPYING file that comes with this distribution
12 #ifndef __TINI_BT_HCI_CMD
13 #define __TINI_BT_HCI_CMD
17 #include "hciembeded.h"
23 #define INQUIRY_CMD_OP 0x0104
24 #define INQUIRY_CANCEL_CMD_OP 0x0204
25 #define CREATE_CONNECTION_CMD_OP 0x0504
26 #define ACCEPT_CONNECTION_REQ_OP 0x0904
27 #define DISCONNECT_CMD_OP 0x0604
28 #define REMOTE_NAME_REQUEST_CMD_OP 0x1904
29 #define RESET_CMD_OP 0x030C
30 #define WRITE_LOCAL_NAME_CMD_OP 0x130C
31 #define READ_LOCAL_NAME_CMD_OP 0x140C
32 #define READ_BD_ADDR_CMD_OP 0x0910
34 #define max(a, b) ((a) > (b) ? (a) : (b))
35 #define min(a, b) ((a) < (b) ? (a) : (b))
53 /* BD_ADDR (bluetooth.h)*/
58 } __attribute__((packed)) dev_lap;
77 /* next function structures*/
80 extern int send_hci_inquiry_cmd(void);
81 extern int send_hci_read_bd_addr_cmd(void);
82 extern int send_hci_read_local_name_cmd(void);
83 extern int send_hci_create_connection_cmd(bt_address *p_dest_addr);
84 extern int send_hci_accept_conn_req_cmd(bt_address *p_address);
86 extern int send_cmd(hci_cmd_request *p_creq);
88 extern void assemble_ocf_ogf(__u8 ogf,__u8 ocf,__u16 *p_ocf_ogf);
89 extern void printba(bt_address *ba);
90 extern int compare_bda(bt_address *p_first, bt_address *p_second);
91 extern void fill_zero(bt_address *p_addr);
92 extern void swap_addrbytes(bt_address *p_addr);
93 extern __u16 swap_2_bytes(__u16 twobytes);
94 extern __u8 swap8(__u8 byte1);
95 extern __u16 swap16(__u16 byte2);
96 extern __u16 swap_2_bytes(__u16 twobytes);
97 extern void fill_add(bt_address *addr,__u8 first, __u8 sec, __u8 third, __u8 forth, __u8 fifth, __u8 sixth);
99 static inline void hci_set_bit(int nr, void *addr)
101 *((uint32_t *) addr + (nr >> 5)) |= (1 << (nr & 31));
104 static inline void hci_clear_bit(int nr, void *addr)
106 *((uint32_t *) addr + (nr >> 5)) &= ~(1 << (nr & 31));
109 static inline int hci_test_bit(int nr, void *addr)
111 return *((uint32_t *) addr + (nr >> 5)) & (1 << (nr & 31));
114 /* HCI filter tools */
115 static inline void hci_filter_clear(struct hci_filter *f)
117 memset(f, 0, sizeof(*f));
119 static inline void hci_filter_set_ptype(int t, struct hci_filter *f)
121 hci_set_bit((t == HCI_VENDOR_PKT) ? 0 : (t & HCI_FLT_TYPE_BITS), &f->type_mask);
123 static inline void hci_filter_clear_ptype(int t, struct hci_filter *f)
125 hci_clear_bit((t == HCI_VENDOR_PKT) ? 0 : (t & HCI_FLT_TYPE_BITS), &f->type_mask);
127 static inline int hci_filter_test_ptype(int t, struct hci_filter *f)
129 return hci_test_bit((t == HCI_VENDOR_PKT) ? 0 : (t & HCI_FLT_TYPE_BITS), &f->type_mask);
131 static inline void hci_filter_all_ptypes(struct hci_filter *f)
133 memset((void *) &f->type_mask, 0xff, sizeof(f->type_mask));
135 static inline void hci_filter_set_event(int e, struct hci_filter *f)
137 hci_set_bit((e & HCI_FLT_EVENT_BITS), &f->event_mask);
139 static inline void hci_filter_clear_event(int e, struct hci_filter *f)
141 hci_clear_bit((e & HCI_FLT_EVENT_BITS), &f->event_mask);
143 static inline int hci_filter_test_event(int e, struct hci_filter *f)
145 return hci_test_bit((e & HCI_FLT_EVENT_BITS), &f->event_mask);
147 static inline void hci_filter_all_events(struct hci_filter *f)
149 memset((void *) f->event_mask, 0xff, sizeof(f->event_mask));
151 static inline void hci_filter_set_opcode(int opcode, struct hci_filter *f)
155 static inline void hci_filter_clear_opcode(struct hci_filter *f)
159 static inline int hci_filter_test_opcode(int opcode, struct hci_filter *f)
161 return (f->opcode == opcode);
164 static inline int bacmp(const bt_address *ba1, const bt_address *ba2)
166 return memcmp(ba1, ba2, sizeof(bt_address));
168 static inline void bacpy(bt_address *dst, const bt_address *src)
170 memcpy(dst, src, sizeof(bt_address));
174 #endif /* __HCIDRIVER */