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

Commit 8e7dc7c0 authored by Jack He's avatar Jack He
Browse files

MCAP: Add test interface for PTS test (2/2)

* PTS tests requires MCAP APIs to be called at protocol level
* This CL creates a test interface to enable the above functionality

Bug: 37867299
Test: make, no user visible effect
Change-Id: I15cc6cc613ce8f7c57564296e45077ab877c269b
parent d026099b
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -66,6 +66,9 @@
#include "osi/include/wakelock.h"
#include "stack_manager.h"

/* Test interface includes */
#include "mca_api.h"

/*******************************************************************************
 *  Static variables
 ******************************************************************************/
@@ -107,6 +110,9 @@ extern btrc_interface_t* btif_rc_ctrl_get_interface();
/*SDP search client*/
extern btsdp_interface_t* btif_sdp_get_interface();

/* List all test interface here */
extern btmcap_test_interface_t* stack_mcap_get_interface();

/*******************************************************************************
 *  Functions
 ******************************************************************************/
@@ -364,6 +370,9 @@ static const void* get_profile_interface(const char* profile_id) {
  if (is_profile(profile_id, BT_PROFILE_AV_RC_CTRL_ID))
    return btif_rc_ctrl_get_interface();

  if (is_profile(profile_id, BT_TEST_INTERFACE_MCAP_ID))
    return stack_mcap_get_interface();

  return NULL;
}

+39 −0
Original line number Diff line number Diff line
@@ -511,4 +511,43 @@ extern tMCA_RESULT MCA_WriteReq(tMCA_DL mdl, BT_HDR* p_pkt);
 ******************************************************************************/
extern uint16_t MCA_GetL2CapChannel(tMCA_DL mdl);

/**
 * The following definitions are for test interface only, they mirror function
 * definitions above. This struct allows an external application to load and
 * call these methods without linking against the core library.
 */
typedef struct {
  size_t size;
  void (*init)(void);
  tMCA_HANDLE (*register_application)(tMCA_REG* p_reg,
                                      tMCA_CTRL_CBACK* p_cback);
  void (*deregister_application)(tMCA_HANDLE handle);
  tMCA_RESULT (*create_mdep)(tMCA_HANDLE handle, tMCA_DEP* p_dep,
                             tMCA_CS* p_cs);
  tMCA_RESULT (*delete_mdep)(tMCA_HANDLE handle, tMCA_DEP dep);
  tMCA_RESULT (*connect_mcl)(tMCA_HANDLE handle, BD_ADDR bd_addr,
                             uint16_t ctrl_psm, uint16_t sec_mask);
  tMCA_RESULT (*disconnect_mcl)(tMCA_CL mcl);
  tMCA_RESULT (*create_mdl_request)(tMCA_CL mcl, tMCA_DEP dep,
                                    uint16_t data_psm, uint16_t mdl_id,
                                    uint8_t peer_dep_id, uint8_t cfg,
                                    const tMCA_CHNL_CFG* p_chnl_cfg);
  tMCA_RESULT (*create_mdl_response)(tMCA_CL mcl, tMCA_DEP dep, uint16_t mdl_id,
                                     uint8_t cfg, uint8_t rsp_code,
                                     const tMCA_CHNL_CFG* p_chnl_cfg);
  tMCA_RESULT (*close_mdl_request)(tMCA_DL mdl);
  tMCA_RESULT (*reconnect_mdl_request)(tMCA_CL mcl, tMCA_DEP dep,
                                       uint16_t data_psm, uint16_t mdl_id,
                                       const tMCA_CHNL_CFG* p_chnl_cfg);
  tMCA_RESULT (*reconnect_mdl_response)(tMCA_CL mcl, tMCA_DEP dep,
                                        uint16_t mdl_id, uint8_t rsp_code,
                                        const tMCA_CHNL_CFG* p_chnl_cfg);
  tMCA_RESULT (*data_channel_config)(tMCA_CL mcl,
                                     const tMCA_CHNL_CFG* p_chnl_cfg);
  tMCA_RESULT (*abort_mdl)(tMCA_CL mcl);
  tMCA_RESULT (*delete_mdl)(tMCA_CL mcl, uint16_t mdl_id);
  tMCA_RESULT (*write_mdl)(tMCA_DL mdl, BT_HDR* p_pkt);
  uint16_t (*get_l2cap_channel)(tMCA_DL mdl);
} btmcap_test_interface_t;

#endif /* MCA_API_H */
+26 −0
Original line number Diff line number Diff line
@@ -827,3 +827,29 @@ uint16_t MCA_GetL2CapChannel(tMCA_DL mdl) {
  if (p_dcb) lcid = p_dcb->lcid;
  return lcid;
}

static const btmcap_test_interface_t mcap_test_interface = {
    sizeof(btmcap_test_interface_t),
    MCA_Init,
    MCA_Register,
    MCA_Deregister,
    MCA_CreateDep,
    MCA_DeleteDep,
    MCA_ConnectReq,
    MCA_DisconnectReq,
    MCA_CreateMdl,
    MCA_CreateMdlRsp,
    MCA_CloseReq,
    MCA_ReconnectMdl,
    MCA_ReconnectMdlRsp,
    MCA_DataChnlCfg,
    MCA_Abort,
    MCA_Delete,
    MCA_WriteReq,
    MCA_GetL2CapChannel,
};

const btmcap_test_interface_t* stack_mcap_get_interface(void) {
  BTIF_TRACE_EVENT("%s", __func__);
  return &mcap_test_interface;
}