Skip to content

Fix PERIPH Simple Protocol mapping (#24) - #25

Merged
c3rebro merged 6 commits into
masterfrom
fix/issue-24-periph-simple-protocol
Aug 24, 2026
Merged

c3rebro merged 6 commits into
masterfrom
fix/issue-24-periph-simple-protocol

Conversation

@c3rebro

@c3rebro c3rebro commented Aug 24, 2026 •

Copy link
Copy Markdown
Owner

Summary

Fixes the PERIPH command mapping for TWN4 readers using the stock Simple Protocol firmware.

Issue #24 correctly identified a regression: the current implementation mixed TWN4 App/API SYSFUNC numbering with Simple Protocol command IDs. The original PERIPH implementation from January 2024 used the correct Simple Protocol mapping (API_PERIPH = 0x04, Beep = 0x0407), but the current implementation had subsequently diverged from that map.

Changes

  • restore API_PERIPH to 0x04
  • fix BeepAsync to send [0407][Volume][Frequency][OnTime][OffTime]
  • restore/document the Simple Protocol PERIPH commands for:
    • GPIO configure/set/clear/toggle/blink/test
    • diagnostic LED controls
    • Wiegand and Omron output
    • LED init/on/off/toggle/blink
    • BeepOn / BeepOff
  • keep compatible existing method names as aliases where they map cleanly to Simple Protocol
  • mark App/API-only SYSFUNC wrappers as obsolete and return NotSupportedException instead of sending misleading Simple Protocol frames
  • add frame-level tests using the examples and command layout from DocRev25
  • add a compatibility test mirroring the README/sample sequence: BeepAsync -> LedInitAsync -> LedBlinkAsync -> PlayMelody
  • mark the old MissingSimpleProtocolCommands.md inventory as stale; it contained additional outdated mappings and should be regenerated separately from the current source tree

The sample compatibility test verifies that the public example API compiles against the current library and that PlayMelody again emits valid 0x0407 Beep frames. The historical melody timing calculation is intentionally left unchanged in this bugfix.

GPIO outputs still need to be configured as outputs before set/clear/toggle operations, as required by the Simple Protocol. This is separate from the Beep command and does not affect BeepAsync.

DESFire implementations are intentionally out of scope and no DESFire source files are modified by this PR.

Fixes #24

@codacy-production

codacy-production Bot commented Aug 24, 2026 •

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 2 medium · 4 minor

Alerts:
⚠ 6 issues (≤ 0 issues of at least minor severity)

Results:
6 new issues

Category Results
BestPractice 2 medium
CodeStyle 4 minor

View in Codacy

🟢 Metrics 34 complexity · 0 duplication

Metric Results
Complexity 34
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@c3rebro
c3rebro merged commit 3671a67 into master Aug 24, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PERIPH commands don't match the Simple Protocol specification (Beep not working)

1 participant