 unsigned long g_previous_millis = 0;
 // ledState used to set the LED
 int ledState = LOW;
+// Interrupt type
+int NO_INTERRUPT = 0;
+int DIAG_INTERRUPT = NO_INTERRUPT + 1;
+int DOOR_INTERRUPT = DIAG_INTERRUPT + 1;
+// Interrupt variable (used to know which interrupt was striggered in the loop)
+volatile int g_interrupt_id = NO_INTERRUPT;
+
+// Interrupt called when presing the diag switch
+void diagnoticInterrupt() {
+  g_interrupt_id = DIAG_INTERRUPT;
+}
+
+// Interrupt called when magentic switch change its state
+void doorInterrupt() {
+  g_interrupt_id = DOOR_INTERRUPT;
+}
 
 void setupRFDevice() {
   // Transmitter is connected to Arduino Pin #10

  pinMode(LED_PIN, OUTPUT);
  //digitalWrite(LED_PIN, (digitalRead(MAGNETIC_SWITCH_PIN) == HIGH) ? LOW : HIGH);
  digitalWrite(LED_PIN, LOW);
  /*********************** Interruption initialisation ************************/
  // Allow wake up pin to trigger interrupt on state change.
  attachInterrupt(digitalPinToInterrupt(MAGNETIC_SWITCH_PIN), doorStateChange, CHANGE);
  attachInterrupt(digitalPinToInterrupt(DIAG_SWITCH_PIN), diagnotic, RISING);
}

void loop() {
  // Go to sleep mode
  LowPower.powerDown(SLEEP_PERIOD, ADC_OFF, BOD_OFF);
  Serial.println("loop end");
}

}

// Print a diagnostic report on the serial line and ask for a new device number
void diagnostic() {
  // Entering DIAG mode
  digitalWrite(LED_PIN, HIGH);

  Serial.println("");
  Serial.println("*** DIAG report ***");
  Serial.print("type of device: ");
  Serial.println(DOOR_SENSOR);
  Serial.print("device id: ");
