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_CLASSIC_RFCOMM_H_
11#define ZEPHYR_INCLUDE_BLUETOOTH_CLASSIC_RFCOMM_H_
12
21
25#include <zephyr/sys/slist.h>
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
32#define BT_RFCOMM_HDR_MAX_SIZE 4
34#define BT_RFCOMM_FCS_SIZE 1
36#define BT_RFCOMM_CREDITS_SIZE 1
37
46#define BT_RFCOMM_OVERHEAD_SIZE \
47 (BT_RFCOMM_HDR_MAX_SIZE + BT_RFCOMM_FCS_SIZE + BT_RFCOMM_CREDITS_SIZE)
48
56#define BT_RFCOMM_BUF_SIZE(mtu) BT_L2CAP_BUF_SIZE(BT_RFCOMM_OVERHEAD_SIZE + (mtu))
57
58/* RFCOMM channels (1-30): pre-allocated for profiles to avoid conflicts */
59enum {
66};
67
68struct bt_rfcomm_dlc;
69
90 void (*connected)(struct bt_rfcomm_dlc *dlc);
91
100 void (*disconnected)(struct bt_rfcomm_dlc *dlc);
101
130 int (*recv)(struct bt_rfcomm_dlc *dlc, struct net_buf *buf);
131
137 void (*sent)(struct bt_rfcomm_dlc *dlc, int err);
138};
139
146
150
156 struct k_work_delayable rtx_work;
157
163 struct k_fifo tx_queue;
164
172 struct k_sem tx_credits;
173
180 struct k_work tx_work;
181
183 struct bt_rfcomm_session *session;
184
186
189
191
193 sys_snode_t _node;
194
196
199
201
203 bt_rfcomm_role_t role;
204
206
213
215
217 uint8_t dlci;
218
224
234 uint8_t rx_credit;
235
237
256
258
272 atomic_t rx_credit_inprogress;
273
276
278};
279
292
304 int (*accept)(struct bt_conn *conn, struct bt_rfcomm_server *server,
305 struct bt_rfcomm_dlc **dlc);
306
308 sys_snode_t node;
310};
311
313enum {
323};
324
326enum {
331};
332
334enum {
337};
338
340enum {
346};
347
356#define BT_RFCOMM_SET_LINE_SETTINGS(data, stop, parity) ((data & 0x3) | \
357 ((stop & 0x1) << 2) | \
358 ((parity & 0x7) << 3))
359
360#define BT_RFCOMM_RPN_FLOW_NONE 0x00
361#define BT_RFCOMM_RPN_XON_CHAR 0x11
362#define BT_RFCOMM_RPN_XOFF_CHAR 0x13
363
364/* Set 1 to all the param mask except reserved */
365#define BT_RFCOMM_RPN_PARAM_MASK_ALL 0x3f7f
366
377
389
399
412int bt_rfcomm_dlc_connect(struct bt_conn *conn, struct bt_rfcomm_dlc *dlc,
413 uint8_t channel);
414
425int bt_rfcomm_dlc_send(struct bt_rfcomm_dlc *dlc, struct net_buf *buf);
426
437
471
480
490
492#define BT_RFCOMM_RLS_NO_ERR (0x00U)
493
502#define BT_RFCOMM_RLS_ERR(err) (BIT(0) | (err))
503
505#define BT_RFCOMM_RLS_ERR_OVERRUN_ERROR BIT(1)
506
508#define BT_RFCOMM_RLS_ERR_PARITY_ERROR BIT(2)
509
511#define BT_RFCOMM_RLS_ERR_FRAMING_ERROR BIT(3)
512
533int bt_rfcomm_send_rls_cmd(struct bt_rfcomm_dlc *dlc, uint8_t line_status);
534
535#ifdef __cplusplus
536}
537#endif
538
542
543#endif /* ZEPHYR_INCLUDE_BLUETOOTH_CLASSIC_RFCOMM_H_ */
Bluetooth data buffer API.
Bluetooth connection handling.
long atomic_t
Atomic integer variable.
Definition atomic_types.h:31
bt_security_t
Security level.
Definition conn.h:1201
enum bt_rfcomm_role bt_rfcomm_role_t
Role of RFCOMM session and dlc.
int bt_rfcomm_send_rls_cmd(struct bt_rfcomm_dlc *dlc, uint8_t line_status)
Send Remote Line Status Command.
int bt_rfcomm_dlc_recv_complete(struct bt_rfcomm_dlc *dlc, struct net_buf *buf)
Complete receiving RFCOMM channel data.
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:142
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:64
@ BT_RFCOMM_CHAN_DYNAMIC_START
Definition rfcomm.h:65
@ BT_RFCOMM_CHAN_HFP_HF
Definition rfcomm.h:60
@ BT_RFCOMM_CHAN_HSP_HS
Definition rfcomm.h:63
@ BT_RFCOMM_CHAN_HFP_AG
Definition rfcomm.h:61
@ BT_RFCOMM_CHAN_HSP_AG
Definition rfcomm.h:62
@ BT_RFCOMM_RPN_PARITY_NONE
Definition rfcomm.h:341
@ BT_RFCOMM_RPN_PARITY_ODD
Definition rfcomm.h:342
@ BT_RFCOMM_RPN_PARITY_EVEN
Definition rfcomm.h:343
@ BT_RFCOMM_RPN_PARITY_MARK
Definition rfcomm.h:344
@ BT_RFCOMM_RPN_PARITY_SPACE
Definition rfcomm.h:345
@ BT_RFCOMM_RPN_STOP_BITS_1_5
Definition rfcomm.h:336
@ BT_RFCOMM_RPN_STOP_BITS_1
Definition rfcomm.h:335
@ BT_RFCOMM_ROLE_INITIATOR
Definition rfcomm.h:144
@ BT_RFCOMM_ROLE_ACCEPTOR
Definition rfcomm.h:143
@ BT_RFCOMM_RPN_BAUD_RATE_4800
Definition rfcomm.h:315
@ BT_RFCOMM_RPN_BAUD_RATE_19200
Definition rfcomm.h:318
@ BT_RFCOMM_RPN_BAUD_RATE_7200
Definition rfcomm.h:316
@ BT_RFCOMM_RPN_BAUD_RATE_230400
Definition rfcomm.h:322
@ BT_RFCOMM_RPN_BAUD_RATE_38400
Definition rfcomm.h:319
@ BT_RFCOMM_RPN_BAUD_RATE_9600
Definition rfcomm.h:317
@ BT_RFCOMM_RPN_BAUD_RATE_2400
Definition rfcomm.h:314
@ BT_RFCOMM_RPN_BAUD_RATE_57600
Definition rfcomm.h:320
@ BT_RFCOMM_RPN_BAUD_RATE_115200
Definition rfcomm.h:321
@ BT_RFCOMM_RPN_DATA_BITS_5
Definition rfcomm.h:327
@ BT_RFCOMM_RPN_DATA_BITS_7
Definition rfcomm.h:329
@ BT_RFCOMM_RPN_DATA_BITS_6
Definition rfcomm.h:328
@ BT_RFCOMM_RPN_DATA_BITS_8
Definition rfcomm.h:330
struct _snode sys_snode_t
Single-linked list node structure.
Definition slist.h:44
Bluetooth L2CAP handling.
flags
Definition parser.h:97
state
Definition parser_state.h:29
Header file for the single-linked list API.
__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:82
void(* sent)(struct bt_rfcomm_dlc *dlc, int err)
DLC sent callback.
Definition rfcomm.h:137
void(* disconnected)(struct bt_rfcomm_dlc *dlc)
DLC disconnected callback.
Definition rfcomm.h:100
int(* recv)(struct bt_rfcomm_dlc *dlc, struct net_buf *buf)
DLC recv callback.
Definition rfcomm.h:130
void(* connected)(struct bt_rfcomm_dlc *dlc)
DLC connected callback.
Definition rfcomm.h:90
RFCOMM DLC structure.
Definition rfcomm.h:148
struct bt_rfcomm_dlc_ops * ops
Pointer to the application callback operations for this DLC.
Definition rfcomm.h:188
uint16_t mtu
Maximum Transmission Unit for this DLC in bytes.
Definition rfcomm.h:212
uint8_t rx_credit_limit
Requested initial number of receive credits for this DLC.
Definition rfcomm.h:255
bt_security_t required_sec_level
Minimum security level required before this DLC may be established.
Definition rfcomm.h:198
RFCOMM Remote Port Negotiation (RPN) structure.
Definition rfcomm.h:368
uint16_t param_mask
Definition rfcomm.h:375
uint8_t baud_rate
Definition rfcomm.h:370
uint8_t line_settings
Definition rfcomm.h:371
uint8_t xoff_char
Definition rfcomm.h:374
uint8_t flow_control
Definition rfcomm.h:372
uint8_t xon_char
Definition rfcomm.h:373
uint8_t dlci
Definition rfcomm.h:369
Definition rfcomm.h:280
uint8_t channel
Server Channel.
Definition rfcomm.h:291
int(* accept)(struct bt_conn *conn, struct bt_rfcomm_server *server, struct bt_rfcomm_dlc **dlc)
Server accept callback.
Definition rfcomm.h:304
Kernel FIFO structure.
Definition kernel.h:2941
Semaphore structure.
Definition kernel.h:3726
A structure used to submit work after a delay.
Definition kernel.h:4678
A structure used to submit work.
Definition kernel.h:4636
Network buffer pool representation.
Definition net_buf.h:1184
Network buffer representation.
Definition net_buf.h:1048