blob: ab36c37d671deb19e21f9b3dd28a9b2d1edb95cb [file] [log] [blame]
Andre Eisenbach05f49542012-09-18 12:15:26 -07001/*
2 * Copyright (C) 2012 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ANDROID_INCLUDE_BT_SOCK_H
18#define ANDROID_INCLUDE_BT_SOCK_H
19
20__BEGIN_DECLS
21
22#define BTSOCK_FLAG_ENCRYPT 1
23#define BTSOCK_FLAG_AUTH (1 << 1)
24
25typedef enum {
26 BTSOCK_RFCOMM = 1,
27 BTSOCK_SCO = 2,
28 BTSOCK_L2CAP = 3
29} btsock_type_t;
30
Srinu Jella3a51aba2013-09-12 17:59:45 +053031typedef enum {
32 BTSOCK_OPT_GET_MODEM_BITS = 1,
33 BTSOCK_OPT_SET_MODEM_BITS = 2,
34 BTSOCK_OPT_CLR_MODEM_BITS = 3,
Srinu Jella33005ff2014-03-19 19:56:56 +053035 BTSOCK_OPT_SET_PUT_MTU = 4,
Srinu Jella3a51aba2013-09-12 17:59:45 +053036} btsock_option_type_t;
37
Andre Eisenbach05f49542012-09-18 12:15:26 -070038/** Represents the standard BT SOCKET interface. */
39typedef struct {
40 short size;
41 bt_bdaddr_t bd_addr;
42 int channel;
43 int status;
44} __attribute__((packed)) sock_connect_signal_t;
45
46typedef struct {
47
48 /** set to size of this struct*/
49 size_t size;
50 /**
51 * listen to a rfcomm uuid or channel. It returns the socket fd from which
52 * btsock_connect_signal can be read out when a remote device connected
53 */
54 bt_status_t (*listen)(btsock_type_t type, const char* service_name, const uint8_t* service_uuid, int channel, int* sock_fd, int flags);
55 /*
56 * connect to a rfcomm uuid channel of remote device, It returns the socket fd from which
57 * the btsock_connect_signal and a new socket fd to be accepted can be read out when connected
58 */
59 bt_status_t (*connect)(const bt_bdaddr_t *bd_addr, btsock_type_t type, const uint8_t* uuid, int channel, int* sock_fd, int flags);
Srinu Jella3a51aba2013-09-12 17:59:45 +053060 /*
61 * get socket option of rfcomm channel socket.
62 */
63 bt_status_t (*get_sock_opt)(btsock_type_t type, int channel, btsock_option_type_t option_name, void *option_value, int *option_len);
64 /*
65 * set socket option of rfcomm channel socket.
66 */
67 bt_status_t (*set_sock_opt)(btsock_type_t type, int channel, btsock_option_type_t option_name, void *option_value, int option_len);
68
Andre Eisenbach05f49542012-09-18 12:15:26 -070069
70} btsock_interface_t;
71
72__END_DECLS
73
74#endif /* ANDROID_INCLUDE_BT_SOCK_H */