git review changes

pull/9790/head
paul-szczepanek-arm 2019-02-20 18:06:15 +00:00 committed by Vincent Coubard
parent cb3d79bf9b
commit 9e710d4309
11 changed files with 51 additions and 53 deletions

View File

@ -55,11 +55,6 @@
#endif
#endif // BLE_FEATURE_PRIVACY
#if BLE_FEATURE_EXTENDED_ADVERTISING
#if !(BLE_FEATURE_PHY_MANAGEMENT)
#error "BLE feature 'EXTENDED ADVERTISING' requires the 'PHY MANAGEMENT' feature"
#endif
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
#if BLE_FEATURE_PERIODIC_ADVERTISING
#if !(BLE_FEATURE_EXTENDED_ADVERTISING)
@ -68,13 +63,13 @@
#endif // BLE_FEATURE_PERIODIC_ADVERTISING
#if BLE_FEATURE_GATT_CLIENT
#if !(BLE_ROLE_PERIPHERAL) && !(BLE_ROLE_CENTRAL)
#if !(BLE_FEATURE_CONNECTABLE)
#error "BLE feature 'GATT CLIENT' requires 'PERIPHERAL' or 'CENTRAL' role"
#endif
#endif // BLE_FEATURE_GATT_CLIENT
#if BLE_FEATURE_GATT_SERVER
#if !(BLE_ROLE_PERIPHERAL) && !(BLE_ROLE_CENTRAL)
#if !(BLE_FEATURE_CONNECTABLE)
#error "BLE feature 'GATT SERVER' requires 'PERIPHERAL' or 'CENTRAL' role"
#endif
#endif // BLE_FEATURE_GATT_SERVER

View File

@ -66,10 +66,12 @@ public:
using ble::interface::Gap<Impl>::startAdvertising;
using ble::interface::Gap<Impl>::stopAdvertising;
#endif // BLE_ROLE_BROADCASTER
#if BLE_FEATURE_CONNECTABLE
#if BLE_ROLE_CENTRAL
using ble::interface::Gap<Impl>::connect;
#endif
#if BLE_FEATURE_CONNECTABLE
using ble::interface::Gap<Impl>::disconnect;
#endif // BLE_FEATURE_CONNECTABLE
#endif
#if BLE_ROLE_OBSERVER
using ble::interface::Gap<Impl>::startScan;
#endif
@ -898,7 +900,7 @@ public:
)
ble_error_t stopAdvertising(void);
#endif //BLE_ROLE_BROADCASTER
#if BLE_FEATURE_CONNECTABLE
#if BLE_ROLE_CENTRAL
/**
* Initiate a connection to a peer.
*
@ -982,7 +984,8 @@ public:
const ConnectionParams_t *connectionParams,
const GapScanningParams *scanParams
);
#endif BLE_ROLE_CENTRAL
#if BLE_FEATURE_CONNECTABLE
/**
* Initiate a disconnection procedure.
*
@ -1137,7 +1140,7 @@ public:
*/
ble_error_t getAppearance(GapAdvertisingData::Appearance *appearanceP);
#endif // BLE_FEATURE_GATT_SERVER
#if BLE_ROLE_BROADCASTER
/**
* Set the radio's transmit power.
*
@ -1171,7 +1174,7 @@ public:
void getPermittedTxPowerValues(
const int8_t **valueArrayPP, size_t *countP
);
#endif // BLE_ROLE_BROADCASTER
#if BLE_FEATURE_WHITELIST
/**
* Get the maximum size of the whitelist.

View File

@ -159,7 +159,7 @@ public:
* It is used to request the server to write the value of an attribute.
* The server does not acknowledge the status of the operation.
*/
GATT_OP_WRITE_CMD = 0x02
GATT_OP_WRITE_CMD = 0x02,
#if BLE_FEATURE_SIGNING
/**
* Signed Write command.
@ -168,7 +168,7 @@ public:
* using a signed packet. The server does not acknowledge the status
* of the operation.
*/
, GATT_OP_SIGNED_WRITE_CMD = 0x03
GATT_OP_SIGNED_WRITE_CMD = 0x03
#endif // BLE_FEATURE_SIGNING
};

View File

@ -392,6 +392,7 @@ public:
return _peerAddressType;
};
#if BLE_FEATURE_WHITELIST
/** Set the filter policy of whitelist use during advertising;
*
* @param mode Policy to use.
@ -400,13 +401,10 @@ public:
*/
AdvertisingParameters &setFilter(advertising_filter_policy_t mode)
{
#if BLE_FEATURE_WHITELIST
_policy = mode;
return *this;
#else
#error "Whitelist feature disabled"
#endif // BLE_FEATURE_WHITELIST
}
#endif // BLE_FEATURE_WHITELIST
/** Get the filter policy of whitelist use during advertising;
*

View File

@ -290,7 +290,7 @@ public:
return *this;
}
#endif // BLE_FEATURE_WHITELIST
/**
* Return the initiator policy.
*
@ -298,19 +298,12 @@ public:
*/
initiator_filter_policy_t getFilter() const
{
#if BLE_FEATURE_WHITELIST
return _filterPolicy;
}
#else
ConnectionParameters &setFilter(initiator_filter_policy_t filterPolicy)
{
#error "Whitelist feature disabled"
}
initiator_filter_policy_t getFilter() const
{
return initiator_filter_policy_t::NO_FILTER;
}
#endif // BLE_FEATURE_WHITELIST
}
#if !defined(DOXYGEN_ONLY)

View File

@ -384,7 +384,7 @@ public:
{
}
#endif // BLE_FEATURE_PERIODIC_ADVERTISING
#if BLE_FEATURE_CONNECTABLE
#if BLE_ROLE_CENTRAL
/**
* Called when connection attempt ends or an advertising device has been
* connected.
@ -397,7 +397,8 @@ public:
virtual void onConnectionComplete(const ConnectionCompleteEvent &event)
{
}
#endif // BLE_ROLE_CENTRAL
#if BLE_FEATURE_CONNECTABLE
/**
* Called when the peer request connection parameters updates.
*

View File

@ -168,25 +168,20 @@ public:
scanning_filter_policy = filter_policy;
return *this;
}
#endif BLE_FEATURE_WHITELIST
/**
* Get the filter to use during scanning
*/
scanning_filter_policy_t getFilter() const
{
#if BLE_FEATURE_WHITELIST
return scanning_filter_policy;
}
#else
ScanParameters &setFilter(scanning_filter_policy_t filter_policy))
{
#error "Whitelist feature disabled"
return scanning_filter_policy_t::NO_FILTER;
#endif // BLE_FEATURE_WHITELIST
}
scanning_filter_policy_t getFilter() const
{
return scanning_filter_policy_t::NO_FILTER;
}
#endif // BLE_FEATURE_WHITELIST
/**
* Enable or disable PHYs that should be used during scanning.
* @param enable_1m True to enable the 1M phy and false to disable it.

View File

@ -470,6 +470,7 @@ GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::
_pal_gap.set_event_handler(this);
#if BLE_FEATURE_EXTENDED_ADVERTISING
if (is_extended_advertising_available()) {
setExtendedAdvertisingParameters(
LEGACY_ADVERTISING_HANDLE,
@ -477,6 +478,8 @@ GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::
);
}
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
_existing_sets.set(LEGACY_ADVERTISING_HANDLE);
}
@ -3133,7 +3136,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
set_random_address_rotation(true);
}
#endif // BLE_FEATURE_PRIVACY
#if BLE_FEATURE_EXTENDED_ADVERTISING
if (is_extended_advertising_available()) {
ble_error_t err = _pal_gap.extended_scan_enable(
/* enable */true,
@ -3145,7 +3148,9 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
if (err) {
return err;
}
} else {
} else
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
{
if (period.value() != 0) {
return BLE_ERROR_INVALID_PARAM;
}
@ -3359,9 +3364,13 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
bool GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::is_extended_advertising_available()
{
#if BLE_FEATURE_EXTENDED_ADVERTISING
return isFeatureSupported(
controller_supported_features_t::LE_EXTENDED_ADVERTISING
);
#else
return false;
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
}
} // generic

View File

@ -36,11 +36,7 @@ namespace cordio {
class CordioAttClient : public ::ble::pal::AttClient<CordioAttClient> {
public:
CordioAttClient() : ::ble::pal::AttClient<CordioAttClient>(), _local_sign_counter(0) {
#if !(BLE_FEATURE_ATT)
#error "Both GattClient and GattSever disabled in config file."
#endif
}
CordioAttClient() : ::ble::pal::AttClient<CordioAttClient>(), _local_sign_counter(0) { }
~CordioAttClient() { }
@ -327,6 +323,7 @@ public:
*/
static void att_client_handler(const attEvt_t* event)
{
#if BLE_FEATURE_GATT_CLIENT
// all handlers are stored in a static array
static const event_handler_t handlers[] = {
&timeout_event_handler,
@ -359,6 +356,7 @@ public:
return;
}
}
#endif // BLE_FEATURE_GATT_CLIENT
#if BLE_FEATURE_GATT_SERVER
// pass events not handled to the server side

View File

@ -288,7 +288,7 @@ void BLE::processEvents()
::BLE::Instance(::BLE::DEFAULT_INSTANCE),
BLE_ERROR_NONE
};
#if BLE_FEATURE_EXTENDED_ADVERTISING
// initialize extended module if supported
if (HciGetLeSupFeat() & HCI_LE_SUP_FEAT_LE_EXT_ADV) {
DmExtAdvInit();
@ -296,11 +296,11 @@ void BLE::processEvents()
DmExtConnMasterInit();
DmExtConnSlaveInit();
}
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
#if BLE_FEATURE_GATT_SERVER
deviceInstance().getGattServer().initialize();
#endif
deviceInstance().initialization_status = INITIALIZED;
#endif // BLE_FEATURE_GATT_SERVER
_init_callback.call(&context);
} break;
@ -482,13 +482,17 @@ void BLE::stack_setup()
#if BLE_ROLE_PERIPHERAL
SmprInit();
#if BLE_FEATURE_SECURE_CONNECTIONS
SmprScInit();
#endif
#endif
#if BLE_ROLE_CENTRAL
SmpiInit();
#if BLE_FEATURE_SECURE_CONNECTIONS
SmpiScInit();
#endif
#endif // BLE_ROLE_CENTRAL
#endif // BLE_FEATURE_SECURITY
@ -504,6 +508,9 @@ void BLE::stack_setup()
#if BLE_FEATURE_ATT
AttConnRegister(BLE::connection_handler);
AttRegister((attCback_t) ble::pal::vendor::cordio::CordioAttClient::att_client_handler);
#if !(BLE_FEATURE_GATT_CLIENT)
AttRegister((attCback_t) ble::vendor::cordio::GattServer::att_cb);
#endif // !(BLE_FEATURE_GATT_CLIENT)
#endif
}

View File

@ -1275,6 +1275,7 @@ bool GattServer::is_update_authorized(
}
}
#if BLE_FEATURE_GATT_SERVER
GattServer::GattServer() :
#if BLE_FEATURE_SIGNING
_signing_event_handler(NULL),
@ -1291,10 +1292,8 @@ GattServer::GattServer() :
allocated_blocks(NULL),
currentHandle(0)
{
#if !(BLE_FEATURE_GATT_SERVER)
#error "GattSever disabled in config file."
#endif
}
#endif // BLE_FEATURE_GATT_SERVER
} // namespace cordio
} // namespace vendor