Zephyr Project API 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
rfcomm.h
Go to the documentation of this file.
1
4
5/*
6 * Copyright (c) 2015-2016 Intel Corporation
7 *
8 * SPDX-License-Identifier: Apache-2.0
9 */
10#ifndef ZEPHYR_INCLUDE_BLUETOOTH_RFCOMM_H_
11#define ZEPHYR_INCLUDE_BLUETOOTH_RFCOMM_H_
12
19
23#include <zephyr/sys/slist.h>
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
30#define BT_RFCOMM_HDR_MAX_SIZE 4
32#define BT_RFCOMM_FCS_SIZE 1
34#define BT_RFCOMM_CREDITS_SIZE 1
35
44#define BT_RFCOMM_OVERHEAD_SIZE \
45 (BT_RFCOMM_HDR_MAX_SIZE + BT_RFCOMM_FCS_SIZE + BT_RFCOMM_CREDITS_SIZE)
46
54#define BT_RFCOMM_BUF_SIZE(mtu) BT_L2CAP_BUF_SIZE(BT_RFCOMM_OVERHEAD_SIZE + (mtu))
55
56/* RFCOMM channels (1-30): pre-allocated for profiles to avoid conflicts */
57enum {
64};
65
66struct bt_rfcomm_dlc;
67
77 void (*connected)(struct bt_rfcomm_dlc *dlc);
78
87 void (*disconnected)(struct bt_rfcomm_dlc *dlc);
88
94 void (*recv)(struct bt_rfcomm_dlc *dlc, struct net_buf *buf);
95
101 void (*sent)(struct bt_rfcomm_dlc *dlc, int err);
102};
103
110
113 /* Response Timeout eXpired (RTX) timer */
115
116 /* Queue for outgoing data */
118
119 /* TX credits, Reuse as a binary sem for MSC FC if CFC is not enabled */
121
122 /* Worker for RFCOMM TX */
124
125 struct bt_rfcomm_session *session;
127
129 sys_snode_t _node;
130
133
138};
139
152
164 int (*accept)(struct bt_conn *conn, struct bt_rfcomm_server *server,
165 struct bt_rfcomm_dlc **dlc);
166
168 sys_snode_t node;
170};
171
173enum {
183};
184
186enum {
191};
192
194enum {
197};
198
200enum {
206};
207
216#define BT_RFCOMM_SET_LINE_SETTINGS(data, stop, parity) ((data & 0x3) | \
217 ((stop & 0x1) << 2) | \
218 ((parity & 0x7) << 3))
219
220#define BT_RFCOMM_RPN_FLOW_NONE 0x00
221#define BT_RFCOMM_RPN_XON_CHAR 0x11
222#define BT_RFCOMM_RPN_XOFF_CHAR 0x13
223
224/* Set 1 to all the param mask except reserved */
225#define BT_RFCOMM_RPN_PARAM_MASK_ALL 0x3f7f
226
237
249
259
272int bt_rfcomm_dlc_connect(struct bt_conn *conn, struct bt_rfcomm_dlc *dlc,
273 uint8_t channel);
274
285int bt_rfcomm_dlc_send(struct bt_rfcomm_dlc *dlc, struct net_buf *buf);
286
297
306
316
317#ifdef __cplusplus
318}
319#endif
320
324
325#endif /* ZEPHYR_INCLUDE_BLUETOOTH_RFCOMM_H_ */
Bluetooth data buffer API.
Bluetooth connection handling.
bt_security_t
Security level.
Definition conn.h:1167
enum bt_rfcomm_role bt_rfcomm_role_t
Role of RFCOMM session and dlc.
int bt_rfcomm_dlc_connect(struct bt_conn *conn, struct bt_rfcomm_dlc *dlc, uint8_t channel)
Connect RFCOMM channel.
int bt_rfcomm_dlc_send(struct bt_rfcomm_dlc *dlc, struct net_buf *buf)
Send data to RFCOMM.
int bt_rfcomm_dlc_disconnect(struct bt_rfcomm_dlc *dlc)
Disconnect RFCOMM dlc.
bt_rfcomm_role
Role of RFCOMM session and dlc.
Definition rfcomm.h:106
int bt_rfcomm_send_rpn_cmd(struct bt_rfcomm_dlc *dlc, struct bt_rfcomm_rpn *rpn)
Send Remote Port Negotiation command.
struct net_buf * bt_rfcomm_create_pdu(struct net_buf_pool *pool)
Allocate the buffer from pool after reserving head room for RFCOMM, L2CAP and ACL headers.
int bt_rfcomm_server_unregister(struct bt_rfcomm_server *server)
Unregister RFCOMM server.
int bt_rfcomm_server_register(struct bt_rfcomm_server *server)
Register RFCOMM server.
@ BT_RFCOMM_CHAN_SPP
Definition rfcomm.h:62
@ BT_RFCOMM_CHAN_DYNAMIC_START
Definition rfcomm.h:63
@ BT_RFCOMM_CHAN_HFP_HF
Definition rfcomm.h:58
@ BT_RFCOMM_CHAN_HSP_HS
Definition rfcomm.h:61
@ BT_RFCOMM_CHAN_HFP_AG
Definition rfcomm.h:59
@ BT_RFCOMM_CHAN_HSP_AG
Definition rfcomm.h:60
@ BT_RFCOMM_RPN_PARITY_NONE
Definition rfcomm.h:201
@ BT_RFCOMM_RPN_PARITY_ODD
Definition rfcomm.h:202
@ BT_RFCOMM_RPN_PARITY_EVEN
Definition rfcomm.h:203
@ BT_RFCOMM_RPN_PARITY_MARK
Definition rfcomm.h:204
@ BT_RFCOMM_RPN_PARITY_SPACE
Definition rfcomm.h:205
@ BT_RFCOMM_RPN_STOP_BITS_1_5
Definition rfcomm.h:196
@ BT_RFCOMM_RPN_STOP_BITS_1
Definition rfcomm.h:195
@ BT_RFCOMM_ROLE_INITIATOR
Definition rfcomm.h:108
@ BT_RFCOMM_ROLE_ACCEPTOR
Definition rfcomm.h:107
@ BT_RFCOMM_RPN_BAUD_RATE_4800
Definition rfcomm.h:175
@ BT_RFCOMM_RPN_BAUD_RATE_19200
Definition rfcomm.h:178
@ BT_RFCOMM_RPN_BAUD_RATE_7200
Definition rfcomm.h:176
@ BT_RFCOMM_RPN_BAUD_RATE_230400
Definition rfcomm.h:182
@ BT_RFCOMM_RPN_BAUD_RATE_38400
Definition rfcomm.h:179
@ BT_RFCOMM_RPN_BAUD_RATE_9600
Definition rfcomm.h:177
@ BT_RFCOMM_RPN_BAUD_RATE_2400
Definition rfcomm.h:174
@ BT_RFCOMM_RPN_BAUD_RATE_57600
Definition rfcomm.h:180
@ BT_RFCOMM_RPN_BAUD_RATE_115200
Definition rfcomm.h:181
@ BT_RFCOMM_RPN_DATA_BITS_5
Definition rfcomm.h:187
@ BT_RFCOMM_RPN_DATA_BITS_7
Definition rfcomm.h:189
@ BT_RFCOMM_RPN_DATA_BITS_6
Definition rfcomm.h:188
@ BT_RFCOMM_RPN_DATA_BITS_8
Definition rfcomm.h:190
struct _snode sys_snode_t
Single-linked list node structure.
Definition slist.h:39
Bluetooth L2CAP handling.
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Opaque type representing a connection to a remote device.
RFCOMM DLC operations structure.
Definition rfcomm.h:69
void(* sent)(struct bt_rfcomm_dlc *dlc, int err)
DLC sent callback.
Definition rfcomm.h:101
void(* recv)(struct bt_rfcomm_dlc *dlc, struct net_buf *buf)
DLC recv callback.
Definition rfcomm.h:94
void(* disconnected)(struct bt_rfcomm_dlc *dlc)
DLC disconnected callback.
Definition rfcomm.h:87
void(* connected)(struct bt_rfcomm_dlc *dlc)
DLC connected callback.
Definition rfcomm.h:77
RFCOMM DLC structure.
Definition rfcomm.h:112
struct bt_rfcomm_dlc_ops * ops
Definition rfcomm.h:126
struct k_fifo tx_queue
Definition rfcomm.h:117
uint8_t dlci
Definition rfcomm.h:135
uint16_t mtu
Definition rfcomm.h:134
struct k_sem tx_credits
Definition rfcomm.h:120
struct k_work_delayable rtx_work
Definition rfcomm.h:114
bt_rfcomm_role_t role
Definition rfcomm.h:132
bt_security_t required_sec_level
Definition rfcomm.h:131
uint8_t state
Definition rfcomm.h:136
uint8_t rx_credit
Definition rfcomm.h:137
struct bt_rfcomm_session * session
Definition rfcomm.h:125
struct k_work tx_work
Definition rfcomm.h:123
RFCOMM Remote Port Negotiation (RPN) structure.
Definition rfcomm.h:228
uint16_t param_mask
Definition rfcomm.h:235
uint8_t baud_rate
Definition rfcomm.h:230
uint8_t line_settings
Definition rfcomm.h:231
uint8_t xoff_char
Definition rfcomm.h:234
uint8_t flow_control
Definition rfcomm.h:232
uint8_t xon_char
Definition rfcomm.h:233
uint8_t dlci
Definition rfcomm.h:229
Definition rfcomm.h:140
uint8_t channel
Server Channel.
Definition rfcomm.h:151
int(* accept)(struct bt_conn *conn, struct bt_rfcomm_server *server, struct bt_rfcomm_dlc **dlc)
Server accept callback.
Definition rfcomm.h:164
Kernel FIFO structure.
Definition kernel.h:2895
Semaphore structure.
Definition kernel.h:3663
A structure used to submit work after a delay.
Definition kernel.h:4603
A structure used to submit work.
Definition kernel.h:4561
Network buffer pool representation.
Definition net_buf.h:1151
Network buffer representation.
Definition net_buf.h:1015