fsdfds

Dependencies:   BLE_API mbed-dev-bin nRF51822

Fork of microbit-dal by Lancaster University

Revision:
5:f0f1cecd65d8
Parent:
1:8aa5cdb4ab67
Child:
22:23d7b9a4b082
diff -r 9fbeeb89de59 -r f0f1cecd65d8 source/drivers/MicroBitMessageBus.cpp
--- a/source/drivers/MicroBitMessageBus.cpp	Thu Apr 07 11:59:17 2016 +0100
+++ b/source/drivers/MicroBitMessageBus.cpp	Thu Apr 07 11:59:19 2016 +0100
@@ -358,7 +358,14 @@
     {
 	    if((l->id == evt.source || l->id == MICROBIT_ID_ANY) && (l->value == evt.value || l->value == MICROBIT_EVT_ANY))
         {
-            listenerUrgent = (l->flags & MESSAGE_BUS_LISTENER_IMMEDIATE) == MESSAGE_BUS_LISTENER_IMMEDIATE;
+            // If we're running under the fiber scheduler, then derive the THREADING_MODE for the callback based on the
+            // metadata in the listener itself.
+            if (fiber_scheduler_running())
+                listenerUrgent = (l->flags & MESSAGE_BUS_LISTENER_IMMEDIATE) == MESSAGE_BUS_LISTENER_IMMEDIATE;
+            else
+                listenerUrgent = true;
+
+            // If we should process this event hander in this pass, then activate the listener.
             if(listenerUrgent == urgent && !(l->flags & MESSAGE_BUS_LISTENER_DELETING))
             {
                 l->evt = evt;
@@ -549,4 +556,4 @@
 MicroBitMessageBus::~MicroBitMessageBus()
 {
     fiber_remove_idle_component(this);
-}
+}
\ No newline at end of file