Merge pull request #10659 from LDong-Arm/replace_ArrayView

Replace uses of ArrayView with mbed::Span
pull/10864/head
Anna Bridge 2019-06-18 16:26:46 +01:00 committed by GitHub
commit 46be52636c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
36 changed files with 251 additions and 697 deletions

View File

@ -1,443 +0,0 @@
/* mbed Microcontroller Library
* Copyright (c) 2017-2017 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef BLE_ARRAY_VIEW_H_
#define BLE_ARRAY_VIEW_H_
#include <algorithm>
#include <stddef.h>
#include <stdint.h>
#include "platform/mbed_assert.h"
/**
* @addtogroup ble
* @{
* @addtogroup common
* @{
*/
/**
* @file
*/
namespace ble {
/**
* Special value for the Size parameter of ArrayView.
* If the type use this value then the size of the array is stored in the object
* at runtime.
*/
#define ARRAY_VIEW_DYNAMIC_SIZE -1
/**
* Immutable view to an array.
*
* Array views encapsulate the pointer to an array and its size into a single
* object or type; however, it does not manage the lifetime of the array viewed.
* You can use instances of ArrayView to replace the traditional pair of pointer
* and size arguments in function calls.
*
* You can use the size member function to query the number of elements present
* in the array, and overloads of the subscript operator allow code using
* this object to access to the content of the array viewed.
*
* @note You can create ArrayView instances with the help of the function
* template make_ArrayView() and make_const_ArrayView().
*
* @note ArrayView<T, Size> objects can be implicitly converted to ArrayView<T>
* objects where required.
*
* @tparam T type of objects held by the array.
* @tparam Size The size of the array viewed. The default value
* ARRAY_VIEW_DYNAMIC_SIZE is special as it allows construction of ArrayView
* objects of any size (set at runtime).
*/
template<typename T, ptrdiff_t Size = ARRAY_VIEW_DYNAMIC_SIZE>
struct ArrayView {
MBED_STATIC_ASSERT(Size >= 0, "Invalid size for an ArrayView");
/**
* Construct a view to an empty array.
*
* @post a call to size() will return 0, and data() will return NULL.
*/
ArrayView() : _array(NULL) { }
/**
* Construct an array view from a pointer to a buffer.
*
* @param array_ptr Pointer to the array data
* @param array_size Number of elements of T present in the array.
*
* @post a call to size() will return array_size and data() will return
* array_tpr.
*/
ArrayView(T* array_ptr, size_t array_size) :
_array(array_ptr) {
MBED_ASSERT(array_size >= (size_t) Size);
}
/**
* Construct an array view from the reference to an array.
*
* @param elements Reference to the array viewed.
*
* @tparam Size Number of elements of T presents in the array.
*
* @post a call to size() will return Size, and data() will return
* a pointer to elements.
*/
ArrayView(T (&elements)[Size]):
_array(elements) { }
/**
* Return the size of the array viewed.
*
* @return The number of elements present in the array viewed.
*/
size_t size() const
{
return _array ? Size : 0;
}
/**
* Access to a mutable element of the array.
*
* @param index Element index to access.
*
* @return A reference to the element at the index specified in input.
*
* @pre index shall be less than size().
*/
T& operator[](size_t index)
{
return _array[index];
}
/**
* Access to an immutable element of the array.
*
* @param index Element index to access.
*
* @return A const reference to the element at the index specified in input.
*
* @pre index shall be less than size().
*/
const T& operator[](size_t index) const
{
return _array[index];
}
/**
* Get the raw pointer to the array.
*
* @return The raw pointer to the array.
*/
T* data()
{
return _array;
}
/**
* Get the raw const pointer to the array.
*
* @return The raw pointer to the array.
*/
const T* data() const
{
return _array;
}
private:
T* const _array;
};
/**
* ArrayView specialisation that handle dynamic array size.
*/
template<typename T>
struct ArrayView<T, ARRAY_VIEW_DYNAMIC_SIZE> {
/**
* Construct a view to an empty array.
*
* @post a call to size() will return 0, and data() will return NULL.
*/
ArrayView() : _array(0), _size(0) { }
/**
* Construct an array view from a pointer to a buffer and its size.
*
* @param array_ptr Pointer to the array data
* @param array_size Number of elements of T present in the array.
*
* @post a call to size() will return array_size and data() will return
* array_tpr.
*/
ArrayView(T* array_ptr, size_t array_size) :
_array(array_ptr), _size(array_size) { }
/**
* Construct an array view from the reference to an array.
*
* @param elements Reference to the array viewed.
*
* @tparam Size Number of elements of T presents in the array.
*
* @post a call to size() will return Size, and data() will return
* a pointer to elements.
*/
template<size_t Size>
ArrayView(T (&elements)[Size]):
_array(elements), _size(Size) { }
/**
* Construct a ArrayView object with a dynamic size from an ArrayView object
* with a static size.
* @param other The ArrayView object used to construct this.
*/
template<size_t Size>
ArrayView(ArrayView<T, Size> other):
_array(other.data()), _size(other.size()) { }
/**
* Return the size of the array viewed.
*
* @return The number of elements present in the array viewed.
*/
size_t size() const
{
return _size;
}
/**
* Access to a mutable element of the array.
*
* @param index Element index to access.
*
* @return A reference to the element at the index specified in input.
*
* @pre index shall be less than size().
*/
T& operator[](size_t index)
{
return _array[index];
}
/**
* Access to an immutable element of the array.
*
* @param index Element index to access.
*
* @return A const reference to the element at the index specified in input.
*
* @pre index shall be less than size().
*/
const T& operator[](size_t index) const
{
return _array[index];
}
/**
* Get the raw pointer to the array.
*
* @return The raw pointer to the array.
*/
T* data()
{
return _array;
}
/**
* Get the raw const pointer to the array.
*
* @return The raw pointer to the array.
*/
const T* data() const
{
return _array;
}
private:
T* const _array;
const size_t _size;
};
/**
* Equality operator.
*
* @param lhs Left hand side of the binary operation.
* @param rhs Right hand side of the binary operation.
*
* @return True if arrays in input have the same size and the same content
* and false otherwise.
*/
template<typename T, ptrdiff_t LhsSize, ptrdiff_t RhsSize>
bool operator==(const ArrayView<T, LhsSize>& lhs, const ArrayView<T, LhsSize>& rhs)
{
if (lhs.size() != rhs.size()) {
return false;
}
if (lhs.data() == rhs.data()) {
return true;
}
return std::equal(lhs.data(), lhs.data() + lhs.size(), rhs.data());
}
/**
* Not equal operator
*
* @param lhs Left hand side of the binary operation.
* @param rhs Right hand side of the binary operation.
*
* @return True if arrays in input do not have the same size or the same
* content and false otherwise.
*/
template<typename T, ptrdiff_t LhsSize, ptrdiff_t RhsSize>
bool operator!=(const ArrayView<T, LhsSize>& lhs, const ArrayView<T, LhsSize>& rhs)
{
return !(lhs == rhs);
}
/**
* Generate an array view from a reference to a C/C++ array.
*
* @tparam T Type of elements held in elements.
* @tparam Size Number of items held in elements.
*
* @param elements The reference to the array viewed.
*
* @return The ArrayView to elements.
*
* @note This helper avoids the typing of template parameter when ArrayView is
* created 'inline'.
*/
template<typename T, size_t Size>
ArrayView<T, Size> make_ArrayView(T (&elements)[Size])
{
return ArrayView<T, Size>(elements);
}
/**
* Generate an array view from a pointer to a C/C++ array.
*
* @tparam Size Number of items held in elements.
* @tparam T Type of elements held in elements.
*
* @param elements The reference to the array viewed.
*
* @return The ArrayView to elements.
*
* @note This helper avoids the typing of template parameter when ArrayView is
* created 'inline'.
*/
template<size_t Size, typename T>
ArrayView<T, Size> make_ArrayView(T* elements)
{
return ArrayView<T, Size>(elements, Size);
}
/**
* Generate an array view from a C/C++ pointer and the size of the array.
*
* @tparam T Type of elements held in array_ptr.
*
* @param array_ptr The pointer to the array to viewed.
* @param array_size The number of T elements in the array.
*
* @return The ArrayView to array_ptr with a size of array_size.
*
* @note This helper avoids the typing of template parameter when ArrayView is
* created 'inline'.
*/
template<typename T>
ArrayView<T> make_ArrayView(T* array_ptr, size_t array_size)
{
return ArrayView<T>(array_ptr, array_size);
}
/**
* Generate a const array view from a reference to a C/C++ array.
*
* @tparam T Type of elements held in elements.
* @tparam Size Number of items held in elements.
*
* @param elements The array viewed.
* @return The ArrayView to elements.
*
* @note This helper avoids the typing of template parameter when ArrayView is
* created 'inline'.
*/
template<typename T, size_t Size>
ArrayView<const T, Size> make_const_ArrayView(T (&elements)[Size])
{
return ArrayView<const T, Size>(elements);
}
/**
* Generate a const array view from a pointer to a C/C++ array.
*
* @tparam Size Number of items held in elements.
* @tparam T Type of elements held in elements.
*
* @param elements The reference to the array viewed.
*
* @return The ArrayView to elements.
*
* @note This helper avoids the typing of template parameter when ArrayView is
* created 'inline'.
*/
template<size_t Size, typename T>
ArrayView<const T, Size> make_const_ArrayView(const T* elements)
{
return ArrayView<const T, Size>(elements, Size);
}
/**
* Generate a const array view from a C/C++ pointer and the size of the array.
*
* @tparam T Type of elements held in array_ptr.
*
* @param array_ptr The pointer to the array to viewed.
* @param array_size The number of T elements in the array.
*
* @return The ArrayView to array_ptr with a size of array_size.
*
* @note This helper avoids the typing of template parameter when ArrayView is
* created 'inline'.
*/
template<typename T>
ArrayView<const T> make_const_ArrayView(T* array_ptr, size_t array_size)
{
return ArrayView<const T>(array_ptr, array_size);
}
} // namespace ble
/**
* @}
* @}
*/
#endif /* BLE_ARRAY_VIEW_H_ */

View File

@ -21,7 +21,7 @@
#include <stdint.h>
#include <string.h>
#include "ble/SafeEnum.h"
#include "ble/ArrayView.h"
#include "platform/Span.h"
#include "ble/gap/Types.h"
/**
@ -33,6 +33,10 @@
namespace ble {
using mbed::Span;
using mbed::make_Span;
using mbed::make_const_Span;
/** Special advertising set handle used for the legacy advertising set. */
static const advertising_handle_t LEGACY_ADVERTISING_HANDLE = 0x00;
@ -412,29 +416,29 @@ protected:
};
/**
* Construct a fixed size ArrayView from a byte_array_t.
* Construct a fixed size Span from a byte_array_t.
*
* @param src byte_array_t to create a view from.
* @param src byte_array_t to create a Span from.
*
* @return An ArrayView to @p src.
* @return A Span to @p src.
*/
template<size_t Size>
ArrayView<uint8_t, Size> make_ArrayView(byte_array_t<Size>& src)
Span<uint8_t, Size> make_Span(byte_array_t<Size>& src)
{
return ArrayView<uint8_t, Size>(src.data(), src.size());
return Span<uint8_t, Size>(src.data(), src.size());
}
/**
* Construct a fixed size ArrayView from a const byte_array_t.
* Construct a fixed size Span from a const byte_array_t.
*
* @param src byte_array_t to create a view from.
* @param src byte_array_t to create a Span from.
*
* @return An ArrayView to @p src.
* @return A Span to @p src.
*/
template<size_t Size>
ArrayView<const uint8_t, Size> make_const_ArrayView(const byte_array_t<Size>& src)
Span<const uint8_t, Size> make_const_Span(const byte_array_t<Size>& src)
{
return ArrayView<const uint8_t, Size>(src.data(), src.size());
return Span<const uint8_t, Size>(src.data(), src.size());
}
/** 128 bit keys used by paired devices */

View File

@ -1438,13 +1438,13 @@ public:
* Reset the value of the advertising payload advertised.
*
* @deprecated Deprecated since addition of extended advertising support.
* Use setAdvertisingPayload(ble::advertising_handle_t, mbed::Span<uint8_t>,
* Use setAdvertisingPayload(ble::advertising_handle_t, Span<uint8_t>,
* bool).
*/
MBED_DEPRECATED_SINCE(
"mbed-os-5.11.0",
"Deprecated since addition of extended advertising support. "
"Use setAdvertisingPayload(ble::advertising_handle_t, mbed::Span<uint8_t>,"
"Use setAdvertisingPayload(ble::advertising_handle_t, Span<uint8_t>,"
"bool)."
)
void clearAdvertisingPayload(void);

View File

@ -21,7 +21,7 @@
#include <string.h>
#include <stdlib.h>
#include "platform/Span.h"
#include "ble/BLETypes.h"
#include "platform/NonCopyable.h"
#include "ble/blecommon.h"

View File

@ -19,7 +19,6 @@
#include <stdint.h>
#include "ble/gap/AdvertisingDataTypes.h"
#include "platform/Span.h"
namespace ble {

View File

@ -19,7 +19,6 @@
#include "ble/blecommon.h"
#include "ble/BLETypes.h"
#include "platform/Span.h"
namespace ble {

View File

@ -183,14 +183,14 @@ public:
*/
ble_error_t setAdvertisingPayload_(
advertising_handle_t handle,
mbed::Span<const uint8_t> payload
Span<const uint8_t> payload
);
/** @copydoc Gap::setAdvertisingScanResponse
*/
ble_error_t setAdvertisingScanResponse_(
advertising_handle_t handle,
mbed::Span<const uint8_t> response
Span<const uint8_t> response
);
/** @copydoc Gap::startAdvertising
@ -222,7 +222,7 @@ public:
*/
ble_error_t setPeriodicAdvertisingPayload_(
advertising_handle_t handle,
mbed::Span<const uint8_t> payload
Span<const uint8_t> payload
);
/** @copydoc Gap::startPeriodicAdvertising
@ -626,7 +626,7 @@ public:
private:
ble_error_t setAdvertisingData(
advertising_handle_t handle,
mbed::Span<const uint8_t> payload,
Span<const uint8_t> payload,
bool minimiseFragmentation,
bool scan_response
);

View File

@ -26,7 +26,6 @@
#include "ble/pal/SigningEventMonitor.h"
#include "ble/generic/GenericGap.h"
#include "ble/pal/PalSecurityManager.h"
#include "ble/ArrayView.h"
namespace ble {
namespace generic {
@ -473,7 +472,7 @@ private:
* @param count Number of identities entries retrieved.
*/
void on_identity_list_retrieved(
ble::ArrayView<SecurityEntryIdentity_t>& identity_list,
Span<SecurityEntryIdentity_t>& identity_list,
size_t count
);

View File

@ -121,7 +121,7 @@ public:
SecurityEntrySigningDbCb_t;
typedef mbed::Callback<void(entry_handle_t, const SecurityEntryIdentity_t*)>
SecurityEntryIdentityDbCb_t;
typedef mbed::Callback<void(ArrayView<SecurityEntryIdentity_t>&, size_t count)>
typedef mbed::Callback<void(Span<SecurityEntryIdentity_t>&, size_t count)>
IdentitylistDbCb_t;
typedef mbed::Callback<void(::Gap::Whitelist_t*)>
WhitelistDbCb_t;
@ -340,7 +340,7 @@ public:
*/
virtual void get_identity_list(
IdentitylistDbCb_t cb,
ArrayView<SecurityEntryIdentity_t>& identity_list
Span<SecurityEntryIdentity_t>& identity_list
) {
size_t count = 0;
for (size_t i = 0; i < get_entry_count() && count < identity_list.size(); ++i) {

View File

@ -20,7 +20,6 @@
#include "ble/common/StaticInterface.h"
#include "ble/UUID.h"
#include "ble/BLETypes.h"
#include "ble/ArrayView.h"
#include "ble/blecommon.h"
#include "platform/Callback.h"
#include "AttServerMessage.h"
@ -197,7 +196,7 @@ public:
connection_handle_t connection_handle,
attribute_handle_range_t discovery_range,
uint16_t type,
const ArrayView<const uint8_t>& value
const Span<const uint8_t>& value
) {
return impl()->find_by_type_value_request_(
connection_handle,
@ -381,7 +380,7 @@ public:
*/
ble_error_t read_multiple_request(
connection_handle_t connection_handle,
const ArrayView<const attribute_handle_t>& attribute_handles
const Span<const attribute_handle_t>& attribute_handles
) {
return impl()->read_multiple_request_(connection_handle, attribute_handles);
}
@ -489,7 +488,7 @@ public:
ble_error_t write_request(
connection_handle_t connection_handle,
attribute_handle_t attribute_handle,
const ArrayView<const uint8_t>& value
const Span<const uint8_t>& value
) {
return impl()->write_request_(connection_handle, attribute_handle, value);
}
@ -511,7 +510,7 @@ public:
ble_error_t write_command(
connection_handle_t connection_handle,
attribute_handle_t attribute_handle,
const ArrayView<const uint8_t>& value
const Span<const uint8_t>& value
) {
return impl()->write_command_(connection_handle, attribute_handle, value);
}
@ -538,7 +537,7 @@ public:
ble_error_t signed_write_command(
connection_handle_t connection_handle,
attribute_handle_t attribute_handle,
const ArrayView<const uint8_t>& value
const Span<const uint8_t>& value
) {
return impl()->signed_write_command_(connection_handle, attribute_handle, value);
}
@ -593,7 +592,7 @@ public:
connection_handle_t connection_handle,
attribute_handle_t attribute_handle,
uint16_t offset,
const ArrayView<const uint8_t>& value
const Span<const uint8_t>& value
) {
return impl()->prepare_write_request_(
connection_handle,

View File

@ -97,7 +97,7 @@ public:
connection_handle,
attribute_handle_range(discovery_range_begining, END_ATTRIBUTE_HANDLE),
SERVICE_TYPE_UUID,
ArrayView<const uint8_t>(
Span<const uint8_t>(
uuid.getBaseUUID(),
(uuid.shortOrLong() == UUID::UUID_TYPE_SHORT) ? 2 : UUID::LENGTH_OF_LONG_UUID
)
@ -193,7 +193,7 @@ public:
*/
ble_error_t read_multiple_characteristic_values_(
connection_handle_t connection_handle,
const ArrayView<const attribute_handle_t>& characteristic_value_handles
const Span<const attribute_handle_t>& characteristic_value_handles
) {
return _client.read_multiple_request(
connection_handle,
@ -207,7 +207,7 @@ public:
ble_error_t write_without_response_(
connection_handle_t connection_handle,
attribute_handle_t characteristic_value_handle,
const ArrayView<const uint8_t>& value
const Span<const uint8_t>& value
) {
return _client.write_command(
connection_handle,
@ -222,7 +222,7 @@ public:
ble_error_t signed_write_without_response_(
connection_handle_t connection_handle,
attribute_handle_t characteristic_value_handle,
const ArrayView<const uint8_t>& value
const Span<const uint8_t>& value
) {
return _client.signed_write_command(
connection_handle,
@ -237,7 +237,7 @@ public:
ble_error_t write_attribute_(
connection_handle_t connection_handle,
attribute_handle_t attribute_handle,
const ArrayView<const uint8_t>& value
const Span<const uint8_t>& value
) {
return _client.write_request(
connection_handle,
@ -252,7 +252,7 @@ public:
ble_error_t queue_prepare_write_(
connection_handle_t connection_handle,
attribute_handle_t characteristic_value_handle,
const ArrayView<const uint8_t>& value,
const Span<const uint8_t>& value,
uint16_t offset
) {
return _client.prepare_write_request(

View File

@ -18,7 +18,6 @@
#define BLE_PAL_ATT_SERVER_MESSAGE_H_
#include "ble/BLETypes.h"
#include "ble/ArrayView.h"
namespace ble {
namespace pal {
@ -400,7 +399,7 @@ struct AttReadByTypeResponse : public AttServerMessage {
*/
struct attribute_data_t {
attribute_handle_t handle;
ArrayView<const uint8_t> value;
Span<const uint8_t> value;
};
/**
@ -446,7 +445,7 @@ struct AttReadResponse : public AttServerMessage {
/**
* Construct a Read Response from an array of bytes.
*/
AttReadResponse(ArrayView<const uint8_t> data_) :
AttReadResponse(Span<const uint8_t> data_) :
AttServerMessage(AttributeOpcode::READ_RESPONSE), _data(data_) {
}
@ -473,7 +472,7 @@ struct AttReadResponse : public AttServerMessage {
}
private:
const ArrayView<const uint8_t> _data;
const Span<const uint8_t> _data;
};
@ -495,7 +494,7 @@ struct AttReadBlobResponse : public AttServerMessage {
/**
* Construct a read blob response from the value responded.
*/
AttReadBlobResponse(ArrayView<const uint8_t> data_) :
AttReadBlobResponse(Span<const uint8_t> data_) :
AttServerMessage(AttributeOpcode::READ_BLOB_RESPONSE), _data(data_) {
}
@ -522,7 +521,7 @@ struct AttReadBlobResponse : public AttServerMessage {
}
private:
const ArrayView<const uint8_t> _data;
const Span<const uint8_t> _data;
};
@ -539,7 +538,7 @@ struct AttReadMultipleResponse : public AttServerMessage {
/**
* Construct a Resd Multiple Response from the set of value received.
*/
AttReadMultipleResponse(ArrayView<const uint8_t> data_) :
AttReadMultipleResponse(Span<const uint8_t> data_) :
AttServerMessage(AttributeOpcode::READ_MULTIPLE_RESPONSE), _data(data_) {
}
@ -559,7 +558,7 @@ struct AttReadMultipleResponse : public AttServerMessage {
}
private:
const ArrayView<const uint8_t> _data;
const Span<const uint8_t> _data;
};
@ -588,7 +587,7 @@ struct AttReadByGroupTypeResponse : public AttServerMessage {
*/
struct attribute_data_t {
attribute_handle_range_t group_range;
ArrayView<const uint8_t> value;
Span<const uint8_t> value;
};
/**
@ -651,7 +650,7 @@ struct AttPrepareWriteResponse : public AttServerMessage {
AttPrepareWriteResponse(
attribute_handle_t handle_,
uint16_t offset_,
ArrayView<const uint8_t> value_
Span<const uint8_t> value_
) : AttServerMessage(AttributeOpcode::PREPARE_WRITE_RESPONSE),
attribute_handle(handle_),
offset(offset_),
@ -671,7 +670,7 @@ struct AttPrepareWriteResponse : public AttServerMessage {
/**
* The value of the attribute to be written at the offset indicated.
*/
const ArrayView<const uint8_t> partial_value;
const Span<const uint8_t> partial_value;
};
@ -712,7 +711,7 @@ struct AttHandleValueNotification : public AttServerMessage {
*/
AttHandleValueNotification(
attribute_handle_t attribute_handle,
ArrayView<const uint8_t> attribute_value
Span<const uint8_t> attribute_value
) : AttServerMessage(AttributeOpcode::HANDLE_VALUE_NOTIFICATION),
attribute_handle(attribute_handle),
attribute_value(attribute_value) {
@ -726,7 +725,7 @@ struct AttHandleValueNotification : public AttServerMessage {
/**
* The current value of the attribute.
*/
const ArrayView<const uint8_t> attribute_value;
const Span<const uint8_t> attribute_value;
};
@ -748,7 +747,7 @@ struct AttHandleValueIndication : public AttServerMessage {
* value indicated.
*/
AttHandleValueIndication(
attribute_handle_t handle, ArrayView<const uint8_t> value
attribute_handle_t handle, Span<const uint8_t> value
) : AttServerMessage(AttributeOpcode::HANDLE_VALUE_INDICATION),
attribute_handle(handle), attribute_value(value) {
}
@ -761,7 +760,7 @@ struct AttHandleValueIndication : public AttServerMessage {
/**
* The current value of the attribute.
*/
const ArrayView<const uint8_t> attribute_value;
const Span<const uint8_t> attribute_value;
};

View File

@ -18,7 +18,7 @@
#define BLE_PAL_GAP_MESSAGE_H_
#include "GapTypes.h"
#include "ble/ArrayView.h"
#include "ble/BLETypes.h"
namespace ble {
namespace pal {
@ -307,7 +307,7 @@ struct GapAdvertisingReportEvent : public GapEvent {
received_advertising_type_t type;
connection_peer_address_type_t address_type;
address_t address;
ArrayView<const uint8_t> data;
Span<const uint8_t> data;
int8_t rssi;
};

View File

@ -18,7 +18,7 @@
#define BLE_PAL_GENERIC_ACCESS_SERVICE_H_
#include "GapTypes.h"
#include "ble/ArrayView.h"
#include "ble/BLETypes.h"
#include "ble/blecommon.h"
#include "ble/GapAdvertisingData.h"
#include "ble/Gap.h"
@ -71,7 +71,7 @@ struct GenericAccessService {
*
* @see Bluetooth 4.2 Vol 3 PartC: 12.1 - Device Name Characteristic
*/
virtual ble_error_t get_device_name(ArrayView<uint8_t>& array) = 0;
virtual ble_error_t get_device_name(Span<uint8_t>& array) = 0;
/**
* Set the value of the device name characteristic exposed by the GAP GATT

View File

@ -20,7 +20,6 @@
#include "ble/common/StaticInterface.h"
#include "ble/UUID.h"
#include "ble/BLETypes.h"
#include "ble/ArrayView.h"
#include "ble/blecommon.h"
#include "platform/Callback.h"
@ -516,7 +515,7 @@ public:
*/
ble_error_t read_multiple_characteristic_values(
connection_handle_t connection_handle,
const ArrayView<const attribute_handle_t>& characteristic_value_handles
const Span<const attribute_handle_t>& characteristic_value_handles
) {
return self()->read_multiple_characteristic_values_(
connection_handle,
@ -540,7 +539,7 @@ public:
ble_error_t write_without_response(
connection_handle_t connection_handle,
attribute_handle_t characteristic_value_handle,
const ArrayView<const uint8_t>& value
const Span<const uint8_t>& value
) {
return self()->write_without_response_(
connection_handle,
@ -568,7 +567,7 @@ public:
ble_error_t signed_write_without_response(
connection_handle_t connection_handle,
attribute_handle_t characteristic_value_handle,
const ArrayView<const uint8_t>& value
const Span<const uint8_t>& value
) {
return self()->signed_write_without_response_(
connection_handle,
@ -600,7 +599,7 @@ public:
ble_error_t write_attribute(
connection_handle_t connection_handle,
attribute_handle_t attribute_handle,
const ArrayView<const uint8_t>& value
const Span<const uint8_t>& value
) {
return self()->write_attribute_(connection_handle, attribute_handle, value);
}
@ -637,7 +636,7 @@ public:
ble_error_t queue_prepare_write(
connection_handle_t connection_handle,
attribute_handle_t characteristic_value_handle,
const ArrayView<const uint8_t>& value,
const Span<const uint8_t>& value,
uint16_t offset
) {
return self()->queue_prepare_write_(

View File

@ -43,7 +43,7 @@ struct SimpleAttFindInformationResponse : public AttFindInformationResponse {
* by the Format field
*/
SimpleAttFindInformationResponse(
Format format, ArrayView<const uint8_t> information_data
Format format, Span<const uint8_t> information_data
) : AttFindInformationResponse(),
_format(format), _information_data(information_data),
_item_size(information_data_item_size()) {
@ -82,7 +82,7 @@ private:
}
const Format _format;
const ArrayView<const uint8_t> _information_data;
const Span<const uint8_t> _information_data;
const size_t _item_size;
};
@ -97,7 +97,7 @@ struct SimpleAttFindByTypeValueResponse : public AttFindByTypeValueResponse {
* Handle Informations.
* @param handles raw array containing one or more Handle Informations.
*/
SimpleAttFindByTypeValueResponse(ArrayView<const uint8_t> handles) :
SimpleAttFindByTypeValueResponse(Span<const uint8_t> handles) :
AttFindByTypeValueResponse(), _handles(handles) {
}
@ -121,7 +121,7 @@ struct SimpleAttFindByTypeValueResponse : public AttFindByTypeValueResponse {
private:
static const size_t item_size = 4;
const ArrayView<const uint8_t> _handles;
const Span<const uint8_t> _handles;
};
@ -138,7 +138,7 @@ struct SimpleAttReadByTypeResponse : public AttReadByTypeResponse {
* data.
*/
SimpleAttReadByTypeResponse(
uint8_t element_size, ArrayView<const uint8_t> attribute_data
uint8_t element_size, Span<const uint8_t> attribute_data
) : AttReadByTypeResponse(),
_attribute_data(attribute_data), _element_size(element_size) {
}
@ -160,7 +160,7 @@ struct SimpleAttReadByTypeResponse : public AttReadByTypeResponse {
attribute_data_t result = {
handle,
ArrayView<const uint8_t>(
Span<const uint8_t>(
item + sizeof(handle),
_element_size - sizeof(handle)
)
@ -170,7 +170,7 @@ struct SimpleAttReadByTypeResponse : public AttReadByTypeResponse {
}
private:
ArrayView<const uint8_t> _attribute_data;
Span<const uint8_t> _attribute_data;
uint8_t _element_size;
};
@ -187,7 +187,7 @@ struct SimpleAttReadByGroupTypeResponse : public AttReadByGroupTypeResponse {
* @param attribute_data Byte array containing the list of Attribute Data.
*/
SimpleAttReadByGroupTypeResponse(
uint8_t element_size, ArrayView<const uint8_t> attribute_data
uint8_t element_size, Span<const uint8_t> attribute_data
) : AttReadByGroupTypeResponse(),
_attribute_data(attribute_data), _element_size(element_size) {
}
@ -212,7 +212,7 @@ struct SimpleAttReadByGroupTypeResponse : public AttReadByGroupTypeResponse {
attribute_data_t result = {
{ begin, end },
ArrayView<const uint8_t>(
Span<const uint8_t>(
item + sizeof(begin) + sizeof(end),
_element_size - (sizeof(begin) + sizeof(end))
)
@ -222,7 +222,7 @@ struct SimpleAttReadByGroupTypeResponse : public AttReadByGroupTypeResponse {
}
private:
ArrayView<const uint8_t> _attribute_data;
Span<const uint8_t> _attribute_data;
uint8_t _element_size;
};

View File

@ -27,7 +27,6 @@
#include "ble/generic/GenericGap.h"
#include "drivers/Timeout.h"
#include "platform/Span.h"
#include "ble/pal/Deprecated.h"
@ -1007,7 +1006,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
return BLE_ERROR_INVALID_PARAM;
}
ArrayView<uint8_t> name(deviceName, *lengthP);
Span<uint8_t> name(deviceName, *lengthP);
err = _gap_service.get_device_name(name);
if (err) {
return err;
@ -1768,7 +1767,7 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
/* NO PERIODIC ADVERTISING */ 0,
peer_address_type_t::ANONYMOUS,
ble::address_t (),
mbed::Span<const uint8_t>(advertising.data.data(), advertising.data.size())
Span<const uint8_t>(advertising.data.data(), advertising.data.size())
)
);
}
@ -2434,7 +2433,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::setAdvertisingPayload_(
advertising_handle_t handle,
mbed::Span<const uint8_t> payload
Span<const uint8_t> payload
)
{
useVersionTwoAPI();
@ -2450,7 +2449,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::setAdvertisingScanResponse_(
advertising_handle_t handle,
mbed::Span<const uint8_t> response
Span<const uint8_t> response
)
{
useVersionTwoAPI();
@ -2466,7 +2465,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::setAdvertisingData(
advertising_handle_t handle,
mbed::Span<const uint8_t> payload,
Span<const uint8_t> payload,
bool minimiseFragmentation,
bool scan_response
)
@ -2562,7 +2561,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
}
// extract the payload
mbed::Span<const uint8_t> sub_payload = payload.subspan(
Span<const uint8_t> sub_payload = payload.subspan(
i,
std::min(hci_length, (end - i))
);
@ -2750,7 +2749,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::setPeriodicAdvertisingPayload_(
advertising_handle_t handle,
mbed::Span<const uint8_t> payload
Span<const uint8_t> payload
)
{
useVersionTwoAPI();
@ -2790,7 +2789,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
}
// extract the payload
mbed::Span<const uint8_t> sub_payload = payload.subspan(
Span<const uint8_t> sub_payload = payload.subspan(
i,
std::min(hci_length, (end - i))
);
@ -2973,7 +2972,7 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
periodic_advertising_interval,
(ble::peer_address_type_t::type) direct_address_type.value(),
(BLEProtocol::AddressBytes_t &) direct_address,
mbed::make_Span(data, data_length)
make_Span(data, data_length)
)
);
} else {
@ -3065,7 +3064,7 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
tx_power,
rssi,
data_status,
mbed::make_const_Span(data, data_length)
make_const_Span(data, data_length)
)
);
}

View File

@ -367,7 +367,7 @@ struct GenericGattClient<TPalGattClient, SigningMonitorEventHandler>::DiscoveryC
GattClient* client,
connection_handle_t connection_handle,
uint16_t decl_handle,
const ArrayView<const uint8_t> value
const Span<const uint8_t> value
) : DiscoveredCharacteristic() {
gattc = client;
uuid = get_uuid(value);
@ -378,7 +378,7 @@ struct GenericGattClient<TPalGattClient, SigningMonitorEventHandler>::DiscoveryC
connHandle = connection_handle;
}
static UUID get_uuid(const ArrayView<const uint8_t>& value) {
static UUID get_uuid(const Span<const uint8_t>& value) {
if (value.size() == 5) {
return UUID(value[3] | (value[4] << 8));
} else {
@ -386,7 +386,7 @@ struct GenericGattClient<TPalGattClient, SigningMonitorEventHandler>::DiscoveryC
}
}
static DiscoveredCharacteristic::Properties_t get_properties(const ArrayView<const uint8_t>& value) {
static DiscoveredCharacteristic::Properties_t get_properties(const Span<const uint8_t>& value) {
uint8_t raw_properties = value[0];
DiscoveredCharacteristic::Properties_t result;
result._broadcast = (raw_properties & (1 << 0)) ? true : false;
@ -399,7 +399,7 @@ struct GenericGattClient<TPalGattClient, SigningMonitorEventHandler>::DiscoveryC
return result;
}
static uint16_t get_value_handle(const ArrayView<const uint8_t>& value) {
static uint16_t get_value_handle(const Span<const uint8_t>& value) {
return value[1] | (value[2] << 8);
}
@ -729,7 +729,7 @@ struct GenericGattClient<TPalGattClient, SigningMonitorEventHandler>::WriteContr
if (offset < len) {
err = client->_pal_client->queue_prepare_write(
connection_handle, attribute_handle,
make_const_ArrayView(
make_const_Span(
data + offset,
std::min((len - offset), (mtu_size - 5))
),
@ -1135,7 +1135,7 @@ ble_error_t GenericGattClient<TPalGattClient, SigningMonitorEventHandler>::write
return _pal_client->write_without_response(
connection_handle,
attribute_handle,
make_const_ArrayView(value, length)
make_const_Span(value, length)
);
#if BLE_FEATURE_SIGNING
} else if (cmd == Base::GATT_OP_SIGNED_WRITE_CMD) {
@ -1145,7 +1145,7 @@ ble_error_t GenericGattClient<TPalGattClient, SigningMonitorEventHandler>::write
ble_error_t status = _pal_client->signed_write_without_response(
connection_handle,
attribute_handle,
make_const_ArrayView(value, length)
make_const_Span(value, length)
);
if (_signing_event_handler && (status == BLE_ERROR_NONE)) {
@ -1183,14 +1183,14 @@ ble_error_t GenericGattClient<TPalGattClient, SigningMonitorEventHandler>::write
err = _pal_client->queue_prepare_write(
connection_handle,
attribute_handle,
make_const_ArrayView(value, mtu - PREPARE_WRITE_HEADER_LENGTH),
make_const_Span(value, mtu - PREPARE_WRITE_HEADER_LENGTH),
/* offset */0
);
} else {
err = _pal_client->write_attribute(
connection_handle,
attribute_handle,
make_const_ArrayView(value, length)
make_const_Span(value, length)
);
}

View File

@ -861,7 +861,7 @@ ble_error_t GenericSecurityManager<TPalSecurityManager, SigningMonitor>::init_re
new (std::nothrow) SecurityEntryIdentity_t[resolving_list_capacity];
if (identity_list_p) {
ArrayView<SecurityEntryIdentity_t> identity_list(
Span<SecurityEntryIdentity_t> identity_list(
identity_list_p,
resolving_list_capacity
);
@ -1187,7 +1187,7 @@ void GenericSecurityManager<TPalSecurityManager, SigningMonitor>::on_security_en
template<template<class> class TPalSecurityManager, template<class> class SigningMonitor>
void GenericSecurityManager<TPalSecurityManager, SigningMonitor>::on_identity_list_retrieved(
ble::ArrayView<SecurityEntryIdentity_t>& identity_list,
Span<SecurityEntryIdentity_t>& identity_list,
size_t count
) {
typedef advertising_peer_address_type_t address_type_t;

View File

@ -83,7 +83,7 @@ public:
connection_handle_t connection_handle,
attribute_handle_range_t discovery_range,
uint16_t type,
const ArrayView<const uint8_t>& value
const Span<const uint8_t>& value
) {
AttcFindByTypeValueReq(
connection_handle,
@ -149,7 +149,7 @@ public:
*/
ble_error_t read_multiple_request_(
connection_handle_t connection_handle,
const ArrayView<const attribute_handle_t>& attribute_handles
const Span<const attribute_handle_t>& attribute_handles
) {
AttcReadMultipleReq(
connection_handle,
@ -184,7 +184,7 @@ public:
ble_error_t write_request_(
connection_handle_t connection_handle,
attribute_handle_t attribute_handle,
const ArrayView<const uint8_t>& value
const Span<const uint8_t>& value
) {
AttcWriteReq(
connection_handle,
@ -201,7 +201,7 @@ public:
ble_error_t write_command_(
connection_handle_t connection_handle,
attribute_handle_t attribute_handle,
const ArrayView<const uint8_t>& value
const Span<const uint8_t>& value
) {
AttcWriteCmd(
connection_handle,
@ -218,7 +218,7 @@ public:
ble_error_t signed_write_command_(
connection_handle_t connection_handle,
attribute_handle_t attribute_handle,
const ArrayView<const uint8_t>& value
const Span<const uint8_t>& value
) {
AttcSignedWriteCmd(
connection_handle,
@ -250,7 +250,7 @@ public:
connection_handle_t connection_handle,
attribute_handle_t attribute_handle,
uint16_t offset,
const ArrayView<const uint8_t>& value
const Span<const uint8_t>& value
) {
AttcPrepareWriteReq(
connection_handle,
@ -409,7 +409,7 @@ private:
{
return SimpleAttFindInformationResponse(
static_cast<SimpleAttFindInformationResponse::Format>(event->pValue[0]),
make_const_ArrayView(
make_const_Span(
event->pValue + 1,
event->valueLen - 1
)
@ -424,7 +424,7 @@ private:
static SimpleAttFindByTypeValueResponse convert(const attEvt_t* event)
{
return SimpleAttFindByTypeValueResponse(
make_const_ArrayView(
make_const_Span(
event->pValue,
event->valueLen
)
@ -440,7 +440,7 @@ private:
{
return SimpleAttReadByTypeResponse(
event->pValue[0],
make_const_ArrayView(
make_const_Span(
event->pValue + 1,
event->valueLen - 1
)
@ -455,7 +455,7 @@ private:
static AttReadResponse convert(const attEvt_t* event)
{
return AttReadResponse(
make_const_ArrayView(
make_const_Span(
event->pValue,
event->valueLen
)
@ -470,7 +470,7 @@ private:
static AttReadBlobResponse convert(const attEvt_t* event)
{
return AttReadBlobResponse(
make_const_ArrayView(
make_const_Span(
event->pValue,
event->valueLen
)
@ -485,7 +485,7 @@ private:
static AttReadMultipleResponse convert(const attEvt_t* event)
{
return AttReadMultipleResponse(
make_const_ArrayView(
make_const_Span(
event->pValue,
event->valueLen
)
@ -501,7 +501,7 @@ private:
{
return SimpleAttReadByGroupTypeResponse(
event->pValue[0],
make_const_ArrayView(
make_const_Span(
event->pValue + 1,
event->valueLen - 1
)
@ -530,7 +530,7 @@ private:
event->handle,
to_uint16_t(event->pValue + 2),
// FIXME: the stack set the lenght to 0, the data won't be seen ...
make_const_ArrayView(
make_const_Span(
event->pValue + 4,
event->valueLen
)
@ -556,7 +556,7 @@ private:
{
return AttHandleValueNotification(
event->handle,
make_const_ArrayView(
make_const_Span(
event->pValue,
event->valueLen
)
@ -572,7 +572,7 @@ private:
{
return AttHandleValueIndication(
event->handle,
make_const_ArrayView(
make_const_Span(
event->pValue,
event->valueLen
)

View File

@ -366,7 +366,7 @@ private:
(received_advertising_type_t::type) scan_report->eventType,
(connection_peer_address_type_t::type) scan_report->addrType,
scan_report->addr,
make_const_ArrayView(scan_report->pData, scan_report->len),
make_const_Span(scan_report->pData, scan_report->len),
scan_report->rssi
};
return CordioGapAdvertisingReportEvent(advertising);

View File

@ -33,7 +33,7 @@ public:
#endif
}
virtual ble_error_t get_device_name(ArrayView<uint8_t>& array) {
virtual ble_error_t get_device_name(Span<uint8_t>& array) {
#if BLE_FEATURE_GATT_SERVER
const uint8_t* name = NULL;
uint16_t length = 0;

View File

@ -66,9 +66,9 @@ CryptoToolbox::~CryptoToolbox() {
}
bool CryptoToolbox::generate_keys(
ArrayView<uint8_t, lesc_key_size_> X,
ArrayView<uint8_t, lesc_key_size_> Y,
ArrayView<uint8_t, lesc_key_size_> secret
Span<uint8_t, lesc_key_size_> X,
Span<uint8_t, lesc_key_size_> Y,
Span<uint8_t, lesc_key_size_> secret
) {
mbedtls_mpi secret_key;
mbedtls_ecp_point public_keys;
@ -97,10 +97,10 @@ bool CryptoToolbox::generate_keys(
}
bool CryptoToolbox::generate_shared_secret(
const ArrayView<const uint8_t, lesc_key_size_>& peer_X,
const ArrayView<const uint8_t, lesc_key_size_>& peer_Y,
const ArrayView<const uint8_t, lesc_key_size_>& own_secret,
ArrayView<uint8_t, lesc_key_size_> shared_secret
const Span<const uint8_t, lesc_key_size_>& peer_X,
const Span<const uint8_t, lesc_key_size_>& peer_Y,
const Span<const uint8_t, lesc_key_size_>& own_secret,
Span<uint8_t, lesc_key_size_> shared_secret
) {
mbedtls_mpi result;
mbedtls_mpi secret_key;
@ -138,9 +138,9 @@ bool CryptoToolbox::generate_shared_secret(
#endif
bool CryptoToolbox::ah(
const ArrayView<const uint8_t, irk_size_>& irk,
const ArrayView<const uint8_t, prand_size_>& prand,
ArrayView<uint8_t, hash_size_> hash
const Span<const uint8_t, irk_size_>& irk,
const Span<const uint8_t, prand_size_>& prand,
Span<uint8_t, hash_size_> hash
) {
// Note copy then swap operation can be optimized.
@ -169,13 +169,13 @@ bool CryptoToolbox::ah(
#if defined(MBEDTLS_ECDH_C)
void CryptoToolbox::load_mpi(mbedtls_mpi& dest, const ArrayView<const uint8_t, lesc_key_size_>& src) {
void CryptoToolbox::load_mpi(mbedtls_mpi& dest, const Span<const uint8_t, lesc_key_size_>& src) {
ble::public_key_coord_t src_be = src.data();
swap_endian(src_be.data(), src_be.size());
mbedtls_mpi_read_binary(&dest, src_be.data(), src_be.size());
}
void CryptoToolbox::store_mpi(ArrayView<uint8_t, lesc_key_size_>& dest, const mbedtls_mpi& src) {
void CryptoToolbox::store_mpi(Span<uint8_t, lesc_key_size_>& dest, const mbedtls_mpi& src) {
mbedtls_mpi_write_binary(&src, dest.data(), dest.size());
swap_endian(dest.data(), dest.size());
}

View File

@ -88,9 +88,9 @@ public:
* false otherwise.
*/
bool generate_keys(
ArrayView<uint8_t, lesc_key_size_> X,
ArrayView<uint8_t, lesc_key_size_> Y,
ArrayView<uint8_t, lesc_key_size_> secret
Span<uint8_t, lesc_key_size_> X,
Span<uint8_t, lesc_key_size_> Y,
Span<uint8_t, lesc_key_size_> secret
);
/**
@ -103,10 +103,10 @@ public:
* false otherwise.
*/
bool generate_shared_secret(
const ArrayView<const uint8_t, lesc_key_size_>& peer_X,
const ArrayView<const uint8_t, lesc_key_size_>& peer_Y,
const ArrayView<const uint8_t, lesc_key_size_>& own_secret,
ArrayView<uint8_t, lesc_key_size_> shared_secret
const Span<const uint8_t, lesc_key_size_>& peer_X,
const Span<const uint8_t, lesc_key_size_>& peer_Y,
const Span<const uint8_t, lesc_key_size_>& own_secret,
Span<uint8_t, lesc_key_size_> shared_secret
);
#endif
@ -125,17 +125,17 @@ public:
* @return true in case of success and false otherwise.
*/
static bool ah(
const ArrayView<const uint8_t, irk_size_>& irk,
const ArrayView<const uint8_t, prand_size_>& prand,
ArrayView<uint8_t, hash_size_> hash
const Span<const uint8_t, irk_size_>& irk,
const Span<const uint8_t, prand_size_>& prand,
Span<uint8_t, hash_size_> hash
);
private:
#if defined(MBEDTLS_ECDH_C)
void load_mpi(mbedtls_mpi& dest, const ArrayView<const uint8_t, lesc_key_size_>& src);
void load_mpi(mbedtls_mpi& dest, const Span<const uint8_t, lesc_key_size_>& src);
void store_mpi(ArrayView<uint8_t, lesc_key_size_>& dest, const mbedtls_mpi& src);
void store_mpi(Span<uint8_t, lesc_key_size_>& dest, const mbedtls_mpi& src);
#endif
static void swap_endian(uint8_t* buf, size_t len);

View File

@ -42,7 +42,7 @@ template class ble::interface::Gap<nRF5xGap>;
using ble::pal::vendor::nordic::nRF5xSecurityManager;
typedef ble::impl::PalSecurityManagerImpl::resolving_list_entry_t resolving_list_entry_t;
using ble::ArrayView;
using mbed::Span;
using ble::pal::advertising_peer_address_type_t;
using ble::peer_address_type_t;
@ -280,10 +280,10 @@ ble_error_t nRF5xGap::startAdvertising_(const GapAdvertisingParams &params)
if (_privacy_enabled) {
if (_peripheral_privacy_configuration.resolution_strategy != PeripheralPrivacyConfiguration_t::DO_NOT_RESOLVE) {
ArrayView<resolving_list_entry_t> entries = get_sm().get_resolving_list();
Span<resolving_list_entry_t> entries = get_sm().get_resolving_list();
size_t limit = std::min(
entries.size(), (size_t) YOTTA_CFG_IRK_TABLE_MAX_SIZE
(size_t) entries.size(), (size_t) YOTTA_CFG_IRK_TABLE_MAX_SIZE
);
for (size_t i = 0; i < limit; ++i) {
@ -348,10 +348,10 @@ ble_error_t nRF5xGap::startRadioScan_(const GapScanningParams &scanningParams)
if (_privacy_enabled) {
if (_central_privacy_configuration.resolution_strategy != CentralPrivacyConfiguration_t::DO_NOT_RESOLVE) {
ArrayView<resolving_list_entry_t> entries = get_sm().get_resolving_list();
Span<resolving_list_entry_t> entries = get_sm().get_resolving_list();
size_t limit = std::min(
entries.size(), (size_t) YOTTA_CFG_IRK_TABLE_MAX_SIZE
(size_t) entries.size(), (size_t) YOTTA_CFG_IRK_TABLE_MAX_SIZE
);
for (size_t i = 0; i < limit; ++i) {
@ -531,10 +531,10 @@ ble_error_t nRF5xGap::connect(
if (_privacy_enabled) {
if (_central_privacy_configuration.resolution_strategy != CentralPrivacyConfiguration_t::DO_NOT_RESOLVE) {
ArrayView<resolving_list_entry_t> entries = get_sm().get_resolving_list();
Span<resolving_list_entry_t> entries = get_sm().get_resolving_list();
size_t limit = std::min(
entries.size(), (size_t) YOTTA_CFG_IRK_TABLE_MAX_SIZE
(size_t) entries.size(), (size_t) YOTTA_CFG_IRK_TABLE_MAX_SIZE
);
for (size_t i = 0; i < limit; ++i) {

View File

@ -136,7 +136,7 @@ public:
*/
ble_error_t read_multiple_characteristic_values_(
connection_handle_t connection,
const ArrayView<const attribute_handle_t>& characteristic_handles
const Span<const attribute_handle_t>& characteristic_handles
);
/**
@ -145,7 +145,7 @@ public:
ble_error_t write_without_response_(
connection_handle_t connection_handle,
attribute_handle_t characteristic_value_handle,
const ArrayView<const uint8_t>& value
const Span<const uint8_t>& value
);
/**
@ -154,7 +154,7 @@ public:
ble_error_t signed_write_without_response_(
connection_handle_t connection_handle,
attribute_handle_t characteristic_value_handle,
const ArrayView<const uint8_t>& value
const Span<const uint8_t>& value
);
/**
@ -163,7 +163,7 @@ public:
ble_error_t write_attribute_(
connection_handle_t connection_handle,
attribute_handle_t attribute_handle,
const ArrayView<const uint8_t>& value
const Span<const uint8_t>& value
);
/**
@ -172,7 +172,7 @@ public:
ble_error_t queue_prepare_write_(
connection_handle_t connection_handle,
attribute_handle_t characteristic_value_handle,
const ArrayView<const uint8_t>& value,
const Span<const uint8_t>& value,
uint16_t offset
);

View File

@ -285,7 +285,7 @@ ble_error_t nRF5xGattClient<EventHandler>::read_attribute_blob_(
template<class EventHandler>
ble_error_t nRF5xGattClient<EventHandler>::read_multiple_characteristic_values_(
connection_handle_t connection,
const ArrayView<const attribute_handle_t>& characteristic_handles
const Span<const attribute_handle_t>& characteristic_handles
) {
return launch_procedure<ReadMultipleCharacteristicsProcedure>(
connection, characteristic_handles
@ -296,7 +296,7 @@ template<class EventHandler>
ble_error_t nRF5xGattClient<EventHandler>::write_without_response_(
connection_handle_t connection_handle,
attribute_handle_t characteristic_value_handle,
const ArrayView<const uint8_t>& value
const Span<const uint8_t>& value
) {
ble_gattc_write_params_t write_params = {
BLE_GATT_OP_WRITE_CMD,
@ -315,7 +315,7 @@ template<class EventHandler>
ble_error_t nRF5xGattClient<EventHandler>::signed_write_without_response_(
connection_handle_t connection_handle,
attribute_handle_t characteristic_value_handle,
const ArrayView<const uint8_t>& value
const Span<const uint8_t>& value
) {
ble_gattc_write_params_t write_params = {
BLE_GATT_OP_SIGN_WRITE_CMD,
@ -334,7 +334,7 @@ template<class EventHandler>
ble_error_t nRF5xGattClient<EventHandler>::write_attribute_(
connection_handle_t connection_handle,
attribute_handle_t attribute_handle,
const ArrayView<const uint8_t>& value
const Span<const uint8_t>& value
) {
return launch_procedure<WriteAttributeProcedure>(
connection_handle, attribute_handle, value
@ -345,7 +345,7 @@ template<class EventHandler>
ble_error_t nRF5xGattClient<EventHandler>::queue_prepare_write_(
connection_handle_t connection_handle,
attribute_handle_t characteristic_value_handle,
const ArrayView<const uint8_t>& value,
const Span<const uint8_t>& value,
uint16_t offset
) {
return launch_procedure<QueuePrepareWriteProcedure>(
@ -513,7 +513,7 @@ struct nRF5xGattClient<EventHandler>::DiscoverPrimaryServiceProcedure : GattProc
using GattProcedure::procedure_opcode;
using GattProcedure::connection_handle;
using GattProcedure::terminate;
typedef ArrayView<const ble_gattc_service_t> services_array_t;
typedef Span<const ble_gattc_service_t> services_array_t;
DiscoverPrimaryServiceProcedure(connection_handle_t connection) :
GattProcedure(connection, AttributeOpcode::READ_BY_GROUP_TYPE_REQUEST),
@ -605,7 +605,7 @@ struct nRF5xGattClient<EventHandler>::DiscoverPrimaryServiceProcedure : GattProc
{
attribute_data_t result = {
to_ble_handle_range(services[i].handle_range),
make_const_ArrayView(
make_const_Span(
reinterpret_cast<const uint8_t*>(&services[i].uuid.uuid),
sizeof(uint16_t)
)
@ -692,7 +692,7 @@ struct nRF5xGattClient<EventHandler>::DiscoverPrimaryServiceProcedure : GattProc
if (idx == count) {
terminate(SimpleAttReadByGroupTypeResponse(
sizeof(packed_discovery_response_t),
make_const_ArrayView(
make_const_Span(
reinterpret_cast<const uint8_t*>(response),
count * sizeof(packed_discovery_response_t)
))
@ -726,7 +726,7 @@ struct nRF5xGattClient<EventHandler>::DiscoverPrimaryServiceByUUIDProcedure : Re
using GattProcedure::procedure_opcode;
using GattProcedure::connection_handle;
using GattProcedure::terminate;
typedef ArrayView<const ble_gattc_service_t> services_array_t;
typedef Span<const ble_gattc_service_t> services_array_t;
DiscoverPrimaryServiceByUUIDProcedure(connection_handle_t connection) :
RegularGattProcedure(
@ -779,7 +779,7 @@ struct nRF5xGattClient<EventHandler>::DiscoverPrimaryServiceByUUIDProcedure : Re
{
attribute_data_t result = {
to_ble_handle_range(services[i].handle_range),
make_ArrayView(uuid.getBaseUUID(), uuid.getLen())
make_Span(uuid.getBaseUUID(), uuid.getLen())
};
return result;
}
@ -804,7 +804,7 @@ struct nRF5xGattClient<EventHandler>::FindIncludedServicesProcedure : RegularGat
using GattProcedure::procedure_opcode;
using GattProcedure::connection_handle;
using GattProcedure::terminate;
typedef ArrayView<const ble_gattc_service_t> services_array_t;
typedef Span<const ble_gattc_service_t> services_array_t;
FindIncludedServicesProcedure(connection_handle_t connection) :
RegularGattProcedure(
@ -860,7 +860,7 @@ struct nRF5xGattClient<EventHandler>::FindIncludedServicesProcedure : RegularGat
terminate(SimpleAttReadByTypeResponse(
element_size,
make_const_ArrayView(buffer, buffer_size)
make_const_Span(buffer, buffer_size)
));
delete[] buffer;
@ -1031,7 +1031,7 @@ struct nRF5xGattClient<EventHandler>::DiscoverCharacteristicsProcedure : GattPro
void forward_response_and_terminate() {
terminate(SimpleAttReadByTypeResponse(
_response.element_size,
make_const_ArrayView(
make_const_Span(
_response.buffer,
_response.element_size * _response.count
)
@ -1223,7 +1223,7 @@ struct nRF5xGattClient<EventHandler>::ReadAttributeProcedure : RegularGattProced
return;
}
terminate(AttReadResponse(make_const_ArrayView(rsp.data, rsp.len)));
terminate(AttReadResponse(make_const_Span(rsp.data, rsp.len)));
}
};
@ -1278,7 +1278,7 @@ struct nRF5xGattClient<EventHandler>::ReadUsingCharacteristicUUIDProcedure : Reg
terminate(SimpleAttReadByTypeResponse(
element_size,
make_const_ArrayView(
make_const_Span(
rsp.handle_value,
rsp.count * element_size
)
@ -1304,7 +1304,7 @@ struct nRF5xGattClient<EventHandler>::ReadUsingCharacteristicUUIDProcedure : Reg
{
attribute_data_t result = {
response.handle_value[i].handle,
make_const_ArrayView(
make_const_Span(
response.handle_value[i].p_value,
response.value_len
)
@ -1345,7 +1345,7 @@ struct nRF5xGattClient<EventHandler>::ReadAttributeBlobProcedure : RegularGattPr
virtual void do_handle(const ble_gattc_evt_t &evt)
{
terminate(AttReadBlobResponse(make_const_ArrayView(
terminate(AttReadBlobResponse(make_const_Span(
evt.params.read_rsp.data,
evt.params.read_rsp.len
)));
@ -1369,7 +1369,7 @@ struct nRF5xGattClient<EventHandler>::ReadMultipleCharacteristicsProcedure : Reg
BLE_GATTC_EVT_CHAR_VALS_READ_RSP
) { }
ble_error_t start(const ArrayView<const attribute_handle_t>& characteristic_handles)
ble_error_t start(const Span<const attribute_handle_t>& characteristic_handles)
{
uint32_t err = sd_ble_gattc_char_values_read(
connection_handle,
@ -1381,7 +1381,7 @@ struct nRF5xGattClient<EventHandler>::ReadMultipleCharacteristicsProcedure : Reg
virtual void do_handle(const ble_gattc_evt_t &evt)
{
terminate(AttReadMultipleResponse(make_const_ArrayView(
terminate(AttReadMultipleResponse(make_const_Span(
evt.params.char_vals_read_rsp.values,
evt.params.char_vals_read_rsp.len
)));
@ -1404,7 +1404,7 @@ struct nRF5xGattClient<EventHandler>::WriteAttributeProcedure : RegularGattProce
) { }
ble_error_t start(
attribute_handle_t attribute_handle, const ArrayView<const uint8_t>& value
attribute_handle_t attribute_handle, const Span<const uint8_t>& value
) {
ble_gattc_write_params_t write_params = {
BLE_GATT_OP_WRITE_REQ,
@ -1444,7 +1444,7 @@ struct nRF5xGattClient<EventHandler>::QueuePrepareWriteProcedure : RegularGattPr
ble_error_t start(
attribute_handle_t characteristic_value_handle,
const ArrayView<const uint8_t>& value,
const Span<const uint8_t>& value,
uint16_t offset
) {
ble_gattc_write_params_t write_params = {
@ -1472,7 +1472,7 @@ struct nRF5xGattClient<EventHandler>::QueuePrepareWriteProcedure : RegularGattPr
terminate(AttPrepareWriteResponse(
response.handle,
response.offset,
make_const_ArrayView(response.data, response.len)
make_const_Span(response.data, response.len)
));
}
};
@ -1730,7 +1730,7 @@ void nRF5xGattClient<EventHandler>::handle_hvx_event(const ble_evt_t &evt)
connection,
AttHandleValueNotification(
hvx_evt.handle,
make_const_ArrayView(hvx_evt.data, hvx_evt.len)
make_const_Span(hvx_evt.data, hvx_evt.len)
)
);
return;
@ -1741,7 +1741,7 @@ void nRF5xGattClient<EventHandler>::handle_hvx_event(const ble_evt_t &evt)
connection,
AttHandleValueIndication(
hvx_evt.handle,
make_const_ArrayView(hvx_evt.data, hvx_evt.len)
make_const_Span(hvx_evt.data, hvx_evt.len)
)
);
return;

View File

@ -110,7 +110,7 @@ public:
* @param count The number of entries present in the resolving list.
* @param pointer to the first entry of the resolving list.
*/
ArrayView<resolving_list_entry_t> get_resolving_list();
Span<resolving_list_entry_t> get_resolving_list();
/**
* Try to resolve a private resolvable address.

View File

@ -114,9 +114,9 @@ ble_error_t nRF5xSecurityManager<EventHandler>::initialize_()
{
#if defined(MBEDTLS_ECDH_C)
if (_crypto.generate_keys(
make_ArrayView(X),
make_ArrayView(Y),
make_ArrayView(secret)
make_Span(X),
make_Span(Y),
make_Span(secret)
)) {
return BLE_ERROR_NONE;
}
@ -216,9 +216,9 @@ ble_error_t nRF5xSecurityManager<EventHandler>::clear_resolving_list_()
}
template<class EventHandler>
ArrayView<typename nRF5xSecurityManager<EventHandler>::resolving_list_entry_t>
Span<typename nRF5xSecurityManager<EventHandler>::resolving_list_entry_t>
nRF5xSecurityManager<EventHandler>::get_resolving_list() {
return ArrayView<resolving_list_entry_t>(
return Span<resolving_list_entry_t>(
resolving_list,
resolving_list_entry_count
);
@ -236,11 +236,11 @@ nRF5xSecurityManager<EventHandler>::resolve_address(const address_t& resolvable_
// Compute the hash part from the random address part when the irk of
// the entry is used
CryptoToolbox::ah(
make_const_ArrayView<CryptoToolbox::irk_size_>(entry.peer_irk),
make_const_ArrayView<CryptoToolbox::prand_size_>(
make_const_Span<CryptoToolbox::irk_size_>(entry.peer_irk),
make_const_Span<CryptoToolbox::prand_size_>(
resolvable_address.data() + CryptoToolbox::hash_size_
),
make_ArrayView(hash_generated)
make_Span(hash_generated)
);
// Compare hash generated with the hash present in the address passed as
@ -953,9 +953,9 @@ bool nRF5xSecurityManager<EventHandler>::sm_handler(const ble_evt_t *evt)
ble_gap_lesc_dhkey_t shared_secret;
_crypto.generate_shared_secret(
make_const_ArrayView<key_size>(dhkey_request.p_pk_peer->pk),
make_const_ArrayView<key_size>(dhkey_request.p_pk_peer->pk + key_size),
make_const_ArrayView(secret),
make_const_Span<key_size>(dhkey_request.p_pk_peer->pk),
make_const_Span<key_size>(dhkey_request.p_pk_peer->pk + key_size),
make_const_Span(secret),
shared_secret.key
);

View File

@ -64,9 +64,9 @@ CryptoToolbox::~CryptoToolbox() {
}
bool CryptoToolbox::generate_keys(
ArrayView<uint8_t, lesc_key_size_> X,
ArrayView<uint8_t, lesc_key_size_> Y,
ArrayView<uint8_t, lesc_key_size_> secret
Span<uint8_t, lesc_key_size_> X,
Span<uint8_t, lesc_key_size_> Y,
Span<uint8_t, lesc_key_size_> secret
) {
mbedtls_mpi secret_key;
mbedtls_ecp_point public_keys;
@ -95,10 +95,10 @@ bool CryptoToolbox::generate_keys(
}
bool CryptoToolbox::generate_shared_secret(
const ArrayView<const uint8_t, lesc_key_size_>& peer_X,
const ArrayView<const uint8_t, lesc_key_size_>& peer_Y,
const ArrayView<const uint8_t, lesc_key_size_>& own_secret,
ArrayView<uint8_t, lesc_key_size_> shared_secret
const Span<const uint8_t, lesc_key_size_>& peer_X,
const Span<const uint8_t, lesc_key_size_>& peer_Y,
const Span<const uint8_t, lesc_key_size_>& own_secret,
Span<uint8_t, lesc_key_size_> shared_secret
) {
mbedtls_mpi result;
mbedtls_mpi secret_key;
@ -134,9 +134,9 @@ bool CryptoToolbox::generate_shared_secret(
}
bool CryptoToolbox::ah(
const ArrayView<const uint8_t, irk_size_>& irk,
const ArrayView<const uint8_t, prand_size_>& prand,
ArrayView<uint8_t, hash_size_> hash
const Span<const uint8_t, irk_size_>& irk,
const Span<const uint8_t, prand_size_>& prand,
Span<uint8_t, hash_size_> hash
) {
// Note copy then swap operation can be optimized.
@ -164,13 +164,13 @@ bool CryptoToolbox::ah(
}
void CryptoToolbox::load_mpi(mbedtls_mpi& dest, const ArrayView<const uint8_t, lesc_key_size_>& src) {
void CryptoToolbox::load_mpi(mbedtls_mpi& dest, const Span<const uint8_t, lesc_key_size_>& src) {
ble::public_key_coord_t src_be = src.data();
swap_endian(src_be.data(), src_be.size());
mbedtls_mpi_read_binary(&dest, src_be.data(), src_be.size());
}
void CryptoToolbox::store_mpi(ArrayView<uint8_t, lesc_key_size_>& dest, const mbedtls_mpi& src) {
void CryptoToolbox::store_mpi(Span<uint8_t, lesc_key_size_>& dest, const mbedtls_mpi& src) {
mbedtls_mpi_write_binary(&src, dest.data(), dest.size());
swap_endian(dest.data(), dest.size());
}

View File

@ -84,9 +84,9 @@ public:
* false otherwise.
*/
bool generate_keys(
ArrayView<uint8_t, lesc_key_size_> X,
ArrayView<uint8_t, lesc_key_size_> Y,
ArrayView<uint8_t, lesc_key_size_> secret
Span<uint8_t, lesc_key_size_> X,
Span<uint8_t, lesc_key_size_> Y,
Span<uint8_t, lesc_key_size_> secret
);
/**
@ -99,10 +99,10 @@ public:
* false otherwise.
*/
bool generate_shared_secret(
const ArrayView<const uint8_t, lesc_key_size_>& peer_X,
const ArrayView<const uint8_t, lesc_key_size_>& peer_Y,
const ArrayView<const uint8_t, lesc_key_size_>& own_secret,
ArrayView<uint8_t, lesc_key_size_> shared_secret
const Span<const uint8_t, lesc_key_size_>& peer_X,
const Span<const uint8_t, lesc_key_size_>& peer_Y,
const Span<const uint8_t, lesc_key_size_>& own_secret,
Span<uint8_t, lesc_key_size_> shared_secret
);
/**
@ -119,15 +119,15 @@ public:
* @return true in case of success and false otherwise.
*/
bool ah(
const ArrayView<const uint8_t, irk_size_>& irk,
const ArrayView<const uint8_t, prand_size_>& prand,
ArrayView<uint8_t, hash_size_> hash
const Span<const uint8_t, irk_size_>& irk,
const Span<const uint8_t, prand_size_>& prand,
Span<uint8_t, hash_size_> hash
);
private:
void load_mpi(mbedtls_mpi& dest, const ArrayView<const uint8_t, lesc_key_size_>& src);
void load_mpi(mbedtls_mpi& dest, const Span<const uint8_t, lesc_key_size_>& src);
void store_mpi(ArrayView<uint8_t, lesc_key_size_>& dest, const mbedtls_mpi& src);
void store_mpi(Span<uint8_t, lesc_key_size_>& dest, const mbedtls_mpi& src);
void swap_endian(uint8_t* buf, size_t len);

View File

@ -40,7 +40,7 @@ template class ble::interface::LegacyGap<nRF5xGap>;
template class ble::interface::Gap<nRF5xGap>;
using ble::pal::vendor::nordic::nRF5xSecurityManager;
using ble::ArrayView;
using mbed::Span;
using ble::pal::advertising_peer_address_type_t;
using ble::peer_address_type_t;
@ -360,10 +360,10 @@ ble_error_t nRF5xGap::startAdvertising_(const GapAdvertisingParams &params)
if (_privacy_enabled) {
if (_peripheral_privacy_configuration.resolution_strategy != PeripheralPrivacyConfiguration_t::DO_NOT_RESOLVE) {
ArrayView<resolving_list_entry_t> entries = get_sm().get_resolving_list();
Span<resolving_list_entry_t> entries = get_sm().get_resolving_list();
size_t limit = std::min(
entries.size(), (size_t) YOTTA_CFG_IRK_TABLE_MAX_SIZE
(size_t) entries.size(), (size_t) YOTTA_CFG_IRK_TABLE_MAX_SIZE
);
for (size_t i = 0; i < limit; ++i) {
@ -703,10 +703,10 @@ ble_error_t nRF5xGap::connect(
// configure the "whitelist" with the IRK associated with the identity
// address in input.
if (is_identity_address(peerAddrType)) {
ArrayView<resolving_list_entry_t> entries = get_sm().get_resolving_list();
Span<resolving_list_entry_t> entries = get_sm().get_resolving_list();
size_t i;
for (i = 0; i < entries.size(); ++i) {
for (i = 0; i < (size_t) entries.size(); ++i) {
const ble::address_t& entry_address = entries[i].peer_identity_address;
// entry found; fill the whitelist and invalidate addr_ptr
@ -720,7 +720,7 @@ ble_error_t nRF5xGap::connect(
}
// Occur only if the address in input hasn't been resolved.
if (i == entries.size()) {
if (i == (size_t) entries.size()) {
return BLE_ERROR_INVALID_PARAM;
}
}
@ -1540,9 +1540,9 @@ ble_error_t nRF5xGap::update_identities_list(bool resolution_enabled)
uint32_t err;
if (resolution_enabled) {
ArrayView<ble_gap_id_key_t> entries = get_sm().get_resolving_list();
Span<ble_gap_id_key_t> entries = get_sm().get_resolving_list();
size_t limit = std::min(
entries.size(), (size_t) YOTTA_CFG_IRK_TABLE_MAX_SIZE
(size_t) entries.size(), (size_t) YOTTA_CFG_IRK_TABLE_MAX_SIZE
);
ble_gap_id_key_t* id_keys_pp[YOTTA_CFG_IRK_TABLE_MAX_SIZE];

View File

@ -136,7 +136,7 @@ public:
*/
ble_error_t read_multiple_characteristic_values_(
connection_handle_t connection,
const ArrayView<const attribute_handle_t>& characteristic_handles
const Span<const attribute_handle_t>& characteristic_handles
);
/**
@ -145,7 +145,7 @@ public:
ble_error_t write_without_response_(
connection_handle_t connection_handle,
attribute_handle_t characteristic_value_handle,
const ArrayView<const uint8_t>& value
const Span<const uint8_t>& value
);
/**
@ -154,7 +154,7 @@ public:
ble_error_t signed_write_without_response_(
connection_handle_t connection_handle,
attribute_handle_t characteristic_value_handle,
const ArrayView<const uint8_t>& value
const Span<const uint8_t>& value
);
/**
@ -163,7 +163,7 @@ public:
ble_error_t write_attribute_(
connection_handle_t connection_handle,
attribute_handle_t attribute_handle,
const ArrayView<const uint8_t>& value
const Span<const uint8_t>& value
);
/**
@ -172,7 +172,7 @@ public:
ble_error_t queue_prepare_write_(
connection_handle_t connection_handle,
attribute_handle_t characteristic_value_handle,
const ArrayView<const uint8_t>& value,
const Span<const uint8_t>& value,
uint16_t offset
);

View File

@ -287,7 +287,7 @@ ble_error_t nRF5xGattClient<EventHandler>::read_attribute_blob_(
template<class EventHandler>
ble_error_t nRF5xGattClient<EventHandler>::read_multiple_characteristic_values_(
connection_handle_t connection,
const ArrayView<const attribute_handle_t>& characteristic_handles
const Span<const attribute_handle_t>& characteristic_handles
) {
return launch_procedure<ReadMultipleCharacteristicsProcedure>(
connection, characteristic_handles
@ -298,7 +298,7 @@ template<class EventHandler>
ble_error_t nRF5xGattClient<EventHandler>::write_without_response_(
connection_handle_t connection_handle,
attribute_handle_t characteristic_value_handle,
const ArrayView<const uint8_t>& value
const Span<const uint8_t>& value
) {
ble_gattc_write_params_t write_params = {
BLE_GATT_OP_WRITE_CMD,
@ -317,7 +317,7 @@ template<class EventHandler>
ble_error_t nRF5xGattClient<EventHandler>::signed_write_without_response_(
connection_handle_t connection_handle,
attribute_handle_t characteristic_value_handle,
const ArrayView<const uint8_t>& value
const Span<const uint8_t>& value
) {
ble_gattc_write_params_t write_params = {
BLE_GATT_OP_SIGN_WRITE_CMD,
@ -336,7 +336,7 @@ template<class EventHandler>
ble_error_t nRF5xGattClient<EventHandler>::write_attribute_(
connection_handle_t connection_handle,
attribute_handle_t attribute_handle,
const ArrayView<const uint8_t>& value
const Span<const uint8_t>& value
) {
return launch_procedure<WriteAttributeProcedure>(
connection_handle, attribute_handle, value
@ -347,7 +347,7 @@ template<class EventHandler>
ble_error_t nRF5xGattClient<EventHandler>::queue_prepare_write_(
connection_handle_t connection_handle,
attribute_handle_t characteristic_value_handle,
const ArrayView<const uint8_t>& value,
const Span<const uint8_t>& value,
uint16_t offset
) {
return launch_procedure<QueuePrepareWriteProcedure>(
@ -515,7 +515,7 @@ struct nRF5xGattClient<EventHandler>::DiscoverPrimaryServiceProcedure : GattProc
using GattProcedure::procedure_opcode;
using GattProcedure::connection_handle;
using GattProcedure::terminate;
typedef ArrayView<const ble_gattc_service_t> services_array_t;
typedef Span<const ble_gattc_service_t> services_array_t;
DiscoverPrimaryServiceProcedure(connection_handle_t connection) :
GattProcedure(connection, AttributeOpcode::READ_BY_GROUP_TYPE_REQUEST),
@ -607,7 +607,7 @@ struct nRF5xGattClient<EventHandler>::DiscoverPrimaryServiceProcedure : GattProc
{
attribute_data_t result = {
to_ble_handle_range(services[i].handle_range),
make_const_ArrayView(
make_const_Span(
reinterpret_cast<const uint8_t*>(&services[i].uuid.uuid),
sizeof(uint16_t)
)
@ -694,7 +694,7 @@ struct nRF5xGattClient<EventHandler>::DiscoverPrimaryServiceProcedure : GattProc
if (idx == count) {
terminate(SimpleAttReadByGroupTypeResponse(
sizeof(packed_discovery_response_t),
make_const_ArrayView(
make_const_Span(
reinterpret_cast<const uint8_t*>(response),
count * sizeof(packed_discovery_response_t)
))
@ -728,7 +728,7 @@ struct nRF5xGattClient<EventHandler>::DiscoverPrimaryServiceByUUIDProcedure : Re
using GattProcedure::procedure_opcode;
using GattProcedure::connection_handle;
using GattProcedure::terminate;
typedef ArrayView<const ble_gattc_service_t> services_array_t;
typedef Span<const ble_gattc_service_t> services_array_t;
DiscoverPrimaryServiceByUUIDProcedure(connection_handle_t connection) :
RegularGattProcedure(
@ -781,7 +781,7 @@ struct nRF5xGattClient<EventHandler>::DiscoverPrimaryServiceByUUIDProcedure : Re
{
attribute_data_t result = {
to_ble_handle_range(services[i].handle_range),
make_ArrayView(uuid.getBaseUUID(), uuid.getLen())
make_Span(uuid.getBaseUUID(), uuid.getLen())
};
return result;
}
@ -806,7 +806,7 @@ struct nRF5xGattClient<EventHandler>::FindIncludedServicesProcedure : RegularGat
using GattProcedure::procedure_opcode;
using GattProcedure::connection_handle;
using GattProcedure::terminate;
typedef ArrayView<const ble_gattc_service_t> services_array_t;
typedef Span<const ble_gattc_service_t> services_array_t;
FindIncludedServicesProcedure(connection_handle_t connection) :
RegularGattProcedure(
@ -862,7 +862,7 @@ struct nRF5xGattClient<EventHandler>::FindIncludedServicesProcedure : RegularGat
terminate(SimpleAttReadByTypeResponse(
element_size,
make_const_ArrayView(buffer, buffer_size)
make_const_Span(buffer, buffer_size)
));
delete[] buffer;
@ -1033,7 +1033,7 @@ struct nRF5xGattClient<EventHandler>::DiscoverCharacteristicsProcedure : GattPro
void forward_response_and_terminate() {
terminate(SimpleAttReadByTypeResponse(
_response.element_size,
make_const_ArrayView(
make_const_Span(
_response.buffer,
_response.element_size * _response.count
)
@ -1226,7 +1226,7 @@ struct nRF5xGattClient<EventHandler>::ReadAttributeProcedure : RegularGattProced
return;
}
terminate(AttReadResponse(make_const_ArrayView(rsp.data, rsp.len)));
terminate(AttReadResponse(make_const_Span(rsp.data, rsp.len)));
}
};
@ -1281,7 +1281,7 @@ struct nRF5xGattClient<EventHandler>::ReadUsingCharacteristicUUIDProcedure : Reg
terminate(SimpleAttReadByTypeResponse(
element_size,
make_const_ArrayView(
make_const_Span(
rsp.handle_value,
rsp.count * element_size
)
@ -1307,7 +1307,7 @@ struct nRF5xGattClient<EventHandler>::ReadUsingCharacteristicUUIDProcedure : Reg
{
attribute_data_t result = {
response.handle_value[i].handle,
make_const_ArrayView(
make_const_Span(
response.handle_value[i].p_value,
response.value_len
)
@ -1348,7 +1348,7 @@ struct nRF5xGattClient<EventHandler>::ReadAttributeBlobProcedure : RegularGattPr
virtual void do_handle(const ble_gattc_evt_t &evt)
{
terminate(AttReadBlobResponse(make_const_ArrayView(
terminate(AttReadBlobResponse(make_const_Span(
evt.params.read_rsp.data,
evt.params.read_rsp.len
)));
@ -1372,7 +1372,7 @@ struct nRF5xGattClient<EventHandler>::ReadMultipleCharacteristicsProcedure : Reg
BLE_GATTC_EVT_CHAR_VALS_READ_RSP
) { }
ble_error_t start(const ArrayView<const attribute_handle_t>& characteristic_handles)
ble_error_t start(const Span<const attribute_handle_t>& characteristic_handles)
{
uint32_t err = sd_ble_gattc_char_values_read(
connection_handle,
@ -1384,7 +1384,7 @@ struct nRF5xGattClient<EventHandler>::ReadMultipleCharacteristicsProcedure : Reg
virtual void do_handle(const ble_gattc_evt_t &evt)
{
terminate(AttReadMultipleResponse(make_const_ArrayView(
terminate(AttReadMultipleResponse(make_const_Span(
evt.params.char_vals_read_rsp.values,
evt.params.char_vals_read_rsp.len
)));
@ -1407,7 +1407,7 @@ struct nRF5xGattClient<EventHandler>::WriteAttributeProcedure : RegularGattProce
) { }
ble_error_t start(
attribute_handle_t attribute_handle, const ArrayView<const uint8_t>& value
attribute_handle_t attribute_handle, const Span<const uint8_t>& value
) {
ble_gattc_write_params_t write_params = {
BLE_GATT_OP_WRITE_REQ,
@ -1447,7 +1447,7 @@ struct nRF5xGattClient<EventHandler>::QueuePrepareWriteProcedure : RegularGattPr
ble_error_t start(
attribute_handle_t characteristic_value_handle,
const ArrayView<const uint8_t>& value,
const Span<const uint8_t>& value,
uint16_t offset
) {
ble_gattc_write_params_t write_params = {
@ -1475,7 +1475,7 @@ struct nRF5xGattClient<EventHandler>::QueuePrepareWriteProcedure : RegularGattPr
terminate(AttPrepareWriteResponse(
response.handle,
response.offset,
make_const_ArrayView(response.data, response.len)
make_const_Span(response.data, response.len)
));
}
};
@ -1733,7 +1733,7 @@ void nRF5xGattClient<EventHandler>::handle_hvx_event(const ble_evt_t &evt)
connection,
AttHandleValueNotification(
hvx_evt.handle,
make_const_ArrayView(hvx_evt.data, hvx_evt.len)
make_const_Span(hvx_evt.data, hvx_evt.len)
)
);
return;
@ -1744,7 +1744,7 @@ void nRF5xGattClient<EventHandler>::handle_hvx_event(const ble_evt_t &evt)
connection,
AttHandleValueIndication(
hvx_evt.handle,
make_const_ArrayView(hvx_evt.data, hvx_evt.len)
make_const_Span(hvx_evt.data, hvx_evt.len)
)
);
return;

View File

@ -95,7 +95,7 @@ public:
* @param count The number of entries present in the resolving list.
* @param pointer to the first entry of the resolving list.
*/
ArrayView<ble_gap_id_key_t> get_resolving_list();
Span<ble_gap_id_key_t> get_resolving_list();
////////////////////////////////////////////////////////////////////////////
// Pairing

View File

@ -114,9 +114,9 @@ ble_error_t nRF5xSecurityManager<EventHandler>::initialize_()
// Please do not change or we risk a stack overflow.
CryptoToolbox* crypto = new CryptoToolbox();
bool success = crypto->generate_keys(
make_ArrayView(X),
make_ArrayView(Y),
make_ArrayView(secret)
make_Span(X),
make_Span(Y),
make_Span(secret)
);
delete crypto;
@ -223,8 +223,8 @@ ble_error_t nRF5xSecurityManager<EventHandler>::clear_resolving_list_()
}
template <class EventHandler>
ArrayView<ble_gap_id_key_t> nRF5xSecurityManager<EventHandler>::get_resolving_list() {
return ArrayView<ble_gap_id_key_t>(
Span<ble_gap_id_key_t> nRF5xSecurityManager<EventHandler>::get_resolving_list() {
return Span<ble_gap_id_key_t>(
resolving_list,
resolving_list_entry_count
);
@ -985,9 +985,9 @@ bool nRF5xSecurityManager<EventHandler>::sm_handler(const ble_evt_t *evt)
// Risk stack overflows if allocated on stack.
CryptoToolbox* crypto = new CryptoToolbox();
crypto->generate_shared_secret(
make_const_ArrayView<key_size>(dhkey_request.p_pk_peer->pk),
make_const_ArrayView<key_size>(dhkey_request.p_pk_peer->pk + key_size),
make_const_ArrayView(secret),
make_const_Span<key_size>(dhkey_request.p_pk_peer->pk),
make_const_Span<key_size>(dhkey_request.p_pk_peer->pk + key_size),
ble::make_const_Span(secret),
shared_secret.key
);
delete crypto;