how to disable Ack payloads

Members

Im trying to disable Ack in the program that's a few post below #11. In the snippet of the code below is the line causing me some headaches

void setup() {

  Serial.begin(9600);
  radio.begin();
  radio.enableAckPayload();// .............this is the culprit
  radio.setRetries(10, 8); // delay, count
  tft.reset();
  uint16_t identifier = tft.readID();
  tft.begin(identifier);

When this line is enabled radio.enableAckPayload(); I get to read the data but the radio stop working normally (as in write a command/ send a command to another unit to switch LED's on/off). In the 2nd section of the program attached I want to use the radio to switch LED's on/off.

When I disable the line // radio.enableAckPayload(); I am able to use the radio to switch the LED's on/off.

Thanks for the help in advance

So you are doing something wrong in a program that evolved from some copied stuff?

If you don't want ackpayload, just don't use it, but it in no way hinders any other operation of an NRF24L01+.

Without seeing all of your code (tx and rx) it's a guessing game what you are doing wrong.

Have a look at this Simple nRF24L01+ Tutorial.

...R

the other program used for the on/off:

/*Rx_OnOff_multi
  Rx UNO
  need to add ACK for PIN status
  working corectly 4 Jan 2019
*/
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
//   ....UNO ...........CHECK
#define CE_PIN 6  //confirm pin connections for nrf
#define CSN_PIN 7


int msg[2];
RF24 radio(CE_PIN, CSN_PIN);
const byte slaveAddress[5] = {'R', 'x', 'A', 'A', 'E'};
//const byte slaveAddress[5] = {'R', 'x', 'A', 'A', 'F'};
int LED0 = 2;     // led pin
int LED1 = 3;

void setup(void) {

  Serial.begin(9600);
  radio.begin();
  radio.openReadingPipe(1, slaveAddress);
  radio.startListening();
  pinMode(LED0, OUTPUT);
  pinMode(LED1, OUTPUT);
}

void loop(void) {
  if (radio.available()) {

    radio.read(msg, 1);
    Serial.println(msg[0]);
    if (msg[0] == 01) {
      delay(10); digitalWrite(LED0, HIGH);
    }
    if (msg[0] == 00) {
      delay(10); digitalWrite(LED0, LOW);
    }
    if (msg[0] == 11) {
      delay(10); digitalWrite(LED1, HIGH);
    }
    if (msg[0] == 10) {
      delay(10); digitalWrite(LED1, LOW);
    }
  }

  else {
    Serial.println("No radio available");
  }
}

program for data:

//UNO
// SimpleRxAckPayload- the slave or the receiver
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

#define CE_PIN 6  //confirm pin connections for nrf
#define CSN_PIN 7

const byte thisSlaveAddress[6] = {'R','x','A','A','A'};//unique for each unit A=0 B=1 C=2 D=3 E=4 F=5

RF24 radio(CE_PIN, CSN_PIN);

char dataReceived[32]; // this must match dataToSend in the TX
float ackData[2] = {11.09, -120.00}; // the two values to be sent to the master
bool newData = false;

//==============

void setup() {

    Serial.begin(9600);

    Serial.println("SimpleRxAckPayload Starting");
    radio.begin();
    radio.setDataRate( RF24_250KBPS );
    radio.openReadingPipe(1, thisSlaveAddress);

    radio.enableAckPayload();
    radio.writeAckPayload(1, &ackData, sizeof(ackData)); // pre-load data

    radio.startListening();
}

//==========

void loop() {
    getData();
    showData();
}

//============

void getData() {
    if ( radio.available() ) {
        radio.read( &dataReceived, sizeof(dataReceived) );
        updateReplyData();
        newData = true;
    }
}

//================

void showData() {
    if (newData == true) {
        Serial.print("Data received ");
        Serial.println(dataReceived);
        Serial.print(" ackPayload sent ");
        Serial.print(ackData[0]);
        Serial.print(", ");
        Serial.println(ackData[1]);
        newData = false;
    }
}

//================

void updateReplyData() {
    ackData[0] -= 0.01;
    ackData[1] -= 0.01;
    if (ackData[0] < 11.00) {
        ackData[0] = 11.09;
    }
    if (ackData[1] < -120.09) {
        ackData[1] = -120.00;
    }
    radio.writeAckPayload(1, &ackData, sizeof(ackData)); // load the payload for the next time
}

Whandall: So you are doing something wrong in a program that evolved from some copied stuff?

If you don't want ackpayload, just don't use it, but it in no way hinders any other operation of an NRF24L01+.

Without seeing all of your code (tx and rx) it's a guessing game what you are doing wrong.

Yes it is copied from Robin2's nRF tutorial. I am curious if its possible to change the RF24.h file. Ive noticed that all pipes are either Ack enabled or disabled.

Two unrelated rx sketches don't help.

Robin2:
Have a look at this Simple nRF24L01+ Tutorial.

…R

I am familiar with your work. I have read the swop roles sketch. My question is:

Is it possible to disableAckPayloads and return the radio to its normal function in this particular case? Can it be done by changing the cpp or h files?

Whandall: Two unrelated rx sketches don't help.

ok, my mistake. Maybe I need to explain better. The Due(main brain) use a submenu. When You flick the menu to Data it should read the Ack data that is send from 2 Uno units.

When I flick the menu again I should be able to switch LED's on/off on another 2 Uno units.

1 Main brain + 4 Uno units

Seems confused/confusing.

You can not read ack data without ackpayload, you can not read ack data without sending.

So presenting two receivers one with and one without ack does not help.

Whandall: Seems confused/confusing.

You can not read ack data without ackpayload, you can not read ack data without sending.

So presenting two receivers one with and one without ack does not help.

Yes, I understand that. Hence the question:

Is it possible to disable Ack once its been called?

I just noticed that the main program did not upload :confused:

Due_SubMenu.ino (11.9 KB)

Looks a little painful to switch back and forth. Why not just enable AckPayload for all units and ignore the payload you get from selective RX units in the TX?

gfvalvo: Looks a little painful to switch back and forth. Why not just enable AckPayload for all units and ignore the payload you get from selective RX units in the TX.

Yes, I have tried doing that but the data to be send for the on /off is then send via AckPayloads. This data is not recognized as valid data( to do something/ perform a function).

The unit want to respond with a payload- in this case no payload is needed because its a switch.

What are the stopListening() calls for? You never call startListening().

Why do you want to switch Ack and dynamic payloads?

Sending one byte of a one element int array seems rather convoluted and strange to me.

If you use exactly four clients, the second and all the following packets with the same content will be regarded as duplicate, which is determined by a 2 bit counter, the pipe and the packet crc.

Use a struct for sending packets and include a counter that will guarantee different packet crc on the next polling round.

I think you problem is caused indirectly by the polling loop.

Whandall: What are the stopListening() calls for? You never call startListening().

Why do you want to switch Ack and dynamic payloads?

Sending one byte of a one element int array seems rather convoluted and strange to me.

stopListening is called before write because its recommended in the cpp file. startListening is an auto response and no need to call in this instance. It works just fine - all data is accounted for when in 'data' mode.

fnb111: This data is not recognized as valid data( to do something/ perform a function).

So ignore it.

fnb111: stopListening is called before write because its recommended in the cpp file. startListening is an auto response and no need to call in this instance.

Nope. Bad advice. Where do you get this stuff from?

Whandall: If you use exactly four clients, the second and all the following packetswith the same content will be regarded as duplicate, which is determined by a 2 bit counter, the pipe and the packet crc.

Use a struct for sending packets and include a counter that will guarantee different packet crc on the next polling round.

I think you problem is caused indirectly by the polling loop.

I have done all that. I receive all the packages from both units. The issue is the on/off switch is not working while Ackpayloads are active