private void RegisterHostCardEmulationEvent()
        {
            _hostCardEmulationEventCallback = (IntPtr handle, int eventType, IntPtr apdu, uint apduLen, IntPtr userData) =>
            {
                IntPtr      _seHandle        = handle;
                NfcHceEvent _hcdEventType    = (NfcHceEvent)eventType;
                byte[]      _apdu            = NfcConvertUtil.UintLengthIntPtrToByteArray(apdu, apduLen);
                HostCardEmulationEventArgs e = new HostCardEmulationEventArgs(_seHandle, _hcdEventType, _apdu);
                _hostCardEmulationEvent.SafeInvoke(null, e);
            };

            int ret = Interop.Nfc.SetHostCardEmulationEventCallback(_hostCardEmulationEventCallback, IntPtr.Zero);

            if (ret != (int)NfcError.None)
            {
                Log.Error(Globals.LogTag, "Failed to set host card emulation event callback, Error - " + (NfcError)ret);
                NfcErrorFactory.ThrowNfcException(ret);
            }
        }
Exemple #2
0
 internal HostCardEmulationEventArgs(IntPtr seHandle, NfcHceEvent hcdEvent, byte[] apdu)
 {
     _se       = new NfcSecureElement(seHandle);
     _hceEvent = hcdEvent;
     _apdu     = apdu;
 }