bt_sock.h
Go to the documentation of this file.
1 /*
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 #pragma once
18 
19 __BEGIN_DECLS
20 
21 #define BTSOCK_FLAG_ENCRYPT 1
22 #define BTSOCK_FLAG_AUTH (1 << 1)
23 #define BTSOCK_FLAG_NO_SDP (1 << 2)
24 #define BTSOCK_FLAG_AUTH_MITM (1 << 3)
25 #define BTSOCK_FLAG_AUTH_16_DIGIT (1 << 4)
26 
27 typedef enum {
32 
33 /** Represents the standard BT SOCKET interface. */
34 typedef struct {
35  short size;
36  bt_bdaddr_t bd_addr;
37  int channel;
38  int status;
39 
40  // The writer must make writes using a buffer of this maximum size
41  // to avoid loosing data. (L2CAP only)
42  unsigned short max_tx_packet_size;
43 
44  // The reader must read using a buffer of at least this size to avoid
45  // loosing data. (L2CAP only)
46  unsigned short max_rx_packet_size;
47 } __attribute__((packed)) sock_connect_signal_t;
48 
49 typedef struct {
50  /** set to size of this struct*/
51  size_t size;
52 
53  /**
54  * Listen to a RFCOMM UUID or channel. It returns the socket fd from which
55  * btsock_connect_signal can be read out when a remote device connected.
56  * If neither a UUID nor a channel is provided, a channel will be allocated
57  * and a service record can be created providing the channel number to
58  * create_sdp_record(...) in bt_sdp.
59  */
60  bt_status_t (*listen)(btsock_type_t type, const char* service_name,
61  const uint8_t* service_uuid, int channel, int* sock_fd, int flags);
62 
63  /**
64  * Connect to a RFCOMM UUID channel of remote device, It returns the socket fd from which
65  * the btsock_connect_signal and a new socket fd to be accepted can be read out when connected
66  */
67  bt_status_t (*connect)(const bt_bdaddr_t *bd_addr, btsock_type_t type, const uint8_t* uuid,
68  int channel, int* sock_fd, int flags);
70 
71 __END_DECLS
72 
int channel
Definition: bt_sock.h:37
int status
Definition: bt_sock.h:38
bt_status_t
Definition: bluetooth.h:80
__attribute__((__deprecated__)) static inline size_t audio_stream_frame_size(const struct audio_stream *s)
Definition: audio.h:439
unsigned short max_tx_packet_size
Definition: bt_sock.h:42
bt_bdaddr_t bd_addr
Definition: bt_sock.h:36
unsigned short max_rx_packet_size
Definition: bt_sock.h:46
btsock_type_t
Definition: bt_sock.h:27
short size
Definition: bt_sock.h:35