private void RegisterSecureElementTransactionEvent(NfcSecureElementType seType) { _secureElementTransactionEventCallback = (int type, IntPtr aid, int aidSize, IntPtr param, int paramSize, IntPtr userData) => { NfcSecureElementType _secureElementType = (NfcSecureElementType)type; byte[] _aid = NfcConvertUtil.IntLengthIntPtrToByteArray(aid, aidSize); byte[] _param = NfcConvertUtil.IntLengthIntPtrToByteArray(param, paramSize); SecureElementTranscationEventArgs e = new SecureElementTranscationEventArgs(_secureElementType, _aid, _param); _secureElementTransactionEvent.SafeInvoke(null, e); }; int ret = Interop.Nfc.SetSecureElementTransactionEventCallback((int)seType, _secureElementTransactionEventCallback, IntPtr.Zero); if (ret != (int)NfcError.None) { Log.Error(Globals.LogTag, "Failed to set secure element transaction event callback, Error - " + (NfcError)ret); } }
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); } }