High level Bluetooth Low Energy API and radio abstraction layer

Dependents:   BLE_ANCS_SDAPI BLE_temperature BLE_HeartRate BLE_ANCS_SDAPI_IRC ... more

Overview

The BLE_API is a high level abstraction for using Bluetooth Low Energy on multiple platforms. For details and examples using the BLE_API please see the BLE_API Summary Page. Or click on the API Documentation tab above.

Supported Services

Supported services can be found in the BLE_API/services folder.

Files at this revision

API Documentation at this revision

Comitter:
rgrover1
Date:
Thu Nov 26 12:52:05 2015 +0000
Parent:
931:97e69faa4a5c
Child:
933:3ec277a0d780
Commit message:
Synchronized with git rev 38e27c4a
Author: Vincent Coubard
FunctionPointer call is not propagated through FunctionPointer call but it
is a mechanism internal to CallChain object.

This change allow to safelly remove a callback in a callchain while
calling it. It also clean responsabilities and reduce coupling.

Changed in this revision

ble/CallChainOfFunctionPointersWithContext.h Show annotated file Show diff for this revision Revisions of this file
ble/FunctionPointerWithContext.h Show annotated file Show diff for this revision Revisions of this file
--- a/ble/CallChainOfFunctionPointersWithContext.h	Thu Nov 26 12:52:05 2015 +0000
+++ b/ble/CallChainOfFunctionPointersWithContext.h	Thu Nov 26 12:52:05 2015 +0000
@@ -118,9 +118,15 @@
 
         while (current) {
             if(*current == toDetach) { 
-                if(previous == NULL) { 
+                if(previous == NULL) {
+                    if(currentCalled == current) { 
+                        currentCalled = NULL;
+                    }
                     chainHead = current->getNext();
                 } else {
+                    if(currentCalled == current) { 
+                        currentCalled = previous;
+                    }
                     previous->chainAsNext(current->getNext());
                 }
                 delete current;
@@ -155,17 +161,23 @@
      *        chained FunctionPointers.
      */
     void call(ContextType context) {
-        if (chainHead) {
-            chainHead->call(context);
-        }
+        ((const CallChainOfFunctionPointersWithContext*) this)->call(context);
     }
 
     /**
      * @brief same as above but const 
      */
     void call(ContextType context) const {
-        if (chainHead) {
-            chainHead->call(context);
+        currentCalled = chainHead;
+
+        while(currentCalled) { 
+            currentCalled->call(context);
+            // if this was the head and the call removed the head
+            if(currentCalled == NULL) { 
+                currentCalled = chainHead;
+            } else {
+                currentCalled = currentCalled->getNext();
+            }
         }
     }
 
@@ -197,6 +209,8 @@
 
 private:
     pFunctionPointerWithContext_t chainHead;
+    mutable pFunctionPointerWithContext_t currentCalled;
+
 
     /* Disallow copy constructor and assignment operators. */
 private:
--- a/ble/FunctionPointerWithContext.h	Thu Nov 26 12:52:05 2015 +0000
+++ b/ble/FunctionPointerWithContext.h	Thu Nov 26 12:52:05 2015 +0000
@@ -104,11 +104,6 @@
     /** Same as above, workaround for mbed os FunctionPointer implementation. */
     void call(ContextType context) {
         _caller(this, context);
-
-        /* Propagate the call to next in the chain. */
-        if (_next) {
-            _next->call(context);
-        }
     }
 
     typedef void (FunctionPointerWithContext::*bool_type)() const;