/* Transmits the L2CAP payload contained in the specified mbuf. The supplied mbuf is consumed, regardless of the outcome of the function call. */
int ble_l2cap_tx(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan, struct os_mbuf *txom)
/* Transmits the L2CAP payload contained in the specified mbuf. The supplied mbuf is consumed, regardless of the outcome of the function call. */
int ble_l2cap_tx(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan, struct os_mbuf *txom)
{
    int rc;
    txom = ble_l2cap_prepend_hdr(txom, chan->dcid, OS_MBUF_PKTLEN(txom));
    if (txom == NULL) {
        return BLE_HS_ENOMEM;
    }
    rc = ble_hs_hci_acl_tx(conn, &txom);
    switch (rc) {
    case 0:
        return 0;
    case BLE_HS_EAGAIN:
        STAILQ_INSERT_TAIL(&conn->bhc_tx_q, OS_MBUF_PKTHDR(txom), omp_next);
        return 0;
    default:
        return rc;
    }
}