Initialize PN532 IFD-NFC at startup when configured and detected on I2C#360
Open
Copilot wants to merge 7 commits into
Open
Initialize PN532 IFD-NFC at startup when configured and detected on I2C#360Copilot wants to merge 7 commits into
Copilot wants to merge 7 commits into
Conversation
Copilot created this pull request from a session on behalf of
3rdIteration
June 1, 2026 19:45
View session
There was a problem hiding this comment.
Pull request overview
This PR ensures the PN532 IFD-NFC stack is activated during application startup when PN532 is already configured in settings, avoiding the prior “only activates on value transition” behavior. Activation is gated by a best-effort I2C probe so it only runs when a PN532 is actually present.
Changes:
- Added an
i2cdetect-based I2C probe helper (_is_i2c_device_detected) to detect a device at0x24. - Added startup-time activation helper (
_maybe_activate_pn532_on_startup) that runsifdnfc-activate yesonly when configured + detected. - Invoked the activation helper during
Settings.get_instance()initialization.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
PN532 smartcard access could remain unavailable after boot when
smartcard_interfacesalready containedpn532, because activation side-effects were only triggered on value transitions. This change adds startup-time PN532 activation, but only when the NFC interface is configured and a PN532 is detected on I2C.Startup activation path
_maybe_activate_pn532_on_startup(settings)and invoked it duringSettings.get_instance()initialization.I2C-gated hardware detection
_is_i2c_device_detected()to probe/dev/i2c-1and/dev/i2c-0withi2cdetectfor address0x24(PN532 default).ifdnfc-activate yesis executed only whenpn532is configured and the device probe succeeds.Fail-safe behavior
ifdnfc-activate,i2cdetect, or I2C buses are unavailable.Example of the new startup gate:
Describe the change simply. Provide a reason for the change.
Include screenshots of any new or modified screens (or at least explain why they were omitted)
No UI changes; screenshots omitted.
This pull request is categorized as a:
Checklist
pytestand made sure all unit tests pass before sumbitting the PRIf you modified or added functionality/workflow, did you add new unit tests?
I have tested this PR on the following platforms/os:
Note: Keep your changes limited in scope; if you uncover other issues or improvements along the way, ideally submit those as a separate PR. The more complicated the PR the harder to review, test, and merge.