  * return - 0 when transmission successfuly finished
  */
 uint8_t transmitPacket( byte destination, byte command, byte data ) {
-  tx_message[DESTINATION] = destination;
-  tx_message[SOURCE] = role_id;
-  tx_message[COMMAND] = command;
-  tx_message[DATA] = data;
-  //tx_message[CHECKSUM] = destination ^ role_id ^ data;
+  /* Assemble the transmission packet */
+  struct Packet tx_packet;
+  tx_packet.destination = destination;
+  tx_packet.source = role_id;
+  tx_packet.command = command;
+  tx_packet.data = data;
   
   /* First, stop listening so we can talk */
   radio.stopListening();
-  /* send the packet to the chosen destination */
-  bool ok = radio.write( tx_message, radio.getPayloadSize() );
+  /* Send the packet to the chosen destination */
+  bool ok = radio.write( &tx_packet, radio.getPayloadSize() );
   /* Now, resume listening so we catch the next packets. */
   radio.startListening();
   
-  /* When the transmission was successful */
-  if ( ok )
-    debug_printf( "transmit %X ok\n", command );
-  else
-    debug_printf( "failed.\n\r" );
+  /* When the transmission was not successful */
+  if ( !ok ) {
+    debug_printf( "transmit failed.\n\r" );
+    return TRANSMIT_FAILED;
+  }
   
+  debug_printf( "transmit %X ok\n", command );
   return SUCCESS;
 }
 
 void setup() {
   /* Initialize serial connection */
-  Serial.begin( 57600 );
+  Serial.begin( BAUD_RATE );
   /* Direct printf to Arduino serial */
   printf_begin();
 

  /* optionally, increase the delay(1) between retries(2) & # of retries */
  radio.setRetries( 15, 15 );

  // optionally, reduce the payload size.  seems to
  // improve reliability
  radio.setPayloadSize( PAYLOAD );
  radio.setAutoAck( true );
  radio.setDataRate( RF24_2MBPS );


/*
 Copyright (C) 2011 J. Coliz <maniacbug@ymail.com>
 Edit by (C) 2012 S. Kuusik <silver.kuusik@gmail.com>
