uint16_t nmgr_ble_get_mtu(struct os_mbuf *req) { uint16_t conn_handle; uint16_t mtu; memcpy(&conn_handle, OS_MBUF_USRHDR(req), sizeof (conn_handle)); mtu = ble_att_mtu(conn_handle); if (!mtu) { assert(0); } /* 3 is the number of bytes for ATT notification base */ mtu = mtu - 3; return (mtu); }
int ble_att_clt_tx_prep_write(uint16_t conn_handle, struct ble_att_prep_write_cmd *req, void *value, uint16_t value_len) { #if !NIMBLE_OPT(ATT_CLT_PREP_WRITE) return BLE_HS_ENOTSUP; #endif struct os_mbuf *txom; int rc; if (req->bapc_handle == 0) { return BLE_HS_EINVAL; } if (req->bapc_offset + value_len > BLE_ATT_ATTR_MAX_LEN) { return BLE_HS_EINVAL; } if (value_len > ble_att_mtu(conn_handle) - BLE_ATT_PREP_WRITE_CMD_BASE_SZ) { return BLE_HS_EINVAL; } rc = ble_att_clt_build_prep_write_req(conn_handle, req, value, value_len, &txom); if (rc != 0) { return rc; } rc = ble_att_clt_tx_req(conn_handle, txom); if (rc != 0) { return rc; } return 0; }