 #include <MirfHardwareSpiDriver.h>
 
 struct Message {
-  uint8_t id;
+  byte id;
   //uint8_t destination;
   //uint8_t source;
-  uint8_t data;
-  uint8_t checksum[2];
+  byte data;
+  byte checksum[2];
 };
 
-Message message;
+Message tx_message;
+Message rx_message;
+/* Initialy our recieving status is 0 and finished is false */
+uint8_t rx_stat = 0;
+volatile bool rx_finished = false;
 
 void setup() {
   Serial.begin( 9600 );

  return 0;
}

int sendPacket() {
  /* Timeout for receiving */
  long time = millis();
  
  /* Send the data packet */
  Mirf.send( (byte *) message.id );
  Mirf.send( (byte *) message.data );
  Mirf.send( (byte *) message.checksum[0] );
  Mirf.send( (byte *) message.checksum[1] );
  
  /* While data is still transmitted */
  while ( Mirf.isSending() );
  Serial.println( "Finished sending" );
  delay( 10 );
  
  /* While we are receiving the data packet */
  while ( !Mirf.dataReady() );
  
  Serial.print( "received: " );
  /* Get the byte from the tranceiver */
  Mirf.getData( (byte *) message.data );
  /* TODO: do something useful */
  int i;
  for ( i = 0; i < Mirf.payload; ) {
    Serial.println( (char) message.data );
  }
  
  /* Timeout when data packet was not received within 1 second */
  if ( ( millis() - time ) > 1000 ) {
    Serial.println("Timeout on response from server!");
    return 1;
  }
  
  /* When transmission was successful */
  return 0;
}

void loop() {

    digitalWrite( 9, HIGH );
    Serial.println( "Finished sending!" );
  }
  
  
  /* don't freeze the MCU */
  delay( 100 );
}

