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
15 #include <asm/types.h>
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))
52 /* BD_ADDR (bluetooth.h)*/
56 } __attribute__((packed)) dev_lap;
78 /* 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);
85 extern int send_hci_disconnect_cmd(__u16 handle);
86 extern int send_hci_data(char *p_data, __u16 lenght, __u16 *p_chandle);
88 extern int send_cmd(hci_cmd_request *p_creq);
89 extern int send_data(hci_data_request *p_dreq);
91 extern void assemble_ocf_ogf(__u8 ogf,__u8 ocf,__u16 *p_ocf_ogf);
92 extern void printba(bt_address *ba);
93 extern int compare_bda(bt_address *p_first, bt_address *p_second);
94 extern void fill_zero(bt_address *p_addr);
95 extern void swap_addrbytes(bt_address *p_addr);
96 extern __u16 swap_2_bytes(__u16 twobytes);
97 extern __u8 swap8(__u8 byte1);
98 extern __u16 swap16(__u16 byte2);
99 extern __u16 swap_2_bytes(__u16 twobytes);
100 extern void fill_add(bt_address *addr,__u8 first,
101 __u8 sec, __u8 third, __u8 forth, __u8 fifth, __u8 sixth);
103 static inline void hci_set_bit(int nr, void *addr)
105 *((uint32_t *) addr + (nr >> 5)) |= (1 << (nr & 31));
108 static inline void hci_clear_bit(int nr, void *addr)
110 *((uint32_t *) addr + (nr >> 5)) &= ~(1 << (nr & 31));
113 static inline int hci_test_bit(int nr, void *addr)
115 return *((uint32_t *) addr + (nr >> 5)) & (1 << (nr & 31));
118 /* HCI filter tools */
119 static inline void hci_filter_clear(struct hci_filter *f)
121 memset(f, 0, sizeof(*f));
123 static inline void hci_filter_set_ptype(int t, struct hci_filter *f)
125 hci_set_bit((t == HCI_VENDOR_PKT) ? 0 : (t & HCI_FLT_TYPE_BITS), &f->type_mask);
127 static inline void hci_filter_clear_ptype(int t, struct hci_filter *f)
129 hci_clear_bit((t == HCI_VENDOR_PKT) ? 0 : (t & HCI_FLT_TYPE_BITS), &f->type_mask);
131 static inline int hci_filter_test_ptype(int t, struct hci_filter *f)
133 return hci_test_bit((t == HCI_VENDOR_PKT) ? 0 : (t & HCI_FLT_TYPE_BITS), &f->type_mask);
135 static inline void hci_filter_all_ptypes(struct hci_filter *f)
137 memset((void *) &f->type_mask, 0xff, sizeof(f->type_mask));
139 static inline void hci_filter_set_event(int e, struct hci_filter *f)
141 hci_set_bit((e & HCI_FLT_EVENT_BITS), &f->event_mask);
143 static inline void hci_filter_clear_event(int e, struct hci_filter *f)
145 hci_clear_bit((e & HCI_FLT_EVENT_BITS), &f->event_mask);
147 static inline int hci_filter_test_event(int e, struct hci_filter *f)
149 return hci_test_bit((e & HCI_FLT_EVENT_BITS), &f->event_mask);
151 static inline void hci_filter_all_events(struct hci_filter *f)
153 memset((void *) f->event_mask, 0xff, sizeof(f->event_mask));
155 static inline void hci_filter_set_opcode(int opcode, struct hci_filter *f)
159 static inline void hci_filter_clear_opcode(struct hci_filter *f)
163 static inline int hci_filter_test_opcode(int opcode, struct hci_filter *f)
165 return (f->opcode == opcode);
168 static inline int bacmp(const bt_address *ba1, const bt_address *ba2)
170 return memcmp(ba1, ba2, sizeof(bt_address));
172 static inline void bacpy(bt_address *dst, const bt_address *src)
174 memcpy(dst, src, sizeof(bt_address));
178 #endif /* __HCIDRIVER */