Skip to content

PN532 SAM_configuration powermode updates - #41

Merged
lastlink merged 2 commits into
mainfrom
f/power_mode_updates
Jun 14, 2026
Merged

lastlink merged 2 commits into
mainfrom
f/power_mode_updates

Conversation

@lastlink

Copy link
Copy Markdown
Collaborator

This pull request improves the robustness and reliability of the PN532 RFID reader integration by adding automatic recovery from I2C errors, enhancing the stub for development, and refactoring initialization logic. It also includes minor test code updates.

PN532 RFID Reader Reliability Improvements:

  • Refactored PN532 initialization into an _init_pn532 function, which returns a hardware instance or a stub on failure, and ensures the reader is always kept in Normal Mode by shadowing power_down with False to prevent accidental sleep.
  • Enhanced the check_rfid loop to track consecutive I2C errors and automatically reinitialize the PN532 after five consecutive failures, improving recovery from hardware stalls without requiring a device reboot. Heartbeat logging and error streak tracking were also added.

Development and Testing Improvements:

  • Updated the PN532Stub class to match the hardware interface more closely by shadowing power_down, adding type annotations, and improving method signatures for better testability and consistency.
  • Updated test imports to include ingest_action_log_file from metrics_storage in preparation for further test enhancements.

@github-actions

Copy link
Copy Markdown

Test Results

136 tests   136 ✅  19s ⏱️
 17 suites    0 💤
 17 files      0 ❌

Results for commit 1d71e53.

Comment thread start.py Dismissed
Comment thread start.py Dismissed
@lastlink
lastlink merged commit c6dbec4 into main Jun 14, 2026
6 checks passed
@lastlink
lastlink deleted the f/power_mode_updates branch June 14, 2026 03:19

This branch was previously deployed

1 inactive deployment
production 1d71e532 Deployed Jun 13, 2026 by lastlink via Deploy to production #28
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.

1 participant