nimble/att: Use packed struct for receiving Write Command Use packed structure to map it to received mbuf instead of using dedicated parsing function. Modern compilers generate effective code in such case anyway.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/3876f10f Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/3876f10f Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/3876f10f Branch: refs/heads/master Commit: 3876f10f11473407fb8326cacd15956105fc10b4 Parents: 255debf Author: Szymon Janc <szymon.j...@codecoup.pl> Authored: Fri Mar 24 15:50:07 2017 +0100 Committer: Szymon Janc <szymon.j...@codecoup.pl> Committed: Mon Apr 10 11:31:33 2017 +0200 ---------------------------------------------------------------------- net/nimble/host/src/ble_att_svr.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/3876f10f/net/nimble/host/src/ble_att_svr.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/src/ble_att_svr.c b/net/nimble/host/src/ble_att_svr.c index 23599a8..8c9a6cb 100644 --- a/net/nimble/host/src/ble_att_svr.c +++ b/net/nimble/host/src/ble_att_svr.c @@ -2109,30 +2109,31 @@ ble_att_svr_rx_write_no_rsp(uint16_t conn_handle, struct os_mbuf **rxom) return BLE_HS_ENOTSUP; #endif - struct ble_att_write_req req; + struct ble_att_write_req *req; uint8_t att_err; + uint16_t handle; int rc; - rc = ble_att_svr_pullup_req_base(rxom, BLE_ATT_WRITE_REQ_BASE_SZ, - &att_err); + /* TODO move this to common part + * Strip L2CAP ATT header from the front of the mbuf. + */ + os_mbuf_adj(*rxom, 1); + + rc = ble_att_svr_pullup_req_base(rxom, sizeof(*req), &att_err); if (rc != 0) { return rc; } - ble_att_write_cmd_parse((*rxom)->om_data, (*rxom)->om_len, &req); + req = (struct ble_att_write_req *)(*rxom)->om_data; BLE_ATT_LOG_CMD(0, "write cmd", conn_handle, - ble_att_write_req_log, &req); + ble_att_write_req_log, req); - /* Strip the request base from the front of the mbuf. */ - os_mbuf_adj(*rxom, BLE_ATT_WRITE_REQ_BASE_SZ); + handle = le16toh(req->bawq_handle); - rc = ble_att_svr_write_handle(conn_handle, req.bawq_handle, 0, rxom, - &att_err); - if (rc != 0) { - return rc; - } + /* Strip the request base from the front of the mbuf. */ + os_mbuf_adj(*rxom, sizeof(*req)); - return 0; + return ble_att_svr_write_handle(conn_handle, handle, 0, rxom, &att_err); } /**