Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for NTAG 21x tags #53

Merged
merged 4 commits into from
Jun 27, 2017
Merged

Added support for NTAG 21x tags #53

merged 4 commits into from
Jun 27, 2017

Conversation

SloCompTech
Copy link
Contributor

Hello,
I added support for NTAG21x tags according to NTAG213/215/216 documentation Rev. 3.2 June 2015
It includes:

  • reading pages
  • writting to pages
  • authentication with tag
  • configuring counters

Before it can be merged some things need to be checked:

  1. I added myself in copyright in files I writen or I updated, so authors need to give permission that they agree with changes
  2. Please check if I correctly updated compiler settings for ntag21x.c and examples

Copy link
Contributor

@smortex smortex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, thank you for this PR.

I added a commit (019bfd1) to revert to UNIX line endings (LF, not Windows CR+LF) to make the diff more readable, please check your editor's configuration and the output of git diff to avoid this kind of problems.

There are currently some style inconsistencies in the libfreefare code, but it would be cool to avoid introducing more (that would be a story for another PR). For example, we have spaces between a function name and the opening parenthesis of it's parameters (but not in diagnostic messages) and also spaces after comas and semi column. Please refer the style section of the file HACKING.md at the repository root for details.

I added a few more points inline

@@ -14,7 +14,8 @@ libfreefare_la_SOURCES = felica.c \
mifare_desfire_key.c \
mad.c \
mifare_application.c \
tlv.c
tlv.c \
ntag21x.c
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep the file list in alphabetical order.

mifare-detect-tag
ntag-write
ntag-setauth
ntag-removeauth
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep the list in alphabetical order.

mifare-detect-tag \
ntag-write \
ntag-setauth \
ntag-removeauth
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alphabetical order + indentation


ntag_removeauth_SOURCES = ntag-removeauth.c
ntag_removeauth_LDADD = $(top_builddir)/libfreefare/libfreefare.la

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alphabetical order of targets

} else if (mifare_ultralight_taste (device, target)) {
tag = mifare_ultralight_tag_new (device, target);
tag = mifare_ultralight_tag_new (device, target);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation changed unexpectedly

@@ -169,6 +171,8 @@ freefare_get_tag_friendly_name (FreefareTag tag)
return "Mifare UltraLightC";
case MIFARE_ULTRALIGHT:
return "Mifare UltraLight";
case NTAG_21x:
return "NTAG21x";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation look inconsistent

int ntag21x_authenticate (FreefareTag tag, const NTAG21xKey key); // Authenticate with tag
bool is_ntag21x(FreefareTag tag); // Check if tag type is NTAG21x
bool ntag21x_is_auth_supported (nfc_device *device, nfc_iso14443a_info nai); // Check if tag supports 21x commands

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See Function prototypes in the style guide for the magic of indentation here :-)

@@ -260,7 +282,7 @@ struct mifare_ultralight_tag {
#define MIFARE_CLASSIC(tag) ((struct mifare_classic_tag *) tag)
#define MIFARE_DESFIRE(tag) ((struct mifare_desfire_tag *) tag)
#define MIFARE_ULTRALIGHT(tag) ((struct mifare_ultralight_tag *) tag)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep the blank line between this group of macros and the comment

@smortex
Copy link
Contributor

smortex commented Mar 24, 2017

Oh, and no need to worry about the copyright, #49 is about removing them all since they are never updated.

@doegox
Copy link
Member

doegox commented Mar 24, 2017

@smortex we've a "style" phony target in libnfc, maybe you could setup sth similar for libfreefare? https://github.com/nfc-tools/libnfc/blob/master/Makefile.am

@SloCompTech
Copy link
Contributor Author

Fixed some identation, is there easy way to check if all is correct ?

@smortex
Copy link
Contributor

smortex commented Jun 26, 2017

Hello @SloCompTech,

is there easy way to check if all is correct ?

In order to check style "the easy way", I simply look at the Files changed tab of the pull request (on top of this page) which shows the wholes changes of all commits combined.

Since these changes are related to adding a new feature, the page should only contain bunches of new lines of code (new files, etc), and a few logical changes.

Therefore, any space change is suspicious and even if the spacing is wrong according to the style, it's better to keep it as it is in order to make the review easier (e.g. most changes in libfreefare/freefare.c should not be part of this pull request in order to make it easy to spot the actual changes (L74-75)).

On this tab, the in-line review comments are automatically hidden when they are attached to code that has been changed, so the comments I made some time ago and are still relevant are shown there.

Thank you for taking care of this, much appreciated 👍

@SloCompTech
Copy link
Contributor Author

Hi,
I think it's better that I take original repository and copy and paste changes into original version and then commit so other stuff will be unaffected.

@smortex
Copy link
Contributor

smortex commented Jun 26, 2017

@SloCompTech yes, you can create a new branch in order to have a reference to the current state of the repository, revert your master branch to origin/master and then update your master branch to only include the wanted changes.

Then, when you push your changes (-f will be required in order to force the commit since some pushed commits will have been changed) the pull request will be updated automatically (when you create a pull-request, it is linked to the branch you created, adding / modifying / removing commits in the branch updates the pull-request).

@SloCompTech
Copy link
Contributor Author

Hi,
I used clean current repo and insert changes only and used force push, so I think it's all done.

@smortex
Copy link
Contributor

smortex commented Jun 27, 2017

Hi

I cloned the repository, rebased on top of master, and added a commit to fix some spacing problems, unfortunately I can't push it to your repository 😮.

Either you did not "Allow edits from maintainers" (checkbox at the bottom of the right column of this page), otherwise GitHub do not want me to rebase your changes and I should revert that. Can you please check that maintainers edits are allowed and tell me?

Thansk!

@smortex smortex dismissed their stale review June 27, 2017 06:42

Most problems where fixed, I have local modification that fix the few remaining ones.

@smortex smortex self-requested a review June 27, 2017 06:42
@SloCompTech
Copy link
Contributor Author

hi @smortex, I have edit by maintainers enabled, but just in case I added you as colaborator, so please try to push to repo again

@smortex
Copy link
Contributor

smortex commented Jun 27, 2017

Nah, with your authorization I realized that I was pushing to a new non-existent branch in your repo and not in master… I just cherry-picked my commit and cleaned-up my mess!

@smortex smortex merged commit b2eca83 into nfc-tools:master Jun 27, 2017
@smortex
Copy link
Contributor

smortex commented Jun 27, 2017

Changes squashed and merged. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants