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!

Committer:
AppNearMe
Date:
Thu Jul 26 09:12:27 2012 +0000
Revision:
0:480387549d89
Child:
3:0b949b2d3b55
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AppNearMe 0:480387549d89 1 /*
AppNearMe 0:480387549d89 2 NdefCallback.h
AppNearMe 0:480387549d89 3 Copyright (c) Donatien Garnier 2012
AppNearMe 0:480387549d89 4 donatien.garnier@appnearme.com
AppNearMe 0:480387549d89 5 http://www.appnearme.com/
AppNearMe 0:480387549d89 6 */
AppNearMe 0:480387549d89 7
AppNearMe 0:480387549d89 8
AppNearMe 0:480387549d89 9 #ifndef NDEFCALLBACK_H_
AppNearMe 0:480387549d89 10 #define NDEFCALLBACK_H_
AppNearMe 0:480387549d89 11
AppNearMe 0:480387549d89 12 #include "TLVList.h"
AppNearMe 0:480387549d89 13
AppNearMe 0:480387549d89 14 #include "munfc/core/fwk.h"
AppNearMe 0:480387549d89 15 #include "munfc/ndef/appnearme_ndef.h"
AppNearMe 0:480387549d89 16
AppNearMe 0:480387549d89 17 class NdefCallback
AppNearMe 0:480387549d89 18 {
AppNearMe 0:480387549d89 19 protected:
AppNearMe 0:480387549d89 20 NdefCallback(); //Callable by MuNFC
AppNearMe 0:480387549d89 21
AppNearMe 0:480387549d89 22 void init(void (*fn)(appnearme_ndef_callback, void*));
AppNearMe 0:480387549d89 23
AppNearMe 0:480387549d89 24 void attach(void (*fn)(TLVList*, void*), void* arg);
AppNearMe 0:480387549d89 25
AppNearMe 0:480387549d89 26 template <class T>
AppNearMe 0:480387549d89 27 void attach(T* inst, void (T::*member)(TLVList*))
AppNearMe 0:480387549d89 28 {
AppNearMe 0:480387549d89 29 m_fn = NULL;
AppNearMe 0:480387549d89 30 m_inst = inst;
AppNearMe 0:480387549d89 31 m_member = member;
AppNearMe 0:480387549d89 32 m_caller = &NdefCallback::memberCaller<T>;
AppNearMe 0:480387549d89 33 }
AppNearMe 0:480387549d89 34
AppNearMe 0:480387549d89 35 private:
AppNearMe 0:480387549d89 36 void callback(tlv_list* payload);
AppNearMe 0:480387549d89 37
AppNearMe 0:480387549d89 38 //Data
AppNearMe 0:480387549d89 39 TLVList m_tlvList;
AppNearMe 0:480387549d89 40
AppNearMe 0:480387549d89 41 //Function
AppNearMe 0:480387549d89 42 void(*m_fn)(TLVList*, void*);
AppNearMe 0:480387549d89 43 void* m_arg;
AppNearMe 0:480387549d89 44
AppNearMe 0:480387549d89 45 //Member of object instance
AppNearMe 0:480387549d89 46 void* m_inst;
AppNearMe 0:480387549d89 47 void* m_member;
AppNearMe 0:480387549d89 48 void* (*m_caller)(TLVList*);
AppNearMe 0:480387549d89 49
AppNearMe 0:480387549d89 50 template <class T>
AppNearMe 0:480387549d89 51 static inline void memberCaller(TLVList* tlvList)
AppNearMe 0:480387549d89 52 {
AppNearMe 0:480387549d89 53 T* inst = (T*) m_inst;
AppNearMe 0:480387549d89 54 void (T::*member)(TLVList*) = m_member;
AppNearMe 0:480387549d89 55 inst->member(tlvList);
AppNearMe 0:480387549d89 56 }
AppNearMe 0:480387549d89 57
AppNearMe 0:480387549d89 58 static void staticCallback(tlv_list* payload, void* param);
AppNearMe 0:480387549d89 59
AppNearMe 0:480387549d89 60 friend class MuNFC;
AppNearMe 0:480387549d89 61 };
AppNearMe 0:480387549d89 62
AppNearMe 0:480387549d89 63
AppNearMe 0:480387549d89 64 #endif /* NDEFCALLBACK_H_ */