1

I want to write application in Delphi, which can communicate with Android phones and DESFire cards. I know, I have to send some bytes to card and card answers me. I read article about it:

https://ridrix.wordpress.com/2009/09/19/mifare-desfire-communication-example/

I have no idea, how can I write and read bytes from card? I wrote simple application according to Daniel Magin:

http://www.danielmagin.de/blog/index.php/2014/09/nfc-android-application-with-delphi-xe6-and-xe7/

This program can only read UID from card.

function TNfc.ReadNFCUID: string;
var
  Intent: JIntent;
  jIntentName: JString;
  IntentName: string;
  tagId: Androidapi.JNIBridge.TJavaArray<Byte>;
  tagFromIntent: JParcelable;
  id: string;
  i: Integer;

begin
  id := '';
  Intent := SharedActivity.getIntent;

  if Intent <> nil then
  begin
    jIntentName := Intent.getAction;
    IntentName := JStringToString(jIntentName);

    tagId := Intent.getByteArrayExtra(TJNFCAdapter.JavaClass.EXTRA_ID);

    tagFromIntent := Intent.getParcelableExtra
      (TJNFCAdapter.JavaClass.EXTRA_TAG);
    if (tagId <> nil) and (tagFromIntent <> nil) then
    begin
      for i := 0 to tagId.Length - 1 do
        id := id + IntToHex(tagId.Items[i], 2);
    end;
  end;

  Result := id;

end;
1
  • Please add the essential part of the code you wrote and add the missing tags e.g. delphi-xe7 Commented Nov 5, 2014 at 22:07

1 Answer 1

1

I find solution for my question:

..
var
    isoNFC : JIsoDep;
    tag : JTag;
    aRawData : TJavaByteArray;
    aResponse : TJavaByteArray;

begin
  aRawData := TJavaByteArray.Create(1);

  tag := TJTag.Wrap((CurrentNFCTag as ILocalObject).GetObjectID);
  isoNFC := TJIsoDep.JavaClass.get(tag);
  isoNFC.connect();

  aRawData.Items[0] := TCmd.GetApplicationIDs;
  aResponse := isoNFC.transceive(aRawData);
..
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.