mirror of https://github.com/ARMmbed/mbed-os.git
BLE: Enable Generic client on Nordic targets.
parent
dea488b4f0
commit
865bd94fbd
|
@ -51,11 +51,9 @@ extern "C" {
|
|||
}
|
||||
|
||||
#include "nrf_ble_hci.h"
|
||||
#include "btle_discovery.h"
|
||||
|
||||
#include "nRF5xGattClient.h"
|
||||
#include "nRF5xServiceDiscovery.h"
|
||||
#include "nRF5xCharacteristicDescriptorDiscoverer.h"
|
||||
#include "nRF5XPalGattClient.h"
|
||||
|
||||
|
||||
|
||||
bool isEventsSignaled = false;
|
||||
|
@ -67,23 +65,6 @@ extern "C" void SD_EVT_IRQHandler(void); // export the softdevice event handler
|
|||
|
||||
static void btle_handler(ble_evt_t *p_ble_evt);
|
||||
|
||||
#if 0
|
||||
#define CENTRAL_LINK_COUNT (YOTTA_CFG_NORDIC_BLE_CENTRAL_LINKS) /**<number of central links used by the application. When changing this number remember to adjust the RAM settings */
|
||||
/** If value for YOTTA_CFG_NORDIC_BLE_PERIPHERAL_LINKS was used, ram settings are adjusted by the yotta target module. */
|
||||
#define PERIPHERAL_LINK_COUNT (YOTTA_CFG_NORDIC_BLE_PERIPHERAL_LINKS) /**<number of peripheral links used by the application. When changing this number remember to adjust the RAM settings*/
|
||||
/** If value for YOTTA_CFG_NORDIC_BLE_CENTRAL_LINKS was used, ram settings are adjusted by the yotta target module. */
|
||||
#define GATTS_ATTR_TAB_SIZE (YOTTA_CFG_NORDIC_BLE_GATTS_ATTR_TAB_SIZE) /**< GATTS attribite table size. */
|
||||
/** If value for YOTTA_CFG_NORDIC_BLE_GATTS_ATTR_TAB_SIZE was used, ram settings are adjusted by the yotta target module. */
|
||||
#else
|
||||
#define CENTRAL_LINK_COUNT 3 /**<number of central links used by the application. When changing this number remember to adjust the RAM settings */
|
||||
/** If value for YOTTA_CFG_NORDIC_BLE_PERIPHERAL_LINKS was used, ram settings are adjusted by the yotta target module. */
|
||||
#define PERIPHERAL_LINK_COUNT 1 /**<number of peripheral links used by the application. When changing this number remember to adjust the RAM settings*/
|
||||
/** If value for YOTTA_CFG_NORDIC_BLE_CENTRAL_LINKS was used, ram settings are adjusted by the yotta target module. */
|
||||
#define GATTS_ATTR_TAB_SIZE 0x600 /**< GATTS attribite table size. */
|
||||
/** If value for YOTTA_CFG_NORDIC_BLE_GATTS_ATTR_TAB_SIZE was used, ram settings are adjusted by the yotta target module. */
|
||||
|
||||
#endif
|
||||
|
||||
static void sys_evt_dispatch(uint32_t sys_evt)
|
||||
{
|
||||
#if (IS_LEGACY_DEVICE_MANAGER_ENABLED)
|
||||
|
@ -121,7 +102,7 @@ error_t btle_init(void)
|
|||
|
||||
// register softdevice handler vector
|
||||
NVIC_SetVector(SD_EVT_IRQn, (uint32_t) SD_EVT_IRQHandler);
|
||||
|
||||
|
||||
// Configure the LF clock according to values provided by btle_clock.h.
|
||||
// It is input from the chain of the yotta configuration system.
|
||||
clockConfiguration.source = LFCLK_CONF_SOURCE;
|
||||
|
@ -189,6 +170,8 @@ error_t btle_init(void)
|
|||
|
||||
static void btle_handler(ble_evt_t *p_ble_evt)
|
||||
{
|
||||
using ble::pal::vendor::nordic::nRF5XGattClient;
|
||||
|
||||
/* Library service handlers */
|
||||
#if SDK_CONN_PARAMS_MODULE_ENABLE
|
||||
ble_conn_params_on_ble_evt(p_ble_evt);
|
||||
|
@ -206,7 +189,7 @@ static void btle_handler(ble_evt_t *p_ble_evt)
|
|||
#endif
|
||||
|
||||
#if !defined(TARGET_MCU_NRF51_16K_S110) && !defined(TARGET_MCU_NRF51_32K_S110)
|
||||
bleGattcEventHandler(p_ble_evt);
|
||||
nRF5XGattClient::handle_events(p_ble_evt);
|
||||
#endif
|
||||
|
||||
nRF5xn &ble = nRF5xn::Instance(BLE::DEFAULT_INSTANCE);
|
||||
|
@ -229,7 +212,7 @@ static void btle_handler(ble_evt_t *p_ble_evt)
|
|||
const ble_gap_addr_t *peer = &p_ble_evt->evt.gap_evt.params.connected.peer_addr;
|
||||
#if (NRF_SD_BLE_API_VERSION <= 2)
|
||||
const ble_gap_addr_t *own = &p_ble_evt->evt.gap_evt.params.connected.own_addr;
|
||||
|
||||
|
||||
gap.processConnectionEvent(handle,
|
||||
role,
|
||||
static_cast<BLEProtocol::AddressType_t>(peer->addr_type), peer->addr,
|
||||
|
@ -275,9 +258,7 @@ static void btle_handler(ble_evt_t *p_ble_evt)
|
|||
|
||||
#if !defined(TARGET_MCU_NRF51_16K_S110) && !defined(TARGET_MCU_NRF51_32K_S110)
|
||||
// Close all pending discoveries for this connection
|
||||
nRF5xGattClient& gattClient = ble.getGattClient();
|
||||
gattClient.characteristicDescriptorDiscoverer().terminate(handle, BLE_ERROR_INVALID_STATE);
|
||||
gattClient.discovery().terminate(handle);
|
||||
nRF5XGattClient::handle_connection_termination(handle);
|
||||
#endif
|
||||
|
||||
gap.processDisconnectionEvent(handle, reason);
|
||||
|
|
|
@ -26,6 +26,13 @@ extern "C" {
|
|||
#include "ble_srv_common.h"
|
||||
#include "headers/nrf_ble.h"
|
||||
|
||||
#define CENTRAL_LINK_COUNT 3 /**<number of central links used by the application. When changing this number remember to adjust the RAM settings */
|
||||
/** If value for YOTTA_CFG_NORDIC_BLE_PERIPHERAL_LINKS was used, ram settings are adjusted by the yotta target module. */
|
||||
#define PERIPHERAL_LINK_COUNT 1 /**<number of peripheral links used by the application. When changing this number remember to adjust the RAM settings*/
|
||||
/** If value for YOTTA_CFG_NORDIC_BLE_CENTRAL_LINKS was used, ram settings are adjusted by the yotta target module. */
|
||||
#define GATTS_ATTR_TAB_SIZE 0x600 /**< GATTS attribite table size. */
|
||||
/** If value for YOTTA_CFG_NORDIC_BLE_GATTS_ATTR_TAB_SIZE was used, ram settings are adjusted by the yotta target module. */
|
||||
|
||||
error_t btle_init(void);
|
||||
|
||||
// flag indicating if events have been signaled or not
|
||||
|
|
|
@ -31,6 +31,8 @@ extern "C" {
|
|||
#include "softdevice_handler.h"
|
||||
}
|
||||
|
||||
#include "nRF5XPalGattClient.h"
|
||||
|
||||
/**
|
||||
* The singleton which represents the nRF51822 transport for the BLE.
|
||||
*/
|
||||
|
@ -60,7 +62,7 @@ nRF5xn::nRF5xn(void) :
|
|||
instanceID(BLE::DEFAULT_INSTANCE),
|
||||
gapInstance(),
|
||||
gattServerInstance(NULL),
|
||||
gattClientInstance(NULL),
|
||||
gattClient(&(ble::pal::vendor::nordic::nRF5XGattClient::get_client())),
|
||||
securityManagerInstance(NULL)
|
||||
{
|
||||
}
|
||||
|
@ -189,11 +191,9 @@ ble_error_t nRF5xn::shutdown(void)
|
|||
|
||||
/* S110 does not support BLE client features, nothing to reset. */
|
||||
#if !defined(TARGET_MCU_NRF51_16K_S110) && !defined(TARGET_MCU_NRF51_32K_S110)
|
||||
if (gattClientInstance != NULL) {
|
||||
error = gattClientInstance->reset();
|
||||
if (error != BLE_ERROR_NONE) {
|
||||
return error;
|
||||
}
|
||||
error = getGattClient().reset();
|
||||
if (error != BLE_ERROR_NONE) {
|
||||
return error;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -20,10 +20,10 @@
|
|||
#include "ble/BLE.h"
|
||||
#include "ble/blecommon.h"
|
||||
#include "ble/BLEInstanceBase.h"
|
||||
#include "ble/generic/GenericGattClient.h"
|
||||
|
||||
#include "nRF5xGap.h"
|
||||
#include "nRF5xGattServer.h"
|
||||
#include "nRF5xGattClient.h"
|
||||
#include "nRF5xSecurityManager.h"
|
||||
|
||||
#include "btle.h"
|
||||
|
@ -77,11 +77,8 @@ public:
|
|||
*
|
||||
* @return A reference to GattClient.
|
||||
*/
|
||||
virtual nRF5xGattClient &getGattClient() {
|
||||
if (gattClientInstance == NULL) {
|
||||
gattClientInstance = new nRF5xGattClient();
|
||||
}
|
||||
return *gattClientInstance;
|
||||
virtual GattClient &getGattClient() {
|
||||
return gattClient;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -171,10 +168,8 @@ private:
|
|||
* If NULL, then GattServer has not been initialized.
|
||||
* The pointer has been declared as 'mutable' so that
|
||||
* it can be assigned inside a 'const' function. */
|
||||
mutable nRF5xGattClient *gattClientInstance; /**< Pointer to the GattClient object instance.
|
||||
* If NULL, then GattClient has not been initialized.
|
||||
* The pointer has been declared as 'mutable' so that
|
||||
* it can be assigned inside a 'const' function. */
|
||||
ble::generic::GenericGattClient gattClient;
|
||||
|
||||
mutable nRF5xSecurityManager *securityManagerInstance; /**< Pointer to the SecurityManager object instance.
|
||||
* If NULL, then SecurityManager has not been initialized.
|
||||
* The pointer has been declared as 'mutable' so that
|
||||
|
|
Loading…
Reference in New Issue