123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241 |
- #ifndef PORT_INT_H
- #define PORT_INT_H
- #include "bt_common.h"
- #include "bt_target.h"
- #include "osi/include/alarm.h"
- #include "osi/include/fixed_queue.h"
- #include "port_api.h"
- #include "rfcdefs.h"
- #define PORT_EVENT_OPEN (1 | BT_EVT_TO_BTU_SP_EVT)
- #define PORT_EVENT_CONTROL (2 | BT_EVT_TO_BTU_SP_EVT)
- #define PORT_EVENT_SET_STATE (3 | BT_EVT_TO_BTU_SP_EVT)
- #define PORT_EVENT_SET_CALLBACK (5 | BT_EVT_TO_BTU_SP_EVT)
- #define PORT_EVENT_WRITE (6 | BT_EVT_TO_BTU_SP_EVT)
- #define PORT_EVENT_PURGE (7 | BT_EVT_TO_BTU_SP_EVT)
- #define PORT_EVENT_SEND_ERROR (8 | BT_EVT_TO_BTU_SP_EVT)
- #define PORT_EVENT_FLOW_CONTROL (9 | BT_EVT_TO_BTU_SP_EVT)
- #define PORT_FC_UNDEFINED 0
- #define PORT_FC_TS710 1
- #define PORT_FC_CREDIT 2
- typedef struct {
- fixed_queue_t* queue;
- bool peer_fc;
- bool user_fc;
- uint32_t queue_size;
- tPORT_CALLBACK* p_callback;
- } tPORT_DATA;
- typedef struct {
- #define MODEM_SIGNAL_DTRDSR 0x01
- #define MODEM_SIGNAL_RTSCTS 0x02
- #define MODEM_SIGNAL_RI 0x04
- #define MODEM_SIGNAL_DCD 0x08
- uint8_t modem_signal;
- uint8_t break_signal;
- uint8_t discard_buffers;
- #define RFCOMM_CTRL_BREAK_ASAP 0
- #define RFCOMM_CTRL_BREAK_IN_SEQ 1
- uint8_t break_signal_seq;
- bool fc;
- } tPORT_CTRL;
- typedef struct {
- alarm_t* mcb_timer;
- fixed_queue_t* cmd_q;
- uint8_t port_handles[RFCOMM_MAX_DLCI + 1];
-
- RawAddress bd_addr;
- uint16_t lcid;
- uint16_t peer_l2cap_mtu;
- uint8_t state;
- uint8_t is_initiator;
- bool local_cfg_sent;
- bool peer_cfg_rcvd;
- bool restart_required;
- bool peer_ready;
- uint8_t flow;
- bool l2cap_congested;
- bool is_disc_initiator;
- uint16_t
- pending_lcid;
- uint8_t
- pending_id;
- } tRFC_MCB;
- typedef struct {
- #define RFC_PORT_STATE_IDLE 0
- #define RFC_PORT_STATE_WAIT_START 1
- #define RFC_PORT_STATE_OPENING 2
- #define RFC_PORT_STATE_OPENED 3
- #define RFC_PORT_STATE_CLOSING 4
- uint8_t state;
- #define RFC_RSP_PN 0x01
- #define RFC_RSP_RPN_REPLY 0x02
- #define RFC_RSP_RPN 0x04
- #define RFC_RSP_MSC 0x08
- #define RFC_RSP_RLS 0x10
- uint8_t expected_rsp;
- tRFC_MCB* p_mcb;
- alarm_t* port_timer;
- } tRFC_PORT;
- typedef struct {
- uint8_t handle;
- bool in_use;
- #define PORT_STATE_CLOSED 0
- #define PORT_STATE_OPENING 1
- #define PORT_STATE_OPENED 2
- #define PORT_STATE_CLOSING 3
- uint8_t state;
- uint8_t scn;
- uint16_t uuid;
- RawAddress bd_addr;
- bool is_server;
- uint8_t dlci;
- uint8_t error;
- uint8_t line_status;
- uint8_t default_signal_state;
- uint16_t mtu;
- uint16_t peer_mtu;
- tPORT_DATA tx;
- tPORT_DATA rx;
- tPORT_STATE user_port_pars;
- tPORT_STATE peer_port_pars;
- tPORT_CTRL local_ctrl;
- tPORT_CTRL peer_ctrl;
- #define PORT_CTRL_REQ_SENT 0x01
- #define PORT_CTRL_REQ_CONFIRMED 0x02
- #define PORT_CTRL_IND_RECEIVED 0x04
- #define PORT_CTRL_IND_RESPONDED 0x08
- uint8_t port_ctrl;
- bool rx_flag_ev_pending;
- tRFC_PORT rfc;
- uint32_t ev_mask;
- tPORT_CALLBACK* p_callback;
- tPORT_CALLBACK*
- p_mgmt_callback;
- tPORT_DATA_CALLBACK*
- p_data_callback;
- tPORT_DATA_CO_CALLBACK*
- p_data_co_callback;
- uint16_t credit_tx;
- uint16_t credit_rx;
-
- uint16_t
- credit_rx_max;
- uint16_t credit_rx_low;
- uint16_t rx_buf_critical;
- bool keep_port_handle;
-
- uint16_t keep_mtu;
- } tPORT;
- typedef struct {
- tPORT port[MAX_RFC_PORTS];
- tRFC_MCB rfc_mcb[MAX_BD_CONNECTIONS];
- } tPORT_CB;
- extern tPORT* port_allocate_port(uint8_t dlci, const RawAddress& bd_addr);
- extern void port_set_defaults(tPORT* p_port);
- extern void port_select_mtu(tPORT* p_port);
- extern void port_release_port(tPORT* p_port);
- extern tPORT* port_find_mcb_dlci_port(tRFC_MCB* p_mcb, uint8_t dlci);
- extern tRFC_MCB* port_find_mcb(const RawAddress& bd_addr);
- extern tPORT* port_find_dlci_port(uint8_t dlci);
- extern tPORT* port_find_port(uint8_t dlci, const RawAddress& bd_addr);
- extern uint32_t port_get_signal_changes(tPORT* p_port, uint8_t old_signals,
- uint8_t signal);
- extern uint32_t port_flow_control_user(tPORT* p_port);
- extern void port_flow_control_peer(tPORT* p_port, bool enable, uint16_t count);
- extern int port_open_continue(tPORT* p_port);
- extern void port_start_port_open(tPORT* p_port);
- extern void port_start_par_neg(tPORT* p_port);
- extern void port_start_control(tPORT* p_port);
- extern void port_start_close(tPORT* p_port);
- extern void port_rfc_closed(tPORT* p_port, uint8_t res);
- #endif
|