-
-
Notifications
You must be signed in to change notification settings - Fork 11
What I learned from contributing to TMRh20's library. #22
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
Conversation
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
`listen = True` now closes pipe 0 if no RX address was written to pipe 0. This is born from dialogue with TMRh20 about startListening() algorithm
- pipe 0 is closed if not specified to open_rx_pipe() `before listen = false` - listen attr does not check current CONFIG register before making changes - open_tx_pipe() does not actually open pipe 0 for RX-ing ACKs in TX mode. Rather, setting listen attr does. - examples demo proper addressing using both pipes 0 & 1 (multiceiver_test remains the same)
- reverts payload_length behavior before v1.2.0 due to inadequate access to internal RF24._pl_len list via payload_length.getter() - replaced per pipe control of payload_length with new RF24.set_payload_length() & RF24.get_payload_length() - added RF24.available() for convenient alternative to ```RF24.update() and RF24.pipe is not None``` - renamed FakeBLE.available() to FakeBLE.len_available() and provided access to RF24.available() via newer FakeBLE.available()
when using material theme
adafruit-adabot
added a commit
to adafruit/CircuitPython_Community_Bundle
that referenced
this pull request
Jan 25, 2021
Updating https://github.com/2bndy5/CircuitPython_nRF24L01 to 2.0.0 from 1.2.3: > Merge pull request nRF24/CircuitPython_nRF24L01#22 from 2bndy5/dev > Revert "listen won't flush RX FIFO; flush TX FIFO of ACKs" > Revert "typo" > typo > listen won't flush RX FIFO; flush TX FIFO of ACKs > Revert "attempt to fix init of _pipe0_read_addr" > attempt to fix init of _pipe0_read_addr > updated docstr in stream test's make_buffer() > typo in examples.rst > clarify docs on Re-use TX FIFO & code in update()
adafruit-adabot
added a commit
to adafruit/CircuitPython_Community_Bundle
that referenced
this pull request
Jan 29, 2021
Updating https://github.com/2bndy5/CircuitPython_nRF24L01 to 1.3.0 from 2.0.0: > refresh internal data when calling setter/getters > fix new get_*() > update configurable API docs > fix timeouts in man_ack test > update release.yml > update BLE limitations list > forgot internal deprecated attr in fakeBLE.init() > fix fake BLE example > reintroduce deprecated docs & corresponding code > actions limited to python 3.6 > corrects docs on listen; adjust build.yml > bump version to 1.3.0 > rollback rtd reqs > retrofit examples for CPython prior to v3.7 > patch all but breaking changes from v2.0 > remove references to CSN_DELAY from docs > patch tweaks from v2.0 < Merge pull request nRF24/CircuitPython_nRF24L01#22 from 2bndy5/dev < Revert "listen won't flush RX FIFO; flush TX FIFO of ACKs" < Revert "typo" < typo < listen won't flush RX FIFO; flush TX FIFO of ACKs < Revert "attempt to fix init of _pipe0_read_addr" < attempt to fix init of _pipe0_read_addr < updated docstr in stream test's make_buffer() < typo in examples.rst < clarify docs on Re-use TX FIFO & code in update()
adafruit-adabot
added a commit
to adafruit/CircuitPython_Community_Bundle
that referenced
this pull request
Jan 30, 2021
Updating https://github.com/2bndy5/CircuitPython_nRF24L01 to 2.0.1 from 1.3.0: > Update get*_() < refresh internal data when calling setter/getters < fix new get_*() < update configurable API docs < fix timeouts in man_ack test < update release.yml > update BLE limitations list < update BLE limitations list < forgot internal deprecated attr in fakeBLE.init() < fix fake BLE example < reintroduce deprecated docs & corresponding code > update adv API docs; remove redundant call in init > update basic API docs < actions limited to python 3.6 < corrects docs on listen; adjust build.yml < bump version to 1.3.0 < rollback rtd reqs < retrofit examples for CPython prior to v3.7 < patch all but breaking changes from v2.0 < remove references to CSN_DELAY from docs < patch tweaks from v2.0 > correct docstrings in ble example > save unecessary new lines in BLE_FREQ src > proofread BLE API docs > update greetings.rst > Merge pull request nRF24/CircuitPython_nRF24L01#22 from 2bndy5/dev > Revert "listen won't flush RX FIFO; flush TX FIFO of ACKs" > Revert "typo" > typo > listen won't flush RX FIFO; flush TX FIFO of ACKs > Revert "attempt to fix init of _pipe0_read_addr" > attempt to fix init of _pipe0_read_addr > updated docstr in stream test's make_buffer() > typo in examples.rst > clarify docs on Re-use TX FIFO & code in update()
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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.
Breaking backward compatibility changes -- next Release will be 2.0
available()function provided as a convenience instead of usingnrf.update() and nrf.pipe is not None(a technique introduced in the last release). To expose this newavailable()function in theFakeBLEAPI, I had to rename the currentavailable()function tolen_available().recv()is nowread(). The descriptive nameread()makes more sense because this function isn't actually doing the receiving, rather it is simply reading payload data that was already received and stored in the radio's RX FIFO.what_happened()toprint_details(). The name "what_happened" came from my misunderstanding of the TMRh20 library'sRF24::whatHappened()(& partly I just liked the name). Now, using "print_details" makes more sense because it is an apt description of what the function actually does.FakeBLE.to_androidattribute because it was marked for deprecation.RF24.read_ack()function because it was marked for deprecation.time.monotonic_ns()to measure transmission times. This change requires Python v3.7 in Linux, thus setup.py stipulates this requirement viapython_requiresoption. Recommend using latest release of the Raspberry Pi OS which ships with Python v3.7.2 (as of this writing).auto_ackreturns an integer (instead of a boolean) where each bit represent the feature's setting about a pipe.dynamic_payloadsreturns an integer (instead of a boolean) where each bit represent the feature's setting about a pipe.payload_lengthreturns the current setting of pipe 0 instead of a list for all pipes. This actually fixes a bug that allowed a flood of other subsequent bugs.payload_length[0] = 0, there was nothing in the code to prevent this mis-configuration (payload length cannot be 0). Furthermore this mis-configuration was not written to the corresponding nRF24L01 registers which would cause errors in every other function that handled payloads and/or payload lengths (namelyany(),send(),write(),recv(), &what_happened(True))Code Changes Include
time.sleep(0.005)calls in the SPI access functions. To compensate for the inherent CSN pin bouncing instability, I've implemented theextra_clocks=8parameter to Circuitpython'sSPIDevicec'tor. Essentially this means that after the CSN pin is set inactive HIGH, theSPIDeviceobject writes another dummy byte to let the CSN pin settle. This technique is faster than trying to do a time-based delay usingtime.sleep()(& also turns the disadvantage of Python's slow execution time into more of a strength). I'm aware that this technique is meant for SD cards and is dependent on the SPI bus' frequency, but if we encounter problems... I'll cross that bridge if we come to it.time.sleep()call that waited for less than 100 microseconds. Also, I took an idea from TMRh20'sRF24::write()and moved thece_pin.value = 0call to after the resulting status flags are asserted.CSN_DELAYconstant since altering its value had no real-time affect on the SPI access functions. Additionally, it isn't needed anymore due to the first point about implementing the huge speed-up.listenno longer flushes RX FIFO when entering RX mode.listennow flushes TX FIFO when entering TX mode andackpayloads are enabled.listencloses pipe 0 if it hasn't been designated for RX when entering RX mode.open_tx_pipe()does not actually open pipe 0 whenauto_ackis enabled. Rather,listennow opens pipe 0 when entering TX mode andauto_ackis enabled for pipe 0.send()&resend()doesn't clear the Status flags when finished anymore. This change will likely have little impact on applications since the status flags are still cleared when enteringwrite()andresend(). This was done to speed up execution.auto_acknow force-enables the automatic acknowledgement feature for pipe 0 when any other RX pipe hasauto_ackenabled.set_*()&get_*()publicly exposed functions forauto_ack,dynamic_payloads,payload_length, &ard/arcattributes. These should allow faster, easier, & less error-prone interaction when setting or getting the configuration for said attributes on any individual pipe or all pipes at once. I haven't deprecated the attribute's older setter-decorated functions for backward compatibility (the newset_*()functions still utilize the attribute's setter-decorated functions as helpers).ard,arc, &crcattributes now clamp invalid input values instead throwing aValueErrorexception.allow_ask_no_ackattribute for unofficial support of the Si24R1 (a flaw from cloning a typo in the nRF24L01 datasheet)last_tx_arcattribute for getting the number of retry attempts made in previous transmission. This data was previously only available inwhat_happened(), I found it useful when helping people troubleshhoot TMRh20's RF24 library.FakeBLEnow inherits fromRF24. Some attributes/functions are overridden to raise aNotImplementedErrorexception, so some vital ingredients to the BLE operation isn't compromised via theFakeBLEAPI.close_rx_pipe()now properly prevents thelistenattribute from overriding the pipe 0 reading addressprint_details()now prints a more accurate representation of the addresses used on the pipes. Like the TMRh20 RF24 library'sprintDetails(), the address now prints a "hexlified" string in big endian form.address_repr()function (belonging to the rf24.py module not the RF24 class) is the helper function that returns the address specified as a "hexlified" string in big endian form.Revised examples + new nrf24l01_manual_ack_test.py & nrf24l01_scanner_test.py
NEW scanner_test example that prints a vertical graph of potential RF interference for all applicable frequencies (vertically labeled by channel number).
In making a similar contribution to TMRh20's RF24 library, @TMRh20 kindly emphasized the importance of demonstrating "proper addressing" related to pipe usage. To show my appreciation for the discussion (& lessons learned), the examples have all (except the multiceiver example) been revised to use pipe 0 for TX & pipe 1 for RX. This revision adds a preliminary prompt that asks "Which radio is this?" Whereby:
b"1Node"on pipe 0 andb"2Node"on pipe 1b"2Node"on pipe 0 andb"1Node"on pipe 1some examples' payloads have also been altered. This has been done to match the new examples I've submitted to TMRh20's RF24 library.
master()&slave()master()&slave()structlibrary (instead of directly encoding the UTF-8 data into the bytearray)REMOVED nrf24l01_2arduino_handling_data.py in favor of the NEW nrf24l01_manual_ack_test.py example (they're practically identical).
Compatibility with TMRh20's library now only requires;
dynamic_payloadshas to be disabledpayload_lengthhas to be set accordingly to match TMRh20's RF24 new examples' configurationI've left these 2 lines commented out for easy modification (instead of typing it in the python REPL). Because most examples are compatible with TMRh20's new examples, the docs now have a table and hints about making this library compatible with TMRh20's RF24 library (instead of using 1 dedicated example).
multiceiver_test doesn't use ACK payloads for
node(1)anymore. This demonstration was a bit over zealous anyway, and removing it better matches the multiceiverDemo.ino example I submitted to TMRh20's RF24 library.all examples can be executed from CLI. This change is really helpful in that it requires less typing and less prone to typos (using terminal's auto-complete mechanism). This really only applies to the Linux platform, and there is no support for CLI args because CircuitPython firmware doesn't use them.
Other changes
Also changed the favicon to a miniature version of this logo. This should fall under the repo's MIT license, and I'm pretty sure its not as original as I think it is.
.. versionadded::and.. versionchanged::.