0

I'm trying to simulate NFC on my Computer with Open-NFC. I managed to install it and it seems to be able to connect with the NFC Controller Simulator. When I simulate a tag, my AVD reacts by opening the web browser or even opening the program that I am developing. The problem is that my program, as well as an open source program from ST-Microelectronics, don't recognize the tag.

Versions:

Android Studio 0.8.6
(Open-NFC)NFC Controller Simulation v 4.5.2
(Open-NFC)Connection Center v4.5.2
(Open-NFC)SDK add-on, 4.4.1 Android 4.0.3
APP M24LR SampleCode form ST-Microelectronics

Settings AVD

  • NFC enabled

  • 10.0.2.2

  • NFC Controller simulator

Settings Connection Center

  • Accept service client connections from other machines

  • Accept service provider connections from other machines

  • Accept child Connection Centers

If you need more information please don’t hesitate to ask. I have another add-on version then the Core-Edition from Open-NFC, could that be a problem?

This is part of the code from the demo program:

protected void onCreate(Bundle savedInstanceState) {
// after checking if nfc is enabled...
                mPendingIntent = PendingIntent.getActivity(this, 0,new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
            IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_TAG_DISCOVERED);
            mFilters = new IntentFilter[] {ndef,};
// and then some other stuff...


protected void onNewIntent(Intent intent) 
{
// TODO Auto-generated method stub
super.onNewIntent(intent);
String action = intent.getAction();
if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(action))       
{
    Tag tagFromIntent = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);

    DataDevice dataDevice = (DataDevice)getApplication();
    dataDevice.setCurrentTag(tagFromIntent);

    byte[] GetSystemInfoAnswer = NFCCommand.SendGetSystemInfoCommandCustom(tagFromIntent,(DataDevice)getApplication());

    if(DecodeGetSystemInfoResponse(GetSystemInfoAnswer))
    {
        Intent intentScan = new Intent(this, Scan.class);
        startActivity(intentScan);
    }
    else
    {
        return;
    }
}
}



protected void onResume() 
{
    // TODO Auto-generated method stub
    super.onResume();
    //Used for DEBUG : Log.v("NFCappsActivity.java", "ON RESUME NFC APPS ACTIVITY");
    mPendingIntent = PendingIntent.getActivity(this, 0,new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
    mAdapter.enableForegroundDispatch(this, mPendingIntent, mFilters, mTechLists);
}
  • What are you trying to do? Attachh a real tag using a real reader device? If yes, what tag and what reader are you using? – Michael Roland Aug 20 '14 at 08:33
  • Well the real device hasn't arrived yet. So I'm trying to get most of the program working, until it comes. – Dave Oelen Aug 20 '14 at 09:17
  • THen I don't understand your question. You write that simulating a tag works but at the same time you write that your tag is not recognized. – Michael Roland Aug 20 '14 at 09:29
  • Yes AVD reacts to the Simulation by opening the web browser, even though this is not programmed. I think the AVD automaticly reads the simulated tag and tries to run it. – Dave Oelen Aug 20 '14 at 09:40
  • the rest... But my app that I wrote as well as the demo app are not able to recognize the tag. Personally I think either the demo program is wrong, that would be really strange. Or the Open-NFC does not allow other Apps to read and write to the simulated tags. – Dave Oelen Aug 20 '14 at 09:46
  • I don't think that the problem is related to open-nfc or your tag but it seems to be a problem with your application (particularly how it registers to receive NFC events). For the case where the web browser opens: The web browser is registered to receive NFC events for tags that contain URI records with web addresses, so it will process those URIs. What tag type do you use? What NDEF message does the tag contain? How did you register your app to listen for NFC events? – Michael Roland Aug 20 '14 at 11:07
  • I tested all Tags. Tags frequently used: LRI_512, LRI_512_TAG_6, LRI_512_TAG_6_LOCKED, TAG_IT, TAG_IT_TAG_6, TAG_IT_TAG_6_LOCKED. Because they use the ISO 15693. The Demo program is written for this Standard. What they contain? I don't know... :( I'll add the code to my question – Dave Oelen Aug 20 '14 at 11:36
  • Well if you did not register your app (in your app's manifest) to be launched upon scanning it simply won't be launched. Regarding the foreground dispatch (to detect tags while your app is visible in the foreground) you did not port the relevant code parts that show how you actually register the froureground dispatch. – Michael Roland Aug 20 '14 at 12:42
  • I added the onResume() function. But I'm not sure which part is relevant. I just started coding two weeks ago. The Manifest file does register the app to be launched upon – Dave Oelen Aug 20 '14 at 13:33
  • I would suggest that you start by reading [NFC Basics](http://developer.android.com/guide/topics/connectivity/nfc/nfc.html) and [Advanced NFC](http://developer.android.com/guide/topics/connectivity/nfc/advanced-nfc.html) in the Android Developer documentation and that you start with some of the available tutorials (e.g. [this one](http://code.tutsplus.com/tutorials/reading-nfc-tags-with-android--mobile-17278)). After that, come back with any specific questions. – Michael Roland Aug 20 '14 at 13:55
  • Thanks for the links. I'll do that. – Dave Oelen Aug 20 '14 at 14:15

0 Answers0