 #define RF24_PAYLOAD sizeof(Packet)
 #define RF24_PIPE    0xF0F0F0F000LL | RECEIVER_ID
 
+// -----------------------------------------
 
-// -----------------------------------------
 struct Packet {
     uint8_t command;
     uint8_t id;
     uint8_t state;
 } packet;
+
+RF24 radio(RF24_CE, RF24_CSN);
+
+bool current_state, rx_ack, tx, fail;
+
 // -----------------------------------------
 
 void goToSleep(uint8_t timeout = 0xFF);
 
 // -----------------------------------------
-
-RF24 radio(RF24_CE, RF24_CSN);
-
-bool timeout, rx_ack, tx, fail;
 
 void setup(void) {
   // Serial.begin(9600);

  wdt_disable();
  wdt_reset();
  WDTCSR &= ~_BV(WDIE);
}
    // Read it
    radio.read(&packet, RF24_PAYLOAD);

    // TODO: validate packet
    
    setSolenoidState(true);  goToSleep(WDTO_60MS);
    setSolenoidState(false); goToSleep(WDTO_120MS);

    if (packet.state != current_state) {
      current_state = packet.state;

      setSolenoidState(packet.state);
    }
  }
  
  // It's done. Now, rest.
  radio.powerDown();

  goToSleep(WDTO_8S);
}

// -----------------------------------------

void checkRadio(void) {
  // Disable wdt.
