Capture and print RF22 packet from the air
#include <SPI.h>
#include <RF22.h>
void setup()
{
Serial.begin(9600);
Serial.println("RF22 init failed");
}
void loop()
{
uint8_t buf[RF22_MAX_MESSAGE_LEN];
uint8_t len = sizeof(buf);
if (rf22.
recv(buf, &len))
{
Serial.print("RF22 Message To: 0x");
Serial.print(to, HEX);
Serial.print(" From: 0x");
Serial.print(from, HEX);
Serial.print(" Id: 0x");
Serial.print(id, DEC);
Serial.print(" Flags: 0x");
Serial.println(flags, HEX);
int i, j;
for (i = 0; i < len; i += 16)
{
for (j = 0; j < 16 && i+j < len; j++)
{
if (buf[i+j] < 16)
Serial.print("0");
Serial.print(buf[i+j], HEX);
Serial.print(" ");
}
while (j++ < 16)
Serial.print(" ");
Serial.print(" ");
for (j = 0; j < 16 && i+j < len; j++)
Serial.print(isprint(buf[i+j]) ? buf[i+j] : '.', BYTE);
Serial.println("");
}
Serial.println("");
}
}