mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-09 12:35:28 +00:00
component/bt : run astyle handle the code files
This commit is contained in:
92
components/bt/bluedroid/stack/rfcomm/rfc_utils.c
Executable file → Normal file
92
components/bt/bluedroid/stack/rfcomm/rfc_utils.c
Executable file → Normal file
@@ -44,8 +44,7 @@
|
||||
** Description Reversed CRC Table , 8-bit, poly=0x07
|
||||
** (GSM 07.10 TS 101 369 V6.3.0)
|
||||
*******************************************************************************/
|
||||
static const UINT8 rfc_crctable[] =
|
||||
{
|
||||
static const UINT8 rfc_crctable[] = {
|
||||
0x00, 0x91, 0xE3, 0x72, 0x07, 0x96, 0xE4, 0x75, 0x0E, 0x9F, 0xED, 0x7C, 0x09, 0x98, 0xEA, 0x7B,
|
||||
0x1C, 0x8D, 0xFF, 0x6E, 0x1B, 0x8A, 0xF8, 0x69, 0x12, 0x83, 0xF1, 0x60, 0x15, 0x84, 0xF6, 0x67,
|
||||
0x38, 0xA9, 0xDB, 0x4A, 0x3F, 0xAE, 0xDC, 0x4D, 0x36, 0xA7, 0xD5, 0x44, 0x31, 0xA0, 0xD2, 0x43,
|
||||
@@ -83,8 +82,7 @@ UINT8 rfc_calc_fcs (UINT16 len, UINT8 *p)
|
||||
{
|
||||
UINT8 fcs = 0xFF;
|
||||
|
||||
while (len--)
|
||||
{
|
||||
while (len--) {
|
||||
fcs = rfc_crctable[fcs ^ *p++];
|
||||
}
|
||||
|
||||
@@ -109,8 +107,7 @@ BOOLEAN rfc_check_fcs (UINT16 len, UINT8 *p, UINT8 received_fcs)
|
||||
{
|
||||
UINT8 fcs = 0xFF;
|
||||
|
||||
while (len--)
|
||||
{
|
||||
while (len--) {
|
||||
fcs = rfc_crctable[fcs ^ *p++];
|
||||
}
|
||||
|
||||
@@ -135,45 +132,43 @@ tRFC_MCB *rfc_alloc_multiplexer_channel (BD_ADDR bd_addr, BOOLEAN is_initiator)
|
||||
int i, j;
|
||||
tRFC_MCB *p_mcb = NULL;
|
||||
RFCOMM_TRACE_DEBUG("rfc_alloc_multiplexer_channel: bd_addr:%02x:%02x:%02x:%02x:%02x:%02x",
|
||||
bd_addr[0], bd_addr[1], bd_addr[2], bd_addr[3], bd_addr[4], bd_addr[5]);
|
||||
bd_addr[0], bd_addr[1], bd_addr[2], bd_addr[3], bd_addr[4], bd_addr[5]);
|
||||
RFCOMM_TRACE_DEBUG("rfc_alloc_multiplexer_channel:is_initiator:%d", is_initiator);
|
||||
|
||||
for (i = 0; i < MAX_BD_CONNECTIONS; i++)
|
||||
{
|
||||
for (i = 0; i < MAX_BD_CONNECTIONS; i++) {
|
||||
RFCOMM_TRACE_DEBUG("rfc_alloc_multiplexer_channel rfc_cb.port.rfc_mcb[%d].state:%d",
|
||||
i, rfc_cb.port.rfc_mcb[i].state);
|
||||
i, rfc_cb.port.rfc_mcb[i].state);
|
||||
RFCOMM_TRACE_DEBUG("(rfc_cb.port.rfc_mcb[i].bd_addr:%02x:%02x:%02x:%02x:%02x:%02x",
|
||||
rfc_cb.port.rfc_mcb[i].bd_addr[0], rfc_cb.port.rfc_mcb[i].bd_addr[1],
|
||||
rfc_cb.port.rfc_mcb[i].bd_addr[2], rfc_cb.port.rfc_mcb[i].bd_addr[3],
|
||||
rfc_cb.port.rfc_mcb[i].bd_addr[4], rfc_cb.port.rfc_mcb[i].bd_addr[5]);
|
||||
rfc_cb.port.rfc_mcb[i].bd_addr[0], rfc_cb.port.rfc_mcb[i].bd_addr[1],
|
||||
rfc_cb.port.rfc_mcb[i].bd_addr[2], rfc_cb.port.rfc_mcb[i].bd_addr[3],
|
||||
rfc_cb.port.rfc_mcb[i].bd_addr[4], rfc_cb.port.rfc_mcb[i].bd_addr[5]);
|
||||
|
||||
if ((rfc_cb.port.rfc_mcb[i].state != RFC_MX_STATE_IDLE)
|
||||
&& (!memcmp (rfc_cb.port.rfc_mcb[i].bd_addr, bd_addr, BD_ADDR_LEN)))
|
||||
{
|
||||
&& (!memcmp (rfc_cb.port.rfc_mcb[i].bd_addr, bd_addr, BD_ADDR_LEN))) {
|
||||
/* Multiplexer channel found do not change anything */
|
||||
/* If there was an inactivity timer running stop it now */
|
||||
if (rfc_cb.port.rfc_mcb[i].state == RFC_MX_STATE_CONNECTED)
|
||||
if (rfc_cb.port.rfc_mcb[i].state == RFC_MX_STATE_CONNECTED) {
|
||||
rfc_timer_stop (&rfc_cb.port.rfc_mcb[i]);
|
||||
}
|
||||
RFCOMM_TRACE_DEBUG("rfc_alloc_multiplexer_channel:is_initiator:%d, found, state:%d, p_mcb:%p",
|
||||
is_initiator, rfc_cb.port.rfc_mcb[i].state, &rfc_cb.port.rfc_mcb[i]);
|
||||
is_initiator, rfc_cb.port.rfc_mcb[i].state, &rfc_cb.port.rfc_mcb[i]);
|
||||
return (&rfc_cb.port.rfc_mcb[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/* connection with bd_addr does not exist */
|
||||
for (i = 0, j = rfc_cb.rfc.last_mux + 1; i < MAX_BD_CONNECTIONS; i++, j++)
|
||||
{
|
||||
if (j >= MAX_BD_CONNECTIONS)
|
||||
for (i = 0, j = rfc_cb.rfc.last_mux + 1; i < MAX_BD_CONNECTIONS; i++, j++) {
|
||||
if (j >= MAX_BD_CONNECTIONS) {
|
||||
j = 0;
|
||||
}
|
||||
|
||||
p_mcb = &rfc_cb.port.rfc_mcb[j];
|
||||
if (rfc_cb.port.rfc_mcb[j].state == RFC_MX_STATE_IDLE)
|
||||
{
|
||||
if (rfc_cb.port.rfc_mcb[j].state == RFC_MX_STATE_IDLE) {
|
||||
/* New multiplexer control block */
|
||||
memset (p_mcb, 0, sizeof (tRFC_MCB));
|
||||
memcpy (p_mcb->bd_addr, bd_addr, BD_ADDR_LEN);
|
||||
RFCOMM_TRACE_DEBUG("rfc_alloc_multiplexer_channel:is_initiator:%d, create new p_mcb:%p, index:%d",
|
||||
is_initiator, &rfc_cb.port.rfc_mcb[j], j);
|
||||
is_initiator, &rfc_cb.port.rfc_mcb[j], j);
|
||||
|
||||
GKI_init_q(&p_mcb->cmd_q);
|
||||
|
||||
@@ -203,8 +198,9 @@ void rfc_release_multiplexer_channel (tRFC_MCB *p_mcb)
|
||||
|
||||
rfc_timer_stop (p_mcb);
|
||||
|
||||
while ((p_buf = GKI_dequeue(&p_mcb->cmd_q)) != NULL)
|
||||
while ((p_buf = GKI_dequeue(&p_mcb->cmd_q)) != NULL) {
|
||||
GKI_freebuf(p_buf);
|
||||
}
|
||||
|
||||
memset (p_mcb, 0, sizeof (tRFC_MCB));
|
||||
p_mcb->state = RFC_MX_STATE_IDLE;
|
||||
@@ -293,23 +289,20 @@ void rfc_check_mcb_active (tRFC_MCB *p_mcb)
|
||||
{
|
||||
UINT16 i;
|
||||
|
||||
for (i = 0; i < RFCOMM_MAX_DLCI; i++)
|
||||
{
|
||||
if (p_mcb->port_inx[i] != 0)
|
||||
{
|
||||
for (i = 0; i < RFCOMM_MAX_DLCI; i++) {
|
||||
if (p_mcb->port_inx[i] != 0) {
|
||||
p_mcb->is_disc_initiator = FALSE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
/* The last port was DISCed. On the client side start disconnecting Mx */
|
||||
/* On the server side start inactivity timer */
|
||||
if (p_mcb->is_disc_initiator)
|
||||
{
|
||||
if (p_mcb->is_disc_initiator) {
|
||||
p_mcb->is_disc_initiator = FALSE;
|
||||
rfc_mx_sm_execute (p_mcb, RFC_MX_EVENT_CLOSE_REQ, NULL);
|
||||
}
|
||||
else
|
||||
} else {
|
||||
rfc_timer_start (p_mcb, RFC_MCB_RELEASE_INACT_TIMER);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -324,8 +317,7 @@ void rfc_check_mcb_active (tRFC_MCB *p_mcb)
|
||||
*******************************************************************************/
|
||||
void rfcomm_process_timeout (TIMER_LIST_ENT *p_tle)
|
||||
{
|
||||
switch (p_tle->event)
|
||||
{
|
||||
switch (p_tle->event) {
|
||||
case BTU_TTYPE_RFCOMM_MFC:
|
||||
rfc_mx_sm_execute ((tRFC_MCB *)p_tle->param, RFC_EVENT_TIMEOUT, NULL);
|
||||
break;
|
||||
@@ -358,9 +350,10 @@ void rfc_sec_check_complete (BD_ADDR bd_addr, tBT_TRANSPORT transport, void *p_r
|
||||
|
||||
/* Verify that PORT is still waiting for Security to complete */
|
||||
if (!p_port->in_use
|
||||
|| ((p_port->rfc.state != RFC_STATE_ORIG_WAIT_SEC_CHECK)
|
||||
&& (p_port->rfc.state != RFC_STATE_TERM_WAIT_SEC_CHECK)))
|
||||
|| ((p_port->rfc.state != RFC_STATE_ORIG_WAIT_SEC_CHECK)
|
||||
&& (p_port->rfc.state != RFC_STATE_TERM_WAIT_SEC_CHECK))) {
|
||||
return;
|
||||
}
|
||||
|
||||
rfc_port_sm_execute ((tPORT *)p_ref_data, RFC_EVENT_SEC_COMPLETE, &res);
|
||||
}
|
||||
@@ -388,8 +381,7 @@ void rfc_port_closed (tPORT *p_port)
|
||||
p_port->rfc.state = RFC_STATE_CLOSED;
|
||||
|
||||
/* If multiplexer channel was up mark it as down */
|
||||
if (p_mcb)
|
||||
{
|
||||
if (p_mcb) {
|
||||
p_mcb->port_inx[p_port->dlci] = 0;
|
||||
|
||||
/* If there are no more ports opened on this MCB release it */
|
||||
@@ -413,14 +405,14 @@ void rfc_port_closed (tPORT *p_port)
|
||||
*******************************************************************************/
|
||||
void rfc_inc_credit (tPORT *p_port, UINT8 credit)
|
||||
{
|
||||
if (p_port->rfc.p_mcb->flow == PORT_FC_CREDIT)
|
||||
{
|
||||
if (p_port->rfc.p_mcb->flow == PORT_FC_CREDIT) {
|
||||
p_port->credit_tx += credit;
|
||||
|
||||
RFCOMM_TRACE_EVENT ("rfc_inc_credit:%d", p_port->credit_tx);
|
||||
|
||||
if (p_port->tx.peer_fc == TRUE)
|
||||
if (p_port->tx.peer_fc == TRUE) {
|
||||
PORT_FlowInd(p_port->rfc.p_mcb, p_port->dlci, TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -437,13 +429,14 @@ void rfc_inc_credit (tPORT *p_port, UINT8 credit)
|
||||
*******************************************************************************/
|
||||
void rfc_dec_credit (tPORT *p_port)
|
||||
{
|
||||
if (p_port->rfc.p_mcb->flow == PORT_FC_CREDIT)
|
||||
{
|
||||
if (p_port->credit_tx > 0)
|
||||
if (p_port->rfc.p_mcb->flow == PORT_FC_CREDIT) {
|
||||
if (p_port->credit_tx > 0) {
|
||||
p_port->credit_tx--;
|
||||
}
|
||||
|
||||
if (p_port->credit_tx == 0)
|
||||
if (p_port->credit_tx == 0) {
|
||||
p_port->tx.peer_fc = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -463,16 +456,13 @@ void rfc_check_send_cmd(tRFC_MCB *p_mcb, BT_HDR *p_buf)
|
||||
BT_HDR *p;
|
||||
|
||||
/* if passed a buffer queue it */
|
||||
if (p_buf != NULL)
|
||||
{
|
||||
if (p_buf != NULL) {
|
||||
GKI_enqueue(&p_mcb->cmd_q, p_buf);
|
||||
}
|
||||
|
||||
/* handle queue if L2CAP not congested */
|
||||
while (p_mcb->l2cap_congested == FALSE)
|
||||
{
|
||||
if ((p = (BT_HDR *) GKI_dequeue(&p_mcb->cmd_q)) == NULL)
|
||||
{
|
||||
while (p_mcb->l2cap_congested == FALSE) {
|
||||
if ((p = (BT_HDR *) GKI_dequeue(&p_mcb->cmd_q)) == NULL) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user