AppNearMe µNFC stack for the NXP PN532 chip License: You can use the stack free of charge to prototype with mbed; if you want to use the stack with your commercial product, get in touch!

Dependents:   IOT_sensor_nfc AppNearMe_MuNFC_PN532_Test p2p_nfc_test NFCMoodLamp ... more

License

You can use the stack free of charge to prototype with mbed; if you want to use the stack with your commercial product, get in touch!

Revision:
0:480387549d89
Child:
3:0b949b2d3b55
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PN532/EventCallback.cpp	Thu Jul 26 09:12:27 2012 +0000
@@ -0,0 +1,47 @@
+/*
+    EventCallback.cpp 
+    Copyright (c) Donatien Garnier 2012
+    donatien.garnier@appnearme.com
+    http://www.appnearme.com/
+*/
+
+#include "EventCallback.h"
+
+EventCallback::EventCallback()
+{
+
+}
+
+void EventCallback::init(void (*fn)(target_event_callback, void*))
+{
+  fn(staticCallback, this);
+}
+
+void EventCallback::attach(void (*fn)(NFCEvent, void*), void* arg)
+{
+  m_inst = NULL;
+  m_fn = fn;
+  m_arg = arg;
+}
+
+void EventCallback::callback(target_event event)
+{
+  if(m_inst)
+  {
+    m_caller((NFCEvent)event); //At some point, should not cast event directly
+  }
+  else if(m_fn)
+  {
+    m_fn((NFCEvent)event, m_arg);
+  }
+}
+
+/*static*/ void EventCallback::staticCallback(target_event event, void* param)
+{
+  ((EventCallback*)(param))->callback(event);
+}
+
+
+
+
+