MPA

group MPA

Provide functions to control L2CAP layer in Bluetooth stack.

MPA(Multi protocol adaptor) is designed for user to implement protocols over L2CAP easily. Many functions are provided to connect, disconnect or send data over L2CAP channels. Upstream messages can be received in callback fucntions registered in MPA.

Note

The structure here must be sycn with internal btif layer.

MPA_L2C_MODE

L2CAP channel mode. mpa.h

MPA_L2C_MODE_BASIC

L2CAP channel mode: basic mode.

MPA_L2C_MODE_ERTM

L2CAP channel mode: enhanced retransmission mode.

MPA_SEC_SETTING

Protocol security requirement settings bit mask. mpa.h

MPA_SEC_BIT_OUTGOING

Request for outgoing connection.

MPA_SEC_BIT_AUTHEN

Authentication is required.

MPA_SEC_BIT_MITM

MITM authentication is required, only possible if authentication is set.

MPA_SEC_BIT_AUTHOR

User level authorization is required.

MPA_SEC_BIT_ENCRYPT

Encryption on link is required, only possible if authentication is set.

MPA_ATT_PSM_DATA_PATH

The ATT data path of the L2CAP channel using PSM_ATT. mpa.h

MPA_ATT_PSM_DATA_PATH_APP

Application needs to handle the data. The ATT layer will not handle the data.

MPA_ATT_PSM_DATA_PATH_GATT

The ATT layer handles the data.

Typedefs

typedef void (*P_PROTO_CB)(void *p_buf, T_PROTO_MSG msg)

Prototype of callback function to handle L2CAP related messages from MPA.

mpa.h

Message types are defined in T_PROTO_MSG. Message data is located at p_buf and the content of data is dependent on message type.

typedef void (*P_RFC_AUTHEN_CB)(T_MPA_RFC_AUTHEN_RSP *p_rsp)

Prototype of callback function to handle response of authenticaion on profile over RFCOMM channel.

mpa.h

Enums

enum T_MPA_L2C_CONN_CFM_CAUSE

L2CAP confirm cause used in mpa_send_l2c_conn_cfm API.

mpa.h

Values:

enumerator MPA_L2C_CONN_ACCEPT

L2CAP connection accept

enumerator MPA_L2C_CONN_PENDING

L2CAP connection pending

enumerator MPA_L2C_CONN_INVALID_PSM

L2CAP connection reject because of PSM not support

enumerator MPA_L2C_CONN_SECURITY_BLOCK

L2CAP connection reject because of security block

enumerator MPA_L2C_CONN_NO_RESOURCE

L2CAP connection reject because of no resources available

enumerator MPA_L2C_CONN_INVALID_PARAM

L2CAP connection reject because of invalid parameter

enumerator MPA_L2C_CONN_INVALID_SOURCE_CID

L2CAP connection reject because of invalid source CID

enumerator MPA_L2C_CONN_SOURCE_CID_ALLOCATED

L2CAP connection reject because of source CID already allocated

enum T_PROTO_MSG

Messages types that protocols will get through callback function registed by mpa_reg_l2c_proto.

mpa.h

Values:

enumerator L2C_PROTO_REG_RSP

Response of register protocol into L2CAP layer. Message data is T_MPA_L2C_PROTO_REG_RSP.

enumerator L2C_CONN_IND

Indication of L2CAP connection request from remote device. Message data is T_MPA_L2C_CONN_IND.

enumerator L2C_CONN_RSP

Response of send L2CAP connection request to remote device. Message data is T_MPA_L2C_CONN_RSP.

enumerator L2C_CONN_CMPL

Information of L2CAP connection establish result. Message data is T_MPA_L2C_CONN_CMPL_INFO.

enumerator L2C_DATA_IND

Indication of L2CAP data received from remote device. Message data is T_MPA_L2C_DATA_IND.

enumerator L2C_DATA_RSP

Indication of L2CAP data response with ack flag set. Message data is T_MPA_L2C_DATA_RSP.

enumerator L2C_DISCONN_IND

Indication of L2CAP disconnection request from remote device. Message data is T_MPA_L2C_DISCONN_IND.

enumerator L2C_DISCONN_RSP

Response of send L2CAP disconnection request ro remote device. Message data is T_MPA_L2C_DISCONN_RSP.

enumerator L2C_SEC_REG_RSP

Response of register protocol security requirement into Bluetooth stack. Message data is T_MPA_L2C_SEC_REG_RSP.

enumerator L2C_PROTO_AUTHOR_IND

Indication of request authorization for service connection establish. Message data is T_MPA_AUTHOR_REQ_IND.

Functions

bool mpa_reg_l2c_proto(uint16_t psm, P_PROTO_CB callback, uint8_t *p_proto_id)

Register a callback function to handle L2CAP related messages for a specific PSM.

mpa.h

Example usage

uint8_t proto_id;

void test_l2c_cb(void *p_buf, T_PROTO_MSG msg)
{
    switch (msg)
    {
    case L2C_PROTO_REG_RSP:
        {
            T_MPA_L2C_PROTO_REG_RSP *p_rsp = (T_MPA_L2C_PROTO_REG_RSP *)p_buf;
            APP_PRINT_TRACE2("protocol register response: psm 0x%04x, cause 0x%04x\r\n", p_rsp->psm, p_rsp->cause);
        }
        break;

    default:
        break;
    }
}

int test(void)
{
    mpa_reg_l2c_proto(PSM_AVDTP, test_l2c_cb, &proto_id);

    return 0;
}

Parameters:
  • psm[in] Protocol service multiplexer that the callback function is related.

  • callback[in] Callback function to handle L2CAP messages. The function must have the prototype defined as P_PROTO_CB.

  • p_proto_id[out] Protocol ID assigned by MPA which will be used in mpa_send_l2c_conn_req.

Return values:
  • true – The function was successfully registered.

  • false – The function was failed to register.

Returns:

The result of callback function register.

bool mpa_set_att_psm_data_path(uint8_t data_path)

Setting the data path of the L2CAP channel using PSM_ATT.

mpa.h

Example usage

int test(void)
{
    mpa_set_att_psm_data_path(MPA_ATT_PSM_DATA_PATH_GATT);

    return 0;
}

Parameters:

data_path[in] Data processing method. Should be use MPA_ATT_PSM_DATA_PATH.

Return values:
  • true – The function was successfully configuration.

  • false – The function was failed to configure.

Returns:

The result of callback function register.

void mpa_send_l2c_conn_req(uint16_t psm, uint16_t uuid, uint16_t proto_id, uint16_t mtu_size, uint8_t *bd_addr, uint8_t mode, uint16_t flush_timeout)

Send a request to create a L2CAP connection. If the request was successfully sent, L2C_CONN_RSP will be received in the callback function registed by mpa_reg_l2c_proto to indicate whether the procedure was started successfully. If the procedure was started, L2C_CONN_CMPL will be received later to tell the result of L2CAP channel establishment.

mpa.h

Example usage

uint8_t proto_id;

void test_l2c_cb(void *p_buf, T_PROTO_MSG msg)
{
    switch (msg)
    {
    case L2C_PROTO_REG_RSP:
        {
            uint8_t bd_addr[6] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
            T_MPA_L2C_PROTO_REG_RSP *p_rsp = (T_MPA_L2C_PROTO_REG_RSP *)p_buf;

            APP_PRINT_TRACE2("protocol register response: psm 0x%04x, cause 0x%04x\r\n", p_rsp->psm, p_rsp->cause);

            if (!p_rsp->cause)
            {
                mpa_send_l2c_conn_req(PSM_AVDTP, UUID_AVDTP, proto_id, 672, bd_addr, MPA_L2C_MODE_BASIC, 0xFFFF);
            }
        }
        break;

    case L2C_CONN_RSP:
        {
            T_MPA_L2C_CONN_RSP *p_rsp = (T_MPA_L2C_CONN_RSP *)p_buf;

            if (p_rsp->cause)
            {
                APP_PRINT_ERROR1("send l2cap connection request fail, cause 0x%04x", p_rsp->cause);
            }
        }
        break;

    case L2C_CONN_CMPL:
        {
            T_MPA_L2C_CONN_CMPL *p_info = (T_MPA_L2C_CONN_CMPL *)p_buf;

            if (!p_info->cause)
            {
                APP_PRINT_TRACE1("l2cap channel connect successfully, cid 0x%04x", p_info->cid);
            }
        }
        break;

    default:
        break;
    }
}

int test(void)
{
    mpa_reg_l2c_proto(PSM_AVDTP, test_l2c_cb, &proto_id);

    return 0;
}

Parameters:
  • psm[in] PSM of the L2CAP channel that will be established.

  • uuid[in] UUID of profile that is established over the L2CAP channel.

  • proto_id[in] Protocol ID assigned by MPA.

  • mtu_size[in] Prefered MTU size value of the L2CAP channel.

  • bd_addr[in] Bluetooth address of remote device.

  • mode[in] Channel mode to use. Should be the combination of MPA_L2C_MODE.

  • flush_timeout[in] Flush timeout of flushable data on this channel, 0xFFFF for not flush.

Returns:

void

void mpa_send_l2c_conn_cfm(T_MPA_L2C_CONN_CFM_CAUSE cause, uint16_t cid, uint16_t mtu_size, uint8_t mode, uint16_t flush_timeout)

Send a confirmation for a L2CAP connection request from remote device. If the confirmation was successfully sent with cause as MPA_L2C_CONN_ACCEPT, L2C_CONN_CMPL will also be received in the callback function registered by mpa_reg_l2c_proto to tell the result of L2CAP channel establishment.

mpa.h

Example usage

void test_l2c_cb(void *p_buf, T_PROTO_MSG msg)
{
    switch (msg)
    {
    case L2C_CONN_IND:
        {
            T_MPA_L2C_CONN_IND *p_ind = (T_MPA_L2C_CONN_IND *)p_buf;

            mpa_send_l2c_conn_cfm(MPA_L2C_CONN_ACCEPT, p_ind->cid, 672, MPA_L2C_MODE_BASIC, 0xFFFF);
        }
        break;

    case L2C_CONN_CMPL:
        {
            T_MPA_L2C_CONN_CMPL *p_info = (T_MPA_L2C_CONN_CMPL *)p_buf;

            if (!p_info->cause)
            {
                APP_PRINT_TRACE1("l2cap channel connect successfully, cid 0x%04x", p_info->cid);
            }
        }
        break;

    default:
        break;
    }
}

int test(void)
{
    mpa_reg_l2c_proto(PSM_AVDTP, test_l2c_cb, &proto_id);

    return 0;
}

Parameters:
  • cause[in] Confirmation cause for the connection request from remote device.

  • cid[in] Local channel ID assigned by Bluetooth stack.

  • mtu_size[in] Prefered MTU size value of the L2CAP channel.

  • mode[in] Channel mode to use. Should be the combination of MPA_L2C_MODE.

  • flush_timeout[in] Flush timeout of flushable data on this channel, 0xFFFF for not flush.

Returns:

void

void mpa_send_l2c_disconn_req(uint16_t cid)

Send a request to disconnect a L2CAP connection. If the request was successfully sent, L2C_DISCONN_RSP will be received in the callback function registed by mpa_reg_l2c_proto to show the result of disconnection.

mpa.h

Example usage

uint8_t proto_id;

void test_l2c_cb(void *p_buf, T_PROTO_MSG msg)
{
    switch (msg)
    {
    case L2C_PROTO_REG_RSP:
        {
            uint8_t bd_addr[6] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
            T_MPA_L2C_PROTO_REG_RSP *p_rsp = (T_MPA_L2C_PROTO_REG_RSP *)p_buf;

            APP_PRINT_TRACE2("protocol register response: psm 0x%04x, cause 0x%04x\r\n", p_rsp->psm, p_rsp->cause);

            if (!p_rsp->cause)
            {
                mpa_send_l2c_conn_req(PSM_AVDTP, UUID_AVDTP, proto_id, 672, bd_addr, MPA_L2C_MODE_BASIC, 0xFFFF);
            }
        }
        break;

    case L2C_CONN_RSP:
        {
            T_MPA_L2C_CONN_RSP *p_rsp = (T_MPA_L2C_CONN_RSP *)p_buf;

            if (p_rsp->cause)
            {
                APP_PRINT_ERROR1("send l2cap connection request fail, cause 0x%04x", p_rsp->cause);
            }
        }
        break;

    case L2C_CONN_CMPL:
        {
            T_MPA_L2C_CONN_CMPL *p_info = (T_MPA_L2C_CONN_CMPL *)p_buf;

            if (!p_info->cause)
            {
                mpa_send_l2c_disconn_req(p_info->cid);
            }
        }
        break;

    case L2C_DISCONN_RSP:
        {
            T_MPA_L2C_DISCONN_RSP *p_rsp = (T_MPA_L2C_DISCONN_RSP *)p_buf;

            if (p_rsp->cause)
            {
                APP_PRINT_TRACE1("l2cap disconnect response, cause 0x%04x", p_rsp->cause);
            }
        }

    default:
        break;
    }
}

int test(void)
{
    mpa_reg_l2c_proto(PSM_AVDTP, test_l2c_cb, &proto_id);

    return 0;
}

Parameters:

cid[in] Local channel ID of the L2CAP channel to disconnect.

Returns:

void

void mpa_send_l2c_disconn_cfm(uint16_t cid)

Send a confirmation for a L2CAP disconnection request from remote device.

mpa.h

Example usage

void test_l2c_cb(void *p_buf, T_PROTO_MSG msg)
{
    switch (msg)
    {
    case L2C_DISCONN_IND:
        {
            T_MPA_L2C_DISCONN_IND *p_ind = (T_MPA_L2C_DISCONN_IND *)p_buf;

            mpa_send_l2c_disconn_cfm(p_ind->cid);
        }
        break;

    default:
        break;
    }
}

int test(void)
{
    mpa_reg_l2c_proto(PSM_AVDTP, test_l2c_cb, &proto_id);

    return 0;
}

Parameters:

cid[in] Local channel ID of the L2CAP channel.

Returns:

void

void *mpa_get_l2c_buf(uint8_t proto_id, uint16_t cid, uint8_t dlci, uint16_t size, uint16_t offset, bool ack)

Get buffer from Bluetooth stack to put in L2CAP data which will be sent to remote device.

mpa.h

Example usage

uint8_t proto_id;
uint8_t proto_data[30] = {0};

void test_l2c_cb(void *p_buf, T_PROTO_MSG msg)
{
    switch (msg)
    {
    case L2C_CONN_CMPL:
        {
            T_MPA_L2C_CONN_CMPL *p_info = (T_MPA_L2C_CONN_CMPL *)p_buf;

            if (!p_info->cause)
            {
                uint8_t *p_buffer = mpa_get_l2c_buf(proto_id, p_info->cid, 0, 30, p_info->ds_data_offset, false, 0);

                if (p_buffer)
                {
                    memcpy(p_buffer + p_info->ds_data_offset, proto_data, 30);
                    mpa_send_l2c_data_req(p_buffer, p_info->ds_data_offset, p_info->cid, 30, false);
                }
            }
        }
        break;

    default:
        break;
    }
}

int test(void)
{
    mpa_reg_l2c_proto(PSM_AVDTP, test_l2c_cb, &proto_id);

    return 0;
}

Parameters:
  • size[in] Length of L2CAP data.

  • offset[in] Offset of real L2CAP data in the buffer. Offset value can be get from L2C_CONN_CMPL message.

  • ack[in] Whether need an ack when the buffer was released. If set to true, L2C_DATA_RSP message will be received in the callback function registered by legacy_register_cb.

Returns:

The address of the allocated buffer. If the address in NULL, the buffer was get failed.

void mpa_send_l2c_data_req(void *p_buf, uint16_t offset, uint16_t cid, uint16_t length, bool auto_flush)

Send a request to send L2CAP data to remote device.

mpa.h

Example usage

uint8_t proto_id;
uint8_t proto_data[30] = {0};

void test_l2c_cb(void *p_buf, T_PROTO_MSG msg)
{
    switch (msg)
    {
    case L2C_CONN_CMPL:
        {
            T_MPA_L2C_CONN_CMPL *p_info = (T_MPA_L2C_CONN_CMPL *)p_buf;

            if (!p_info->cause)
            {
                uint8_t *p_buffer = mpa_get_l2c_buf(proto_id, p_info->cid, 0, 30, p_info->ds_data_offset, false, 0);

                if (p_buffer)
                {
                    memcpy(p_buffer + p_info->ds_data_offset, proto_data, 30);
                    mpa_send_l2c_data_req(p_buffer, p_info->ds_data_offset, p_info->cid, 30, false);
                }
            }
        }
        break;

    default:
        break;
    }
}

int test(void)
{
    mpa_reg_l2c_proto(PSM_AVDTP, test_l2c_cb, &proto_id);

    return 0;
}

Parameters:
  • p_buf[in] Address of L2CAP data buffer which is allocated by mpa_get_l2c_buf.

  • offset[in] Offset of real L2CAP data in the buffer. Offset value can be get from L2C_CONN_CMPL message.

  • cid[in] Local channel ID. The value can be get from L2C_CONN_CMPL message.

  • length[in] Length of real L2CAP data.

  • auto_flush[in] Whether the L2CAP data can be flushed or not.

Returns:

void.

void mpa_send_l2c_sec_reg_req(uint8_t active, uint16_t psm, uint16_t server_chann, uint16_t uuid, uint8_t requirement)

Send a request to register/deregister a protocol security entry over L2CAP. The security will be used when establishing a L2CAP channel. If the request was successfully sent, a message whose type is L2C_SEC_REG_RSP and data is T_MPA_L2C_SEC_REG_RSP will be received in the callback function registered by mpa_reg_l2c_proto.

mpa.h

Example usage

void test_l2c_cb(void *p_buf, T_PROTO_MSG msg)
{
    switch (msg)
    {
    case L2C_PROTO_REG_RSP:
        {
            T_MPA_L2C_PROTO_REG_RSP *p_rsp = (T_MPA_L2C_PROTO_REG_RSP *)p_buf;
            APP_PRINT_TRACE2("protocol register response: psm 0x%04x, cause 0x%04x\r\n", p_rsp->psm, p_rsp->cause);
        }
        break;

    case L2C_SEC_REG_RSP:
        {
            T_MPA_L2C_SEC_REG_RSP *p_rsp = (T_MPA_L2C_SEC_REG_RSP *)p_buf;
            APP_PRINT_TRACE1("protocol security requirement register response: cause 0x%04x\r\n", p_rsp->cause);
        }
        break;

    default:
        break;
    }
}

int test(void)
{
    mpa_reg_l2c_proto(PSM_AVDTP, test_l2c_cb, &proto_id);
    mpa_send_l2c_sec_reg_req(1, PSM_AVDTP, 0, UUID_AVDTP, MPA_SEC_BIT_AUTHEN | MPA_SEC_BIT_MITM);

    return 0;
}

Parameters:
  • active – Register/Deregister the security entry.

  • psm – PSM value for protocol.

  • server_chann – Local server channel number for RFCOMM, for other protocols set to 0.

  • uuid – UUID for profiles over rfcomm or UUID for other protocols except RFCOMM.

  • requirement – Security requirement of the entry. Valid values are combinations of MPA_SEC_SETTING.

Returns:

None.

void mpa_send_author_cfm(uint8_t *bd_addr, T_GAP_CFM_CAUSE result)

Send a confirmation for authorization request indication. This function is used when receiving a message whose type is L2C_PROTO_AUTHOR_IND and data is T_MPA_AUTHOR_REQ_IND in the callback function registered by mpa_reg_l2c_proto.

mpa.h

Example usage

uint8_t proto_id;

void test_l2c_cb(void *p_buf, T_PROTO_MSG msg)
{
    switch (msg)
    {
    case L2C_PROTO_REG_RSP:
        {
            T_MPA_L2C_PROTO_REG_RSP *p_rsp = (T_MPA_L2C_PROTO_REG_RSP *)p_buf;
            APP_PRINT_TRACE2("protocol register response: psm 0x%04x, cause 0x%04x\r\n", p_rsp->psm, p_rsp->cause);
        }
        break;

    case L2C_PROTO_AUTHOR_IND:
        {
            T_MPA_AUTHOR_REQ_IND *p_ind = (T_MPA_AUTHOR_REQ_IND *)p_buf;
            mpa_send_author_cfm(p_ind->bd_addr, GAP_CFM_CAUSE_ACCEPT);
        }
        break;

    default:
        break;
    }
}

int test(void)
{
    mpa_reg_l2c_proto(PSM_AVDTP, test_l2c_cb, &proto_id);

    return 0;
}

Parameters:
  • bd_addr[in] Bluetooth address of remote device.

  • cause[in] Confirmation cause of authorization.

Returns:

None.

void mpa_reg_rfc_authen_cb(P_RFC_AUTHEN_CB p_func)

Register a callback function to handle authentication responses over RFCOMM. This API can only be used when realize RFCOMM protocol.

mpa.h

Example usage

void rfc_handle_authen_rsp(T_MPA_RFC_AUTHEN_RSP *p_rsp)
{
    APP_PRINT_TRACE1("RFCOMM authentication response: cause 0x%04x", p_rsp->cause);
}

void test(void)
{
    uint8_t bd_addr[6] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66};

    mpa_reg_rfc_authen_cb(rfc_handle_authen_rsp);

    // ...
    // HFP connected
    // ...

    mpa_send_rfc_authen_req(bd_addr, 0x40, 0x12, UUID_HANDSFREE, 0);
}

Parameters:

p_func – Callback function to handle authentication response. The function must have the prototype as P_RFC_AUTHEN_CB.

Returns:

None.

void mpa_send_rfc_authen_req(uint8_t *bd_addr, uint16_t cid, uint16_t dlci, uint16_t uuid, uint8_t outgoing)

Send a request to start authentication for a profile on RFCOMM channel. If the request was successfully sent, a response message will be received in the callback function registered by mpa_reg_rfc_authen_cb. This API can only be used when realize RFCOMM protocol.

mpa.h

Example usage

void rfc_handle_authen_rsp(T_MPA_RFC_AUTHEN_RSP *p_rsp)
{
    APP_PRINT_TRACE1("RFCOMM authentication response: cause 0x%04x", p_rsp->cause);
}

void test(void)
{
    uint8_t bd_addr[6] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66};

    mpa_reg_rfc_authen_cb(rfc_handle_authen_rsp);

    // ...
    // HFP connected
    // ...

    mpa_send_rfc_authen_req(bd_addr, 0x40, 0x12, UUID_HANDSFREE, 0);
}

Parameters:
  • bd_addr – Bluetooth address of remote device.

  • cid – L2CAP local channel ID.

  • dlci – DLCI value for the RFCOMM channel.

  • uuid – UUID for profiles over rfcomm.

  • outgoing – Direction of the profile over rfcomm channel.

Returns:

None.

struct T_MPA_L2C_PROTO_REG_RSP

Response of registering protocol over L2CAP. It will be received in the callback function registered by mpa_reg_l2c_proto with message type as L2C_PROTO_REG_RSP.

mpa.h

Public Members

uint16_t psm

PSM of the protocol.

uint16_t proto_id

Protocol ID assigned by MPA layer.

uint16_t cause

Result of registering protocol to L2CAP layer.

struct T_MPA_L2C_CONN_IND

Indication of remote L2CAP connection request. It will be received in the callback function registered by mpa_reg_l2c_proto with message type as L2C_CONN_IND.

mpa.h

Public Members

uint16_t cid

Local CID assigned by Bluetooth stack.

uint16_t proto_id

Protocol ID which is assigned by MPA.

uint8_t bd_addr[6]

Bluetooth address of remote device.

struct T_MPA_L2C_CONN_RSP

Response of starting L2CAP connection request. It will be received in the callback function registered by mpa_reg_l2c_proto with message type as L2C_CONN_RSP.

mpa.h

Public Members

uint16_t cid

Local CID assigned by Bluetooth stack.

uint16_t proto_id

Protocol ID assigned by MPA.

uint16_t cause

Result of executing L2CAP connection request.

uint8_t bd_addr[6]

Bluetooth address of remote device.

struct T_MPA_L2C_CONN_CMPL_INFO

Information of L2CAP channel establish result. It will be received in the callback function registered by mpa_reg_l2c_proto with message type as L2C_CONN_CMPL.

mpa.h

Public Members

uint16_t cause

Result of establishing a L2CAP channel with remote device.

uint16_t cid

Local CID assigned by Bluetooth stack.

uint16_t remote_mtu

Remote MTU value.

uint16_t proto_id

Protocol ID assigned by MPA.

uint16_t ds_data_offset

Offset used to fill user data when sending L2CAP data to remote.

uint8_t bd_addr[6]

Bluetooth address of remote device.

uint16_t local_mtu

Local MTU value.

uint16_t conn_handle

Connection handle.

struct T_MPA_L2C_DATA_IND

Indication of L2CAP data received from remote side. It will be received in the callback function registered by mpa_reg_l2c_proto with message type as L2C_DATA_IND.

mpa.h

Public Members

uint32_t bt_clock

Bluetooth native clock.

uint16_t proto_id

Protocol ID assigned by upper layer.

uint16_t cid

Local CID assigned by Bluetooth stack.

uint16_t length

Length of L2CAP data.

uint16_t gap

Offset from data parameter to the real L2CAP data.

uint8_t data[1]

The rest of message which contains real L2CAP data at offset of gap.

struct T_MPA_L2C_DATA_RSP

Indication of L2CAP data response with ack flag set. It will be received in the callback function registered by mpa_reg_l2c_proto with message type as L2C_DATA_RSP.

mpa.h

Public Members

uint16_t cid

Local CID assigned by Bluetooth stack.

uint8_t proto_id

Protocol ID assigned by MPA.

uint8_t dlci

RFCOMM DLCI assigned by RFCOMM.

struct T_MPA_L2C_DISCONN_IND

Indication of receiving L2CAP disconnection request from remote device. It will be received in the callback function registered by mpa_reg_l2c_proto with message type as L2C_DISCONN_IND.

mpa.h

Public Members

uint16_t cid

Local CID assigned by Bluetooth stack.

uint16_t proto_id

Protocol ID assigned by MPA.

uint16_t cause

L2CAP channel disconnect reason received.

struct T_MPA_L2C_DISCONN_RSP

Response of sending L2CAP disconnection request to remote device. It will be received in the callback function registered by mpa_reg_l2c_proto with message type as L2C_DISCONN_RSP.

mpa.h

Public Members

uint16_t cid

Local CID assigned by Bluetooth stack.

uint16_t proto_id

Protocol ID assigned by MPA.

uint16_t cause

Result of disconnecting L2CAP channel with remote device.

struct T_MPA_L2C_SEC_REG_RSP

Response of registering protocol security into Bluetooth stack. It will be received in the callback function registered by mpa_reg_l2c_proto with message type as L2C_SEC_REG_RSP.

mpa.h

Public Members

uint16_t psm

PSM of the protocol.

uint16_t server_chann

Server channel when PSM is RFCOMM, otherwise is 0.

uint8_t active

Active/Deactive the security entry.

uint16_t uuid

UUID of the protocol the security entry registered for.

uint16_t cause

Result of registering protocol security.

struct T_MPA_AUTHOR_REQ_IND

Indication to request user’s authorization for service connection establish. It will be received in the callback function registered by mpa_reg_l2c_proto with message type as L2C_PROTO_AUTHOR_IND.

mpa.h

Public Members

uint16_t psm

PSM of the protocol.

uint16_t server_chann

Server channel number when PSM is RFCOMM, otherwise is 0.

uint16_t uuid

UUID of the service.

uint8_t bd_addr[6]

Bluetooth address of remote device.

uint8_t outgoing

Direction of the service establishment, 1: outgoing, 0: incoming.

struct T_MPA_RFC_AUTHEN_RSP

Reponse of authenticaion on profile over RFCOMM channel. It will be received in the callback function registered by mpa_reg_rfc_authen_cb.

mpa.h

Public Members

uint16_t cid

Local CID assigned by Bluetooth stack.

uint16_t dlci

DCLI value of the RFCOMM channel.

uint16_t cause

Result of authentication on the profile.

uint8_t outgoing

Direction of the service establishment, 1: outgoing, 0: incoming.

uint8_t bd_addr[6]

Bluetooth address of remote device.