Skip to content
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

Set radio settings before or after network.begin()? #53

Closed
n8henrie opened this issue Aug 17, 2015 · 1 comment
Closed

Set radio settings before or after network.begin()? #53

n8henrie opened this issue Aug 17, 2015 · 1 comment
Labels

Comments

@n8henrie
Copy link

Is one supposed to set radio details (such as data rate, PA level) before or after network.begin()?

I had assumed we would set up the radio as desired, then call network.begin(), e.g.

radio.begin();
radio.setPALevel(RF24_PA_MAX);
radio.setDataRate(RF24_250KBPS);

network.begin(82, base_node);
radio.printDetails();

However, I keep ending up with Data Rate = 1MBPS with this strategy.

Reviewing the examples, I can see that in the Network Ping example it's done similarly: the radio.setPALevel is called after radio.begin() but before network.begin(). None of the other examples set up any other of the radio parameters.

It looks like this is because the data rate is hard-coded into network.begin(), so in order to work at RF24_250KBPS and maximize my range, I have to rearrange things like so:

radio.begin();
radio.setPALevel(RF24_PA_MAX);
network.begin(82, base_node);
radio.setDataRate(RF24_250KBPS);

radio.printDetails();

It just seems odd to do go from setting up the radio to setting up the network back to configuring the radio. Is this how I'm supposed to be going about things? If so, perhaps I could put something into the documentation.

Otherwise, I wonder if we could eliminate this piece of code from RF24Network since setDataRate( RF24_1MBPS ) ; is already set by default in radio.begin(), and seems to be just overriding manually set values as is.

EDIT: When / if you have time to respond, it would be helpful if you could expand to include other radio settings as well, e.g. whether the preferred order would be:

radio.begin();
radio.setPALevel(RF24_PA_MAX);    
radio.setDataRate(RF24_250KBPS); // Doesn't work as is, gets overridden
radio.setAutoAck(1);
radio.setRetries(15, 15); // Also gets overridden in network.begin(), should probably just leave out
network.begin(82, base_node);

or

radio.begin();
network.begin(82, base_node);
radio.setPALevel(RF24_PA_MAX);    
radio.setDataRate(RF24_250KBPS);
radio.setAutoAck(1);
radio.setRetries(15, 15); // Also gets reset in network.begin(), would break anti-collision optimizations
@TMRh20
Copy link
Member

TMRh20 commented Aug 17, 2015

Intuitively it does seem odd to configure core radio settings after configuring the network, however, the network does require specific radio settings to be configured. The only way to set them is at the network layer, so any changes should come after everything has been loaded (.begin()) but before utilization (network.update())

Preferred order is as follows:

radio.begin();
network.begin();
<all custom settings here>

Setting the datarate has been removed in the development branch . Since things have changed so much from the master branch, I am probably just going to replace master with dev soon, and 'archive' the current master instead of trying to bring it up to date.

I think dynamicAck and dynamicPayloads are the main settings the network layer needs, pretty much everything else cna be changed, as long as it matches as required, between radios.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants