Huge list of updates
Import statements have changed with the addition of a couple new modules
See the examples for the proper expected usage. WARNING: examples from older versions are NOT compatible with this version because of this fundamental change (__init__.py
file is blank now).
New Modules
- A lite version (
rf24_lite.py
) has been introduced for boards with limited available memory (e.g. ATSAMD21 core M0 based boards). Although, using TMRh20's Arduino/PlatformIO library is still highly recommended (especially for complex applications) as CircuitPython leaves little room for user-space code in this scenario. This lite version may not remain in the next release, so consider it experimental. Info about what was stripped away can be found in the docs (main difference is no context manager compatibility in the lite version). #10 - A new module named
fake_ble.py
has been added to implement using the nRF24L01+ as a fake BLE advertising beacon. Docs have been updated to include an example and describe the additional API including battery level, URL, and temperature measurement service data helper classes.FakeBLE
class allows advertising a devicename
, the nRF24L01'spa_level
as "TX power level", custommac
address, & ato_iphone
flag to aim advertisements at different smartphones. This newfake_ble.py
module is NOT compatible with therf24_lite.py
module.
Optimizations:
- Constructor now only takes required parameters (spi, csn, & ce objects). This saves storage space and de-clutters the docs a bit. Notice there are setters for all attributes that were affected by all previously available kwargs to constructor. Per #15 the constructor also takes an optional kwarg
spi_frequency
to customize the frequency used for SPI transactions. However the SPI frequency cannot be changed after instantiating the RF24 or FakeBLE objects. send()
has been re-written. It now employs recursion when passing a list/tuple of payloads. Payload format checking now relies on internalwrite()
call.send()
no longer calculates a timeout, rather it blocks until a status flag is asserted by the ESB protocol from the nRF24L01 (application will only hang if there is a SPI bus malfunction).send()
now only returnsFalse
orTrue
; it can still return an ACK payload, but empty ACK payloads will show asTrue
(notNone
). NEWsend_only
parameter to disable automatic fetching of ACK payloads when callingsend()
orresend()
(this parameter defaults toFalse
for backward compatibility).- Docs have been more adequately indexed in the sidebar navigation.
- Fixed an issue where
any()
may have been returning incorrect data in some cases. This seemed to affectrecv()
also because it callsany()
to get the RX'd payload length. recv()
now takes an optional parameter,length
, that can manually specify how many bytes to read from the RX FIFO. Notice every attempt to read from the RX FIFO starts with the first byte (if available) in the top level of the RX FIFO. A payload is only removed when it is completely read from the RX FIFO.- If
length
is greater than payload in top level, then data from next available payload(s) is returned. - If
length
is greater than last available payload in RX FIFO, then the returned buffer is padded with the last byte in payload and payload is removed from FIFO. Also, the last byte read from RX FIFO is repeatedly returned when reading from an empty RX FIFO. - If
length
is less than payload in top level, the payload will remain in RX FIFO.
- If
- Doc strings split. Source code now only contains a brief description of functions/attributes (for quick usage of python's builtin
help()
). Detailed info on function parameters and attributes now live in online documentation. This reduced the size of source code stored on CIRCUITPY drive by more than 50% (84 kB -> 30 kB when using rf24.py -- rf24.mpy compiles to less than 20 kB). - Switched to Github actions instead of using travisCI.
- Tested compatible with STM32F405 Feather (requires CircuitPython v6.x). Thank you @water5
- Removed
address_length
check onopen_rx_pipe()
&open_tx_pipe()
. The nRF24L01 will only save up to 5 bytes for addresses assigned to pipes 0 & 1 (1 byte max for the rest of the data pipes). Furthermore, the nRF24L01 will only use the first X number of bytes (where X is specified usingaddress_length
attribute) when reading addresses from the respective pipe address registers during automatic packet assembly. write()
now has an optional parameter calledwrite_only
. Use this parameter asTrue
to fill the nRF24L01's TX FIFO before beginning transmissions.
Changes
- import statements now require the form
from circuitpython_nrf24l01.<module> import <object(s)>
(see examples as they have been updated accordingly). read_ack()
marked for deprecation. It is currently still available until the next major release for backward compatibility with previous versions of this library. I highly recommend usingrecv()
instead as it is synonymous withread_ack()
- IRQ attributes' names are now pythonic.
irq_DS
is nowirq_ds
,irq_DF
is nowirq_df
,irq_DR
is nowirq_dr
. - Context manager now powers down the nRF24L01 when exiting a with statement block. Context manager also now persists pipe addresses (both RX & TX).
pipe()
is now a read-only attribute with same name (RF24.pipe
)- RX & TX addresses can be fetched using the new
address()
function (read-only; see docs for more info). - Expanded info about data pipes in
what_happened(True)
to show expectedpayload_length
setting for static payloads (whendynamic_payloads
are disabled) only on open pipes. - Fixed typo in examples and readme about what MCU pin to connect to the nRF24L01's IRQ pin. Thank you @jerryneedell
- Removed the
reset
parameter fromclose_rx_pipe()
. It doesn't matter what the address for a data pipe is if that data pipe is closed. Error in v1.1.2 docs: addresses for data pipes do reset to factory defaults on nRF24L01 boot (when VCC goes from 0V to 3.3V). - NEW
rpd
attribute (read-only) for advanced usage. This can be used to detect interference or a carrier wave on a specific channel. Docs contain link to datasheet for more detail. - NEW
start_carrier_wave()
andstop_carrier_wave()
functions to verify the nRF24L01 TX output is functioning. This a hardware test only. The carrier wave can be detected with another nRF24l01listen
ing for arpd
flag (example code in API docs). pa_level
now accepts list or tuple in addition to original functionality to compensate for the peculiar LNA_HUCRR bit used by nRF24L01 (non-plus variant) and the Si24R1 (cheap nRF24L01 clone).- NEW
is_plus_variant
attribute to determine if the nRF24L01 is a plus variant module or an older non-plus variant module. This attribute is also used internally to accommodate the difference in expected behaviors among the 2 variants. dynamic_payloads
,auto_ack
, &payload_length
all now take an optional tuple or list of parameters to control the respective features on a per pipe basis. Apayload_length
of 0 means that pipe remains unaffected. Setting a pipe'sauto_ack
ordynamic_payload
feature to a negative number means that pipe will remain unaffected.- The interrupt pin example has been re-written to show how to use the
write()
function properly in conjunction with the nRF24L01's IRQ pin (while also using the nRF24L01'sack
payloads feature). Notice that this example runs extremely quick as there are no unnecessarytime.sleep()
calls.