Skip to content

Commit 4758ddd

Browse files
authored
Merge pull request #8738 from pan-/ble-extended-advertising
Ble extended advertising
2 parents e69aa15 + 6677fab commit 4758ddd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+13558
-2228
lines changed

features/FEATURE_BLE/ble/BLE.h

Lines changed: 160 additions & 170 deletions
Large diffs are not rendered by default.

features/FEATURE_BLE/ble/BLEInstanceBase.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#ifndef MBED_BLE_DEVICE_INSTANCE_BASE__
2222
#define MBED_BLE_DEVICE_INSTANCE_BASE__
2323

24-
#include "Gap.h"
24+
#include "ble/Gap.h"
2525
#include "ble/SecurityManager.h"
2626
#include "ble/BLE.h"
2727

features/FEATURE_BLE/ble/BLETypes.h

Lines changed: 86 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <string.h>
2323
#include "ble/SafeEnum.h"
2424
#include "ble/ArrayView.h"
25+
#include "ble/gap/Types.h"
2526

2627
/**
2728
* @addtogroup ble
@@ -32,6 +33,43 @@
3233

3334
namespace ble {
3435

36+
/** Special advertising set handle used for the legacy advertising set. */
37+
static const advertising_handle_t LEGACY_ADVERTISING_HANDLE = 0x00;
38+
39+
/** Special advertising set handle used as return or parameter to signify an invalid handle. */
40+
static const advertising_handle_t INVALID_ADVERTISING_HANDLE = 0xFF;
41+
42+
/** Maximum advertising data length that can fit in a legacy PDU. */
43+
static const uint8_t LEGACY_ADVERTISING_MAX_SIZE = 0x1F;
44+
45+
/** Features supported by the controller.
46+
* @see BLUETOOTH SPECIFICATION Version 5.0 | Vol 6, Part B - 4.6 */
47+
struct controller_supported_features_t : SafeEnum<controller_supported_features_t, uint8_t> {
48+
enum type {
49+
LE_ENCRYPTION = 0,
50+
CONNECTION_PARAMETERS_REQUEST_PROCEDURE,
51+
EXTENDED_REJECT_INDICATION,
52+
SLAVE_INITIATED_FEATURES_EXCHANGE,
53+
LE_PING,
54+
LE_DATA_PACKET_LENGTH_EXTENSION,
55+
LL_PRIVACY,
56+
EXTENDED_SCANNER_FILTER_POLICIES,
57+
LE_2M_PHY,
58+
STABLE_MODULATION_INDEX_TRANSMITTER,
59+
STABLE_MODULATION_INDEX_RECEIVER,
60+
LE_CODED_PHY,
61+
LE_EXTENDED_ADVERTISING,
62+
LE_PERIODIC_ADVERTISING,
63+
CHANNEL_SELECTION_ALGORITHM_2,
64+
LE_POWER_CLASS
65+
};
66+
67+
/**
68+
* Construct a new instance of ControllerSupportedFeatures_t.
69+
*/
70+
controller_supported_features_t(type value) : SafeEnum(value) { }
71+
};
72+
3573
/**
3674
* Opaque reference to a connection.
3775
*
@@ -48,7 +86,6 @@ typedef uintptr_t connection_handle_t;
4886
*/
4987
typedef uint16_t attribute_handle_t;
5088

51-
5289
/**
5390
* Inclusive range of GATT attributes handles.
5491
*
@@ -284,6 +321,10 @@ void set_all_zeros(byte_array_class &byte_array) {
284321
memset(&byte_array[0], 0x00, byte_array.size());
285322
}
286323

324+
/**
325+
* Model fixed size array values.
326+
* @tparam array_size The size of the array.
327+
*/
287328
template <size_t array_size>
288329
struct byte_array_t {
289330
/**
@@ -556,7 +597,12 @@ struct peer_address_type_t :SafeEnum<peer_address_type_t, uint8_t> {
556597
/**
557598
* A Random static address used as a device identity address.
558599
*/
559-
RANDOM_STATIC_IDENTITY
600+
RANDOM_STATIC_IDENTITY,
601+
602+
/**
603+
* No address provided (anonymous advertisement).
604+
*/
605+
ANONYMOUS = 0xFF
560606
};
561607

562608
/**
@@ -578,6 +624,13 @@ struct peer_address_type_t :SafeEnum<peer_address_type_t, uint8_t> {
578624
struct phy_t : SafeEnum<phy_t, uint8_t> {
579625
/** struct scoped enum wrapped by the class */
580626
enum type {
627+
/**
628+
* No phy selected.
629+
*
630+
* @note This value can be used to indicate the absence of phy
631+
*/
632+
NONE = 0,
633+
581634
/**
582635
* 1Mbit/s LE.
583636
*
@@ -625,6 +678,8 @@ struct phy_t : SafeEnum<phy_t, uint8_t> {
625678
*/
626679
phy_t(type value) :
627680
SafeEnum<phy_t, uint8_t>(value) { }
681+
682+
explicit phy_t(uint8_t raw_value) : SafeEnum(raw_value) { }
628683
};
629684

630685
/**
@@ -658,16 +713,36 @@ class phy_set_t {
658713
* @param phy_2m Prefer LE 2M if avaiable
659714
* @param phy_coded Prefer coded modulation if avaiable
660715
*/
661-
phy_set_t(
662-
bool phy_1m,
663-
bool phy_2m,
664-
bool phy_coded
665-
) {
716+
phy_set_t(bool phy_1m, bool phy_2m, bool phy_coded) :
717+
_value()
718+
{
666719
set_1m(phy_1m);
667720
set_2m(phy_2m);
668721
set_coded(phy_coded);
669722
}
670723

724+
/**
725+
* Create a set from a single phy.
726+
*
727+
* @param phy The phy to add to the set.
728+
*/
729+
phy_set_t(phy_t phy) : _value()
730+
{
731+
switch (phy.value()) {
732+
case phy_t::LE_1M:
733+
set_1m(true);
734+
break;
735+
case phy_t::LE_2M:
736+
set_2m(true);
737+
break;
738+
case phy_t::LE_CODED:
739+
set_coded(true);
740+
break;
741+
default:
742+
break;
743+
}
744+
}
745+
671746
/** Prefer 1M PHY. */
672747
void set_1m(bool enabled = true) {
673748
if (enabled) {
@@ -715,6 +790,10 @@ class phy_set_t {
715790
return _value;
716791
}
717792

793+
uint8_t count() const {
794+
return (get_1m() ? 1 : 0) + (get_2m() ? 1 : 0) + (get_coded() ? 1 : 0);
795+
}
796+
718797
private:
719798
uint8_t _value;
720799
};

features/FEATURE_BLE/ble/DiscoveredCharacteristic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#define MBED_DISCOVERED_CHARACTERISTIC_H__
1919

2020
#include "UUID.h"
21-
#include "Gap.h"
21+
#include "ble/Gap.h"
2222
#include "GattAttribute.h"
2323
#include "GattClient.h"
2424
#include "CharacteristicDescriptorDiscovery.h"

features/FEATURE_BLE/ble/DiscoveredCharacteristicDescriptor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#define MBED_DISCOVERED_CHARACTERISTIC_DESCRIPTOR_H__
1919

2020
#include "UUID.h"
21-
#include "Gap.h"
21+
#include "ble/Gap.h"
2222
#include "GattAttribute.h"
2323
#include "GattClient.h"
2424
#include "CharacteristicDescriptorDiscovery.h"

0 commit comments

Comments
 (0)