nRF24 / RF24Network

OSI Layer 3 Networking for nRF24L01(+) and nRF52x on Arduino and Raspberry Pi
https://nrf24.github.io/RF24Network/
GNU General Public License v2.0
353 stars 163 forks source link

[Request] make multicast_level and node_address members protected #187

Closed 2bndy5 closed 2 years ago

2bndy5 commented 2 years ago

This feature request is similar to nRF24/RF24#782 in that I'll be using inheritence to provide additional functionality in the newer python wrappers that isn't available in the the C++ libs (for low-memory reasons).

With this feature added, I do plan on letting users set the multicast_level and node_address members via existing functionality (RF24Network::multicast_level() and RF24Network::begin() respectively). The following psuedo-code might help to better describe my intentions here

import pyRF24.rf24 as rf24
import pyRF24.rf24_network as rf24_network

THIS_NODE = 0o1

radio = rf24.RF24(22, 0)
if not radio.begin:
    print("radio hardware not responding")
    exit()

network = rf24_network.RF24Network(radio)

# new python wrapper's setter for the node's logical address
# keep in mind that channel should be set with radio.set_channel(new_chnl) or radio.channel = new_chnl
network.node_address = THIS_NODE  # underlying functionality calls RF24Network::begin(THIS_NODE)
# new python wrapper's getter for the node's logical address
addr = network.node_address  # simply returns the private/protected member RF24Network::node_address

# set the multicast level
network.multicast_level = 1  # underlying functionality calls RF24Network::multicast_level()
# get the current multicast level
lvl = network.multicast_level  # simply returns the private/protected member RF24Network::multicast_level
TMRh20 commented 2 years ago

Yeah I think I’m good with this

On Aug 10, 2021, at 9:40 PM, Brendan @.***> wrote:

 This feature request is similar to nRF24/RF24#782 in that I'll be using inheritence to provide additional functionality in the newer python wrappers that isn't available in the the C++ libs (for low-memory reasons).

With this feature added, I do plan on letting users set the multicast_level and node_address members via existing functionality (RF24Network::multicast_level() and RF24Network::begin() respectively). The following psuedo-code might help to better describe my intentions here

import pyRF24.rf24 as rf24 import pyRF24.rf24_network as rf24_network

THIS_NODE = 0o1

radio = rf24.RF24(22, 0) if not radio.begin: print("radio hardware not responding") exit()

network = rf24_network.RF24Network(radio)

new python wrapper's setter for the node's logical address

keep in mind that channel should be set with radio.set_channel(new_chnl) or radio.channel = new_chnl

network.node_address = THIS_NODE # underlying functionality calls RF24Network::begin(THIS_NODE)

new python wrapper's getter for the node's logical address

addr = network.node_address # simply returns the private/protected member RF24Network::node_address

set the multicast level

network.multicast_level = 1 # underlying functionality calls RF24Network::multicast_level()

get the current multicast level

lvl = network.multicast_level # simply returns the private/protected member RF24Network::multicast_level — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

2bndy5 commented 2 years ago

I'll also prefix the private/protected multicast_level with a _. This is to not confuse with the public function by the same name.