you need to include the ATC code in both ends of the connection, otherwise it will be unsupported in the link. ATC does NOT have to be enabled on any end of the link that is using fixed transmit level.
Which code?
So i can comment out (disable ATC):
#define ENABLE_ATC //comment out this line to disable AUTO TRANSMISSION CONTROL
This means RFM69 is used instead of RFM69_ATC:
#ifdef ENABLE_ATC
RFM69_ATC radio;
#else
RFM69 radio;
#endif
As ChemE pointed out, you need to save the radio.RSSI immediately after return from receiveDone() and before any transmission, including sending an ACK.
In all the examples "radio.sendACK" is at the bottom and there is allot serial.print going on before.
And i don't see something like saving radio.RSSI.
Putting "if radio.ACKRequested" above "if radio.DATALEN" gives "invalid payload".
EditOk i found out the serial output does not need to be inside the "else { theData".
I thought it needs to be there because that is how it is in the examples.
So now it looks like this on the gateway:
void loop() {
if (radio.receiveDone()) {
if (radio.DATALEN != sizeof(Payload)) {
#ifdef DEBUG
Serial.print("Invalid Payload received!");
#endif // END DEBUG
} else {
theData = *(Payload*)radio.DATA; // Assume radio.DATA actually contains our struct and not something else
} // END radio.DATALEN
if (radio.ACKRequested()) { // When a node requests an ACK, respond to the ACK
uint16_t theNodeID = radio.SENDERID;
radio.sendACK();
Serial.println("ACK sent! ");
if (ackCount++%3==0) {
Serial.print("Pinging node ");
Serial.print(theNodeID);
Serial.print(" - ACK...");
delay(3); //need this when sending right after reception .. ?
if (radio.sendWithRetry(theNodeID, "ACK TEST", 8, 0)) { // 0 = only 1 attempt, no retries
Serial.println("ok!");
} else {
Serial.println("nothing");
}
}
} // END radio.ACKRequested
#ifdef DEBUG
Serial.print("Node:");
Serial.print(theData.nodeId);
Serial.print(", Temp:");
Serial.print(theData.temp);
Serial.print(", Vcc:");
Serial.print(theData.vcc);
Serial.print(", TX Level:");
Serial.print(theData.tx);
Serial.print(", RSSI:");
Serial.print(radio.RSSI);
Serial.println();
Serial.print("Gateway TX Level:");
Serial.print(radio._transmitLevel,DEC); // Current transmit level used by this sender
Serial.print(", Gateway RSSI:");
Serial.print(radio.getAckRSSI(),DEC); // This sender's RSSI acked back from the receiving node (Gateway)
Serial.println();
#endif // END DEBUG
} // END radio.receiveDone
} // END loop
And i really don't need a "radio.sendACK" or "radio.receiveDone" on the node?
EditI made a test.
I removed the sleep from the node and did put:
if (radio.receiveDone()) {
if (radio.ACKRequested()) {
radio.sendACK();
Serial.print(" - ACK sent.");
Serial.flush();
}
}
in the main loop.
Then the ping from the gateway works and tx goes down.