Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 17790ae5 authored by Hsin-chen Chuang's avatar Hsin-chen Chuang
Browse files

btif_sock: Add control_req interface

RFCOMM layer automatically starts the control request only when it is
the client.

RFCOMM/DEVA-DEVB/RFC/BV-21-C and RFCOMM/DEVA-DEVB/RFC/BV-22-C require
the IUT to be as the RFCOMM server and also the initiator of the flow
control, this patch unblocks the 2 tests.

Bug: 278505039
Tag: #floss
Test: together with the later CLs
Change-Id: I01f41305458fae839891c13b80286e4296929428
parent e375009b
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -32,6 +32,10 @@
#include "types/raw_address.h"
bt_status_t btsock_rfc_init(int handle, uid_set_t* set);
bt_status_t btsock_rfc_cleanup();
bt_status_t btsock_rfc_control_req(uint8_t dlci, const RawAddress& bd_addr,
                                   uint8_t modem_signal, uint8_t break_signal,
                                   uint8_t discard_buffers,
                                   uint8_t break_signal_seq, bool fc);
bt_status_t btsock_rfc_listen(const char* name, const bluetooth::Uuid* uuid,
                              int channel, int* sock_fd, int flags,
                              int app_uid);
+18 −3
Original line number Diff line number Diff line
@@ -57,6 +57,11 @@ static bt_status_t btsock_connect(const RawAddress* bd_addr, btsock_type_t type,
                                  int flags, int app_uid);

static void btsock_request_max_tx_data_length(const RawAddress& bd_addr);
static bt_status_t btsock_control_req(uint8_t dlci, const RawAddress& bd_addr,
                                      uint8_t modem_signal,
                                      uint8_t break_signal,
                                      uint8_t discard_buffers,
                                      uint8_t break_signal_seq, bool fc);

static void btsock_signaled(int fd, int type, int flags, uint32_t user_id);

@@ -83,7 +88,8 @@ const btsock_interface_t* btif_sock_get_interface(void) {
  static btsock_interface_t interface = {
      sizeof(interface), btsock_listen,  /* listen */
      btsock_connect,                    /* connect */
      btsock_request_max_tx_data_length /* request_max_tx_data_length */
      btsock_request_max_tx_data_length, /* request_max_tx_data_length */
      btsock_control_req                 /* send_control_req */
  };

  return &interface;
@@ -232,6 +238,15 @@ void SockConnectionEvent::dump(const int fd) {
          ADDRESS_TO_LOGGABLE_CSTR(addr), str_state, str_role);
}

static bt_status_t btsock_control_req(uint8_t dlci, const RawAddress& bd_addr,
                                      uint8_t modem_signal,
                                      uint8_t break_signal,
                                      uint8_t discard_buffers,
                                      uint8_t break_signal_seq, bool fc) {
  return btsock_rfc_control_req(dlci, bd_addr, modem_signal, break_signal,
                                discard_buffers, break_signal_seq, fc);
}

static bt_status_t btsock_listen(btsock_type_t type, const char* service_name,
                                 const Uuid* service_uuid, int channel,
                                 int* sock_fd, int flags, int app_uid) {
+14 −0
Original line number Diff line number Diff line
@@ -265,6 +265,20 @@ static rfc_slot_t* create_srv_accept_rfc_slot(rfc_slot_t* srv_rs,
  return accept_rs;
}

bt_status_t btsock_rfc_control_req(uint8_t dlci, const RawAddress& bd_addr,
                                   uint8_t modem_signal, uint8_t break_signal,
                                   uint8_t discard_buffers,
                                   uint8_t break_signal_seq, bool fc) {
  int status =
      RFCOMM_ControlReqFromBTSOCK(dlci, bd_addr, modem_signal, break_signal,
                                  discard_buffers, break_signal_seq, fc);
  if (status != PORT_SUCCESS) {
    LOG_WARN("failed to send control parameters, status=%d", status);
    return BT_STATUS_FAIL;
  }
  return BT_STATUS_SUCCESS;
}

bt_status_t btsock_rfc_listen(const char* service_name,
                              const Uuid* service_uuid, int channel,
                              int* sock_fd, int flags, int app_uid) {
+11 −0
Original line number Diff line number Diff line
@@ -90,6 +90,17 @@ typedef struct {
   */
  void (*request_max_tx_data_length)(const RawAddress& bd_addr);

  /**
   * Send control parameters to the peer. So far only for qualification use.
   * RFCOMM layer starts the control request only when it is the client.
   * This API allows the host to start the control request while it works as an
   * RFCOMM server.
   */
  bt_status_t (*control_req)(uint8_t dlci, const RawAddress& bd_addr,
                             uint8_t modem_signal, uint8_t break_signal,
                             uint8_t discard_buffers, uint8_t break_signal_seq,
                             bool fc);

} btsock_interface_t;

__END_DECLS
+26 −0
Original line number Diff line number Diff line
@@ -191,6 +191,32 @@ int RFCOMM_CreateConnectionWithSecurity(uint16_t uuid, uint8_t scn,
                                        tPORT_CALLBACK* p_mgmt_cb,
                                        uint16_t sec_mask);

/*******************************************************************************
 *
 * Function         RFCOMM_ControlReqFromBTSOCK
 *
 * Description      Send control parameters to the peer.
 *                  So far only for qualification use.
 *                  RFCOMM layer starts the control request only when it is the
 *                  client. This API allows the host to start the control
 *                  request while it works as a RFCOMM server.
 *
 * Parameters:      dlci             - the DLCI to send the MSC command
 *                  bd_addr          - bd_addr of the peer
 *                  modem_signal     - [DTR/DSR | RTS/CTS | RI | DCD]
 *                  break_signal     - 0-3 s in steps of 200 ms
 *                  discard_buffers  - 0 for do not discard, 1 for discard
 *                  break_signal_seq - ASAP or in sequence
 *                  fc               - true when the device is unable to accept
 *                                     frames
 *
 ******************************************************************************/
extern int RFCOMM_ControlReqFromBTSOCK(uint8_t dlci, const RawAddress& bd_addr,
                                       uint8_t modem_signal,
                                       uint8_t break_signal,
                                       uint8_t discard_buffers,
                                       uint8_t break_signal_seq, bool fc);

/*******************************************************************************
 *
 * Function         RFCOMM_RemoveConnection
Loading