Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: IOT_sensor_nfc AppNearMe_MuNFC_PN532_Test p2p_nfc_test NFCMoodLamp ... more
NdefCallback.h
00001 /* 00002 NdefCallback.h 00003 Copyright (c) Donatien Garnier 2012 00004 donatien.garnier@appnearme.com 00005 http://www.appnearme.com/ 00006 */ 00007 00008 00009 #ifndef NDEFCALLBACK_H_ 00010 #define NDEFCALLBACK_H_ 00011 00012 #include "TLVList.h" 00013 00014 #include "munfc/core/fwk.h" 00015 #include "munfc/ndef/appnearme_ndef.h" 00016 00017 class NdefCallback 00018 { 00019 protected: 00020 NdefCallback(); //Callable by MuNFC 00021 00022 void init(void (*fn)(appnearme_ndef_callback, void*)); 00023 00024 void attach(void (*fn)(TLVList*, void*), void* arg); 00025 00026 template <class T> 00027 void attach(T* inst, void (T::*member)(TLVList*)) 00028 { 00029 m_fn = NULL; 00030 m_inst = inst; 00031 memcpy(m_pMember, (char*)&member, sizeof(member)); 00032 m_caller = &NdefCallback::memberCaller<T>; 00033 } 00034 00035 private: 00036 void callback(tlv_list* payload); 00037 00038 //Data 00039 TLVList m_tlvList; 00040 00041 //Function 00042 void(*m_fn)(TLVList*, void*); 00043 void* m_arg; 00044 00045 //Member of object instance 00046 void* m_inst; 00047 char m_pMember[16]; 00048 void (*m_caller)(NdefCallback*, TLVList*); 00049 00050 template <class T> 00051 static inline void memberCaller(NdefCallback* p, TLVList* tlvList) 00052 { 00053 T* inst = (T*) (p->m_inst); 00054 void (T::*member)(TLVList*); 00055 memcpy(&member, p->m_pMember, sizeof(member)); 00056 (inst->*member)(tlvList); 00057 } 00058 00059 static void staticCallback(tlv_list* payload, void* param); 00060 00061 friend class MuNFC; 00062 }; 00063 00064 00065 #endif /* NDEFCALLBACK_H_ */
Generated on Tue Jul 12 2022 17:28:36 by
1.7.2