Online Store
Write Protect / Loc...
 
Notifications
Clear all

Write Protect / Lock Tag


bbordwell
Posts: 3
Registered
Topic starter
(@bbordwell)
Active Member
Joined: 2 months ago

Any help in SDK methods to write protect the card at both Page 2 Lock Bytes and Page 130 Lock Bytes for an NTAG215 would be appreciated.

I code in Delphi, but I can likely convert just about any language to what I need.

 

Do I make a call to BlockWrite()?

 

Help, any examples, any language appreciated....

 

Bret Bordwell

Topic Tags
5 Replies
elyley
Posts: 4
Admin Registered
(@elyley)
Illustrious Member
Joined: 11 years ago

Hello Mr. Bordwell. 
We currently have two SDK projects supporting all the functions for working with NTAG215 tags:

Unfortunately, we do not currently have this SDK in Delphi or a related programming language. Still, you can develop your own Delphi solution using the functions explained in the uFR Series API (page 55).

Reply
bbordwell
Posts: 3
Registered
Topic starter
(@bbordwell)
Active Member
Joined: 2 months ago

Hey, that's great, and thank you.

I downloaded the exe, but it got tagged by virus checker, so waiting on that to be okayed.
I took a peek at the code, but too much to decipher for a single request. Can you point me to specific methods?

If I look at Page 2, bytes 2 and 3, and page 130 bytes 0, 1 and 2, I can set these bytes to FF and lock the tag permanently.

What would be best method to achieve this goal?

Best regards.

All I want to do is read and update the lock bytes.

>>Do I make a call to BlockWrite()?

Reply
elyley
Posts: 4
Admin Registered
(@elyley)
Illustrious Member
Joined: 11 years ago

Hello, Sir. Sorry for the late response. 

I overlooked that we already have the proper tools with NFC Type 2 Tag lock byte functions implemented. Please check the following: 

I hope this will be more helpful for your project. 

You may also find useful some related video tutorials:

https://www.youtube.com/watch?v=e6BK9CF86tc

https://www.youtube.com/watch?v=5rZIEmfjfQw&t=6s&ab_channel=D-LogicNFC_SDK

https://www.youtube.com/watch?v=OsRoqhgeHiM&ab_channel=D-LogicNFC_SDK

https://www.youtube.com/watch?v=fwqk6No9KRw&ab_channel=D-LogicNFC_SDK

and documentation: https://github.com/nfc-rfid-reader-sdk/ufr-doc/blob/master/%C2%B5FR_NDEF_C%23_Example%20-%20Tag_locking_%26_password_settings.pdf

As for the Delphi support, we have an SDK with mostly used NDEF functions available at https://www.d-logic.net/code/nfc-rfid-reader-sdk/ufr-ndef-examples-delphi

Reply
1 Reply
bbordwell
Registered
(@bbordwell)
Joined: 2 months ago

Active Member
Posts: 3

Thank you. Just what I needed.

 

If anybody cares, here is the source to slam the lock bytes for an NTAG215 in Delphi.

What I didn't understand was why page_data needed to be defined as 16 bytes, when I'm interested in only 4 bytes. When I defined it as only 4 bytes, I kept getting an access violation on exit of the program.

I also didn't understand why we set Key array to all 255.  For now, doesn't really matter to me, as this code does slam the lock bytes, and is exactly what I was seeking.

 

Thanks.

 

procedure TfrmuFrSimple.Button4Click(Sender: TObject);
var
  pd : PByte;
  k : PByte;
  page_data : array of Byte; //= new byte[16];
  page_address : Byte;
  Key: array[0..3] of byte;
  iResult : DL_STATUS;
begin
  Key[0] := 255;
  Key[1] := 255;
  Key[2] := 255;
  Key[3] := 255;

  page_address := 2;
  SetLength(page_data,16);
  pd   :=PByte(@page_data[0]);
  k    := Pbyte(@Key[0]);
  try
    //   Read Page 2 
    iResult := BlockRead_PK(PD,
                 page_address,
                 MIFARE_AUTHENT1A,
                 k);

    SetStatusBar(stbFunction,iResult);
    if iResult <> 0  then
    begin
      ShowMessage('Fail to read 2');
      exit;
    end;
    lblValues.Caption := Format('%d %d %d %d',[page_data[0],page_data[1],page_data[2],page_data[3]]);

        //   Write Page 2 

    page_data[2] := 255;
    page_data[3] := 255;
    pd          :=PByte(@page_data[0]);
    iResult := BlockWrite_PK(PD,
                 page_address,
                 MIFARE_AUTHENT1A,
                 k);
    SetStatusBar(stbFunction,iResult);

    //   Read Page 130 
    if iResult = 0 then
    begin
      page_address := 130;
      iResult := BlockRead_PK(PD,
                   page_address,
                   MIFARE_AUTHENT1A,
                   k);

    //   Write Page 130 
      if iResult = 0 then
      begin
        page_data[0] := 255;
        page_data[1] := 255;
        page_data[2] := 255;
        iResult := BlockWrite_PK(PD,
                     page_address,
                     MIFARE_AUTHENT1A,
                     k);
        if iResult <> 0 then
          ShowMessage('Fail to write 130');
      end else
        ShowMessage('Fail to read 130');
    end else
      ShowMessage('Fail to write 2');

  finally
    SetFunctStart(false);
  end;

end;

 

Reply
elyley
Posts: 4
Admin Registered
(@elyley)
Illustrious Member
Joined: 11 years ago

Thank you very much for sharing your work with us!

Reply