cordio peripheral role pass

pull/9790/head
paul-szczepanek-arm 2019-02-22 16:56:37 +00:00 committed by Vincent Coubard
parent 45eca7c373
commit ec6783ed77
5 changed files with 42 additions and 14 deletions

View File

@ -1136,6 +1136,7 @@ public:
Gap::GapState_t getGapState(void) const;
#if BLE_FEATURE_CONNECTABLE
#if BLE_FEATURE_GATT_SERVER
/**
* Get the GAP peripheral's preferred connection parameters. These are the
* defaults that the peripheral would like to have in a connection. The
@ -1180,6 +1181,7 @@ public:
{
return gap().setPreferredConnectionParams(params);
}
#endif // BLE_FEATURE_GATT_SERVER
/**
* Update connection parameters while in the peripheral role.

View File

@ -824,7 +824,6 @@ private:
#endif
mbed::Ticker _address_rotation_ticker;
#if BLE_FEATURE_EXTENDED_ADVERTISING
template<size_t bit_size>
struct BitArray {
BitArray() : data()
@ -871,12 +870,15 @@ private:
uint8_t data[bit_size / 8 + 1];
};
#if BLE_FEATURE_EXTENDED_ADVERTISING
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;
#endif
BitArray<MAX_ADVERTISING_SETS> _active_sets;
BitArray<MAX_ADVERTISING_SETS> _connectable_payload_size_exceeded;
BitArray<MAX_ADVERTISING_SETS> _set_is_connectable;
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
// deprecation flags
mutable bool _deprecated_scan_api_used : 1;

View File

@ -3,17 +3,17 @@
"config": {
"ble-feature-observer": {
"help": "Include observer BLE role support, allows listening for and processing advertising packets.",
"value": true,
"value": false,
"macro_name": "BLE_ROLE_OBSERVER"
},
"ble-role-broadcaster": {
"help": "Include broadcaster BLE role support, allows sending advertising packets.",
"value": false,
"value": true,
"macro_name": "BLE_ROLE_BROADCASTER"
},
"ble-role-peripheral": {
"help": "Include peripheral BLE role support, depends on observer role.",
"value": false,
"value": true,
"macro_name": "BLE_ROLE_PERIPHERAL"
},
"ble-role-central": {

View File

@ -687,6 +687,7 @@ uint8_t Gap<Impl>::getMaxPeriodicAdvertiserListSize_()
return 0;
}
#if BLE_ROLE_CENTRAL
template<class Impl>
ble_error_t Gap<Impl>::connect_(
peer_address_type_t peerAddressType,
@ -702,7 +703,9 @@ ble_error_t Gap<Impl>::cancelConnect_()
{
return BLE_ERROR_NOT_IMPLEMENTED;
}
#endif // BLE_ROLE_CENTRAL
#if BLE_FEATURE_CONNECTABLE
template<class Impl>
ble_error_t Gap<Impl>::updateConnectionParameters_(
connection_handle_t connectionHandle,

View File

@ -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>
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::getPreferredConnectionParams_(ConnectionParams_t *params)
{
@ -1018,6 +1019,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
*params
);
}
#endif BLE_FEATURE_GATT_SERVER
#endif // BLE_FEATURE_CONNECTABLE
#if BLE_FEATURE_GATT_SERVER
@ -1514,7 +1516,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
#if BLE_FEATURE_EXTENDED_ADVERTISING
if (is_extended_advertising_available()) {
/* 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)) {
_pal_gap.extended_advertising_enable(
/* enable */ false,
@ -1534,8 +1536,20 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
/* clear state of all advertising sets */
_existing_sets.clear();
_active_sets.clear();
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
#if BLE_FEATURE_PERIODIC_ADVERTISING
_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();
_set_is_connectable.clear();
@ -1546,6 +1560,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
LEGACY_ADVERTISING_HANDLE,
AdvertisingParameters()
);
#if BLE_FEATURE_EXTENDED_ADVERTISING
}
_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_()
{
useVersionTwoAPI();
#if BLE_FEATURE_EXTENDED_ADVERTISING
if (is_extended_advertising_available()) {
uint8_t set_number = _pal_gap.get_max_number_of_advertising_sets();
return std::min(MAX_ADVERTISING_SETS, set_number);
} else {
} else
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
{
return 1;
}
}
@ -2336,6 +2353,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
{
useVersionTwoAPI();
#if BLE_FEATURE_EXTENDED_ADVERTISING
if (handle >= getMaxAdvertisingSetNumber()) {
return BLE_ERROR_INVALID_PARAM;
}
@ -2344,7 +2362,6 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
return BLE_ERROR_INVALID_PARAM;
}
#if BLE_FEATURE_EXTENDED_ADVERTISING
if (is_extended_advertising_available()) {
return setExtendedAdvertisingParameters(handle, params);
} else
@ -2496,6 +2513,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
const uint8_t *scan_response_data
);
#if BLE_FEATURE_EXTENDED_ADVERTISING
if (handle >= getMaxAdvertisingSetNumber()) {
return BLE_ERROR_INVALID_PARAM;
}
@ -2506,6 +2524,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
// handle special case of legacy advertising
if (is_extended_advertising_available() == false) {
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
if (handle != LEGACY_ADVERTISING_HANDLE) {
return BLE_ERROR_INVALID_PARAM;
}
@ -2524,6 +2543,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
payload.size(),
pal::advertising_data_t(payload.data(), payload.size())
);
#if BLE_FEATURE_EXTENDED_ADVERTISING
}
if (payload.size() > getMaxAdvertisingDataLength()) {
@ -2589,6 +2609,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
}
}
return BLE_ERROR_NONE;
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
}
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
@ -2599,9 +2620,9 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
)
{
useVersionTwoAPI();
#if BLE_FEATURE_EXTENDED_ADVERTISING
ble_error_t error = BLE_ERROR_NONE;
#if BLE_FEATURE_EXTENDED_ADVERTISING
if (handle >= getMaxAdvertisingSetNumber()) {
return BLE_ERROR_INVALID_PARAM;
}
@ -2668,11 +2689,13 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
if (!_existing_sets.get(handle)) {
return BLE_ERROR_INVALID_PARAM;
}
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
if (!_active_sets.get(handle)) {
return BLE_ERROR_INVALID_STATE;
}
#if BLE_FEATURE_EXTENDED_ADVERTISING
if (is_extended_advertising_available()) {
status = _pal_gap.extended_advertising_enable(
/*enable ? */ false,
@ -3050,7 +3073,6 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
#endif // BLE_FEATURE_PERIODIC_ADVERTISING
#if BLE_ROLE_BROADCASTER
#if BLE_FEATURE_EXTENDED_ADVERTISING
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::on_advertising_set_terminated_(
pal::hci_error_code_t status,
@ -3074,7 +3096,6 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
)
);
}
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
#endif // BLE_ROLE_BROADCASTER
#if BLE_ROLE_BROADCASTER