library for BLE_GAP_backpack

Dependencies:   nrf51-sdk

Fork of nRF51822 by Nordic Semiconductor

Committer:
vcoubard
Date:
Mon Jan 11 10:19:18 2016 +0000
Revision:
565:cf03471a4ec4
Parent:
563:9c4b96f7be8d
Child:
566:e425ad9e5d6e
Synchronized with git rev 0bcc2e96
Author: Andres Amaya Garcia
Modify shutdown due to BLE API change

The module is updated to comply with the changes to BLE API regarding correct
shutdown functionality. The following changes are introduced to ble-nrf51822:

* Calls to the old static function shutdown in Gap, GattClient, GattServer and
SecurityManager are removed.
* The cleanup function in Gap, GattClient, GattServer and SecurityManager is
renamed to `reset()` and made public.
* The static references inside nRF5xGap, nRF5xGattClient, nRF5xGattServer and
nRF5xSecurityManager to objects of their own class are moved to nRF5xn.
* The static getInstance accessors in nRF5xGap, nRF5xGattClient,
nRF5xGattServer and nRF5xSecurityManager are removed and their functionality is
moved to the implemented virtual accessors in nRF5xn i.e. getGap(),
getGattClient, etc.
* A static function Instance is added to nRF5xn class to make the transport
object accessible across the module.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
vcoubard 558:c4b56f9d6f3b 1 /* mbed Microcontroller Library
vcoubard 558:c4b56f9d6f3b 2 * Copyright (c) 2006-2013 ARM Limited
vcoubard 558:c4b56f9d6f3b 3 *
vcoubard 558:c4b56f9d6f3b 4 * Licensed under the Apache License, Version 2.0 (the "License");
vcoubard 558:c4b56f9d6f3b 5 * you may not use this file except in compliance with the License.
vcoubard 558:c4b56f9d6f3b 6 * You may obtain a copy of the License at
vcoubard 558:c4b56f9d6f3b 7 *
vcoubard 558:c4b56f9d6f3b 8 * http://www.apache.org/licenses/LICENSE-2.0
vcoubard 558:c4b56f9d6f3b 9 *
vcoubard 558:c4b56f9d6f3b 10 * Unless required by applicable law or agreed to in writing, software
vcoubard 558:c4b56f9d6f3b 11 * distributed under the License is distributed on an "AS IS" BASIS,
vcoubard 558:c4b56f9d6f3b 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
vcoubard 558:c4b56f9d6f3b 13 * See the License for the specific language governing permissions and
vcoubard 558:c4b56f9d6f3b 14 * limitations under the License.
vcoubard 558:c4b56f9d6f3b 15 */
vcoubard 558:c4b56f9d6f3b 16
vcoubard 558:c4b56f9d6f3b 17 #ifndef __NRF51822_SECURITY_MANAGER_H__
vcoubard 558:c4b56f9d6f3b 18 #define __NRF51822_SECURITY_MANAGER_H__
vcoubard 558:c4b56f9d6f3b 19
vcoubard 558:c4b56f9d6f3b 20 #include <stddef.h>
vcoubard 558:c4b56f9d6f3b 21
vcoubard 558:c4b56f9d6f3b 22 #include "ble/SecurityManager.h"
vcoubard 558:c4b56f9d6f3b 23 #include "btle_security.h"
vcoubard 558:c4b56f9d6f3b 24
vcoubard 558:c4b56f9d6f3b 25 class nRF5xSecurityManager : public SecurityManager
vcoubard 558:c4b56f9d6f3b 26 {
vcoubard 558:c4b56f9d6f3b 27 public:
vcoubard 558:c4b56f9d6f3b 28 /* Functions that must be implemented from SecurityManager */
vcoubard 558:c4b56f9d6f3b 29 virtual ble_error_t init(bool enableBonding,
vcoubard 558:c4b56f9d6f3b 30 bool requireMITM,
vcoubard 558:c4b56f9d6f3b 31 SecurityIOCapabilities_t iocaps,
vcoubard 558:c4b56f9d6f3b 32 const Passkey_t passkey) {
vcoubard 558:c4b56f9d6f3b 33 return btle_initializeSecurity(enableBonding, requireMITM, iocaps, passkey);
vcoubard 558:c4b56f9d6f3b 34 }
vcoubard 558:c4b56f9d6f3b 35
vcoubard 558:c4b56f9d6f3b 36 virtual ble_error_t getLinkSecurity(Gap::Handle_t connectionHandle, LinkSecurityStatus_t *securityStatusP) {
vcoubard 558:c4b56f9d6f3b 37 return btle_getLinkSecurity(connectionHandle, securityStatusP);
vcoubard 558:c4b56f9d6f3b 38 }
vcoubard 558:c4b56f9d6f3b 39
vcoubard 558:c4b56f9d6f3b 40 virtual ble_error_t setLinkSecurity(Gap::Handle_t connectionHandle, SecurityMode_t securityMode) {
vcoubard 558:c4b56f9d6f3b 41 return btle_setLinkSecurity(connectionHandle, securityMode);
vcoubard 558:c4b56f9d6f3b 42 }
vcoubard 558:c4b56f9d6f3b 43
vcoubard 558:c4b56f9d6f3b 44 virtual ble_error_t purgeAllBondingState(void) {
vcoubard 558:c4b56f9d6f3b 45 return btle_purgeAllBondingState();
vcoubard 558:c4b56f9d6f3b 46 }
vcoubard 558:c4b56f9d6f3b 47
vcoubard 565:cf03471a4ec4 48 /**
vcoubard 565:cf03471a4ec4 49 * @brief Clear nRF5xSecurityManager's state.
vcoubard 565:cf03471a4ec4 50 *
vcoubard 565:cf03471a4ec4 51 * @return
vcoubard 565:cf03471a4ec4 52 * BLE_ERROR_NONE if successful.
vcoubard 565:cf03471a4ec4 53 */
vcoubard 565:cf03471a4ec4 54 virtual ble_error_t reset(void)
vcoubard 565:cf03471a4ec4 55 {
vcoubard 565:cf03471a4ec4 56 if (SecurityManager::reset() != BLE_ERROR_NONE) {
vcoubard 565:cf03471a4ec4 57 return BLE_ERROR_INVALID_STATE;
vcoubard 565:cf03471a4ec4 58 }
vcoubard 565:cf03471a4ec4 59
vcoubard 565:cf03471a4ec4 60 return BLE_ERROR_NONE;
vcoubard 565:cf03471a4ec4 61 }
vcoubard 565:cf03471a4ec4 62
vcoubard 558:c4b56f9d6f3b 63 public:
vcoubard 565:cf03471a4ec4 64 /*
vcoubard 565:cf03471a4ec4 65 * Allow instantiation from nRF5xn when required.
vcoubard 565:cf03471a4ec4 66 */
vcoubard 565:cf03471a4ec4 67 friend class nRF5xn;
vcoubard 565:cf03471a4ec4 68
vcoubard 558:c4b56f9d6f3b 69 nRF5xSecurityManager() {
vcoubard 558:c4b56f9d6f3b 70 /* empty */
vcoubard 558:c4b56f9d6f3b 71 }
vcoubard 558:c4b56f9d6f3b 72
vcoubard 558:c4b56f9d6f3b 73 private:
vcoubard 558:c4b56f9d6f3b 74 nRF5xSecurityManager(const nRF5xSecurityManager &);
vcoubard 558:c4b56f9d6f3b 75 const nRF5xSecurityManager& operator=(const nRF5xSecurityManager &);
vcoubard 558:c4b56f9d6f3b 76 };
vcoubard 558:c4b56f9d6f3b 77
rgrover1 388:db85a09c27ef 78 #endif // ifndef __NRF51822_SECURITY_MANAGER_H__