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

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers NdefCallback.cpp Source File

NdefCallback.cpp

00001 /*
00002     NdefCallback.cpp 
00003     Copyright (c) Donatien Garnier 2012
00004     donatien.garnier@appnearme.com
00005     http://www.appnearme.com/
00006 */
00007 
00008 #include "NdefCallback.h"
00009 #include "TLVList.h"
00010 
00011 NdefCallback::NdefCallback()
00012 {
00013 
00014 }
00015 
00016 void NdefCallback::init(void (*fn)(appnearme_ndef_callback, void*))
00017 {
00018   fn(staticCallback, this);
00019 }
00020 
00021 void NdefCallback::attach(void (*fn)(TLVList*, void*), void* arg)
00022 {
00023   m_inst = NULL;
00024   m_fn = fn;
00025   m_arg = arg;
00026 }
00027 
00028 void NdefCallback::callback(tlv_list* payload)
00029 {
00030   m_tlvList.wrap(payload);
00031   if(m_inst)
00032   {
00033     m_caller(this, &m_tlvList);
00034   }
00035   else if(m_fn)
00036   {
00037     m_fn(&m_tlvList, m_arg);
00038   }
00039 }
00040 
00041 /*static*/ void NdefCallback::staticCallback(tlv_list* payload, void* param)
00042 {
00043   ((NdefCallback*)(param))->callback(payload);
00044 }
00045 
00046