Exemple #1
0
int
ble_l2cap_sig_update_rsp_tx(struct ble_hs_conn *conn,
                            struct ble_l2cap_chan *chan, uint8_t id,
                            uint16_t result)
{
    struct ble_l2cap_sig_update_rsp rsp;
    struct os_mbuf *txom;
    void *payload_buf;
    int rc;

    rc = ble_l2cap_sig_init_cmd(BLE_L2CAP_SIG_OP_UPDATE_RSP, id,
                                BLE_L2CAP_SIG_UPDATE_RSP_SZ, &txom,
                                &payload_buf);
    if (rc != 0) {
        return rc;
    }

    rsp.result = result;
    ble_l2cap_sig_update_rsp_write(payload_buf, BLE_L2CAP_SIG_UPDATE_RSP_SZ,
                                   &rsp);

    rc = ble_l2cap_tx(conn, chan, txom);
    if (rc != 0) {
        return rc;
    }

    return 0;
}
Exemple #2
0
int
ble_l2cap_sig_update_req_tx(struct ble_hs_conn *conn,
                            struct ble_l2cap_chan *chan, uint8_t id,
                            struct ble_l2cap_sig_update_req *req)
{
    struct os_mbuf *txom;
    void *payload_buf;
    int rc;

    rc = ble_l2cap_sig_init_cmd(BLE_L2CAP_SIG_OP_UPDATE_REQ, id,
                                BLE_L2CAP_SIG_UPDATE_REQ_SZ, &txom,
                                &payload_buf);
    if (rc != BLE_HS_ENONE) {
        return rc;
    }

    ble_l2cap_sig_update_req_write(payload_buf, BLE_L2CAP_SIG_UPDATE_REQ_SZ,
                                   req);

    rc = ble_l2cap_tx(conn, chan, txom);
    if (rc != BLE_HS_ENONE) {
        return rc;
    }

    return BLE_HS_ENONE;
}
int
ble_l2cap_sig_update_req_tx(uint16_t conn_handle, uint8_t id,
                            struct ble_l2cap_sig_update_req *req)
{
    struct os_mbuf *txom;
    void *payload_buf;
    int rc;

    rc = ble_l2cap_sig_init_cmd(BLE_L2CAP_SIG_OP_UPDATE_REQ, id,
                                BLE_L2CAP_SIG_UPDATE_REQ_SZ, &txom,
                                &payload_buf);
    if (rc != 0) {
        return rc;
    }

    ble_l2cap_sig_update_req_write(payload_buf, BLE_L2CAP_SIG_UPDATE_REQ_SZ,
                                   req);

    rc = ble_l2cap_sig_tx(conn_handle, txom);
    if (rc != 0) {
        return rc;
    }

    return 0;
}
Exemple #4
0
int
ble_l2cap_sig_reject_tx(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan,
                        uint8_t id, uint16_t reason,
                        void *data, int data_len)
{
    struct ble_l2cap_sig_reject cmd;
    struct os_mbuf *txom;
    void *payload_buf;
    int rc;

    rc = ble_l2cap_sig_init_cmd(BLE_L2CAP_SIG_OP_REJECT, id,
                                BLE_L2CAP_SIG_REJECT_MIN_SZ + data_len, &txom,
                                &payload_buf);
    if (rc != 0) {
        return rc;
    }

    cmd.reason = reason;
    ble_l2cap_sig_reject_write(payload_buf, txom->om_len, &cmd,
                               data, data_len);

    STATS_INC(ble_l2cap_stats, sig_rx);
    rc = ble_l2cap_tx(conn, chan, txom);
    if (rc != 0) {
        return rc;
    }

    return 0;
}
int
ble_l2cap_sig_reject_tx(uint16_t conn_handle, uint8_t id, uint16_t reason)
{
    /* XXX: Add support for optional data field. */

    struct ble_l2cap_sig_reject cmd;
    struct os_mbuf *txom;
    void *payload_buf;
    int rc;

    rc = ble_l2cap_sig_init_cmd(BLE_L2CAP_SIG_OP_REJECT, id,
                                BLE_L2CAP_SIG_REJECT_MIN_SZ, &txom,
                                &payload_buf);

    cmd.reason = reason;
    ble_l2cap_sig_reject_write(payload_buf, BLE_L2CAP_SIG_REJECT_MIN_SZ, &cmd);

    STATS_INC(ble_l2cap_stats, sig_rx);
    rc = ble_l2cap_sig_tx(conn_handle, txom);
    return rc;
}