RF24Network network.failures() printing zero

Hello,

I am using the RF24 radio modules and the RF24Network library to communicate between an Arduino uno and a series of Arduino nanos. I was trying to implement the network.failures() function to print out the number of successfully sent payloads but all I get is zero. What am I doing wrong?

Here is the snippet of relevant code from my base module (the uno)

void loop(void) {

  network.update();  // Check the network regularly
  while (network.available()) {  // Is there anything ready for us?
 
    RF24NetworkHeader header;  // If so, grab it and print it out
    payload_t payload;
    network.read(header, &payload, sizeof(payload));
    
    // print the payload for each node
    printPayload(payload);

    uint32_t fails, success;
    network.failures(&fails, &success); // Return the number of failures and successes for all transmitted payloads, routed or sent directly 
    Serial.print(F(", Success="));
    Serial.print(success);
    Serial.print(F(", Failures="));
    Serial.println(fails);
  }
}

this is some of my output

Node ID: 1, Received packet: counter=1664, origin timestamp=3330000, moisture=59.37, Percentage=0.00, Success=0, Failures=0
Node ID: 1, Received packet: counter=1665, origin timestamp=3332000, moisture=59.37, Percentage=0.00, Success=0, Failures=0
Node ID: 1, Received packet: counter=1666, origin timestamp=3334000, moisture=59.36, Percentage=0.00, Success=0, Failures=0
Node ID: 1, Received packet: counter=1667, origin timestamp=3336000, moisture=59.38, Percentage=0.00, Success=0, Failures=0

It doesn't look like that code could produce that output.

I think the function should be used on the sending side,
how could the receiver know of failures?

Ive also tried on the sending side and I get similar output.

heres the code for the sender(the arduino nano)

void loop() {

  uint32_t fails, success;

  network.update();  // Check the network regularly

  unsigned long now = millis();

  // If it's time to send a message, send it!
  if (now - last_sent >= interval) {
    last_sent = now;

    Serial.print(F("Sending... "));
    payload_t payload = { this_node, millis(), packets_sent++, updateMoisture() };  // payload consists of {ID, ms, packets, moisure}
    RF24NetworkHeader header(/*to node*/ other_node);
    bool ok = network.write(header, &payload, sizeof(payload));
    Serial.println(ok ? F("ok.") : F("failed."));

    network.failures(&fails, &success); // Return the number of failures and successes for all transmitted payloads, routed or sent directly 
    Serial.print(F(", Success="));
    Serial.print(success);
    Serial.print(F(", Failures="));
    Serial.println(fails);
  }
}

My bad I cut out the part of the code that formats that output. printPayload is a function that I wrote.

void printPayload(payload_t p) {
  Serial.print(F("Node ID: "));
  Serial.print(p.nodeID, OCT);
  Serial.print(F(", Received packet: counter="));
  Serial.print(p.counter);
  Serial.print(F(", origin timestamp="));
  Serial.print(p.ms);
  Serial.print(F(", moisture="));
  Serial.print(p.moistValue);
  Serial.print(F(", Percentage="));
  Serial.print(calculateMoisturePercentage(p.moistValue));
}

It prints out the contents of the payload that is sent from each nano and is working as expected.

You have enabled the feature via the define mentioned in the documentation?

yes, ive gone into the header file and uncommented #define ENABLE_NETWORK_STATS

Then it should work.

I never used that layer, so I can only guess.

Maybe the mistake is elsewhere then. Thanks for the help!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.