Loading system/bta/jv/bta_jv_act.cc +12 −12 Original line number Diff line number Diff line Loading @@ -1442,7 +1442,7 @@ void bta_jv_rfcomm_connect(tBTA_SEC sec_mask, uint8_t remote_scn, const RawAddre tBTA_JV_RFCOMM_CBACK* p_cback, uint32_t rfcomm_slot_id) { uint16_t handle = 0; uint32_t event_mask = BTA_JV_RFC_EV_MASK; tPORT_STATE port_state; PortSettings port_settings; tBTA_JV bta_jv = { .rfc_cl_init = Loading Loading @@ -1485,13 +1485,13 @@ void bta_jv_rfcomm_connect(tBTA_SEC sec_mask, uint8_t remote_scn, const RawAddre if (PORT_SetDataCOCallback(handle, bta_jv_port_data_co_cback) != PORT_SUCCESS) { log::warn("Unable to set RFCOMM client data callback handle:{}", handle); } if (PORT_GetState(handle, &port_state) != PORT_SUCCESS) { if (PORT_GetSettings(handle, &port_settings) != PORT_SUCCESS) { log::warn("Unable to get RFCOMM client state handle:{}", handle); } port_state.fc_type = (PORT_FC_CTS_ON_INPUT | PORT_FC_CTS_ON_OUTPUT); port_settings.fc_type = (PORT_FC_CTS_ON_INPUT | PORT_FC_CTS_ON_OUTPUT); if (PORT_SetState(handle, &port_state) != PORT_SUCCESS) { if (PORT_SetSettings(handle, &port_settings) != PORT_SUCCESS) { log::warn("Unable to set RFCOMM client state handle:{}", handle); } Loading Loading @@ -1677,7 +1677,7 @@ static void bta_jv_port_event_sr_cback(uint32_t code, uint16_t port_handle) { static tBTA_JV_PCB* bta_jv_add_rfc_port(tBTA_JV_RFC_CB* p_cb, tBTA_JV_PCB* p_pcb_open) { uint8_t used = 0, i, listen = 0; uint32_t si = 0; tPORT_STATE port_state; PortSettings port_settings; uint32_t event_mask = BTA_JV_RFC_EV_MASK; tBTA_JV_PCB* p_pcb = NULL; tBTA_SEC sec_mask; Loading Loading @@ -1733,13 +1733,13 @@ static tBTA_JV_PCB* bta_jv_add_rfc_port(tBTA_JV_RFC_CB* p_cb, tBTA_JV_PCB* p_pcb if (PORT_SetDataCOCallback(p_pcb->port_handle, bta_jv_port_data_co_cback) != PORT_SUCCESS) { log::warn("Unable to set RFCOMM server data callback handle:{}", p_pcb->port_handle); } if (PORT_GetState(p_pcb->port_handle, &port_state) != PORT_SUCCESS) { if (PORT_GetSettings(p_pcb->port_handle, &port_settings) != PORT_SUCCESS) { log::warn("Unable to get RFCOMM server state handle:{}", p_pcb->port_handle); } port_state.fc_type = (PORT_FC_CTS_ON_INPUT | PORT_FC_CTS_ON_OUTPUT); port_settings.fc_type = (PORT_FC_CTS_ON_INPUT | PORT_FC_CTS_ON_OUTPUT); if (PORT_SetState(p_pcb->port_handle, &port_state) != PORT_SUCCESS) { if (PORT_SetSettings(p_pcb->port_handle, &port_settings) != PORT_SUCCESS) { log::warn("Unable to set RFCOMM server state handle:{}", p_pcb->port_handle); } p_pcb->handle = BTA_JV_RFC_H_S_TO_HDL(p_cb->handle, si); Loading @@ -1762,7 +1762,7 @@ void bta_jv_rfcomm_start_server(tBTA_SEC sec_mask, uint8_t local_scn, uint8_t ma tBTA_JV_RFCOMM_CBACK* p_cback, uint32_t rfcomm_slot_id) { uint16_t handle = 0; uint32_t event_mask = BTA_JV_RFC_EV_MASK; tPORT_STATE port_state; PortSettings port_settings; tBTA_JV_RFC_CB* p_cb = NULL; tBTA_JV_PCB* p_pcb; tBTA_JV_RFCOMM_START evt_data; Loading Loading @@ -1800,13 +1800,13 @@ void bta_jv_rfcomm_start_server(tBTA_SEC sec_mask, uint8_t local_scn, uint8_t ma PORT_SUCCESS) { log::warn("Unable to set RFCOMM server event mask and callback handle:{}", handle); } if (PORT_GetState(handle, &port_state) != PORT_SUCCESS) { if (PORT_GetSettings(handle, &port_settings) != PORT_SUCCESS) { log::warn("Unable to get RFCOMM server state handle:{}", handle); } port_state.fc_type = (PORT_FC_CTS_ON_INPUT | PORT_FC_CTS_ON_OUTPUT); port_settings.fc_type = (PORT_FC_CTS_ON_INPUT | PORT_FC_CTS_ON_OUTPUT); if (PORT_SetState(handle, &port_state) != PORT_SUCCESS) { if (PORT_SetSettings(handle, &port_settings) != PORT_SUCCESS) { log::warn("Unable to set RFCOMM port state handle:{}", handle); } } while (0); Loading system/stack/include/port_api.h +9 −10 Original line number Diff line number Diff line Loading @@ -38,7 +38,7 @@ * Define port settings structure send from the application in the * set settings request, or to the application in the set settings indication. */ typedef struct { struct PortSettings { #define PORT_BAUD_RATE_9600 0x03 uint8_t baud_rate; Loading Loading @@ -70,8 +70,7 @@ typedef struct { #define PORT_XOFF_DC3 0x13 uint8_t xoff_char; } tPORT_STATE; }; /* * Define the callback function prototypes. Parameters are specific Loading Loading @@ -350,28 +349,28 @@ typedef void(tPORT_MGMT_CALLBACK)(const tPORT_RESULT code, uint16_t port_handle) * Function PORT_SetState * * Description This function configures connection according to the * specifications in the tPORT_STATE structure. * specifications in the PortSettings structure. * * Parameters: handle - Handle returned in the RFCOMM_CreateConnection * p_settings - Pointer to a tPORT_STATE structure containing * p_settings - Pointer to a PortSettings structure containing * configuration information for the connection. * ******************************************************************************/ [[nodiscard]] int PORT_SetState(uint16_t handle, tPORT_STATE* p_settings); [[nodiscard]] int PORT_SetSettings(uint16_t handle, PortSettings* p_settings); /******************************************************************************* * * Function PORT_GetState * Function PORT_GetSettings * * Description This function is called to fill tPORT_STATE structure * Description This function is called to fill PortSettings structure * with the current control settings for the port * * Parameters: handle - Handle returned in the RFCOMM_CreateConnection * p_settings - Pointer to a tPORT_STATE structure in which * p_settings - Pointer to a PortSettings structure in which * configuration information is returned. * ******************************************************************************/ [[nodiscard]] int PORT_GetState(uint16_t handle, tPORT_STATE* p_settings); [[nodiscard]] int PORT_GetSettings(uint16_t handle, PortSettings* p_settings); /******************************************************************************* * Loading system/stack/rfcomm/port_api.cc +31 −32 Original line number Diff line number Diff line Loading @@ -359,7 +359,7 @@ int RFCOMM_RemoveServer(uint16_t handle) { } int PORT_SetEventMaskAndCallback(uint16_t handle, uint32_t mask, tPORT_CALLBACK* p_port_cb) { log::verbose("PORT_SetEventMask() handle:{} mask:0x{:x}", handle, mask); log::verbose("handle:{} mask:0x{:x}", handle, mask); tPORT* p_port = get_port_from_handle(handle); if (p_port == nullptr) { log::error("Unable to get RFCOMM port control block bad handle:{}", handle); Loading Loading @@ -410,7 +410,7 @@ int PORT_ClearKeepHandleFlag(uint16_t handle) { * ******************************************************************************/ int PORT_SetDataCOCallback(uint16_t handle, tPORT_DATA_CO_CALLBACK* p_port_cb) { log::verbose("PORT_SetDataCOCallback() handle:{} cb 0x{}", handle, fmt::ptr(p_port_cb)); log::verbose("handle:{} cb 0x{}", handle, fmt::ptr(p_port_cb)); tPORT* p_port = get_port_from_handle(handle); if (p_port == nullptr) { Loading Loading @@ -561,21 +561,21 @@ bool PORT_IsCollisionDetected(RawAddress bd_addr) { /******************************************************************************* * * Function PORT_SetState * Function PORT_SetSettings * * Description This function configures connection according to the * specifications in the tPORT_STATE structure. * specifications in the PortSettings structure. * * Parameters: handle - Handle returned in the RFCOMM_CreateConnection * p_settings - Pointer to a tPORT_STATE structure containing * p_settings - Pointer to a PortSettings structure containing * configuration information for the connection. * * ******************************************************************************/ int PORT_SetState(uint16_t handle, tPORT_STATE* p_settings) { int PORT_SetSettings(uint16_t handle, PortSettings* p_settings) { uint8_t baud_rate; log::verbose("PORT_SetState() handle:{}", handle); log::verbose("handle:{}", handle); tPORT* p_port = get_port_from_handle(handle); if (p_port == nullptr) { log::error("Unable to get RFCOMM port control block bad handle:{}", handle); Loading @@ -590,10 +590,10 @@ int PORT_SetState(uint16_t handle, tPORT_STATE* p_settings) { return PORT_LINE_ERR; } log::verbose("PORT_SetState() handle:{} FC_TYPE:0x{:x}", handle, p_settings->fc_type); log::verbose("handle:{} FC_TYPE:0x{:x}", handle, p_settings->fc_type); baud_rate = p_port->user_port_pars.baud_rate; p_port->user_port_pars = *p_settings; baud_rate = p_port->user_port_settings.baud_rate; p_port->user_port_settings = *p_settings; /* for now we've been asked to pass only baud rate */ if (baud_rate != p_settings->baud_rate) { Loading @@ -604,18 +604,18 @@ int PORT_SetState(uint16_t handle, tPORT_STATE* p_settings) { /******************************************************************************* * * Function PORT_GetState * Function PORT_GetSettings * * Description This function is called to fill tPORT_STATE structure * Description This function is called to fill PortSettings structure * with the curremt control settings for the port * * Parameters: handle - Handle returned in the RFCOMM_CreateConnection * p_settings - Pointer to a tPORT_STATE structure in which * p_settings - Pointer to a PortSettings structure in which * configuration information is returned. * ******************************************************************************/ int PORT_GetState(uint16_t handle, tPORT_STATE* p_settings) { log::verbose("PORT_GetState() handle:{}", handle); int PORT_GetSettings(uint16_t handle, PortSettings* p_settings) { log::verbose("handle:{}", handle); tPORT* p_port = get_port_from_handle(handle); if (p_port == nullptr) { Loading @@ -631,7 +631,7 @@ int PORT_GetState(uint16_t handle, tPORT_STATE* p_settings) { return PORT_LINE_ERR; } *p_settings = p_port->user_port_pars; *p_settings = p_port->user_port_settings; return PORT_SUCCESS; } Loading @@ -653,7 +653,7 @@ int PORT_FlowControl_MaxCredit(uint16_t handle, bool enable) { bool old_fc; uint32_t events; log::verbose("PORT_FlowControl() handle:{} enable: {}", handle, enable); log::verbose("handle:{} enable: {}", handle, enable); tPORT* p_port = get_port_from_handle(handle); if (p_port == nullptr) { Loading Loading @@ -720,7 +720,7 @@ int PORT_ReadData(uint16_t handle, char* p_data, uint16_t max_len, uint16_t* p_l BT_HDR* p_buf; uint16_t count; log::verbose("PORT_ReadData() handle:{} max_len:{}", handle, max_len); log::verbose("handle:{} max_len:{}", handle, max_len); /* Initialize this in case of an error */ *p_len = 0; Loading Loading @@ -793,10 +793,9 @@ int PORT_ReadData(uint16_t handle, char* p_data, uint16_t max_len, uint16_t* p_l } if (*p_len == 1) { log::verbose("PORT_ReadData queue:{} returned:{} {:x}", p_port->rx.queue_size, *p_len, p_data[0]); log::verbose("queue:{} returned:{} {:x}", p_port->rx.queue_size, *p_len, p_data[0]); } else { log::verbose("PORT_ReadData queue:{} returned:{}", p_port->rx.queue_size, *p_len); log::verbose("queue:{} returned:{}", p_port->rx.queue_size, *p_len); } /* If rfcomm suspended traffic from the peer based on the rx_queue_size */ Loading Loading @@ -834,7 +833,7 @@ static int port_write(tPORT* p_port, BT_HDR* p_buf) { (PORT_CTRL_REQ_SENT | PORT_CTRL_IND_RECEIVED))) { if ((p_port->tx.queue_size > PORT_TX_CRITICAL_WM) || (fixed_queue_length(p_port->tx.queue) > PORT_TX_BUF_CRITICAL_WM)) { log::warn("PORT_Write: Queue size: {}", p_port->tx.queue_size); log::warn("Queue size: {}", p_port->tx.queue_size); osi_free(p_buf); Loading @@ -846,7 +845,7 @@ static int port_write(tPORT* p_port, BT_HDR* p_buf) { } log::verbose( "PORT_Write : Data is enqueued. flow disabled {} peer_ready {} state {} ctrl_state " "Data is enqueued. flow disabled {} peer_ready {} state {} ctrl_state " "{:x}", p_port->tx.peer_fc, p_port->rfc.p_mcb && p_port->rfc.p_mcb->peer_ready, p_port->rfc.state, p_port->port_ctrl); Loading @@ -856,7 +855,7 @@ static int port_write(tPORT* p_port, BT_HDR* p_buf) { return PORT_CMD_PENDING; } else { log::verbose("PORT_Write : Data is being sent"); log::verbose("Data is being sent"); RFCOMM_DataReq(p_port->rfc.p_mcb, p_port->dlci, p_buf); return PORT_SUCCESS; Loading @@ -881,7 +880,7 @@ int PORT_WriteDataCO(uint16_t handle, int* p_len) { int rc = 0; uint16_t length; log::verbose("PORT_WriteDataCO() handle:{}", handle); log::verbose("handle:{}", handle); *p_len = 0; tPORT* p_port = get_port_from_handle(handle); Loading @@ -891,12 +890,12 @@ int PORT_WriteDataCO(uint16_t handle, int* p_len) { } if (!p_port->in_use || (p_port->state == PORT_CONNECTION_STATE_CLOSED)) { log::warn("PORT_WriteDataByFd() no port state:{}", p_port->state); log::warn("no port state:{}", p_port->state); return PORT_NOT_OPENED; } if (!p_port->peer_mtu) { log::error("PORT_WriteDataByFd() peer_mtu:{}", p_port->peer_mtu); log::error("peer_mtu:{}", p_port->peer_mtu); return PORT_UNKNOWN_ERROR; } int available = 0; Loading Loading @@ -983,7 +982,7 @@ int PORT_WriteDataCO(uint16_t handle, int* p_len) { return PORT_UNKNOWN_ERROR; } log::verbose("PORT_WriteData {} bytes", length); log::verbose("{} bytes", length); rc = port_write(p_port, p_buf); Loading Loading @@ -1035,7 +1034,7 @@ int PORT_WriteData(uint16_t handle, const char* p_data, uint16_t max_len, uint16 int rc = 0; uint16_t length; log::verbose("PORT_WriteData() max_len:{}", max_len); log::verbose("max_len:{}", max_len); *p_len = 0; Loading @@ -1046,7 +1045,7 @@ int PORT_WriteData(uint16_t handle, const char* p_data, uint16_t max_len, uint16 } if (!p_port->in_use || (p_port->state == PORT_CONNECTION_STATE_CLOSED)) { log::warn("PORT_WriteData() no port state:{}", p_port->state); log::warn("no port state:{}", p_port->state); return PORT_NOT_OPENED; } Loading @@ -1055,7 +1054,7 @@ int PORT_WriteData(uint16_t handle, const char* p_data, uint16_t max_len, uint16 } if (!max_len || !p_port->peer_mtu) { log::error("PORT_WriteData() peer_mtu:{}", p_port->peer_mtu); log::error("peer_mtu:{}", p_port->peer_mtu); return PORT_UNKNOWN_ERROR; } Loading Loading @@ -1107,7 +1106,7 @@ int PORT_WriteData(uint16_t handle, const char* p_data, uint16_t max_len, uint16 memcpy((uint8_t*)(p_buf + 1) + p_buf->offset, p_data, length); log::verbose("PORT_WriteData {} bytes", length); log::verbose("{} bytes", length); rc = port_write(p_port, p_buf); Loading system/stack/rfcomm/port_int.h +2 −2 Original line number Diff line number Diff line Loading @@ -172,8 +172,8 @@ typedef struct { tPORT_DATA tx; /* Control block for data from app to peer */ tPORT_DATA rx; /* Control block for data from peer to app */ tPORT_STATE user_port_pars; /* Port parameters for user connection */ tPORT_STATE peer_port_pars; /* Port parameters for user connection */ PortSettings user_port_settings; /* Port parameters for user connection */ PortSettings peer_port_settings; /* Port parameters for peer connection */ tPORT_CTRL local_ctrl; tPORT_CTRL peer_ctrl; Loading system/stack/rfcomm/port_rfc.cc +9 −7 Original line number Diff line number Diff line Loading @@ -142,7 +142,7 @@ void port_start_par_neg(tPORT* p_port) { return; } RFCOMM_PortParameterNegotiationRequest(p_mcb, p_port->dlci, &p_port->user_port_pars); RFCOMM_PortParameterNegotiationRequest(p_mcb, p_port->dlci, &p_port->user_port_settings); } /******************************************************************************* Loading Loading @@ -519,7 +519,7 @@ void PORT_DlcEstablishCnf(tRFC_MCB* p_mcb, uint8_t dlci, uint16_t mtu, uint16_t * allocated before meaning that application already made open. * ******************************************************************************/ void PORT_PortNegInd(tRFC_MCB* p_mcb, uint8_t dlci, tPORT_STATE* p_pars, uint16_t param_mask) { void PORT_PortNegInd(tRFC_MCB* p_mcb, uint8_t dlci, PortSettings* p_settings, uint16_t param_mask) { tPORT* p_port = port_find_mcb_dlci_port(p_mcb, dlci); log::verbose("PORT_PortNegInd"); Loading @@ -528,15 +528,15 @@ void PORT_PortNegInd(tRFC_MCB* p_mcb, uint8_t dlci, tPORT_STATE* p_pars, uint16_ /* This can be a first request for this port */ p_port = port_find_dlci_port(dlci); if (!p_port) { RFCOMM_PortParameterNegotiationResponse(p_mcb, dlci, p_pars, 0); RFCOMM_PortParameterNegotiationResponse(p_mcb, dlci, p_settings, 0); return; } p_mcb->port_handles[dlci] = p_port->handle; } /* Check if the flow control is acceptable on local side */ p_port->peer_port_pars = *p_pars; RFCOMM_PortParameterNegotiationResponse(p_mcb, dlci, p_pars, param_mask); p_port->peer_port_settings = *p_settings; RFCOMM_PortParameterNegotiationResponse(p_mcb, dlci, p_settings, param_mask); } /******************************************************************************* Loading @@ -547,7 +547,8 @@ void PORT_PortNegInd(tRFC_MCB* p_mcb, uint8_t dlci, tPORT_STATE* p_pars, uint16_ * state for the port. Propagate change to the user. * ******************************************************************************/ void PORT_PortNegCnf(tRFC_MCB* p_mcb, uint8_t dlci, tPORT_STATE* /* p_pars */, uint16_t result) { void PORT_PortNegCnf(tRFC_MCB* p_mcb, uint8_t dlci, PortSettings* /* p_settings */, uint16_t result) { tPORT* p_port = port_find_mcb_dlci_port(p_mcb, dlci); log::verbose("PORT_PortNegCnf"); Loading Loading @@ -822,7 +823,8 @@ void PORT_DataInd(tRFC_MCB* p_mcb, uint8_t dlci, BT_HDR* p_buf) { } /* If user registered to receive notification when a particular byte is */ /* received we mast check all received bytes */ if (((rx_char1 = p_port->user_port_pars.rx_char1) != 0) && (p_port->ev_mask & PORT_EV_RXFLAG)) { if (((rx_char1 = p_port->user_port_settings.rx_char1) != 0) && (p_port->ev_mask & PORT_EV_RXFLAG)) { for (i = 0, p = (uint8_t*)(p_buf + 1) + p_buf->offset; i < p_buf->len; i++) { if (*p++ == rx_char1) { events |= PORT_EV_RXFLAG; Loading Loading
system/bta/jv/bta_jv_act.cc +12 −12 Original line number Diff line number Diff line Loading @@ -1442,7 +1442,7 @@ void bta_jv_rfcomm_connect(tBTA_SEC sec_mask, uint8_t remote_scn, const RawAddre tBTA_JV_RFCOMM_CBACK* p_cback, uint32_t rfcomm_slot_id) { uint16_t handle = 0; uint32_t event_mask = BTA_JV_RFC_EV_MASK; tPORT_STATE port_state; PortSettings port_settings; tBTA_JV bta_jv = { .rfc_cl_init = Loading Loading @@ -1485,13 +1485,13 @@ void bta_jv_rfcomm_connect(tBTA_SEC sec_mask, uint8_t remote_scn, const RawAddre if (PORT_SetDataCOCallback(handle, bta_jv_port_data_co_cback) != PORT_SUCCESS) { log::warn("Unable to set RFCOMM client data callback handle:{}", handle); } if (PORT_GetState(handle, &port_state) != PORT_SUCCESS) { if (PORT_GetSettings(handle, &port_settings) != PORT_SUCCESS) { log::warn("Unable to get RFCOMM client state handle:{}", handle); } port_state.fc_type = (PORT_FC_CTS_ON_INPUT | PORT_FC_CTS_ON_OUTPUT); port_settings.fc_type = (PORT_FC_CTS_ON_INPUT | PORT_FC_CTS_ON_OUTPUT); if (PORT_SetState(handle, &port_state) != PORT_SUCCESS) { if (PORT_SetSettings(handle, &port_settings) != PORT_SUCCESS) { log::warn("Unable to set RFCOMM client state handle:{}", handle); } Loading Loading @@ -1677,7 +1677,7 @@ static void bta_jv_port_event_sr_cback(uint32_t code, uint16_t port_handle) { static tBTA_JV_PCB* bta_jv_add_rfc_port(tBTA_JV_RFC_CB* p_cb, tBTA_JV_PCB* p_pcb_open) { uint8_t used = 0, i, listen = 0; uint32_t si = 0; tPORT_STATE port_state; PortSettings port_settings; uint32_t event_mask = BTA_JV_RFC_EV_MASK; tBTA_JV_PCB* p_pcb = NULL; tBTA_SEC sec_mask; Loading Loading @@ -1733,13 +1733,13 @@ static tBTA_JV_PCB* bta_jv_add_rfc_port(tBTA_JV_RFC_CB* p_cb, tBTA_JV_PCB* p_pcb if (PORT_SetDataCOCallback(p_pcb->port_handle, bta_jv_port_data_co_cback) != PORT_SUCCESS) { log::warn("Unable to set RFCOMM server data callback handle:{}", p_pcb->port_handle); } if (PORT_GetState(p_pcb->port_handle, &port_state) != PORT_SUCCESS) { if (PORT_GetSettings(p_pcb->port_handle, &port_settings) != PORT_SUCCESS) { log::warn("Unable to get RFCOMM server state handle:{}", p_pcb->port_handle); } port_state.fc_type = (PORT_FC_CTS_ON_INPUT | PORT_FC_CTS_ON_OUTPUT); port_settings.fc_type = (PORT_FC_CTS_ON_INPUT | PORT_FC_CTS_ON_OUTPUT); if (PORT_SetState(p_pcb->port_handle, &port_state) != PORT_SUCCESS) { if (PORT_SetSettings(p_pcb->port_handle, &port_settings) != PORT_SUCCESS) { log::warn("Unable to set RFCOMM server state handle:{}", p_pcb->port_handle); } p_pcb->handle = BTA_JV_RFC_H_S_TO_HDL(p_cb->handle, si); Loading @@ -1762,7 +1762,7 @@ void bta_jv_rfcomm_start_server(tBTA_SEC sec_mask, uint8_t local_scn, uint8_t ma tBTA_JV_RFCOMM_CBACK* p_cback, uint32_t rfcomm_slot_id) { uint16_t handle = 0; uint32_t event_mask = BTA_JV_RFC_EV_MASK; tPORT_STATE port_state; PortSettings port_settings; tBTA_JV_RFC_CB* p_cb = NULL; tBTA_JV_PCB* p_pcb; tBTA_JV_RFCOMM_START evt_data; Loading Loading @@ -1800,13 +1800,13 @@ void bta_jv_rfcomm_start_server(tBTA_SEC sec_mask, uint8_t local_scn, uint8_t ma PORT_SUCCESS) { log::warn("Unable to set RFCOMM server event mask and callback handle:{}", handle); } if (PORT_GetState(handle, &port_state) != PORT_SUCCESS) { if (PORT_GetSettings(handle, &port_settings) != PORT_SUCCESS) { log::warn("Unable to get RFCOMM server state handle:{}", handle); } port_state.fc_type = (PORT_FC_CTS_ON_INPUT | PORT_FC_CTS_ON_OUTPUT); port_settings.fc_type = (PORT_FC_CTS_ON_INPUT | PORT_FC_CTS_ON_OUTPUT); if (PORT_SetState(handle, &port_state) != PORT_SUCCESS) { if (PORT_SetSettings(handle, &port_settings) != PORT_SUCCESS) { log::warn("Unable to set RFCOMM port state handle:{}", handle); } } while (0); Loading
system/stack/include/port_api.h +9 −10 Original line number Diff line number Diff line Loading @@ -38,7 +38,7 @@ * Define port settings structure send from the application in the * set settings request, or to the application in the set settings indication. */ typedef struct { struct PortSettings { #define PORT_BAUD_RATE_9600 0x03 uint8_t baud_rate; Loading Loading @@ -70,8 +70,7 @@ typedef struct { #define PORT_XOFF_DC3 0x13 uint8_t xoff_char; } tPORT_STATE; }; /* * Define the callback function prototypes. Parameters are specific Loading Loading @@ -350,28 +349,28 @@ typedef void(tPORT_MGMT_CALLBACK)(const tPORT_RESULT code, uint16_t port_handle) * Function PORT_SetState * * Description This function configures connection according to the * specifications in the tPORT_STATE structure. * specifications in the PortSettings structure. * * Parameters: handle - Handle returned in the RFCOMM_CreateConnection * p_settings - Pointer to a tPORT_STATE structure containing * p_settings - Pointer to a PortSettings structure containing * configuration information for the connection. * ******************************************************************************/ [[nodiscard]] int PORT_SetState(uint16_t handle, tPORT_STATE* p_settings); [[nodiscard]] int PORT_SetSettings(uint16_t handle, PortSettings* p_settings); /******************************************************************************* * * Function PORT_GetState * Function PORT_GetSettings * * Description This function is called to fill tPORT_STATE structure * Description This function is called to fill PortSettings structure * with the current control settings for the port * * Parameters: handle - Handle returned in the RFCOMM_CreateConnection * p_settings - Pointer to a tPORT_STATE structure in which * p_settings - Pointer to a PortSettings structure in which * configuration information is returned. * ******************************************************************************/ [[nodiscard]] int PORT_GetState(uint16_t handle, tPORT_STATE* p_settings); [[nodiscard]] int PORT_GetSettings(uint16_t handle, PortSettings* p_settings); /******************************************************************************* * Loading
system/stack/rfcomm/port_api.cc +31 −32 Original line number Diff line number Diff line Loading @@ -359,7 +359,7 @@ int RFCOMM_RemoveServer(uint16_t handle) { } int PORT_SetEventMaskAndCallback(uint16_t handle, uint32_t mask, tPORT_CALLBACK* p_port_cb) { log::verbose("PORT_SetEventMask() handle:{} mask:0x{:x}", handle, mask); log::verbose("handle:{} mask:0x{:x}", handle, mask); tPORT* p_port = get_port_from_handle(handle); if (p_port == nullptr) { log::error("Unable to get RFCOMM port control block bad handle:{}", handle); Loading Loading @@ -410,7 +410,7 @@ int PORT_ClearKeepHandleFlag(uint16_t handle) { * ******************************************************************************/ int PORT_SetDataCOCallback(uint16_t handle, tPORT_DATA_CO_CALLBACK* p_port_cb) { log::verbose("PORT_SetDataCOCallback() handle:{} cb 0x{}", handle, fmt::ptr(p_port_cb)); log::verbose("handle:{} cb 0x{}", handle, fmt::ptr(p_port_cb)); tPORT* p_port = get_port_from_handle(handle); if (p_port == nullptr) { Loading Loading @@ -561,21 +561,21 @@ bool PORT_IsCollisionDetected(RawAddress bd_addr) { /******************************************************************************* * * Function PORT_SetState * Function PORT_SetSettings * * Description This function configures connection according to the * specifications in the tPORT_STATE structure. * specifications in the PortSettings structure. * * Parameters: handle - Handle returned in the RFCOMM_CreateConnection * p_settings - Pointer to a tPORT_STATE structure containing * p_settings - Pointer to a PortSettings structure containing * configuration information for the connection. * * ******************************************************************************/ int PORT_SetState(uint16_t handle, tPORT_STATE* p_settings) { int PORT_SetSettings(uint16_t handle, PortSettings* p_settings) { uint8_t baud_rate; log::verbose("PORT_SetState() handle:{}", handle); log::verbose("handle:{}", handle); tPORT* p_port = get_port_from_handle(handle); if (p_port == nullptr) { log::error("Unable to get RFCOMM port control block bad handle:{}", handle); Loading @@ -590,10 +590,10 @@ int PORT_SetState(uint16_t handle, tPORT_STATE* p_settings) { return PORT_LINE_ERR; } log::verbose("PORT_SetState() handle:{} FC_TYPE:0x{:x}", handle, p_settings->fc_type); log::verbose("handle:{} FC_TYPE:0x{:x}", handle, p_settings->fc_type); baud_rate = p_port->user_port_pars.baud_rate; p_port->user_port_pars = *p_settings; baud_rate = p_port->user_port_settings.baud_rate; p_port->user_port_settings = *p_settings; /* for now we've been asked to pass only baud rate */ if (baud_rate != p_settings->baud_rate) { Loading @@ -604,18 +604,18 @@ int PORT_SetState(uint16_t handle, tPORT_STATE* p_settings) { /******************************************************************************* * * Function PORT_GetState * Function PORT_GetSettings * * Description This function is called to fill tPORT_STATE structure * Description This function is called to fill PortSettings structure * with the curremt control settings for the port * * Parameters: handle - Handle returned in the RFCOMM_CreateConnection * p_settings - Pointer to a tPORT_STATE structure in which * p_settings - Pointer to a PortSettings structure in which * configuration information is returned. * ******************************************************************************/ int PORT_GetState(uint16_t handle, tPORT_STATE* p_settings) { log::verbose("PORT_GetState() handle:{}", handle); int PORT_GetSettings(uint16_t handle, PortSettings* p_settings) { log::verbose("handle:{}", handle); tPORT* p_port = get_port_from_handle(handle); if (p_port == nullptr) { Loading @@ -631,7 +631,7 @@ int PORT_GetState(uint16_t handle, tPORT_STATE* p_settings) { return PORT_LINE_ERR; } *p_settings = p_port->user_port_pars; *p_settings = p_port->user_port_settings; return PORT_SUCCESS; } Loading @@ -653,7 +653,7 @@ int PORT_FlowControl_MaxCredit(uint16_t handle, bool enable) { bool old_fc; uint32_t events; log::verbose("PORT_FlowControl() handle:{} enable: {}", handle, enable); log::verbose("handle:{} enable: {}", handle, enable); tPORT* p_port = get_port_from_handle(handle); if (p_port == nullptr) { Loading Loading @@ -720,7 +720,7 @@ int PORT_ReadData(uint16_t handle, char* p_data, uint16_t max_len, uint16_t* p_l BT_HDR* p_buf; uint16_t count; log::verbose("PORT_ReadData() handle:{} max_len:{}", handle, max_len); log::verbose("handle:{} max_len:{}", handle, max_len); /* Initialize this in case of an error */ *p_len = 0; Loading Loading @@ -793,10 +793,9 @@ int PORT_ReadData(uint16_t handle, char* p_data, uint16_t max_len, uint16_t* p_l } if (*p_len == 1) { log::verbose("PORT_ReadData queue:{} returned:{} {:x}", p_port->rx.queue_size, *p_len, p_data[0]); log::verbose("queue:{} returned:{} {:x}", p_port->rx.queue_size, *p_len, p_data[0]); } else { log::verbose("PORT_ReadData queue:{} returned:{}", p_port->rx.queue_size, *p_len); log::verbose("queue:{} returned:{}", p_port->rx.queue_size, *p_len); } /* If rfcomm suspended traffic from the peer based on the rx_queue_size */ Loading Loading @@ -834,7 +833,7 @@ static int port_write(tPORT* p_port, BT_HDR* p_buf) { (PORT_CTRL_REQ_SENT | PORT_CTRL_IND_RECEIVED))) { if ((p_port->tx.queue_size > PORT_TX_CRITICAL_WM) || (fixed_queue_length(p_port->tx.queue) > PORT_TX_BUF_CRITICAL_WM)) { log::warn("PORT_Write: Queue size: {}", p_port->tx.queue_size); log::warn("Queue size: {}", p_port->tx.queue_size); osi_free(p_buf); Loading @@ -846,7 +845,7 @@ static int port_write(tPORT* p_port, BT_HDR* p_buf) { } log::verbose( "PORT_Write : Data is enqueued. flow disabled {} peer_ready {} state {} ctrl_state " "Data is enqueued. flow disabled {} peer_ready {} state {} ctrl_state " "{:x}", p_port->tx.peer_fc, p_port->rfc.p_mcb && p_port->rfc.p_mcb->peer_ready, p_port->rfc.state, p_port->port_ctrl); Loading @@ -856,7 +855,7 @@ static int port_write(tPORT* p_port, BT_HDR* p_buf) { return PORT_CMD_PENDING; } else { log::verbose("PORT_Write : Data is being sent"); log::verbose("Data is being sent"); RFCOMM_DataReq(p_port->rfc.p_mcb, p_port->dlci, p_buf); return PORT_SUCCESS; Loading @@ -881,7 +880,7 @@ int PORT_WriteDataCO(uint16_t handle, int* p_len) { int rc = 0; uint16_t length; log::verbose("PORT_WriteDataCO() handle:{}", handle); log::verbose("handle:{}", handle); *p_len = 0; tPORT* p_port = get_port_from_handle(handle); Loading @@ -891,12 +890,12 @@ int PORT_WriteDataCO(uint16_t handle, int* p_len) { } if (!p_port->in_use || (p_port->state == PORT_CONNECTION_STATE_CLOSED)) { log::warn("PORT_WriteDataByFd() no port state:{}", p_port->state); log::warn("no port state:{}", p_port->state); return PORT_NOT_OPENED; } if (!p_port->peer_mtu) { log::error("PORT_WriteDataByFd() peer_mtu:{}", p_port->peer_mtu); log::error("peer_mtu:{}", p_port->peer_mtu); return PORT_UNKNOWN_ERROR; } int available = 0; Loading Loading @@ -983,7 +982,7 @@ int PORT_WriteDataCO(uint16_t handle, int* p_len) { return PORT_UNKNOWN_ERROR; } log::verbose("PORT_WriteData {} bytes", length); log::verbose("{} bytes", length); rc = port_write(p_port, p_buf); Loading Loading @@ -1035,7 +1034,7 @@ int PORT_WriteData(uint16_t handle, const char* p_data, uint16_t max_len, uint16 int rc = 0; uint16_t length; log::verbose("PORT_WriteData() max_len:{}", max_len); log::verbose("max_len:{}", max_len); *p_len = 0; Loading @@ -1046,7 +1045,7 @@ int PORT_WriteData(uint16_t handle, const char* p_data, uint16_t max_len, uint16 } if (!p_port->in_use || (p_port->state == PORT_CONNECTION_STATE_CLOSED)) { log::warn("PORT_WriteData() no port state:{}", p_port->state); log::warn("no port state:{}", p_port->state); return PORT_NOT_OPENED; } Loading @@ -1055,7 +1054,7 @@ int PORT_WriteData(uint16_t handle, const char* p_data, uint16_t max_len, uint16 } if (!max_len || !p_port->peer_mtu) { log::error("PORT_WriteData() peer_mtu:{}", p_port->peer_mtu); log::error("peer_mtu:{}", p_port->peer_mtu); return PORT_UNKNOWN_ERROR; } Loading Loading @@ -1107,7 +1106,7 @@ int PORT_WriteData(uint16_t handle, const char* p_data, uint16_t max_len, uint16 memcpy((uint8_t*)(p_buf + 1) + p_buf->offset, p_data, length); log::verbose("PORT_WriteData {} bytes", length); log::verbose("{} bytes", length); rc = port_write(p_port, p_buf); Loading
system/stack/rfcomm/port_int.h +2 −2 Original line number Diff line number Diff line Loading @@ -172,8 +172,8 @@ typedef struct { tPORT_DATA tx; /* Control block for data from app to peer */ tPORT_DATA rx; /* Control block for data from peer to app */ tPORT_STATE user_port_pars; /* Port parameters for user connection */ tPORT_STATE peer_port_pars; /* Port parameters for user connection */ PortSettings user_port_settings; /* Port parameters for user connection */ PortSettings peer_port_settings; /* Port parameters for peer connection */ tPORT_CTRL local_ctrl; tPORT_CTRL peer_ctrl; Loading
system/stack/rfcomm/port_rfc.cc +9 −7 Original line number Diff line number Diff line Loading @@ -142,7 +142,7 @@ void port_start_par_neg(tPORT* p_port) { return; } RFCOMM_PortParameterNegotiationRequest(p_mcb, p_port->dlci, &p_port->user_port_pars); RFCOMM_PortParameterNegotiationRequest(p_mcb, p_port->dlci, &p_port->user_port_settings); } /******************************************************************************* Loading Loading @@ -519,7 +519,7 @@ void PORT_DlcEstablishCnf(tRFC_MCB* p_mcb, uint8_t dlci, uint16_t mtu, uint16_t * allocated before meaning that application already made open. * ******************************************************************************/ void PORT_PortNegInd(tRFC_MCB* p_mcb, uint8_t dlci, tPORT_STATE* p_pars, uint16_t param_mask) { void PORT_PortNegInd(tRFC_MCB* p_mcb, uint8_t dlci, PortSettings* p_settings, uint16_t param_mask) { tPORT* p_port = port_find_mcb_dlci_port(p_mcb, dlci); log::verbose("PORT_PortNegInd"); Loading @@ -528,15 +528,15 @@ void PORT_PortNegInd(tRFC_MCB* p_mcb, uint8_t dlci, tPORT_STATE* p_pars, uint16_ /* This can be a first request for this port */ p_port = port_find_dlci_port(dlci); if (!p_port) { RFCOMM_PortParameterNegotiationResponse(p_mcb, dlci, p_pars, 0); RFCOMM_PortParameterNegotiationResponse(p_mcb, dlci, p_settings, 0); return; } p_mcb->port_handles[dlci] = p_port->handle; } /* Check if the flow control is acceptable on local side */ p_port->peer_port_pars = *p_pars; RFCOMM_PortParameterNegotiationResponse(p_mcb, dlci, p_pars, param_mask); p_port->peer_port_settings = *p_settings; RFCOMM_PortParameterNegotiationResponse(p_mcb, dlci, p_settings, param_mask); } /******************************************************************************* Loading @@ -547,7 +547,8 @@ void PORT_PortNegInd(tRFC_MCB* p_mcb, uint8_t dlci, tPORT_STATE* p_pars, uint16_ * state for the port. Propagate change to the user. * ******************************************************************************/ void PORT_PortNegCnf(tRFC_MCB* p_mcb, uint8_t dlci, tPORT_STATE* /* p_pars */, uint16_t result) { void PORT_PortNegCnf(tRFC_MCB* p_mcb, uint8_t dlci, PortSettings* /* p_settings */, uint16_t result) { tPORT* p_port = port_find_mcb_dlci_port(p_mcb, dlci); log::verbose("PORT_PortNegCnf"); Loading Loading @@ -822,7 +823,8 @@ void PORT_DataInd(tRFC_MCB* p_mcb, uint8_t dlci, BT_HDR* p_buf) { } /* If user registered to receive notification when a particular byte is */ /* received we mast check all received bytes */ if (((rx_char1 = p_port->user_port_pars.rx_char1) != 0) && (p_port->ev_mask & PORT_EV_RXFLAG)) { if (((rx_char1 = p_port->user_port_settings.rx_char1) != 0) && (p_port->ev_mask & PORT_EV_RXFLAG)) { for (i = 0, p = (uint8_t*)(p_buf + 1) + p_buf->offset; i < p_buf->len; i++) { if (*p++ == rx_char1) { events |= PORT_EV_RXFLAG; Loading