PBL mbed final
Fork of nRF51822 by
Revision 588:65d256258533, committed 2016-01-11
- Comitter:
- vcoubard
- Date:
- Mon Jan 11 10:19:30 2016 +0000
- Parent:
- 587:596071444447
- Child:
- 589:f27ac458e152
- Commit message:
- Synchronized with git rev 9b14870e
Author: Andres Amaya Garcia
Fix shutdown of Gap instance to avoid NULL refs
Changed in this revision
source/nRF5xn.cpp | Show annotated file Show diff for this revision Revisions of this file |
source/nRF5xn.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/source/nRF5xn.cpp Mon Jan 11 10:19:29 2016 +0000 +++ b/source/nRF5xn.cpp Mon Jan 11 10:19:30 2016 +0000 @@ -53,8 +53,7 @@ nRF5xn::nRF5xn(void) : initialized(false), instanceID(BLE::DEFAULT_INSTANCE), - _gapInstance(), - gapInstance(NULL), + gapInstance(), gattServerInstance(NULL), gattClientInstance(NULL), securityManagerInstance(NULL) @@ -193,8 +192,7 @@ } #endif - /* Gap instance is always present */ - error = gapInstance->reset(); + error = gapInstance.reset(); if (error != BLE_ERROR_NONE) { return error; }
--- a/source/nRF5xn.h Mon Jan 11 10:19:29 2016 +0000 +++ b/source/nRF5xn.h Mon Jan 11 10:19:30 2016 +0000 @@ -53,10 +53,7 @@ * statically. */ virtual Gap &getGap() { - if (gapInstance == NULL) { - gapInstance = &_gapInstance; - } - return *gapInstance; + return gapInstance; }; /** @@ -116,10 +113,7 @@ * internal pointer has been declared mutable. */ virtual const Gap &getGap() const { - if (gapInstance == NULL) { - gapInstance = &_gapInstance; - } - return *gapInstance; + return gapInstance; }; /** @@ -166,15 +160,11 @@ BLE::InstanceID_t instanceID; private: - mutable nRF5xGap _gapInstance; /**< Gap instance whose reference is returned from a call to - * getGap(). Unlike the GattClient, GattServer and - * SecurityManager, Gap is always needed in a BLE application. */ + mutable nRF5xGap gapInstance; /**< Gap instance whose reference is returned from a call to + * getGap(). Unlike the GattClient, GattServer and + * SecurityManager, Gap is always needed in a BLE application. */ private: - mutable nRF5xGap *gapInstance; /**< Pointer to the Gap object instance. - * If NULL, then Gap has not been initialized. - * The pointer has been declared as 'mutable' so that - * it can be assigned inside a 'const' function. */ mutable nRF5xGattServer *gattServerInstance; /**< Pointer to the GattServer object instance. * If NULL, then GattServer has not been initialized. * The pointer has been declared as 'mutable' so that