From ca0bfb84d0048f571a3167163aabe12d3f9596fb Mon Sep 17 00:00:00 2001 From: lly Date: Thu, 24 Oct 2019 15:08:33 +0800 Subject: [PATCH] ble_mesh: Expose header parsing outside net --- components/bt/esp_ble_mesh/mesh_core/net.c | 11 +++++++++++ components/bt/esp_ble_mesh/mesh_core/net.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/components/bt/esp_ble_mesh/mesh_core/net.c b/components/bt/esp_ble_mesh/mesh_core/net.c index 9f5bde9372..0592031a7f 100644 --- a/components/bt/esp_ble_mesh/mesh_core/net.c +++ b/components/bt/esp_ble_mesh/mesh_core/net.c @@ -1308,6 +1308,17 @@ done: #endif /* CONFIG_BLE_MESH_NODE */ +void bt_mesh_net_header_parse(struct net_buf_simple *buf, + struct bt_mesh_net_rx *rx) +{ + rx->old_iv = (IVI(buf->data) != (bt_mesh.iv_index & 0x01)); + rx->ctl = CTL(buf->data); + rx->ctx.recv_ttl = TTL(buf->data); + rx->seq = SEQ(buf->data); + rx->ctx.addr = SRC(buf->data); + rx->ctx.recv_dst = DST(buf->data); +} + int bt_mesh_net_decode(struct net_buf_simple *data, enum bt_mesh_net_if net_if, struct bt_mesh_net_rx *rx, struct net_buf_simple *buf) { diff --git a/components/bt/esp_ble_mesh/mesh_core/net.h b/components/bt/esp_ble_mesh/mesh_core/net.h index 2a74f9779b..200cf7982c 100644 --- a/components/bt/esp_ble_mesh/mesh_core/net.h +++ b/components/bt/esp_ble_mesh/mesh_core/net.h @@ -365,6 +365,8 @@ u32_t bt_mesh_next_seq(void); void bt_mesh_net_start(void); void bt_mesh_net_init(void); +void bt_mesh_net_header_parse(struct net_buf_simple *buf, + struct bt_mesh_net_rx *rx); /* Friendship Credential Management */ struct friend_cred {