Implement CTX/RTX. #59
Merged
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.
CTX/RTX requires interacting with 2 GPIO pins, so I added a gpio.py file to
handle abstracting GPIO for 3 platforms: CircuitPython, MicroPython, and
Raspberry Pi (Raspbian). The core of the CTX/RTX code lives in
transaction_manager.py. This file uses the code in gpio.py to implement the
CTX/RTX protocol. This gets used in notecard.py when any Notecard transaction
occurs, so long as the transaction pins have been set. If they haven't been set,
everything behaves as before.
I tested this functionality on all 3 supported platforms by hooking up a
push button to the CTX pin and an LED to the RTX pin. I issued a hub.set request
and the LED lit up. The transaction only went through after I pushed the button,
simulating a CTX pulse from the Notecard.
Additionally, I refactored some other code:
info throughout the code, so it makes sense to move it into a single file.