-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
RF24Network, RF24Mesh, and RXing BLE #33
Merged
Merged
Conversation
This file contains 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
all supported platforms
corrected is_plus_variant check when setting data_rate
adafruit-adabot
added a commit
to adafruit/CircuitPython_Community_Bundle
that referenced
this pull request
Nov 27, 2021
Updating https://github.com/2bndy5/CircuitPython_nRF24L01 to 2.1.0 from 2.0.2: > proofread docs > RF24Network, RF24Mesh, and RXing BLE (nRF24/CircuitPython_nRF24L01#33) > Create CONTRIBUTING.md
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.
yeah, I've been busy adding/improving this lib (yet again)... As always docs are hosted at rtfd.io.
You may notice that the docs' theme has changed slightly. This is due to the use of the new sphinx-immaterial theme. This theme allows for both light and dark themed color palettes (which can be sought from the system settings by the internet browser).
BLE can now receive
the fake_ble module now has a new class called
QueueElement
which is used to decode incoming BLE data as it goes from theFakeBLE
class' newrx_cache
buffer and is saved in the newrx_queue
attribute. The existing example has been updated to demonstrate this additional API (which includes a new overriddenavailable()
&read()
).QueueElement
object will always contain the MAC address of the transmitting BLE deviceQueueElement.data
list (as a bytearray). All supported service data will coexist in thedata
attribute/list as objects that can be used for transmitting BLE data.ServiceData
based classes have their own__repr__()
method that will allow printing human-readable encapsulated data.RF24Network & RF24Mesh
The C++ libraries that were ported to pure python are a freaking beast. Many of the compile time macros used in C++ could not be used in python (same goes for ALL the overloaded C++ functions). Instead, I had to utilize inheritance to limit consumed memory resources, but some C++ features that were hard-coded at compile-time are straight-up dynamic attributes in this lib. Instead of listing all the features, I will list the differences between C++ libs and this pure python lib's modules.
Instead of writing numerous examples that are almost identical, there is only 1 new example for networking. It demonstrates both fragmented and un-fragmented payloads as well as
RF24Network
,RF24Mesh
, andRF24MeshNoMaster
classes. Note, I had to diverge from using the typicalmaster()
andslave()
named functions as to not confuse with network node operations; this example usesemit()
andidle()
functions instead.context manager
As always I've kept compatibility with python's context management system (the
with
statements). Thus you can use the same radio to take a break from networking and quickly do BLE or basic RF24 operations. This will prove even more useful when using the radio to participate in separate networks on different channels and/or using different physical address "seeds".RF24Network
address_prefix
andaddress_suffix
attributes (bothbytearrays
). There is a quick tutorial in the docs' topology page about using different physical address "seeds" for 2 networks coexisting on the same channel.DISABLE_USER_PAYLOADS
exists in this lib as base class thatRF24Network
class inherits from calledRF24NetworkRoutingOnly
. In practice this may be used for routing nodes or possibly RF24Ethernet in the future (I need to better understand TCP/IP protocol first).write(header, message)
function is calledsend()
in this lib due to lack of function overloading, However, users can pass entire frames to be sent using this lib'swrite(frame, traffic_direct)
function.collections
module because it doesn't have what I need in CircuitPython.NETWORK_EXTERNAL_DATA
message types do not get put into their own queue. This may change with the introduction of RF24Ethernet/RF24Gateway in the future.MAX_PAYLOAD_SIZE
is a dynamically set attribute callmax_message_length
bool
attribute calledfragmentation
. Changing this attribute will reduce some memory (but not that much), and also resets themax_message_length
attribute accordingly.begin()
function is basically an attribute in this lib callednode_address
. The RF24Network class' constructor takes thisnode_address
as a required parameter, so there is very little need to set the attribute after instantiation.networkFlags
member is replaced with a private boolean called_parenthood
(which is only used byRF24Mesh.allow_children
member). All othernetworkFlags
are not necessary for this lib (or they were not actually used in the original C++ libs).RF24Mesh
All RF24Network functionality is inherited into RF24Mesh.
MESH_NO_MASTER
macro exists as a base class calledRF24MeshNoMaster
. Obviously, this is meant for nodes that don't need the code that mesh master nodes use.node_address
attribute cannot be set (it is read-only in RF24Mesh) because mesh nodes need to be automatically assigned an address from the mesh network master node per the uniquenode_id
number. Thenode_id
number can be changed though doing so will disconnect the node from the network (if it is connected)dhcp_dict
in this lib's RF24Mesh class. Currently, I'm not supporting persistence on Circuitpython MCUs because it requires a write-accessible file system or using circuitpython'snvm
module (every write to NVM should be carefully controlled by the user because those chips have a limited lifetime of write cycles).dhcp_dict
can be saved/loaded to/from a JSON file. This is not automatically done like it is in the C++ lib however.DHCP()
function is private function in this lib, and it is automatically called when needed on master nodes.Examples revisited
All examples have been slightly modified to use constant-type names for the
SPI_BUS
,CE_PIN
, &CSN_PIN
.New Wrappers
SpiDev
from pypi.org. This module is much faster than using CircuiPython'spureio
module, thus it is encouraged to usespidev.SpiDev
objects instead ofboard.SPI
objects on Linux.