Conversation
|
So in reviewing this, additional changes are required to support large payloads. The write() function needed to be modified to take into account the max dynamic payload size set in nrf_to_nrf so it knows when to fragment payloads. Additionally on line 705: we need to check if encryption is enabled to fragment payloads at the proper sizes. This seems to require adding a new variable to RF24, This is still a bit messy, I'm thinking I can clean it up a whole bunch still by defining variables for MAX_FRAME_SIZE and max_frame_payload_size instead of a mess of #defines. |
This comment has been minimized.
This comment has been minimized.
|
Can you simply guard the encryption stuff with |
I tried that here: and get:
I think because RF24 is included by default, the compiler expects it to have the same variables as nrf_to_nrf |
|
I think we'd need to go by the template typename ( #if defined(ARDUINO_ARCH_NRF52) || defined(ARDUINO_ARCH_NRF52840) || defined(ARDUINO_ARCH_NRF52833)
// nrf_to_nrf is defined, now compare template radio type
if (radio_t == nrf_to_nrf) {
// do nRF5x specific stuff
}
#endif |
- Specify nrf_to_nrf or RF24 behavior in the overloaded beginWrite() functions
modify doc comment
|
I'm going to setup a dedicated CI workflow for nrf_to_nrf, so we can try to detect build failures before merging without local having to locally build first. I'll have to build an example from nrf_to_nrf lib... |
|
Memory usage change @ 8d4ecc8
Click for full report table
Click for full report CSV |
|
ok, I tested this on linux and found no disruption: examples work as expected. I added copies of RF24Network examples from nrf2nrf library and used them in CI to test build the lib for adafruit feather nrf52840 (using PlatformIO). I'm not proud of the keeping duplicate examples in this lib and nrf2nrf lib, but it was path of least resistance that allowed using the reusable workflow in nRF24/.github repo. |
|
There's a not insignificant increase in compile size on Arduino Nano, So I'm hoping we can do better with the new specialized functions (maybe mark them as |
|
@TMRh20 I noticed a growing list of stale branches in the nrf2nrf repo (most of which have been merged to main). I would suggest allowing github to auto-delete merged branches and delete the 1 branch that was abandoned for a different approach (which was merged to main). |
|
Hmm, adding |
|
The following code still compiles on an ATtiny 84: Sketch uses 7194 bytes (95%) of program storage space. Maximum is 7552 bytes. #include "RF24.h"
#include "RF24Network.h"
#include "RF24Mesh.h"
/**** Configure the nrf24l01 CE and CS pins ****/
RF24 radio(7, 8);
RF24Network network(radio);
RF24Mesh mesh(radio, network);
/*
* User Configuration: nodeID - A unique identifier for each radio. Allows addressing
* to change dynamically with physical changes to the mesh.
*
* In this example, configuration takes place below, prior to uploading the sketch to the device
* A unique value from 1-255 must be configured for each node.
*/
#define nodeID 1
uint32_t displayTimer = 0;
struct payload_t {
unsigned long ms;
unsigned long counter;
};
void setup() {
mesh.setNodeID(nodeID);
mesh.begin();
}
void loop() {
mesh.update();
// Send to the master node every second
if (millis() - displayTimer >= 1000) {
displayTimer = millis();
// Send an 'M' type message containing the current millis()
if (!mesh.write(&displayTimer, 'M', sizeof(displayTimer))) {
// If a write fails, check connectivity to the mesh network
if (!mesh.checkConnection()) {
//refresh the network address
if (mesh.renewAddress() == MESH_DEFAULT_ADDRESS) {
//If address renewal fails, reconfigure the radio and restart the mesh
//This allows recovery from most if not all radio errors
mesh.begin();
}
}
}
while (network.available()) {
RF24NetworkHeader header;
payload_t payload;
network.read(header, &payload, sizeof(payload));
}
}
} |
|
I just realized this changes the behavior of the For now, users would need to call the standard write I think I'm good with that, since most users probably don't use this function, a comment in the docs is probably good. |
- Need to put the max_frame_size calcs in the final write function, or it will not be set properly if using Multicast or WriteDirect functions
|
Re-thinking it, I'm not good with the previously noted behavior, its like adding a bug for no reason, so I put the max_payload_size calculations in the final |
|
I guess my concerns about compile size are negligible. Especially since I also agree that behavior is important to remain consistent. Further changes to v2 might be complicated to cherry pick into v1 branch. But I think we can still make it work. |
|
Yeah, for the v1 branch I think it will have to be left up to the user to set the correct MAX_FRAME_SIZE in RF24Network.h |
- Add intermediate function write() and change the old write() function to main_write()
|
I ended up re-adding the intermediate function, it seemed a better option than recreating the entire Now the main user What a mess of commits lol. Can you tell I've been feeling under the weather lately? |
|
I just went through a week of the flu myself. Still coughing up phlegm... |
Co-authored-by: Brendan <2bndy5@gmail.com>
|
Ok, we've let it stew a bit here, and I don't see any more changes required. You figure this one is ready to merge? |
* Fix for large payloads with NRF52 * Specify nrf_to_nrf or RF24 behavior in the overloaded write() functions * modify doc comment * add CI for nrf_to_nrf * disambiguate examples in docs - Add intermediate function write() and change the old write() function to main_write() * Make main_write() function inline Co-authored-by: Brendan <2bndy5@gmail.com> * Remove max_frame_size var Per @2bndy5 in #244 * Remove setting max_frame_payload_size in RF24 write function * Missing bracket... --------- Co-authored-by: Brendan <2bndy5@gmail.com>
It seems we missed configuring the
MAX_FRAME_SIZEwith NRF52 devices in V2.0.This fix clears that issue up.