config changes

Fork of nRF51822 by Nordic Semiconductor

Files at this revision

API Documentation at this revision

Comitter:
rgrover1
Date:
Tue Jul 21 13:23:46 2015 +0100
Parent:
395:07973ce31786
Child:
397:c7adea3c1e37
Commit message:
Synchronized with git rev 553132b4
Author: Rohit Grover
add support to handle radio-notification event as a FuncionPointer so that we can have <object, member> pairs for callbacks.

Changed in this revision

source/nRF5xGap.cpp Show annotated file Show diff for this revision Revisions of this file
source/nRF5xGap.h Show annotated file Show diff for this revision Revisions of this file
--- a/source/nRF5xGap.cpp	Tue Jul 21 13:23:45 2015 +0100
+++ b/source/nRF5xGap.cpp	Tue Jul 21 13:23:46 2015 +0100
@@ -26,6 +26,10 @@
     return m_instance;
 }
 
+void radioNotificationStaticCallback(bool param) {
+    nRF5xGap::getInstance().processRadioNotificationEvent(param);
+}
+
 /**************************************************************************/
 /*!
     @brief  Sets the advertising parameters and payload for the device
--- a/source/nRF5xGap.h	Tue Jul 21 13:23:45 2015 +0100
+++ b/source/nRF5xGap.h	Tue Jul 21 13:23:46 2015 +0100
@@ -29,6 +29,8 @@
 #include "ble_radio_notification.h"
 #include "btle_security.h"
 
+void radioNotificationStaticCallback(bool param);
+
 /**************************************************************************/
 /*!
     \brief
@@ -70,9 +72,12 @@
     virtual ble_error_t setPreferredConnectionParams(const ConnectionParams_t *params);
     virtual ble_error_t updateConnectionParams(Handle_t handle, const ConnectionParams_t *params);
 
-    virtual void onRadioNotification(RadioNotificationEventCallback_t callback) {
-        Gap::onRadioNotification(callback);
-        ble_radio_notification_init(NRF_APP_PRIORITY_HIGH, NRF_RADIO_NOTIFICATION_DISTANCE_800US, radioNotificationCallback);
+    virtual ble_error_t initRadioNotification(void) {
+        if (ble_radio_notification_init(NRF_APP_PRIORITY_HIGH, NRF_RADIO_NOTIFICATION_DISTANCE_800US, radioNotificationStaticCallback) == NRF_SUCCESS) {
+            return BLE_ERROR_NONE;
+        }
+
+        return BLE_ERROR_UNSPECIFIED;
     }
 
     virtual ble_error_t startRadioScan(const GapScanningParams &scanningParams) {
@@ -101,6 +106,16 @@
     }
 
 private:
+    /**
+     * A helper function to process radio-notification events; to be called internally.
+     * @param param [description]
+     */
+    void processRadioNotificationEvent(bool param) {
+        radioNotificationCallback.call(param);
+    }
+    friend void radioNotificationStaticCallback(bool param); /* allow invocations of processRadioNotificationEvent() */
+
+private:
     uint16_t m_connectionHandle;
     nRF5xGap() {
         m_connectionHandle = BLE_CONN_HANDLE_INVALID;