mirror of https://github.com/ARMmbed/mbed-os.git
cordio peripheral role pass
parent
45eca7c373
commit
ec6783ed77
|
|
@ -1136,6 +1136,7 @@ public:
|
||||||
Gap::GapState_t getGapState(void) const;
|
Gap::GapState_t getGapState(void) const;
|
||||||
|
|
||||||
#if BLE_FEATURE_CONNECTABLE
|
#if BLE_FEATURE_CONNECTABLE
|
||||||
|
#if BLE_FEATURE_GATT_SERVER
|
||||||
/**
|
/**
|
||||||
* Get the GAP peripheral's preferred connection parameters. These are the
|
* Get the GAP peripheral's preferred connection parameters. These are the
|
||||||
* defaults that the peripheral would like to have in a connection. The
|
* defaults that the peripheral would like to have in a connection. The
|
||||||
|
|
@ -1180,6 +1181,7 @@ public:
|
||||||
{
|
{
|
||||||
return gap().setPreferredConnectionParams(params);
|
return gap().setPreferredConnectionParams(params);
|
||||||
}
|
}
|
||||||
|
#endif // BLE_FEATURE_GATT_SERVER
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update connection parameters while in the peripheral role.
|
* Update connection parameters while in the peripheral role.
|
||||||
|
|
|
||||||
|
|
@ -824,7 +824,6 @@ private:
|
||||||
#endif
|
#endif
|
||||||
mbed::Ticker _address_rotation_ticker;
|
mbed::Ticker _address_rotation_ticker;
|
||||||
|
|
||||||
#if BLE_FEATURE_EXTENDED_ADVERTISING
|
|
||||||
template<size_t bit_size>
|
template<size_t bit_size>
|
||||||
struct BitArray {
|
struct BitArray {
|
||||||
BitArray() : data()
|
BitArray() : data()
|
||||||
|
|
@ -871,12 +870,15 @@ private:
|
||||||
uint8_t data[bit_size / 8 + 1];
|
uint8_t data[bit_size / 8 + 1];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if BLE_FEATURE_EXTENDED_ADVERTISING
|
||||||
BitArray<MAX_ADVERTISING_SETS> _existing_sets;
|
BitArray<MAX_ADVERTISING_SETS> _existing_sets;
|
||||||
BitArray<MAX_ADVERTISING_SETS> _active_sets;
|
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
|
||||||
|
#if BLE_FEATURE_PERIODIC_ADVERTISING
|
||||||
BitArray<MAX_ADVERTISING_SETS> _active_periodic_sets;
|
BitArray<MAX_ADVERTISING_SETS> _active_periodic_sets;
|
||||||
|
#endif
|
||||||
|
BitArray<MAX_ADVERTISING_SETS> _active_sets;
|
||||||
BitArray<MAX_ADVERTISING_SETS> _connectable_payload_size_exceeded;
|
BitArray<MAX_ADVERTISING_SETS> _connectable_payload_size_exceeded;
|
||||||
BitArray<MAX_ADVERTISING_SETS> _set_is_connectable;
|
BitArray<MAX_ADVERTISING_SETS> _set_is_connectable;
|
||||||
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
|
|
||||||
|
|
||||||
// deprecation flags
|
// deprecation flags
|
||||||
mutable bool _deprecated_scan_api_used : 1;
|
mutable bool _deprecated_scan_api_used : 1;
|
||||||
|
|
|
||||||
|
|
@ -3,17 +3,17 @@
|
||||||
"config": {
|
"config": {
|
||||||
"ble-feature-observer": {
|
"ble-feature-observer": {
|
||||||
"help": "Include observer BLE role support, allows listening for and processing advertising packets.",
|
"help": "Include observer BLE role support, allows listening for and processing advertising packets.",
|
||||||
"value": true,
|
"value": false,
|
||||||
"macro_name": "BLE_ROLE_OBSERVER"
|
"macro_name": "BLE_ROLE_OBSERVER"
|
||||||
},
|
},
|
||||||
"ble-role-broadcaster": {
|
"ble-role-broadcaster": {
|
||||||
"help": "Include broadcaster BLE role support, allows sending advertising packets.",
|
"help": "Include broadcaster BLE role support, allows sending advertising packets.",
|
||||||
"value": false,
|
"value": true,
|
||||||
"macro_name": "BLE_ROLE_BROADCASTER"
|
"macro_name": "BLE_ROLE_BROADCASTER"
|
||||||
},
|
},
|
||||||
"ble-role-peripheral": {
|
"ble-role-peripheral": {
|
||||||
"help": "Include peripheral BLE role support, depends on observer role.",
|
"help": "Include peripheral BLE role support, depends on observer role.",
|
||||||
"value": false,
|
"value": true,
|
||||||
"macro_name": "BLE_ROLE_PERIPHERAL"
|
"macro_name": "BLE_ROLE_PERIPHERAL"
|
||||||
},
|
},
|
||||||
"ble-role-central": {
|
"ble-role-central": {
|
||||||
|
|
|
||||||
|
|
@ -687,6 +687,7 @@ uint8_t Gap<Impl>::getMaxPeriodicAdvertiserListSize_()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if BLE_ROLE_CENTRAL
|
||||||
template<class Impl>
|
template<class Impl>
|
||||||
ble_error_t Gap<Impl>::connect_(
|
ble_error_t Gap<Impl>::connect_(
|
||||||
peer_address_type_t peerAddressType,
|
peer_address_type_t peerAddressType,
|
||||||
|
|
@ -702,7 +703,9 @@ ble_error_t Gap<Impl>::cancelConnect_()
|
||||||
{
|
{
|
||||||
return BLE_ERROR_NOT_IMPLEMENTED;
|
return BLE_ERROR_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
#endif // BLE_ROLE_CENTRAL
|
||||||
|
|
||||||
|
#if BLE_FEATURE_CONNECTABLE
|
||||||
template<class Impl>
|
template<class Impl>
|
||||||
ble_error_t Gap<Impl>::updateConnectionParameters_(
|
ble_error_t Gap<Impl>::updateConnectionParameters_(
|
||||||
connection_handle_t connectionHandle,
|
connection_handle_t connectionHandle,
|
||||||
|
|
|
||||||
|
|
@ -995,6 +995,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if BLE_FEATURE_GATT_SERVER
|
||||||
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>::getPreferredConnectionParams_(ConnectionParams_t *params)
|
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::getPreferredConnectionParams_(ConnectionParams_t *params)
|
||||||
{
|
{
|
||||||
|
|
@ -1018,6 +1019,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
|
||||||
*params
|
*params
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
#endif BLE_FEATURE_GATT_SERVER
|
||||||
#endif // BLE_FEATURE_CONNECTABLE
|
#endif // BLE_FEATURE_CONNECTABLE
|
||||||
|
|
||||||
#if BLE_FEATURE_GATT_SERVER
|
#if BLE_FEATURE_GATT_SERVER
|
||||||
|
|
@ -1514,7 +1516,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
|
||||||
#if BLE_FEATURE_EXTENDED_ADVERTISING
|
#if BLE_FEATURE_EXTENDED_ADVERTISING
|
||||||
if (is_extended_advertising_available()) {
|
if (is_extended_advertising_available()) {
|
||||||
/* stop all advertising sets */
|
/* stop all advertising sets */
|
||||||
for (size_t i = 0; i < MAX_ADVERTISING_SETS; ++i) {
|
for (size_t i = 1; i < MAX_ADVERTISING_SETS; ++i) {
|
||||||
if (_active_sets.get(i)) {
|
if (_active_sets.get(i)) {
|
||||||
_pal_gap.extended_advertising_enable(
|
_pal_gap.extended_advertising_enable(
|
||||||
/* enable */ false,
|
/* enable */ false,
|
||||||
|
|
@ -1534,8 +1536,20 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
|
||||||
|
|
||||||
/* clear state of all advertising sets */
|
/* clear state of all advertising sets */
|
||||||
_existing_sets.clear();
|
_existing_sets.clear();
|
||||||
_active_sets.clear();
|
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
|
||||||
|
#if BLE_FEATURE_PERIODIC_ADVERTISING
|
||||||
_active_periodic_sets.clear();
|
_active_periodic_sets.clear();
|
||||||
|
#endif
|
||||||
|
if (_active_sets.get(LEGACY_ADVERTISING_HANDLE)) {
|
||||||
|
_pal_gap.extended_advertising_enable(
|
||||||
|
/* enable */ false,
|
||||||
|
/* number of advertising sets */ 1,
|
||||||
|
(advertising_handle_t*)&LEGACY_ADVERTISING_HANDLE,
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
}
|
||||||
|
_active_sets.clear();
|
||||||
_connectable_payload_size_exceeded.clear();
|
_connectable_payload_size_exceeded.clear();
|
||||||
_set_is_connectable.clear();
|
_set_is_connectable.clear();
|
||||||
|
|
||||||
|
|
@ -1546,6 +1560,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
|
||||||
LEGACY_ADVERTISING_HANDLE,
|
LEGACY_ADVERTISING_HANDLE,
|
||||||
AdvertisingParameters()
|
AdvertisingParameters()
|
||||||
);
|
);
|
||||||
|
#if BLE_FEATURE_EXTENDED_ADVERTISING
|
||||||
}
|
}
|
||||||
|
|
||||||
_existing_sets.set(LEGACY_ADVERTISING_HANDLE);
|
_existing_sets.set(LEGACY_ADVERTISING_HANDLE);
|
||||||
|
|
@ -2219,11 +2234,13 @@ template <template<class> class PalGapImpl, class PalSecurityManager, class Conn
|
||||||
uint8_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::getMaxAdvertisingSetNumber_()
|
uint8_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::getMaxAdvertisingSetNumber_()
|
||||||
{
|
{
|
||||||
useVersionTwoAPI();
|
useVersionTwoAPI();
|
||||||
|
#if BLE_FEATURE_EXTENDED_ADVERTISING
|
||||||
if (is_extended_advertising_available()) {
|
if (is_extended_advertising_available()) {
|
||||||
uint8_t set_number = _pal_gap.get_max_number_of_advertising_sets();
|
uint8_t set_number = _pal_gap.get_max_number_of_advertising_sets();
|
||||||
return std::min(MAX_ADVERTISING_SETS, set_number);
|
return std::min(MAX_ADVERTISING_SETS, set_number);
|
||||||
} else {
|
} else
|
||||||
|
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
|
||||||
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2336,6 +2353,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
|
||||||
{
|
{
|
||||||
useVersionTwoAPI();
|
useVersionTwoAPI();
|
||||||
|
|
||||||
|
#if BLE_FEATURE_EXTENDED_ADVERTISING
|
||||||
if (handle >= getMaxAdvertisingSetNumber()) {
|
if (handle >= getMaxAdvertisingSetNumber()) {
|
||||||
return BLE_ERROR_INVALID_PARAM;
|
return BLE_ERROR_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
|
@ -2344,7 +2362,6 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
|
||||||
return BLE_ERROR_INVALID_PARAM;
|
return BLE_ERROR_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if BLE_FEATURE_EXTENDED_ADVERTISING
|
|
||||||
if (is_extended_advertising_available()) {
|
if (is_extended_advertising_available()) {
|
||||||
return setExtendedAdvertisingParameters(handle, params);
|
return setExtendedAdvertisingParameters(handle, params);
|
||||||
} else
|
} else
|
||||||
|
|
@ -2496,6 +2513,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
|
||||||
const uint8_t *scan_response_data
|
const uint8_t *scan_response_data
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#if BLE_FEATURE_EXTENDED_ADVERTISING
|
||||||
if (handle >= getMaxAdvertisingSetNumber()) {
|
if (handle >= getMaxAdvertisingSetNumber()) {
|
||||||
return BLE_ERROR_INVALID_PARAM;
|
return BLE_ERROR_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
|
@ -2506,6 +2524,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
|
||||||
|
|
||||||
// handle special case of legacy advertising
|
// handle special case of legacy advertising
|
||||||
if (is_extended_advertising_available() == false) {
|
if (is_extended_advertising_available() == false) {
|
||||||
|
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
|
||||||
if (handle != LEGACY_ADVERTISING_HANDLE) {
|
if (handle != LEGACY_ADVERTISING_HANDLE) {
|
||||||
return BLE_ERROR_INVALID_PARAM;
|
return BLE_ERROR_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
|
@ -2524,6 +2543,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
|
||||||
payload.size(),
|
payload.size(),
|
||||||
pal::advertising_data_t(payload.data(), payload.size())
|
pal::advertising_data_t(payload.data(), payload.size())
|
||||||
);
|
);
|
||||||
|
#if BLE_FEATURE_EXTENDED_ADVERTISING
|
||||||
}
|
}
|
||||||
|
|
||||||
if (payload.size() > getMaxAdvertisingDataLength()) {
|
if (payload.size() > getMaxAdvertisingDataLength()) {
|
||||||
|
|
@ -2589,6 +2609,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return BLE_ERROR_NONE;
|
return BLE_ERROR_NONE;
|
||||||
|
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
|
||||||
}
|
}
|
||||||
|
|
||||||
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
|
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
|
||||||
|
|
@ -2599,9 +2620,9 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
useVersionTwoAPI();
|
useVersionTwoAPI();
|
||||||
#if BLE_FEATURE_EXTENDED_ADVERTISING
|
|
||||||
ble_error_t error = BLE_ERROR_NONE;
|
ble_error_t error = BLE_ERROR_NONE;
|
||||||
|
|
||||||
|
#if BLE_FEATURE_EXTENDED_ADVERTISING
|
||||||
if (handle >= getMaxAdvertisingSetNumber()) {
|
if (handle >= getMaxAdvertisingSetNumber()) {
|
||||||
return BLE_ERROR_INVALID_PARAM;
|
return BLE_ERROR_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
|
@ -2668,11 +2689,13 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
|
||||||
if (!_existing_sets.get(handle)) {
|
if (!_existing_sets.get(handle)) {
|
||||||
return BLE_ERROR_INVALID_PARAM;
|
return BLE_ERROR_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
|
||||||
|
|
||||||
if (!_active_sets.get(handle)) {
|
if (!_active_sets.get(handle)) {
|
||||||
return BLE_ERROR_INVALID_STATE;
|
return BLE_ERROR_INVALID_STATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if BLE_FEATURE_EXTENDED_ADVERTISING
|
||||||
if (is_extended_advertising_available()) {
|
if (is_extended_advertising_available()) {
|
||||||
status = _pal_gap.extended_advertising_enable(
|
status = _pal_gap.extended_advertising_enable(
|
||||||
/*enable ? */ false,
|
/*enable ? */ false,
|
||||||
|
|
@ -3050,7 +3073,6 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
|
||||||
#endif // BLE_FEATURE_PERIODIC_ADVERTISING
|
#endif // BLE_FEATURE_PERIODIC_ADVERTISING
|
||||||
|
|
||||||
#if BLE_ROLE_BROADCASTER
|
#if BLE_ROLE_BROADCASTER
|
||||||
#if BLE_FEATURE_EXTENDED_ADVERTISING
|
|
||||||
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
|
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
|
||||||
void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::on_advertising_set_terminated_(
|
void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::on_advertising_set_terminated_(
|
||||||
pal::hci_error_code_t status,
|
pal::hci_error_code_t status,
|
||||||
|
|
@ -3074,7 +3096,6 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
|
|
||||||
#endif // BLE_ROLE_BROADCASTER
|
#endif // BLE_ROLE_BROADCASTER
|
||||||
|
|
||||||
#if BLE_ROLE_BROADCASTER
|
#if BLE_ROLE_BROADCASTER
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue