nimble/att: Use packed struct for receiving Read By Group Type Request 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/37cec14c Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/37cec14c Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/37cec14c Branch: refs/heads/master Commit: 37cec14c0d828dbb71febbb6ffaa2ad5ad1b6819 Parents: de742e2 Author: Szymon Janc <szymon.j...@codecoup.pl> Authored: Fri Mar 24 15:50:05 2017 +0100 Committer: Szymon Janc <szymon.j...@codecoup.pl> Committed: Mon Apr 10 11:31:32 2017 +0200 ---------------------------------------------------------------------- net/nimble/host/src/ble_att_clt.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/37cec14c/net/nimble/host/src/ble_att_clt.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/src/ble_att_clt.c b/net/nimble/host/src/ble_att_clt.c index a8220f4..6e91079 100644 --- a/net/nimble/host/src/ble_att_clt.c +++ b/net/nimble/host/src/ble_att_clt.c @@ -715,31 +715,39 @@ ble_att_clt_rx_read_group_type(uint16_t conn_handle, struct os_mbuf **rxom) #endif struct ble_att_read_group_type_adata adata; - struct ble_att_read_group_type_rsp rsp; + struct ble_att_read_group_type_rsp *rsp; + uint8_t len; int rc; - rc = ble_hs_mbuf_pullup_base(rxom, BLE_ATT_READ_GROUP_TYPE_RSP_BASE_SZ); + /* TODO move this to common part + * Strip L2CAP ATT header from the front of the mbuf. + */ + os_mbuf_adj(*rxom, 1); + + rc = ble_hs_mbuf_pullup_base(rxom, sizeof(*rsp)); if (rc != 0) { goto done; } - ble_att_read_group_type_rsp_parse((*rxom)->om_data, (*rxom)->om_len, &rsp); + rsp = (struct ble_att_read_group_type_rsp *)(*rxom)->om_data; + BLE_ATT_LOG_CMD(0, "read group type rsp", conn_handle, - ble_att_read_group_type_rsp_log, &rsp); + ble_att_read_group_type_rsp_log, rsp); + + len = rsp->bagp_length; /* Strip the base from the front of the response. */ - os_mbuf_adj(*rxom, BLE_ATT_READ_GROUP_TYPE_RSP_BASE_SZ); + os_mbuf_adj(*rxom, sizeof(*rsp)); /* Parse the Attribute Data List field, passing each entry to GATT. */ while (OS_MBUF_PKTLEN(*rxom) > 0) { - rc = ble_att_clt_parse_read_group_type_adata(rxom, rsp.bagp_length, - &adata); + rc = ble_att_clt_parse_read_group_type_adata(rxom, len, &adata); if (rc != 0) { goto done; } ble_gattc_rx_read_group_type_adata(conn_handle, &adata); - os_mbuf_adj(*rxom, rsp.bagp_length); + os_mbuf_adj(*rxom, len); } done: