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; }
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_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; }
static int ble_sm_tx(uint16_t conn_handle, struct os_mbuf *txom) { struct ble_l2cap_chan *chan; struct ble_hs_conn *conn; int rc; BLE_HS_DBG_ASSERT(ble_hs_locked_by_cur_task()); STATS_INC(ble_l2cap_stats, sm_tx); ble_hs_misc_conn_chan_find_reqd(conn_handle, BLE_L2CAP_CID_SM, &conn, &chan); rc = ble_l2cap_tx(conn, chan, txom); if (rc != BLE_HS_ENONE) { return rc; } return BLE_HS_ENONE; }
static int ble_att_clt_tx_req_flags(uint16_t conn_handle, struct os_mbuf *txom, ble_hs_conn_flags_t flags_on_success) { struct ble_l2cap_chan *chan; struct ble_hs_conn *conn; uint16_t total_len; uint16_t mtu; int extra_len; int rc; BLE_HS_DBG_ASSERT_EVAL(txom->om_len >= 1); ble_att_inc_tx_stat(txom->om_data[0]); ble_hs_lock(); rc = ble_att_conn_chan_find(conn_handle, &conn, &chan); if (rc == 0) { /* Reduce the size of the transmission to fit the connection's ATT * MTU. */ total_len = OS_MBUF_PKTLEN(txom); mtu = ble_l2cap_chan_mtu(chan); extra_len = total_len - mtu; if (extra_len > 0) { os_mbuf_adj(txom, -extra_len); } rc = ble_l2cap_tx(conn, chan, txom); txom = NULL; if (rc == 0) { conn->bhc_flags |= flags_on_success; } } ble_hs_unlock(); os_mbuf_free_chain(txom); return rc; }
static int ble_l2cap_sig_tx(uint16_t conn_handle, struct os_mbuf *txom) { struct ble_l2cap_chan *chan; struct ble_hs_conn *conn; int rc; STATS_INC(ble_l2cap_stats, sig_tx); ble_hs_lock(); rc = ble_hs_misc_conn_chan_find_reqd(conn_handle, BLE_L2CAP_CID_SIG, &conn, &chan); if (rc == 0) { rc = ble_l2cap_tx(conn, chan, txom); } ble_hs_unlock(); return rc; }