Disable GattClient features when using S110 SoftDevice

S110 compatibility is already present, but this patch adds proper handling
of observer/central related features:
* Gap::startScan will return BLE_ERRROR_NOT_IMPLEMENTED (instead of
  PARAM_OUT_OF_RANGE)
* nRF5xGattClient uses the default GattClient implementation when S110 is
  in use. All if its methods return NOT_IMPLEMENTED.

Example: for an application that acts as both a central and a peripheral,
using S110 will make the ble.gap().startScan() call return
BLE_ERROR_NOT_IMPLEMENTED, and advertisement features will continue
running normally.
In addition, with GCC, this patch will free 344 bytes of RAM and 2504
bytes of flash.
This commit is contained in:
Jean-Philippe Brucker 2015-08-11 12:55:15 +01:00
parent fa0f12d376
commit 3eabc779a0
5 changed files with 17 additions and 0 deletions

View file

@ -107,7 +107,9 @@ static void btle_handler(ble_evt_t *p_ble_evt)
dm_ble_evt_handler(p_ble_evt);
#if !defined(MCU_NORDIC_16K_S110) && !defined(MCU_NORDIC_32K_S110)
bleGattcEventHandler(p_ble_evt);
#endif
/* Custom event handler */
switch (p_ble_evt->header.evt_id) {

View file

@ -17,6 +17,7 @@
#include "nRF5xServiceDiscovery.h"
#include "nRF5xGattClient.h"
#if !defined(MCU_NORDIC_16K_S110) && !defined(MCU_NORDIC_32K_S110)
void bleGattcEventHandler(const ble_evt_t *p_ble_evt)
{
nRF5xServiceDiscovery &sdSingleton = nRF5xGattClient::getInstance().discovery;
@ -92,4 +93,5 @@ void bleGattcEventHandler(const ble_evt_t *p_ble_evt)
sdSingleton.progressCharacteristicDiscovery();
sdSingleton.progressServiceDiscovery();
}
#endif

View file

@ -80,6 +80,8 @@ public:
return BLE_ERROR_UNSPECIFIED;
}
/* Observer role is not supported by S110, return BLE_ERROR_NOT_IMPLEMENTED */
#if !defined(MCU_NORDIC_16K_S110) && !defined(MCU_NORDIC_32K_S110)
virtual ble_error_t startRadioScan(const GapScanningParams &scanningParams) {
ble_gap_scan_params_t scanParams = {
.active = scanningParams.getActiveScanning(), /**< If 1, perform active scanning (scan requests). */
@ -104,6 +106,7 @@ public:
return BLE_STACK_BUSY;
}
#endif
private:
/**

View file

@ -23,6 +23,7 @@ nRF5xGattClient::getInstance(void) {
return nRFGattClientSingleton;
}
#if !defined(MCU_NORDIC_16K_S110) && !defined(MCU_NORDIC_32K_S110)
ble_error_t
nRF5xGattClient::launchServiceDiscovery(Gap::Handle_t connectionHandle,
ServiceDiscovery::ServiceCallback_t sc,
@ -32,3 +33,4 @@ nRF5xGattClient::launchServiceDiscovery(Gap::Handle_t
{
return discovery.launch(connectionHandle, sc, cc, matchingServiceUUIDIn, matchingCharacteristicUUIDIn);
}
#endif

View file

@ -25,6 +25,12 @@ class nRF5xGattClient : public GattClient
public:
static nRF5xGattClient &getInstance();
/**
* When using S110, all Gatt client features will return
* BLE_ERROR_NOT_IMPLEMENTED
*/
#if !defined(MCU_NORDIC_16K_S110) && !defined(MCU_NORDIC_32K_S110)
/**
* Launch service discovery. Once launched, service discovery will remain
* active with callbacks being issued back into the application for matching
@ -152,6 +158,8 @@ private:
private:
nRF5xServiceDiscovery discovery;
#endif // if !S110
};
#endif // ifndef __NRF51822_GATT_CLIENT_H__