×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Regular Contributor
    Join Date
    Mar 2003
    Posts
    53

    Lightbulb Exception on Writing an image file (jpeg) in MIFARE 4k

    Hello !

    Following codelines work with "audio/midi" but not with "image/jpeg" MIME type. Example code from ContactlessWrite MIDlet. Image file is in right place.

    conn.writeNDEF (...) throws a
    java.io.IOException: Authentication failed during write at block 68

    Best regards,
    - Yo


    hier are the codelines:
    ...
    ...
    try {
    // properties[0].getUrl () -> "nfc:ndef;type=mf4k;uid=0x5e37d121"
    NDEFTagConnection conn = (NDEFTagConnection)Connector.open (properties [0].getUrl ());

    NDEFRecord recordToWrite = getImageRecord ("smiley_01-half.jpg");

    NDEFMessage write_container = new NDEFMessage ();
    write_container.appendRecord (recordToWrite);

    conn.writeNDEF (write_container);

    } catch (IOException ex) {
    ...
    } catch (Exception ex) {
    ...
    }

    private NDEFRecord getImageRecord (String fileName) {
    try {
    Class c = this.getClass();
    InputStream is = c.getResourceAsStream(fileName);

    byte[] b = new byte [2048];
    int len = is.read (b);
    byte[] data = new byte [len];
    for (int i = 0; i < len; ++i)
    data [i] = b [i];

    is.close();

    return new NDEFRecord (new NDEFRecordType (NDEFRecordType.MIME, "image/jpeg"), null, data);
    }
    catch (IOException e) {
    e.printStackTrace();
    return null;
    }
    }

  2. #2
    Regular Contributor
    Join Date
    Mar 2003
    Posts
    53

    Re: Exception on Writing an image file (jpeg) in MIFARE 4k

    ... additional info and maybe a bug in NDEFTagConnectionImpl.writeNDEF(.. ) method

    I tested with 4 different size of (.jpg) image files and found out the IOEXception occurs only for file sizes larger then 678 bytes.
    images
    446 bytes OK.
    678 bytes OK.
    800 bytes IOException occurs
    911 bytes IOException occurs

    My Environment is: Nokia 6131 NFC SDK with Eclipse 3.2 - carbide.j not integrated
    no external card reader


    Results: NDEFTagConnectionImpl.writeNDEF(.. )
    method throws java.io.IOException for images larger then 678 bytes.


    StackTrace on case of IOException:
    ----------------------------------

    TARGET DETECTED: .nfc:ndef;type=mf4k;uid=0x

    java.io.IOException: java.io.IOException: Authentication failed during write at block 68
    at com.nokia.phone.ri.contactless.NDEFTagConnectionImpl.writeNDEF(+195)
    at ContactlessWrite.targetDetected(+113)
    at com.nokia.phone.ri.contactless.DiscoveryManagerImpl.fireTargetDetected(+116)
    at com.nokia.phone.sdk.concept.event.ContactlessEventHandler.handleEvent0(+50)
    at com.nokia.phone.sdk.concept.event.ContactlessEventHandler.run(+23)


    Best regards,
    yakdogan

  3. #3
    Regular Contributor
    Join Date
    Mar 2007
    Location
    Helsinki, Finland
    Posts
    91

    Re: Exception on Writing an image file (jpeg) in MIFARE 4k

    The "Authentication failed during write at block 68" error message suggests that the tag you are trying to write to might have different keys starting from block 68.

    Can you please try and see if you are able to access/write anything to any of the blocks from that sector using an external reader? Also, can you please try the same operation with a different 4k tag? Do you get the same authentication failure?
    Raluca Cindrea
    Helsinki, Finland
    www.nokia.com/nfc

  4. #4
    Registered User
    Join Date
    Apr 2007
    Posts
    11

    Re: Exception on Writing an image file (jpeg) in MIFARE 4k

    Hi!!

    I have the same problem with Mifare 4K!

    Any solution?

  5. #5
    Regular Contributor
    Join Date
    Mar 2003
    Posts
    53

    Re: Exception on Writing an image file (jpeg) in MIFARE 4k

    Quote Originally Posted by Raluca_
    The "Authentication failed during write at block 68" error message suggests that the tag you are trying to write to might have different keys starting from block 68.

    Can you please try and see if you are able to access/write anything to any of the blocks from that sector using an external reader? Also, can you please try the same operation with a different 4k tag? Do you get the same authentication failure?
    I got my reader and MiFare 4k card today.
    Test with Omnikey reader and real 4k card - writing 800 bytes image: (Authentication error occurs, but there is not any reference to block 68)
    Stacktrace:


    TARGET DETECTED: .nfc:ndef;type=mf4k;uid=0x16892a99
    javax.microedition.contactless.ContactlessException: Authentication failure
    at com.nokia.phone.sdk.concept.srv.modules.nfc.omnikey.CardAccess.authenticate(Native Method)
    at com.nokia.phone.sdk.concept.srv.modules.nfc.omnikey.MFNativeSector.authenticate(MFNativeSector.java)
    at com.nokia.phone.sdk.concept.srv.modules.nfc.simulated.mifare.classic.MFClassicCard.authenticate(MFClassicCard.java)
    at com.nokia.phone.sdk.concept.srv.modules.nfc.util.mifare.a.a(a.java)
    at com.nokia.phone.sdk.concept.srv.modules.nfc.util.mifare.c.a(c.java)
    at com.nokia.phone.sdk.concept.srv.modules.nfc.util.mifare.c.b(c.java)
    at com.nokia.phone.sdk.concept.srv.modules.nfc.util.mifare.c.a(c.java)
    at com.nokia.phone.sdk.concept.srv.modules.nfc.util.mifare.ClassicNDEF.write(ClassicNDEF.java)
    at com.nokia.phone.sdk.concept.srv.modules.nfc.simulated.mifare.classic.MFClassicCard.write(MFClassicCard.java)
    at com.nokia.phone.sdk.concept.mirrors.contactless.NDEFTagMirror.writeNDEF(NDEFTagMirror.java)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.nokia.phone.sdk.concept.gateway.g.a(g.java)
    at com.nokia.phone.sdk.concept.gateway.g.run(g.java)
    at java.lang.Thread.run(Unknown Source)

    Best regads.

  6. #6
    Regular Contributor
    Join Date
    Mar 2007
    Location
    Helsinki, Finland
    Posts
    91

    Re: Exception on Writing an image file (jpeg) in MIFARE 4k

    Thanks for your answers and for your interest in this.

    This seems to be an issue - it will be investigated and I will keep you posted as soon as we have more information about it.

    Thank you for your patience.
    Raluca Cindrea
    Helsinki, Finland
    www.nokia.com/nfc

  7. #7
    Regular Contributor
    Join Date
    Mar 2007
    Location
    Helsinki, Finland
    Posts
    91

    Re: Exception on Writing an image file (jpeg) in MIFARE 4k

    Hello again,

    The issue that you described in this post a while ago has been addressed in the new version of the SDK. Writing image files to MiFare 4k tags now works correctly.

    You can download the Nokia 6131 NFC SDK version 1.1 from here.

    Thank you again for your patience.
    Raluca Cindrea
    Helsinki, Finland
    www.nokia.com/nfc

Similar Threads

  1. [announce] PyUIQ. Python for UIQ 2.1 and 3.x
    By OscarBernabeu in forum Symbian
    Replies: 35
    Last Post: 2008-01-17, 09:12
  2. Replies: 7
    Last Post: 2007-03-28, 08:53
  3. Replies: 1
    Last Post: 2006-11-16, 19:51
  4. open image file
    By Rx-lee in forum Symbian
    Replies: 3
    Last Post: 2004-04-02, 03:29
  5. can not successfully link any sample using .NET
    By lobotomat in forum Symbian Tools & SDKs
    Replies: 2
    Last Post: 2002-08-20, 00:29

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×