From cd39406d2075a463d386887c7e18fa0aa06702fc Mon Sep 17 00:00:00 2001 From: Vincent Coubard Date: Wed, 4 Apr 2018 15:28:52 +0100 Subject: [PATCH] BLE: Add conversion function from byte_array_t to ArrayView. --- features/FEATURE_BLE/ble/BLETypes.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/features/FEATURE_BLE/ble/BLETypes.h b/features/FEATURE_BLE/ble/BLETypes.h index 5f20c232a4..bbd6785bc2 100644 --- a/features/FEATURE_BLE/ble/BLETypes.h +++ b/features/FEATURE_BLE/ble/BLETypes.h @@ -21,6 +21,7 @@ #include #include #include "ble/SafeEnum.h" +#include "ble/ArrayView.h" /** * @addtogroup ble @@ -355,6 +356,32 @@ protected: uint8_t _value[array_size]; }; +/** + * Construct a fixed size ArrayView from a byte_array_t. + * + * @param src byte_array_t to create a view from. + * + * @return An ArrayView to @p src. + */ +template +ArrayView make_ArrayView(byte_array_t& src) +{ + return ArrayView(src.data(), src.size()); +} + +/** + * Construct a fixed size ArrayView from a const byte_array_t. + * + * @param src byte_array_t to create a view from. + * + * @return An ArrayView to @p src. + */ +template +ArrayView make_const_ArrayView(const byte_array_t& src) +{ + return ArrayView(src.data(), src.size()); +} + /** 128 bit keys used by paired devices */ typedef byte_array_t<16> irk_t; typedef byte_array_t<16> csrk_t;