×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Sep 2007
    Posts
    3

    Thumbs up Problem writing in the internal Mifare 4k Invalid block byte range

    Hi, I´m trying to write in a specific sector and block of the internal mifare 4k of 6131 NFC.

    The Excetion is:

    java.lang.IlegalArgumentException: Invalid block byte range

    Is this the correct way to do it? How can I write in an specific block - sector?

    Thanks in advance,...

    Code:
    	public String InitTitle(){
    		String data = "";
    		if (conectar()){
    			sector = conn.getSector(0);
    			bloque = sector.getBlock(1);	
    			data = bloque.toString();
    			try {
    				byte[] registro = new byte[128];
    [.....]
    Here the registro byte array are filled with 1s and 0s.
    [.....]
    
    			        bloque.write(null,registro,0,registro.length-1,17);
    
    				
    			} catch (MFStandardException e) {
    				// TODO Auto-generated catch block
    				e.printStackTrace();
    			} catch (IOException e) {
    				// TODO Auto-generated catch block
    				e.printStackTrace();
    			}
    	       }
    	}
    	private boolean conectar(){
    		// 1. Open connection to internal tag		
    		String internalUrl = System.getProperty("internal.mf.url");
    		try {
    			conn = (MFStandardConnection) Connector.open(internalUrl);
    		} catch (IOException e) {
    			return false;
    		}
    		return true;
    
    	}

  2. #2
    Regular Contributor
    Join Date
    Jul 2007
    Location
    Lisbon - Portugal
    Posts
    96

    Re: Problem writing in the internal Mifare 4k Invalid block byte range

    Hi
    The Mifare 4K has a block size of 16 bytes.

    In your code you are trying to write 128 bytes. Change it to 16 bytes and check if the problem persists.

    Good Luck

  3. #3
    Registered User
    Join Date
    Sep 2007
    Posts
    3

    Re: Problem writing in the internal Mifare 4k Invalid block byte range

    Thanks!!

    I have tested with:
    Code:
    bloque.write(null,registro,0,16,0);
    And works well,
    Later with the purpose of write in the sector without having to write in each block. I have tryed with:

    Code:
    sector = conn.getSector(1);
    sector.write(null,registro,0,128,0);
    With the result of java.lang.IllegalArgumentException: Invalid sector byte range

    Taking in account that sector 1 have 14 data block of 16 bytes, and 128 is a multiple of block size i think that no source or destination byte range is out of bounds.

    Have you got some idea?

  4. #4
    Regular Contributor
    Join Date
    Jul 2007
    Location
    Lisbon - Portugal
    Posts
    96

    Re: Problem writing in the internal Mifare 4k Invalid block byte range

    Sector 1 has (just like the sectors 0 through 31) 4 blocks of 16 bytes each, where only the 3 first blocks are usable [the last one is called sector trailer and has access conditions and keys for that block].

    You might want to check the Mifare 4k datasheet at: http://www.nxp.com/acrobat_download/...on/m043531.pdf

    Be careful when writing data to the device, because if you overwrite the key values, the next time you try to access the card, the keys to access will be the values you wrote. If you don't know what values you wrote in the key A or B field, you won't be able to gain access to those sectors again.
    Please check the specification throughly before actually testing it in the real device, so you don't render your phone useless. Test it in other tags first.

    Good luck

  5. #5
    Registered User
    Join Date
    Sep 2007
    Posts
    3

    Re: Problem writing in the internal Mifare 4k Invalid block byte range

    Thanks, Its my fault, i have this document but i have got an error reading the memory organization,... I had understood that the sector with 4 blocks were 0 AND 31,... This is the problem of read the documentation too quick!!

    I try with sector 32 and all works fine.

    And thanks for the advice, i must write only in the data blocks from 0 to 14.

    Thanks for your quick Answer!!!

  6. #6
    Registered User
    Join Date
    Sep 2007
    Posts
    40

    Smile Re: Problem writing in the internal Mifare 4k Invalid block byte range

    Hi arodriguez.

    I'm new to NFC. Actually, I haven't got the phone nor the kit yet. I would like to know if you have any ideas (not massive, as in my country NFC is still far from coming) for solving problems in industry or whatever, that involves few phones and tags. I dont know, maybe control or something like that.

    Any help is appreciated!
    Juan C. Ramirez

Similar Threads

  1. G729 problem
    By noam segal in forum VoIP
    Replies: 7
    Last Post: 2008-09-25, 14:03
  2. Nokia 6260 internal memory problem
    By nxx7 in forum General Development Questions
    Replies: 1
    Last Post: 2006-02-05, 18:01
  3. Problem when writing to bluetooth SPP port, the second time.
    By lj@jvl.dk in forum Bluetooth Technology
    Replies: 2
    Last Post: 2005-07-18, 08:16
  4. byte array in series 60 problem
    By robon in forum Mobile Java Media (Graphics & Sounds)
    Replies: 8
    Last Post: 2004-04-21, 16:02
  5. Loading images from byte array on 6130i
    By enlightment in forum Mobile Java General
    Replies: 2
    Last Post: 2002-06-05, 19:44

Posting Permissions

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