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

Ensure users are compatible between v1 and v2 #625

Merged
merged 2 commits into from
Mar 24, 2024

Conversation

mcnewton
Copy link

RC522 UIDs were broken in v1 - they sometimes missed '0's. This was fixed in abd0e66 and 20e4dcb, but that means a user database from v1 will not be entirely compatible after upgrading to v2, so some users could get locked out.

To solve this we calculate both the new (correct) format and the old (broken) format. If the new format UID doesn't exist in the database we do a check for the old format as well, and continue with that if it exists. This allows a seamless upgrade to v2.

Commits abd0e66 and 20e4dcb fixed how UIDs are converted to strings.
Previously some '0's in the UID would be missed, meaning the old stored UIDs
were actually incorrect. This had the effect of meaning esp-rfid v2 is not
compatible with all users from v1. To fix this we create UIDs at scan time in
both the new (fixed) format and the old (broken) format, and check the database
for both.
@mcnewton
Copy link
Author

Note I considered automatically updating the database if a v1 UID was found, but that would mean it's impossible to downgrade to v1, unless a second duplicate user was created for each card (may hit storage limits on systems with a large number of users, which would be an unexpected failure). Something automatic could be done in a later release once v2 has been out a while and v1 less likely to be found in the wild. Unfortunately it's not possible to convert a full v1 database to v2 without re-scanning cards (it should be possible to "break" the UIDs from v2 to work again in v1, though).

There are a few different automatic upgrade methods that could be used, but I think it's simplest and best to just permit old cards to work and leave it at that.

@matjack1
Copy link
Collaborator

Thank you, I tried to make the upgrade to v2 as easy as possible, but I didn't notice this!

@matjack1 matjack1 merged commit 56c0fb9 into esprfid:dev Mar 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants