 
 	// If a timeout of 0 is used this might try forever, locking up the code.
 	unsigned long before = millis();
-	while (WiFi.status() != WL_CONNECTED) {
+	while (is_connected()) {
 		if (timeout && millis() - before > timeout) {
 			return;
 		}

	if (led_mode == LED_ACTIVITY) {
		is_on = millis() - last_activity < 500;
	} else if (led_mode == LED_CONNECTION) {
		is_on = WiFi.status() == WL_CONNECTED;
	} else if (led_mode == LED_OFF) {
		is_on = false;
	} else if (led_mode == LED_ON) {

	// The chip remembers its last ssid and password, so generally just running the server will make it reachable,
	// even without reconfiguring.
	server.begin();
}

bool is_connected() {
	return WiFi.status() == WL_CONNECTED;
}

void handle_request() {
