mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-15 22:20:59 +00:00
l2cap: use #defines for L2CAP_CHANNEL_STATE_VAR_INCOMING
This commit is contained in:
parent
61d1a45e7d
commit
e777ec9519
12
src/l2cap.c
12
src/l2cap.c
@ -1378,12 +1378,12 @@ int l2cap_send_echo_request(hci_con_handle_t con_handle, uint8_t *data, uint16_t
|
||||
return l2cap_send_signaling_packet(con_handle, ECHO_REQUEST, l2cap_next_sig_id(), len, data);
|
||||
}
|
||||
|
||||
static inline void channelStateVarSetFlag(l2cap_channel_t *channel, L2CAP_CHANNEL_STATE_VAR flag){
|
||||
channel->state_var = (L2CAP_CHANNEL_STATE_VAR) (channel->state_var | flag);
|
||||
static inline void channelStateVarSetFlag(l2cap_channel_t *channel, uint16_t flag){
|
||||
channel->state_var = channel->state_var | flag;
|
||||
}
|
||||
|
||||
static inline void channelStateVarClearFlag(l2cap_channel_t *channel, L2CAP_CHANNEL_STATE_VAR flag){
|
||||
channel->state_var = (L2CAP_CHANNEL_STATE_VAR) (channel->state_var & ~flag);
|
||||
static inline void channelStateVarClearFlag(l2cap_channel_t *channel, uint16_t flag){
|
||||
channel->state_var = channel->state_var & ~flag;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -2648,10 +2648,10 @@ static void l2cap_handle_connection_request(hci_con_handle_t handle, uint8_t sig
|
||||
|
||||
// assert security requirements
|
||||
if (channel->required_security_level <= gap_security_level(handle)){
|
||||
channel->state_var = (L2CAP_CHANNEL_STATE_VAR) (L2CAP_CHANNEL_STATE_VAR_INCOMING);
|
||||
channel->state_var = L2CAP_CHANNEL_STATE_VAR_INCOMING;
|
||||
l2cap_handle_security_level_incoming_sufficient(channel);
|
||||
} else {
|
||||
channel->state_var = (L2CAP_CHANNEL_STATE_VAR) (L2CAP_CHANNEL_STATE_VAR_SEND_CONN_RESP_PEND | L2CAP_CHANNEL_STATE_VAR_INCOMING);
|
||||
channel->state_var = L2CAP_CHANNEL_STATE_VAR_SEND_CONN_RESP_PEND | L2CAP_CHANNEL_STATE_VAR_INCOMING;
|
||||
gap_request_security_level(handle, channel->required_security_level);
|
||||
}
|
||||
}
|
||||
|
37
src/l2cap.h
37
src/l2cap.h
@ -97,24 +97,23 @@ typedef enum {
|
||||
L2CAP_STATE_INVALID,
|
||||
} L2CAP_STATE;
|
||||
|
||||
typedef enum {
|
||||
L2CAP_CHANNEL_STATE_VAR_NONE = 0,
|
||||
L2CAP_CHANNEL_STATE_VAR_RCVD_CONF_REQ = 1 << 0,
|
||||
L2CAP_CHANNEL_STATE_VAR_RCVD_CONF_RSP = 1 << 1,
|
||||
L2CAP_CHANNEL_STATE_VAR_SEND_CONF_REQ = 1 << 2,
|
||||
L2CAP_CHANNEL_STATE_VAR_SEND_CONF_RSP = 1 << 3,
|
||||
L2CAP_CHANNEL_STATE_VAR_SENT_CONF_REQ = 1 << 4,
|
||||
L2CAP_CHANNEL_STATE_VAR_SENT_CONF_RSP = 1 << 5,
|
||||
L2CAP_CHANNEL_STATE_VAR_SEND_CONF_RSP_MTU = 1 << 6, // in CONF RSP, add MTU option
|
||||
L2CAP_CHANNEL_STATE_VAR_SEND_CONF_RSP_ERTM = 1 << 7, // in CONF RSP, add Retransmission and Flowcontrol option
|
||||
L2CAP_CHANNEL_STATE_VAR_SEND_CONF_RSP_CONT = 1 << 8, // in CONF RSP, set CONTINUE flag
|
||||
L2CAP_CHANNEL_STATE_VAR_SEND_CONF_RSP_INVALID = 1 << 9, // in CONF RSP, send UNKNOWN OPTIONS
|
||||
L2CAP_CHANNEL_STATE_VAR_SEND_CONF_RSP_REJECTED = 1 << 10, // in CONF RSP, send Unacceptable Parameters (ERTM)
|
||||
L2CAP_CHANNEL_STATE_VAR_BASIC_FALLBACK_TRIED = 1 << 11, // set when ERTM was requested but we want only Basic mode (ERM)
|
||||
L2CAP_CHANNEL_STATE_VAR_SEND_CMD_REJ_UNKNOWN = 1 << 12, // send CMD_REJ with reason unknown
|
||||
L2CAP_CHANNEL_STATE_VAR_SEND_CONN_RESP_PEND = 1 << 13, // send Connection Respond with pending
|
||||
L2CAP_CHANNEL_STATE_VAR_INCOMING = 1 << 15, // channel is incoming
|
||||
} L2CAP_CHANNEL_STATE_VAR;
|
||||
#define L2CAP_CHANNEL_STATE_VAR_NONE 0
|
||||
#define L2CAP_CHANNEL_STATE_VAR_RCVD_CONF_REQ 1 << 0
|
||||
#define L2CAP_CHANNEL_STATE_VAR_RCVD_CONF_RSP 1 << 1
|
||||
#define L2CAP_CHANNEL_STATE_VAR_SEND_CONF_REQ 1 << 2
|
||||
#define L2CAP_CHANNEL_STATE_VAR_SEND_CONF_RSP 1 << 3
|
||||
#define L2CAP_CHANNEL_STATE_VAR_SENT_CONF_REQ 1 << 4
|
||||
#define L2CAP_CHANNEL_STATE_VAR_SENT_CONF_RSP 1 << 5
|
||||
#define L2CAP_CHANNEL_STATE_VAR_SEND_CONF_RSP_MTU 1 << 6 // in CONF RSP, add MTU option
|
||||
#define L2CAP_CHANNEL_STATE_VAR_SEND_CONF_RSP_ERTM 1 << 7 // in CONF RSP, add Retransmission and Flowcontrol option
|
||||
#define L2CAP_CHANNEL_STATE_VAR_SEND_CONF_RSP_CONT 1 << 8 // in CONF RSP, set CONTINUE flag
|
||||
#define L2CAP_CHANNEL_STATE_VAR_SEND_CONF_RSP_INVALID 1 << 9 // in CONF RSP, send UNKNOWN OPTIONS
|
||||
#define L2CAP_CHANNEL_STATE_VAR_SEND_CONF_RSP_REJECTED 1 << 10 // in CONF RSP, send Unacceptable Parameters (ERTM)
|
||||
#define L2CAP_CHANNEL_STATE_VAR_BASIC_FALLBACK_TRIED 1 << 11 // set when ERTM was requested but we want only Basic mode (ERM)
|
||||
#define L2CAP_CHANNEL_STATE_VAR_SEND_CMD_REJ_UNKNOWN 1 << 12 // send CMD_REJ with reason unknown
|
||||
#define L2CAP_CHANNEL_STATE_VAR_SEND_CONN_RESP_PEND 1 << 13 // send Connection Respond with pending
|
||||
#define L2CAP_CHANNEL_STATE_VAR_INCOMING 1 << 15 // channel is incoming
|
||||
|
||||
|
||||
typedef enum {
|
||||
L2CAP_CHANNEL_TYPE_CLASSIC, // Classic Basic or ERTM
|
||||
@ -220,7 +219,7 @@ typedef struct {
|
||||
btstack_timer_source_t rtx; // also used for ertx
|
||||
|
||||
L2CAP_STATE state;
|
||||
L2CAP_CHANNEL_STATE_VAR state_var;
|
||||
uint16_t state_var;
|
||||
|
||||
// info
|
||||
hci_con_handle_t con_handle;
|
||||
|
Loading…
x
Reference in New Issue
Block a user