BLE: Replace uses of ArrayView with mbed::Span

The platform API mbed::Span provides the same features as ArrayView.
pull/10659/head
Lingkai Dong 2019-05-24 12:18:57 +01:00
parent 6a1ab73988
commit 6f7f1337cd
35 changed files with 251 additions and 254 deletions

View File

@ -21,7 +21,7 @@
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
#include "ble/SafeEnum.h" #include "ble/SafeEnum.h"
#include "ble/ArrayView.h" #include "platform/Span.h"
#include "ble/gap/Types.h" #include "ble/gap/Types.h"
/** /**
@ -33,6 +33,10 @@
namespace ble { namespace ble {
using mbed::Span;
using mbed::make_Span;
using mbed::make_const_Span;
/** Special advertising set handle used for the legacy advertising set. */ /** Special advertising set handle used for the legacy advertising set. */
static const advertising_handle_t LEGACY_ADVERTISING_HANDLE = 0x00; 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> 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> 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 */ /** 128 bit keys used by paired devices */

View File

@ -1438,13 +1438,13 @@ public:
* Reset the value of the advertising payload advertised. * Reset the value of the advertising payload advertised.
* *
* @deprecated Deprecated since addition of extended advertising support. * @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). * bool).
*/ */
MBED_DEPRECATED_SINCE( MBED_DEPRECATED_SINCE(
"mbed-os-5.11.0", "mbed-os-5.11.0",
"Deprecated since addition of extended advertising support. " "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)." "bool)."
) )
void clearAdvertisingPayload(void); void clearAdvertisingPayload(void);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -121,7 +121,7 @@ public:
SecurityEntrySigningDbCb_t; SecurityEntrySigningDbCb_t;
typedef mbed::Callback<void(entry_handle_t, const SecurityEntryIdentity_t*)> typedef mbed::Callback<void(entry_handle_t, const SecurityEntryIdentity_t*)>
SecurityEntryIdentityDbCb_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; IdentitylistDbCb_t;
typedef mbed::Callback<void(::Gap::Whitelist_t*)> typedef mbed::Callback<void(::Gap::Whitelist_t*)>
WhitelistDbCb_t; WhitelistDbCb_t;
@ -340,7 +340,7 @@ public:
*/ */
virtual void get_identity_list( virtual void get_identity_list(
IdentitylistDbCb_t cb, IdentitylistDbCb_t cb,
ArrayView<SecurityEntryIdentity_t>& identity_list Span<SecurityEntryIdentity_t>& identity_list
) { ) {
size_t count = 0; size_t count = 0;
for (size_t i = 0; i < get_entry_count() && count < identity_list.size(); ++i) { 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/common/StaticInterface.h"
#include "ble/UUID.h" #include "ble/UUID.h"
#include "ble/BLETypes.h" #include "ble/BLETypes.h"
#include "ble/ArrayView.h"
#include "ble/blecommon.h" #include "ble/blecommon.h"
#include "platform/Callback.h" #include "platform/Callback.h"
#include "AttServerMessage.h" #include "AttServerMessage.h"
@ -197,7 +196,7 @@ public:
connection_handle_t connection_handle, connection_handle_t connection_handle,
attribute_handle_range_t discovery_range, attribute_handle_range_t discovery_range,
uint16_t type, uint16_t type,
const ArrayView<const uint8_t>& value const Span<const uint8_t>& value
) { ) {
return impl()->find_by_type_value_request_( return impl()->find_by_type_value_request_(
connection_handle, connection_handle,
@ -381,7 +380,7 @@ public:
*/ */
ble_error_t read_multiple_request( ble_error_t read_multiple_request(
connection_handle_t connection_handle, 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); return impl()->read_multiple_request_(connection_handle, attribute_handles);
} }
@ -489,7 +488,7 @@ public:
ble_error_t write_request( ble_error_t write_request(
connection_handle_t connection_handle, connection_handle_t connection_handle,
attribute_handle_t attribute_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); return impl()->write_request_(connection_handle, attribute_handle, value);
} }
@ -511,7 +510,7 @@ public:
ble_error_t write_command( ble_error_t write_command(
connection_handle_t connection_handle, connection_handle_t connection_handle,
attribute_handle_t attribute_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); return impl()->write_command_(connection_handle, attribute_handle, value);
} }
@ -538,7 +537,7 @@ public:
ble_error_t signed_write_command( ble_error_t signed_write_command(
connection_handle_t connection_handle, connection_handle_t connection_handle,
attribute_handle_t attribute_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); return impl()->signed_write_command_(connection_handle, attribute_handle, value);
} }
@ -593,7 +592,7 @@ public:
connection_handle_t connection_handle, connection_handle_t connection_handle,
attribute_handle_t attribute_handle, attribute_handle_t attribute_handle,
uint16_t offset, uint16_t offset,
const ArrayView<const uint8_t>& value const Span<const uint8_t>& value
) { ) {
return impl()->prepare_write_request_( return impl()->prepare_write_request_(
connection_handle, connection_handle,

View File

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

View File

@ -18,7 +18,6 @@
#define BLE_PAL_ATT_SERVER_MESSAGE_H_ #define BLE_PAL_ATT_SERVER_MESSAGE_H_
#include "ble/BLETypes.h" #include "ble/BLETypes.h"
#include "ble/ArrayView.h"
namespace ble { namespace ble {
namespace pal { namespace pal {
@ -400,7 +399,7 @@ struct AttReadByTypeResponse : public AttServerMessage {
*/ */
struct attribute_data_t { struct attribute_data_t {
attribute_handle_t handle; 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. * 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_) { AttServerMessage(AttributeOpcode::READ_RESPONSE), _data(data_) {
} }
@ -473,7 +472,7 @@ struct AttReadResponse : public AttServerMessage {
} }
private: 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. * 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_) { AttServerMessage(AttributeOpcode::READ_BLOB_RESPONSE), _data(data_) {
} }
@ -522,7 +521,7 @@ struct AttReadBlobResponse : public AttServerMessage {
} }
private: 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. * 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_) { AttServerMessage(AttributeOpcode::READ_MULTIPLE_RESPONSE), _data(data_) {
} }
@ -559,7 +558,7 @@ struct AttReadMultipleResponse : public AttServerMessage {
} }
private: 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 { struct attribute_data_t {
attribute_handle_range_t group_range; 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( AttPrepareWriteResponse(
attribute_handle_t handle_, attribute_handle_t handle_,
uint16_t offset_, uint16_t offset_,
ArrayView<const uint8_t> value_ Span<const uint8_t> value_
) : AttServerMessage(AttributeOpcode::PREPARE_WRITE_RESPONSE), ) : AttServerMessage(AttributeOpcode::PREPARE_WRITE_RESPONSE),
attribute_handle(handle_), attribute_handle(handle_),
offset(offset_), offset(offset_),
@ -671,7 +670,7 @@ struct AttPrepareWriteResponse : public AttServerMessage {
/** /**
* The value of the attribute to be written at the offset indicated. * 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( AttHandleValueNotification(
attribute_handle_t attribute_handle, attribute_handle_t attribute_handle,
ArrayView<const uint8_t> attribute_value Span<const uint8_t> attribute_value
) : AttServerMessage(AttributeOpcode::HANDLE_VALUE_NOTIFICATION), ) : AttServerMessage(AttributeOpcode::HANDLE_VALUE_NOTIFICATION),
attribute_handle(attribute_handle), attribute_handle(attribute_handle),
attribute_value(attribute_value) { attribute_value(attribute_value) {
@ -726,7 +725,7 @@ struct AttHandleValueNotification : public AttServerMessage {
/** /**
* The current value of the attribute. * 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. * value indicated.
*/ */
AttHandleValueIndication( AttHandleValueIndication(
attribute_handle_t handle, ArrayView<const uint8_t> value attribute_handle_t handle, Span<const uint8_t> value
) : AttServerMessage(AttributeOpcode::HANDLE_VALUE_INDICATION), ) : AttServerMessage(AttributeOpcode::HANDLE_VALUE_INDICATION),
attribute_handle(handle), attribute_value(value) { attribute_handle(handle), attribute_value(value) {
} }
@ -761,7 +760,7 @@ struct AttHandleValueIndication : public AttServerMessage {
/** /**
* The current value of the attribute. * 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_ #define BLE_PAL_GAP_MESSAGE_H_
#include "GapTypes.h" #include "GapTypes.h"
#include "ble/ArrayView.h" #include "ble/BLETypes.h"
namespace ble { namespace ble {
namespace pal { namespace pal {
@ -307,7 +307,7 @@ struct GapAdvertisingReportEvent : public GapEvent {
received_advertising_type_t type; received_advertising_type_t type;
connection_peer_address_type_t address_type; connection_peer_address_type_t address_type;
address_t address; address_t address;
ArrayView<const uint8_t> data; Span<const uint8_t> data;
int8_t rssi; int8_t rssi;
}; };

View File

@ -18,7 +18,7 @@
#define BLE_PAL_GENERIC_ACCESS_SERVICE_H_ #define BLE_PAL_GENERIC_ACCESS_SERVICE_H_
#include "GapTypes.h" #include "GapTypes.h"
#include "ble/ArrayView.h" #include "ble/BLETypes.h"
#include "ble/blecommon.h" #include "ble/blecommon.h"
#include "ble/GapAdvertisingData.h" #include "ble/GapAdvertisingData.h"
#include "ble/Gap.h" #include "ble/Gap.h"
@ -71,7 +71,7 @@ struct GenericAccessService {
* *
* @see Bluetooth 4.2 Vol 3 PartC: 12.1 - Device Name Characteristic * @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 * 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/common/StaticInterface.h"
#include "ble/UUID.h" #include "ble/UUID.h"
#include "ble/BLETypes.h" #include "ble/BLETypes.h"
#include "ble/ArrayView.h"
#include "ble/blecommon.h" #include "ble/blecommon.h"
#include "platform/Callback.h" #include "platform/Callback.h"
@ -516,7 +515,7 @@ public:
*/ */
ble_error_t read_multiple_characteristic_values( ble_error_t read_multiple_characteristic_values(
connection_handle_t connection_handle, 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_( return self()->read_multiple_characteristic_values_(
connection_handle, connection_handle,
@ -540,7 +539,7 @@ public:
ble_error_t write_without_response( ble_error_t write_without_response(
connection_handle_t connection_handle, connection_handle_t connection_handle,
attribute_handle_t characteristic_value_handle, attribute_handle_t characteristic_value_handle,
const ArrayView<const uint8_t>& value const Span<const uint8_t>& value
) { ) {
return self()->write_without_response_( return self()->write_without_response_(
connection_handle, connection_handle,
@ -568,7 +567,7 @@ public:
ble_error_t signed_write_without_response( ble_error_t signed_write_without_response(
connection_handle_t connection_handle, connection_handle_t connection_handle,
attribute_handle_t characteristic_value_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_( return self()->signed_write_without_response_(
connection_handle, connection_handle,
@ -600,7 +599,7 @@ public:
ble_error_t write_attribute( ble_error_t write_attribute(
connection_handle_t connection_handle, connection_handle_t connection_handle,
attribute_handle_t attribute_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); return self()->write_attribute_(connection_handle, attribute_handle, value);
} }
@ -637,7 +636,7 @@ public:
ble_error_t queue_prepare_write( ble_error_t queue_prepare_write(
connection_handle_t connection_handle, connection_handle_t connection_handle,
attribute_handle_t characteristic_value_handle, attribute_handle_t characteristic_value_handle,
const ArrayView<const uint8_t>& value, const Span<const uint8_t>& value,
uint16_t offset uint16_t offset
) { ) {
return self()->queue_prepare_write_( return self()->queue_prepare_write_(

View File

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

View File

@ -27,7 +27,6 @@
#include "ble/generic/GenericGap.h" #include "ble/generic/GenericGap.h"
#include "drivers/Timeout.h" #include "drivers/Timeout.h"
#include "platform/Span.h"
#include "ble/pal/Deprecated.h" #include "ble/pal/Deprecated.h"
@ -1018,7 +1017,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
return BLE_ERROR_INVALID_PARAM; return BLE_ERROR_INVALID_PARAM;
} }
ArrayView<uint8_t> name(deviceName, *lengthP); Span<uint8_t> name(deviceName, *lengthP);
err = _gap_service.get_device_name(name); err = _gap_service.get_device_name(name);
if (err) { if (err) {
return err; return err;
@ -1768,7 +1767,7 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
/* NO PERIODIC ADVERTISING */ 0, /* NO PERIODIC ADVERTISING */ 0,
peer_address_type_t::ANONYMOUS, peer_address_type_t::ANONYMOUS,
ble::address_t (), 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> template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::setAdvertisingPayload_( ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::setAdvertisingPayload_(
advertising_handle_t handle, advertising_handle_t handle,
mbed::Span<const uint8_t> payload Span<const uint8_t> payload
) )
{ {
useVersionTwoAPI(); useVersionTwoAPI();
@ -2450,7 +2449,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::setAdvertisingScanResponse_( ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::setAdvertisingScanResponse_(
advertising_handle_t handle, advertising_handle_t handle,
mbed::Span<const uint8_t> response Span<const uint8_t> response
) )
{ {
useVersionTwoAPI(); useVersionTwoAPI();
@ -2466,7 +2465,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::setAdvertisingData( ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::setAdvertisingData(
advertising_handle_t handle, advertising_handle_t handle,
mbed::Span<const uint8_t> payload, Span<const uint8_t> payload,
bool minimiseFragmentation, bool minimiseFragmentation,
bool scan_response bool scan_response
) )
@ -2562,7 +2561,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
} }
// extract the payload // extract the payload
mbed::Span<const uint8_t> sub_payload = payload.subspan( Span<const uint8_t> sub_payload = payload.subspan(
i, i,
std::min(hci_length, (end - 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> template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::setPeriodicAdvertisingPayload_( ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::setPeriodicAdvertisingPayload_(
advertising_handle_t handle, advertising_handle_t handle,
mbed::Span<const uint8_t> payload Span<const uint8_t> payload
) )
{ {
useVersionTwoAPI(); useVersionTwoAPI();
@ -2790,7 +2789,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
} }
// extract the payload // extract the payload
mbed::Span<const uint8_t> sub_payload = payload.subspan( Span<const uint8_t> sub_payload = payload.subspan(
i, i,
std::min(hci_length, (end - i)) std::min(hci_length, (end - i))
); );
@ -2973,7 +2972,7 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
periodic_advertising_interval, periodic_advertising_interval,
(ble::peer_address_type_t::type) direct_address_type.value(), (ble::peer_address_type_t::type) direct_address_type.value(),
(BLEProtocol::AddressBytes_t &) direct_address, (BLEProtocol::AddressBytes_t &) direct_address,
mbed::make_Span(data, data_length) make_Span(data, data_length)
) )
); );
} else { } else {
@ -3065,7 +3064,7 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
tx_power, tx_power,
rssi, rssi,
data_status, 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, GattClient* client,
connection_handle_t connection_handle, connection_handle_t connection_handle,
uint16_t decl_handle, uint16_t decl_handle,
const ArrayView<const uint8_t> value const Span<const uint8_t> value
) : DiscoveredCharacteristic() { ) : DiscoveredCharacteristic() {
gattc = client; gattc = client;
uuid = get_uuid(value); uuid = get_uuid(value);
@ -378,7 +378,7 @@ struct GenericGattClient<TPalGattClient, SigningMonitorEventHandler>::DiscoveryC
connHandle = connection_handle; 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) { if (value.size() == 5) {
return UUID(value[3] | (value[4] << 8)); return UUID(value[3] | (value[4] << 8));
} else { } 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]; uint8_t raw_properties = value[0];
DiscoveredCharacteristic::Properties_t result; DiscoveredCharacteristic::Properties_t result;
result._broadcast = (raw_properties & (1 << 0)) ? true : false; result._broadcast = (raw_properties & (1 << 0)) ? true : false;
@ -399,7 +399,7 @@ struct GenericGattClient<TPalGattClient, SigningMonitorEventHandler>::DiscoveryC
return result; 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); return value[1] | (value[2] << 8);
} }
@ -729,7 +729,7 @@ struct GenericGattClient<TPalGattClient, SigningMonitorEventHandler>::WriteContr
if (offset < len) { if (offset < len) {
err = client->_pal_client->queue_prepare_write( err = client->_pal_client->queue_prepare_write(
connection_handle, attribute_handle, connection_handle, attribute_handle,
make_const_ArrayView( make_const_Span(
data + offset, data + offset,
std::min((len - offset), (mtu_size - 5)) std::min((len - offset), (mtu_size - 5))
), ),
@ -1135,7 +1135,7 @@ ble_error_t GenericGattClient<TPalGattClient, SigningMonitorEventHandler>::write
return _pal_client->write_without_response( return _pal_client->write_without_response(
connection_handle, connection_handle,
attribute_handle, attribute_handle,
make_const_ArrayView(value, length) make_const_Span(value, length)
); );
#if BLE_FEATURE_SIGNING #if BLE_FEATURE_SIGNING
} else if (cmd == Base::GATT_OP_SIGNED_WRITE_CMD) { } 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( ble_error_t status = _pal_client->signed_write_without_response(
connection_handle, connection_handle,
attribute_handle, attribute_handle,
make_const_ArrayView(value, length) make_const_Span(value, length)
); );
if (_signing_event_handler && (status == BLE_ERROR_NONE)) { 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( err = _pal_client->queue_prepare_write(
connection_handle, connection_handle,
attribute_handle, attribute_handle,
make_const_ArrayView(value, mtu - PREPARE_WRITE_HEADER_LENGTH), make_const_Span(value, mtu - PREPARE_WRITE_HEADER_LENGTH),
/* offset */0 /* offset */0
); );
} else { } else {
err = _pal_client->write_attribute( err = _pal_client->write_attribute(
connection_handle, connection_handle,
attribute_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]; new (std::nothrow) SecurityEntryIdentity_t[resolving_list_capacity];
if (identity_list_p) { if (identity_list_p) {
ArrayView<SecurityEntryIdentity_t> identity_list( Span<SecurityEntryIdentity_t> identity_list(
identity_list_p, identity_list_p,
resolving_list_capacity resolving_list_capacity
); );
@ -1187,7 +1187,7 @@ void GenericSecurityManager<TPalSecurityManager, SigningMonitor>::on_security_en
template<template<class> class TPalSecurityManager, template<class> class SigningMonitor> template<template<class> class TPalSecurityManager, template<class> class SigningMonitor>
void GenericSecurityManager<TPalSecurityManager, SigningMonitor>::on_identity_list_retrieved( void GenericSecurityManager<TPalSecurityManager, SigningMonitor>::on_identity_list_retrieved(
ble::ArrayView<SecurityEntryIdentity_t>& identity_list, Span<SecurityEntryIdentity_t>& identity_list,
size_t count size_t count
) { ) {
typedef advertising_peer_address_type_t address_type_t; typedef advertising_peer_address_type_t address_type_t;

View File

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

View File

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

View File

@ -33,7 +33,7 @@ public:
#endif #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 #if BLE_FEATURE_GATT_SERVER
const uint8_t* name = NULL; const uint8_t* name = NULL;
uint16_t length = 0; uint16_t length = 0;

View File

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

View File

@ -88,9 +88,9 @@ public:
* false otherwise. * false otherwise.
*/ */
bool generate_keys( bool generate_keys(
ArrayView<uint8_t, lesc_key_size_> X, Span<uint8_t, lesc_key_size_> X,
ArrayView<uint8_t, lesc_key_size_> Y, Span<uint8_t, lesc_key_size_> Y,
ArrayView<uint8_t, lesc_key_size_> secret Span<uint8_t, lesc_key_size_> secret
); );
/** /**
@ -103,10 +103,10 @@ public:
* false otherwise. * false otherwise.
*/ */
bool generate_shared_secret( bool generate_shared_secret(
const ArrayView<const uint8_t, lesc_key_size_>& peer_X, const Span<const uint8_t, lesc_key_size_>& peer_X,
const ArrayView<const uint8_t, lesc_key_size_>& peer_Y, const Span<const uint8_t, lesc_key_size_>& peer_Y,
const ArrayView<const uint8_t, lesc_key_size_>& own_secret, const Span<const uint8_t, lesc_key_size_>& own_secret,
ArrayView<uint8_t, lesc_key_size_> shared_secret Span<uint8_t, lesc_key_size_> shared_secret
); );
#endif #endif
@ -125,17 +125,17 @@ public:
* @return true in case of success and false otherwise. * @return true in case of success and false otherwise.
*/ */
static bool ah( static bool ah(
const ArrayView<const uint8_t, irk_size_>& irk, const Span<const uint8_t, irk_size_>& irk,
const ArrayView<const uint8_t, prand_size_>& prand, const Span<const uint8_t, prand_size_>& prand,
ArrayView<uint8_t, hash_size_> hash Span<uint8_t, hash_size_> hash
); );
private: private:
#if defined(MBEDTLS_ECDH_C) #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 #endif
static void swap_endian(uint8_t* buf, size_t len); 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; using ble::pal::vendor::nordic::nRF5xSecurityManager;
typedef ble::impl::PalSecurityManagerImpl::resolving_list_entry_t resolving_list_entry_t; 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::pal::advertising_peer_address_type_t;
using ble::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 (_privacy_enabled) {
if (_peripheral_privacy_configuration.resolution_strategy != PeripheralPrivacyConfiguration_t::DO_NOT_RESOLVE) { 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( 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) { for (size_t i = 0; i < limit; ++i) {
@ -348,10 +348,10 @@ ble_error_t nRF5xGap::startRadioScan_(const GapScanningParams &scanningParams)
if (_privacy_enabled) { if (_privacy_enabled) {
if (_central_privacy_configuration.resolution_strategy != CentralPrivacyConfiguration_t::DO_NOT_RESOLVE) { 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( 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) { for (size_t i = 0; i < limit; ++i) {
@ -531,10 +531,10 @@ ble_error_t nRF5xGap::connect(
if (_privacy_enabled) { if (_privacy_enabled) {
if (_central_privacy_configuration.resolution_strategy != CentralPrivacyConfiguration_t::DO_NOT_RESOLVE) { 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( 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) { for (size_t i = 0; i < limit; ++i) {

View File

@ -136,7 +136,7 @@ public:
*/ */
ble_error_t read_multiple_characteristic_values_( ble_error_t read_multiple_characteristic_values_(
connection_handle_t connection, 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_( ble_error_t write_without_response_(
connection_handle_t connection_handle, connection_handle_t connection_handle,
attribute_handle_t characteristic_value_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_( ble_error_t signed_write_without_response_(
connection_handle_t connection_handle, connection_handle_t connection_handle,
attribute_handle_t characteristic_value_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_( ble_error_t write_attribute_(
connection_handle_t connection_handle, connection_handle_t connection_handle,
attribute_handle_t attribute_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_( ble_error_t queue_prepare_write_(
connection_handle_t connection_handle, connection_handle_t connection_handle,
attribute_handle_t characteristic_value_handle, attribute_handle_t characteristic_value_handle,
const ArrayView<const uint8_t>& value, const Span<const uint8_t>& value,
uint16_t offset uint16_t offset
); );

View File

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

View File

@ -110,7 +110,7 @@ public:
* @param count The number of entries present in the resolving list. * @param count The number of entries present in the resolving list.
* @param pointer to the first entry of 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. * 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 defined(MBEDTLS_ECDH_C)
if (_crypto.generate_keys( if (_crypto.generate_keys(
make_ArrayView(X), make_Span(X),
make_ArrayView(Y), make_Span(Y),
make_ArrayView(secret) make_Span(secret)
)) { )) {
return BLE_ERROR_NONE; return BLE_ERROR_NONE;
} }
@ -216,9 +216,9 @@ ble_error_t nRF5xSecurityManager<EventHandler>::clear_resolving_list_()
} }
template<class EventHandler> template<class EventHandler>
ArrayView<typename nRF5xSecurityManager<EventHandler>::resolving_list_entry_t> Span<typename nRF5xSecurityManager<EventHandler>::resolving_list_entry_t>
nRF5xSecurityManager<EventHandler>::get_resolving_list() { nRF5xSecurityManager<EventHandler>::get_resolving_list() {
return ArrayView<resolving_list_entry_t>( return Span<resolving_list_entry_t>(
resolving_list, resolving_list,
resolving_list_entry_count 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 // Compute the hash part from the random address part when the irk of
// the entry is used // the entry is used
CryptoToolbox::ah( CryptoToolbox::ah(
make_const_ArrayView<CryptoToolbox::irk_size_>(entry.peer_irk), make_const_Span<CryptoToolbox::irk_size_>(entry.peer_irk),
make_const_ArrayView<CryptoToolbox::prand_size_>( make_const_Span<CryptoToolbox::prand_size_>(
resolvable_address.data() + CryptoToolbox::hash_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 // 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; ble_gap_lesc_dhkey_t shared_secret;
_crypto.generate_shared_secret( _crypto.generate_shared_secret(
make_const_ArrayView<key_size>(dhkey_request.p_pk_peer->pk), make_const_Span<key_size>(dhkey_request.p_pk_peer->pk),
make_const_ArrayView<key_size>(dhkey_request.p_pk_peer->pk + key_size), make_const_Span<key_size>(dhkey_request.p_pk_peer->pk + key_size),
make_const_ArrayView(secret), make_const_Span(secret),
shared_secret.key shared_secret.key
); );

View File

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

View File

@ -84,9 +84,9 @@ public:
* false otherwise. * false otherwise.
*/ */
bool generate_keys( bool generate_keys(
ArrayView<uint8_t, lesc_key_size_> X, Span<uint8_t, lesc_key_size_> X,
ArrayView<uint8_t, lesc_key_size_> Y, Span<uint8_t, lesc_key_size_> Y,
ArrayView<uint8_t, lesc_key_size_> secret Span<uint8_t, lesc_key_size_> secret
); );
/** /**
@ -99,10 +99,10 @@ public:
* false otherwise. * false otherwise.
*/ */
bool generate_shared_secret( bool generate_shared_secret(
const ArrayView<const uint8_t, lesc_key_size_>& peer_X, const Span<const uint8_t, lesc_key_size_>& peer_X,
const ArrayView<const uint8_t, lesc_key_size_>& peer_Y, const Span<const uint8_t, lesc_key_size_>& peer_Y,
const ArrayView<const uint8_t, lesc_key_size_>& own_secret, const Span<const uint8_t, lesc_key_size_>& own_secret,
ArrayView<uint8_t, lesc_key_size_> shared_secret Span<uint8_t, lesc_key_size_> shared_secret
); );
/** /**
@ -119,15 +119,15 @@ public:
* @return true in case of success and false otherwise. * @return true in case of success and false otherwise.
*/ */
bool ah( bool ah(
const ArrayView<const uint8_t, irk_size_>& irk, const Span<const uint8_t, irk_size_>& irk,
const ArrayView<const uint8_t, prand_size_>& prand, const Span<const uint8_t, prand_size_>& prand,
ArrayView<uint8_t, hash_size_> hash Span<uint8_t, hash_size_> hash
); );
private: 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); 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>; template class ble::interface::Gap<nRF5xGap>;
using ble::pal::vendor::nordic::nRF5xSecurityManager; using ble::pal::vendor::nordic::nRF5xSecurityManager;
using ble::ArrayView; using mbed::Span;
using ble::pal::advertising_peer_address_type_t; using ble::pal::advertising_peer_address_type_t;
using ble::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 (_privacy_enabled) {
if (_peripheral_privacy_configuration.resolution_strategy != PeripheralPrivacyConfiguration_t::DO_NOT_RESOLVE) { 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( 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) { 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 // configure the "whitelist" with the IRK associated with the identity
// address in input. // address in input.
if (is_identity_address(peerAddrType)) { 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; 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; const ble::address_t& entry_address = entries[i].peer_identity_address;
// entry found; fill the whitelist and invalidate addr_ptr // 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. // 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; return BLE_ERROR_INVALID_PARAM;
} }
} }
@ -1540,9 +1540,9 @@ ble_error_t nRF5xGap::update_identities_list(bool resolution_enabled)
uint32_t err; uint32_t err;
if (resolution_enabled) { 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( 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]; 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_( ble_error_t read_multiple_characteristic_values_(
connection_handle_t connection, 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_( ble_error_t write_without_response_(
connection_handle_t connection_handle, connection_handle_t connection_handle,
attribute_handle_t characteristic_value_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_( ble_error_t signed_write_without_response_(
connection_handle_t connection_handle, connection_handle_t connection_handle,
attribute_handle_t characteristic_value_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_( ble_error_t write_attribute_(
connection_handle_t connection_handle, connection_handle_t connection_handle,
attribute_handle_t attribute_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_( ble_error_t queue_prepare_write_(
connection_handle_t connection_handle, connection_handle_t connection_handle,
attribute_handle_t characteristic_value_handle, attribute_handle_t characteristic_value_handle,
const ArrayView<const uint8_t>& value, const Span<const uint8_t>& value,
uint16_t offset uint16_t offset
); );

View File

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

View File

@ -95,7 +95,7 @@ public:
* @param count The number of entries present in the resolving list. * @param count The number of entries present in the resolving list.
* @param pointer to the first entry of 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 // Pairing

View File

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