// Demonstrate makePacketPrinter

u8 myBuffer[PACKET_PRINTER_PACKET_BUFFER_SIZE];    // Let's make room for a max-size packet..
u8 * myPacket;                                     // Location of printed packet
u8 myFace;                                         // My virtual face number

void handleD(u8 * packet) {
  logNormal("Got '%#p' from %c\n",packet,FACE_CODE(packetSource(packet)));  // Just log 'd' packets
}
void setup() {
  myPacket = makePacketPrinter(myFace,myBuffer,sizeof(myBuffer),NORTH); // Create the packet printer
  if (myPacket == 0) POISON(0);                    // Really can't happen at this point; die if it does
  Body.reflex('d',handleD);                        // Create our reflex
}
void loop() {
  static u32 loops = 0;
  delay(random(10000));                            // Wait about five seconds.
  facePrintf(myFace,"d%d\n",++loops);              // Make a 'd' packet in myPacket
  Body.trigger(myPacket,packetSource(myPacket));   // React as though it arrived from the north
}
