fix the build error resulting from missing template instantiation in the case <object,member> tuple was used for BLE::init()

This commit is contained in:
Rohit Grover 2015-11-03 11:56:46 +00:00
parent aa7e4b2da7
commit 1f30b48a15
2 changed files with 15 additions and 24 deletions

View file

@ -22,6 +22,8 @@
#include "GattServer.h"
#include "GattClient.h"
#include "ble/FunctionPointerWithContext.h"
#ifdef YOTTA_CFG_MBED_OS
#include "mbed-drivers/mbed_error.h"
#else
@ -75,7 +77,7 @@ public:
* context where ordering is compiler specific and can't be guaranteed--it
* is safe to call BLE::init() from within main().
*
* @param callback
* @param initCompleteCallback
* A callback for when initialization completes for a BLE
* instance. This is an optional parameter, if no callback is
* setup the application can still determine the status of
@ -100,14 +102,20 @@ public:
* function-pointer, init() can also take an <Object, member> tuple as its
* callback target.
*/
ble_error_t init(InitializationCompleteCallback_t callback = NULL);
ble_error_t init(InitializationCompleteCallback_t initCompleteCallback = NULL) {
FunctionPointerWithContext<InitializationCompleteCallbackContext *> callback(initCompleteCallback);
initImplementation(callback);
}
/**
* An alternate declaration for init(). This one takes an <Object, member> tuple as its
* callback target.
*/
template<typename T>
ble_error_t init(T *object, void (T::*initCompleteCallback)(InitializationCompleteCallbackContext *context));
ble_error_t init(T *object, void (T::*initCompleteCallback)(InitializationCompleteCallbackContext *context)) {
FunctionPointerWithContext<InitializationCompleteCallbackContext *> callback(object, initCompleteCallback);
initImplementation(callback);
}
/**
* @return true if initialization has completed for the underlying BLE
@ -1412,6 +1420,9 @@ public:
return securityManager().onPasskeyDisplay(callback);
}
private:
ble_error_t BLE::initImplementation(FunctionPointerWithContext<InitializationCompleteCallbackContext *> callback);
private:
BLE(const BLE&);
BLE &operator=(const BLE &);

View file

@ -22,28 +22,8 @@
#endif
ble_error_t
BLE::init(BLE::InitializationCompleteCallback_t initCompleteCallback)
BLE::initImplementation(FunctionPointerWithContext<InitializationCompleteCallbackContext *> callback)
{
FunctionPointerWithContext<InitializationCompleteCallbackContext *>callback(initCompleteCallback);
ble_error_t err = transport->init(instanceID, callback);
if (err != BLE_ERROR_NONE) {
return err;
}
/* Platforms enabled for DFU should introduce the DFU Service into
* applications automatically. */
#if defined(TARGET_OTA_ENABLED)
static DFUService dfu(*this); // defined static so that the object remains alive
#endif // TARGET_OTA_ENABLED
return BLE_ERROR_NONE;
}
template <typename T>
ble_error_t
BLE::init(T *object, void (T::*initCompleteCallback)(InitializationCompleteCallbackContext *))
{
FunctionPointerWithContext<InitializationCompleteCallbackContext *>callback(object, initCompleteCallback);
ble_error_t err = transport->init(instanceID, callback);
if (err != BLE_ERROR_NONE) {
return err;