   }
   return return_value;
 }
-
+

#define APPS_STATE          2

// The number of join retries. Set to -1 if you want to retry indefinatly.
static const int8_t RETRIES = 10;

// Set this to true if you want to override the keys that were set during commissioning at the E&A fair
// or if you did not commission your gadget at the fair.

  //Always start with Unknown mode (8sec)
  current_state = UNKNOWN_MODE;

  set_rgb_led(80,80,0);
  
  //join network
  char appEui[17];
  ttn.getAppEui(appEui, sizeof(appEui));
  
  /*
  * If the appEui is 0's, the device is not commissioned.
  * Then use the keys defined at the top of this sketch.
  * Otherwise join using the keys programmed during commissioning.
  */
  if (OVERRIDE || strcmp(appEui, "0000000000000000") == 0) 
  {
    ttn.join(appEUI, appKey, RETRIES, 1);
  } 
  else 
  {
    ttn.join(RETRIES, 1);
  }
  joined_network = 1;
  set_rgb_led(0,0,0);
  
  //Start LoRa communication
	usbserial.println(F("-- Status"));
