byte ackCount=0;
uint32_t packetCount = 0;
void loop() {
//process any serial input
if (Serial.available() > 0)
{
char input = Serial.read();
if (input == 'r') //d=dump all register values
radio.readAllRegs();
if (input == 't')
{
byte temperature = radio.readTemperature(-1); // -1 = user cal factor, adjust for correct ambient
byte fTemp = 1.8 * temperature + 32; // 9/5=1.8
Serial.print( "Radio Temp is ");
Serial.print(temperature);
Serial.print("C, ");
Serial.print(fTemp); //converting to F loses some resolution, obvious when C is on edge between 2 values (ie 26C=78F, 27C=80F)
Serial.println('F');
}
}
if (radio.receiveDone())
{
Serial.print("#[");
Serial.print(++packetCount);
Serial.print(']');
Serial.print("[Sender Node ID = ");
int MoteinoID = radio.SENDERID;
//Serial.print(radio.SENDERID, DEC);
Serial.print(MoteinoID);
Serial.print("] ");
for (byte i = 0; i < radio.DATALEN; i++)
Serial.print((char)radio.DATA[i]);
Serial.print(" [RX_RSSI:");Serial.print(radio.RSSI);Serial.print("]");
if (radio.ACKRequested())
{
delay(10);
byte theNodeID = radio.SENDERID;
radio.sendACK();
Serial.print(" - ACK sent.");
Serial.print(" Pinging node ");
Serial.print(theNodeID);
Serial.print(" - ACK...");
delay(10); //need this when sending right after reception .. increased from 3 to 10
if (radio.sendWithRetry(theNodeID, "ACK TEST", 8, 0)) // 0 = only 1 attempt, no retries
Serial.print("ok!");
else Serial.print("nothing");
}
Serial.println();
Blink(LED,3);
}
}