From cac2ca9a60719c50d8e31bc30601df5d7a04a60a Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 30 Jun 2025 20:35:54 +0200 Subject: [PATCH] Reimplement WebSerial --- lib/MqttLogger/src/MqttLogger.cpp | 7 +- lib/MqttLogger/src/MqttLogger.h | 3 +- lib/PsychicHttp/src/PsychicRequest.cpp | 1 + platformio.ini | 12 +- resources/how-to-flash.txt | 24 +-- src/Config.h | 2 +- src/WebCfgServer.cpp | 242 ++++++++++++++++++++++++- src/WebCfgServer.h | 4 +- src/WebCfgServerConstants.h | 6 + src/main.cpp | 47 +++-- src/networkDevices/WifiDevice.cpp | 32 +++- 11 files changed, 317 insertions(+), 63 deletions(-) diff --git a/lib/MqttLogger/src/MqttLogger.cpp b/lib/MqttLogger/src/MqttLogger.cpp index 4290c12..32adddd 100644 --- a/lib/MqttLogger/src/MqttLogger.cpp +++ b/lib/MqttLogger/src/MqttLogger.cpp @@ -75,7 +75,7 @@ void MqttLogger::sendBuffer() { bool doSerial = this->mode==MqttLoggerMode::SerialOnly || this->mode==MqttLoggerMode::MqttAndSerial || this->mode==MqttLoggerMode::MqttAndSerialAndWeb || this->mode==MqttLoggerMode::SerialAndWeb; bool doWebSerial = this->mode==MqttLoggerMode::MqttAndSerialAndWeb || this->mode==MqttLoggerMode::SerialAndWeb; - if (this->mode!=MqttLoggerMode::SerialOnly && this->mode!=MqttLoggerMode::SerialAndWeb && this->client != NULL && this->client->connected()) + if (this->mode!=MqttLoggerMode::SerialOnly && this->mode!=MqttLoggerMode::SerialAndWeb && this->client != NULL && this->client->connected()) { this->client->publish(topic, 0, true, this->buffer, this->bufferCnt); } @@ -88,10 +88,9 @@ void MqttLogger::sendBuffer() Serial.write(this->buffer, this->bufferCnt); Serial.println(); } - if (doWebSerial) + if (doWebSerial && websocketHandler != nullptr) { - //WebSerial.write(this->buffer, this->bufferCnt); - //WebSerial.println(); + websocketHandler->sendAll(HTTPD_WS_TYPE_TEXT, this->buffer, this->bufferCnt); } this->bufferCnt=0; } diff --git a/lib/MqttLogger/src/MqttLogger.h b/lib/MqttLogger/src/MqttLogger.h index fceff1c..99bc689 100644 --- a/lib/MqttLogger/src/MqttLogger.h +++ b/lib/MqttLogger/src/MqttLogger.h @@ -12,10 +12,11 @@ #include #include #include -//#include "MycilaWebSerial.h" +#include "PsychicWebSocket.h" #define MQTT_MAX_PACKET_SIZE 1024 +extern PsychicWebSocketHandler* websocketHandler; extern bool coredumpPrinted; enum MqttLoggerMode { diff --git a/lib/PsychicHttp/src/PsychicRequest.cpp b/lib/PsychicHttp/src/PsychicRequest.cpp index f5664e9..ee1639e 100644 --- a/lib/PsychicHttp/src/PsychicRequest.cpp +++ b/lib/PsychicHttp/src/PsychicRequest.cpp @@ -306,6 +306,7 @@ String PsychicRequest::getCookie(const char* key) if (!hasCookie(key, &size)) return cookie; + //Following line is needed until https://github.com/espressif/esp-idf/pull/16202 is merged and available in ESP-IDF 5.5 (beta2/RC/final) size = httpd_req_get_hdr_value_len(this->_req, "Cookie"); // allocate cookie buffer... keep it on the stack diff --git a/platformio.ini b/platformio.ini index 55a49e6..3c96a49 100644 --- a/platformio.ini +++ b/platformio.ini @@ -58,8 +58,12 @@ lib_ignore = SimpleBLE WiFiProv NimBLE-Arduino + AsyncTCP + ESPAsyncWebServer + ESPAsyncTCP ESPAsyncTCP-esphome AsyncTCP_RP2040W + RPAsyncTCP monitor_speed = 115200 monitor_filters = esp32_exception_decoder @@ -148,13 +152,7 @@ board_build.cmake_extra_args = -DNUKI_TARGET_H2=y -DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.release.defaults;sdkconfig.singlecore.defaults;sdkconfig.ramoptimize.defaults" lib_ignore = - BLE - BluetoothSerial - SimpleBLE - WiFiProv - NimBLE-Arduino - ESPAsyncTCP-esphome - AsyncTCP_RP2040W + ${env.lib_ignore} WiFiManager build_flags = ${env.build_flags} diff --git a/resources/how-to-flash.txt b/resources/how-to-flash.txt index 8f601d5..6b2e6aa 100644 --- a/resources/how-to-flash.txt +++ b/resources/how-to-flash.txt @@ -120,50 +120,50 @@ As an alternative to the Download Tools, you can also use the esptool from the E ## ESP32 -esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0xe000 boot_app0.bin 0x1000 nuki_hub_bootloader_esp32.bin 0x10000 nuki_hub_esp32.bin 0x270000 nuki_hub_updater_esp32.bin 0x8000 nuki_hub_partitions_esp32.bin +esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 --before default-reset --after hard-reset write-flash -z --flash-mode dio --flash-freq keep --flash-size detect 0xe000 boot_app0.bin 0x1000 nuki_hub_bootloader_esp32.bin 0x10000 nuki_hub_esp32.bin 0x270000 nuki_hub_updater_esp32.bin 0x8000 nuki_hub_partitions_esp32.bin ## ESP32-NOPSRAM -esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0xe000 boot_app0.bin 0x1000 nuki_hub_bootloader_esp32nopsram.bin 0x10000 nuki_hub_esp32nopsram.bin 0x270000 nuki_hub_updater_esp32nopsram.bin 0x8000 nuki_hub_partitions_esp32nopsram.bin +esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 --before default-reset --after hard-reset write-flash -z --flash-mode dio --flash-freq keep --flash-size detect 0xe000 boot_app0.bin 0x1000 nuki_hub_bootloader_esp32nopsram.bin 0x10000 nuki_hub_esp32nopsram.bin 0x270000 nuki_hub_updater_esp32nopsram.bin 0x8000 nuki_hub_partitions_esp32nopsram.bin ## ESP32-GL-S10 -esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0xe000 boot_app0.bin 0x1000 nuki_hub_bootloader_esp32gls10.bin 0x10000 nuki_hub_esp32gls10.bin 0x270000 nuki_hub_updater_esp32gls10.bin 0x8000 nuki_hub_partitions_esp32gls10.bin +esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 --before default-reset --after hard-reset write-flash -z --flash-mode dio --flash-freq keep --flash-size detect 0xe000 boot_app0.bin 0x1000 nuki_hub_bootloader_esp32gls10.bin 0x10000 nuki_hub_esp32gls10.bin 0x270000 nuki_hub_updater_esp32gls10.bin 0x8000 nuki_hub_partitions_esp32gls10.bin ## ESP32-S3 -esptool.py --chip esp32s3 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0xe000 boot_app0.bin 0x0 nuki_hub_bootloader_esp32s3.bin 0x10000 nuki_hub_esp32s3.bin 0x270000 nuki_hub_updater_esp32s3.bin 0x8000 nuki_hub_partitions_esp32s3.bin +esptool.py --chip esp32s3 --port /dev/ttyUSB0 --baud 921600 --before default-reset --after hard-reset write-flash -z --flash-mode dio --flash-freq keep --flash-size detect 0xe000 boot_app0.bin 0x0 nuki_hub_bootloader_esp32s3.bin 0x10000 nuki_hub_esp32s3.bin 0x270000 nuki_hub_updater_esp32s3.bin 0x8000 nuki_hub_partitions_esp32s3.bin ## ESP32-S3-NOPSRAM -esptool.py --chip esp32s3 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0xe000 boot_app0.bin 0x0 nuki_hub_bootloader_esp32s3nopsram.bin 0x10000 nuki_hub_esp32s3nopsram.bin 0x270000 nuki_hub_updater_esp32s3nopsram.bin 0x8000 nuki_hub_partitions_esp32s3nopsram.bin +esptool.py --chip esp32s3 --port /dev/ttyUSB0 --baud 921600 --before default-reset --after hard-reset write-flash -z --flash-mode dio --flash-freq keep --flash-size detect 0xe000 boot_app0.bin 0x0 nuki_hub_bootloader_esp32s3nopsram.bin 0x10000 nuki_hub_esp32s3nopsram.bin 0x270000 nuki_hub_updater_esp32s3nopsram.bin 0x8000 nuki_hub_partitions_esp32s3nopsram.bin ## ESP32-S3-OCT -esptool.py --chip esp32s3 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0xe000 boot_app0.bin 0x0 nuki_hub_bootloader_esp32s3oct.bin 0x10000 nuki_hub_esp32s3oct.bin 0x270000 nuki_hub_updater_esp32s3oct.bin 0x8000 nuki_hub_partitions_esp32s3oct.bin +esptool.py --chip esp32s3 --port /dev/ttyUSB0 --baud 921600 --before default-reset --after hard-reset write-flash -z --flash-mode dio --flash-freq keep --flash-size detect 0xe000 boot_app0.bin 0x0 nuki_hub_bootloader_esp32s3oct.bin 0x10000 nuki_hub_esp32s3oct.bin 0x270000 nuki_hub_updater_esp32s3oct.bin 0x8000 nuki_hub_partitions_esp32s3oct.bin ## ESP32-C3 -esptool.py --chip esp32c3 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0xe000 boot_app0.bin 0x0 nuki_hub_bootloader_esp32c3.bin 0x10000 nuki_hub_esp32c3.bin 0x270000 nuki_hub_updater_esp32c3.bin 0x8000 nuki_hub_partitions_esp32c3.bin +esptool.py --chip esp32c3 --port /dev/ttyUSB0 --baud 921600 --before default-reset --after hard-reset write-flash -z --flash-mode dio --flash-freq keep --flash-size detect 0xe000 boot_app0.bin 0x0 nuki_hub_bootloader_esp32c3.bin 0x10000 nuki_hub_esp32c3.bin 0x270000 nuki_hub_updater_esp32c3.bin 0x8000 nuki_hub_partitions_esp32c3.bin ## ESP32-C5 -esptool.py --chip esp32c5 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0xe000 boot_app0.bin 0x2000 nuki_hub_bootloader_esp32c5.bin 0x10000 nuki_hub_esp32c5.bin 0x260000 nuki_hub_updater_esp32c5.bin 0x8000 nuki_hub_partitions_esp32c5.bin +esptool.py --chip esp32c5 --port /dev/ttyUSB0 --baud 921600 --before default-reset --after hard-reset write-flash -z --flash-mode dio --flash-freq keep --flash-size detect 0xe000 boot_app0.bin 0x2000 nuki_hub_bootloader_esp32c5.bin 0x10000 nuki_hub_esp32c5.bin 0x260000 nuki_hub_updater_esp32c5.bin 0x8000 nuki_hub_partitions_esp32c5.bin ## ESP32-C6 -esptool.py --chip esp32c6 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0xe000 boot_app0.bin 0x0 nuki_hub_bootloader_esp32c6.bin 0x10000 nuki_hub_esp32c6.bin 0x270000 nuki_hub_updater_esp32c6.bin 0x8000 nuki_hub_partitions_esp32c6.bin +esptool.py --chip esp32c6 --port /dev/ttyUSB0 --baud 921600 --before default-reset --after hard-reset write-flash -z --flash-mode dio --flash-freq keep --flash-size detect 0xe000 boot_app0.bin 0x0 nuki_hub_bootloader_esp32c6.bin 0x10000 nuki_hub_esp32c6.bin 0x270000 nuki_hub_updater_esp32c6.bin 0x8000 nuki_hub_partitions_esp32c6.bin ## ESP32-H2 -esptool.py --chip esp32h2 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0xe000 boot_app0.bin 0x0 nuki_hub_bootloader_esp32h2.bin 0x10000 nuki_hub_esp32h2.bin 0x270000 nuki_hub_updater_esp32h2.bin 0x8000 nuki_hub_partitions_esp32h2.bin +esptool.py --chip esp32h2 --port /dev/ttyUSB0 --baud 921600 --before default-reset --after hard-reset write-flash -z --flash-mode dio --flash-freq keep --flash-size detect 0xe000 boot_app0.bin 0x0 nuki_hub_bootloader_esp32h2.bin 0x10000 nuki_hub_esp32h2.bin 0x270000 nuki_hub_updater_esp32h2.bin 0x8000 nuki_hub_partitions_esp32h2.bin ## ESP32-P4 -esptool.py --chip esp32p4 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0xe000 boot_app0.bin 0x2000 nuki_hub_bootloader_esp32p4.bin 0x10000 nuki_hub_esp32p4.bin 0x270000 nuki_hub_updater_esp32p4.bin 0x8000 nuki_hub_partitions_esp32p4.bin +esptool.py --chip esp32p4 --port /dev/ttyUSB0 --baud 921600 --before default-reset --after hard-reset write-flash -z --flash-mode dio --flash-freq keep --flash-size detect 0xe000 boot_app0.bin 0x2000 nuki_hub_bootloader_esp32p4.bin 0x10000 nuki_hub_esp32p4.bin 0x270000 nuki_hub_updater_esp32p4.bin 0x8000 nuki_hub_partitions_esp32p4.bin ## ESP32-SOLO1 -esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0xe000 boot_app0.bin 0x1000 nuki_hub_bootloader_esp32solo1.bin 0x10000 nuki_hub_esp32solo1.bin 0x270000 nuki_hub_updater_esp32solo1.bin 0x8000 nuki_hub_partitions_esp32solo1.bin +esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 --before default-reset --after hard-reset write-flash -z --flash-mode dio --flash-freq keep --flash-size detect 0xe000 boot_app0.bin 0x1000 nuki_hub_bootloader_esp32solo1.bin 0x10000 nuki_hub_esp32solo1.bin 0x270000 nuki_hub_updater_esp32solo1.bin 0x8000 nuki_hub_partitions_esp32solo1.bin Adjust the serial device and path to the binaries if necessary. \ No newline at end of file diff --git a/src/Config.h b/src/Config.h index f495d0a..d0b4819 100644 --- a/src/Config.h +++ b/src/Config.h @@ -5,7 +5,7 @@ #define NUKI_HUB_VERSION "9.12" #define NUKI_HUB_VERSION_INT (uint32_t)912 #define NUKI_HUB_BUILD "unknownbuildnr" -#define NUKI_HUB_DATE "2025-06-27" +#define NUKI_HUB_DATE "2025-06-30" #define GITHUB_LATEST_RELEASE_URL (char*)"https://github.com/technyon/nuki_hub/releases/latest" #define GITHUB_OTA_MANIFEST_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/manifest.json" diff --git a/src/WebCfgServer.cpp b/src/WebCfgServer.cpp index a76781b..1cd5ddc 100644 --- a/src/WebCfgServer.cpp +++ b/src/WebCfgServer.cpp @@ -28,6 +28,15 @@ extern bool timeSynced; #include #include #include "ArduinoJson.h" +#include + +typedef struct { + int socket; + char *buffer; + size_t len; +} WebsocketMessage; + +QueueHandle_t wsMessages; WebCfgServer::WebCfgServer(NukiWrapper* nuki, NukiOpenerWrapper* nukiOpener, NukiNetwork* network, Gpio* gpio, Preferences* preferences, bool allowRestartToPortal, uint8_t partitionType, PsychicHttpServer* psychicServer, ImportExport* importExport) : _nuki(nuki), @@ -88,6 +97,7 @@ WebCfgServer::WebCfgServer(NukiNetwork* network, Preferences* preferences, bool } _confirmCode = generateConfirmCode(); + #ifndef NUKI_HUB_UPDATER _brokerConfigured = _preferences->getString(preference_mqtt_broker).length() > 0 && _preferences->getInt(preference_mqtt_broker_port) > 0; #endif @@ -422,6 +432,96 @@ void WebCfgServer::initialize() { return sendCss(request, resp); }); + + + if(_preferences->getBool(preference_webserial_enabled, false)) + { + #ifndef NUKI_HUB_UPDATER + if (websocketHandler == nullptr) + { + websocketHandler = new PsychicWebSocketHandler; + } + + _psychicServer->on("/webserial", HTTP_GET, [&](PsychicRequest *request, PsychicResponse* resp) + { + int authReq = doAuthentication(request); + + switch (authReq) + { + case 0: + return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in."); + break; + case 1: + return request->requestAuthentication(DIGEST_AUTH, "Nuki Hub", "You must log in."); + break; + case 2: + resp->setCode(302); + resp->addHeader("Cache-Control", "no-cache"); + return resp->redirect("/get?page=login"); + break; + case 3: + case 5: + case 4: + default: + break; + } + + return sendWebSerial(request, resp); + }); + + //prepare our message queue of 10 messages + wsMessages = xQueueCreate(10, sizeof(WebsocketMessage)); + if (wsMessages == 0) { + Log->printf("Failed to create queue= %p\n", wsMessages); + } + + websocketHandler->onOpen([](PsychicWebSocketClient *client) { + Log->printf("[socket] connection #%u connected from %s\n", client->socket(), client->remoteIP().toString()); + client->sendMessage("NukiHub WebSerial started"); + }); + websocketHandler->onFrame([](PsychicWebSocketRequest *request, httpd_ws_frame *frame) + { + if(strcmp((char *)frame->payload, "ping") == 0) + { + WebsocketMessage wm; + wm.socket = request->client()->socket(); + wm.len = frame->len; + wm.buffer = (char *)malloc(frame->len); + + if (wm.buffer == NULL) + { + Log->printf("Queue message: unable to allocate %d bytes\n", frame->len); + return ESP_FAIL; + } + + memcpy(wm.buffer, "pong", frame->len); + + if (xQueueSend(wsMessages, &wm, 1) != pdTRUE) + { + Log->printf("[socket] queue full #%d\n", wm.socket); + free(wm.buffer); + } + + if (!uxQueueSpacesAvailable(wsMessages)) + { + return request->reply("Queue Full"); + } + } + else + { + Log->printf("[socket] #%d sent: %s\n", request->client()->socket(), (char *)frame->payload); + } + return ESP_OK; + }); + websocketHandler->onClose([](PsychicWebSocketClient *client) { + Log->printf("[socket] connection #%u closed from %s\n", client->socket(), client->remoteIP().toString()); + }); + + _psychicServer->on("/ws", websocketHandler); + #endif + + } + _psychicServer->on("/favicon.ico", HTTP_GET, [&](PsychicRequest *request, PsychicResponse* resp) { return sendFavicon(request, resp); @@ -430,6 +530,110 @@ void WebCfgServer::initialize() if(_network->isApOpen()) { #ifndef CONFIG_IDF_TARGET_ESP32H2 + _psychicServer->on("/get", HTTP_GET, [&](PsychicRequest *request, PsychicResponse* resp) + { + String value = ""; + if(request->hasParam("page")) + { + const PsychicWebParameter* p = request->getParam("page"); + if(p->value() != "") + { + value = p->value(); + } + } + if (value != "login") + { + int authReq = doAuthentication(request); + + switch (authReq) + { + case 0: + return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in."); + break; + case 1: + return request->requestAuthentication(DIGEST_AUTH, "Nuki Hub", "You must log in."); + break; + case 2: + resp->setCode(302); + resp->addHeader("Cache-Control", "no-cache"); + return resp->redirect("/get?page=login"); + break; + case 4: + default: + break; + } + } + if (value == "login") + { + return buildLoginHtml(request, resp); + } + else + { + Log->println("Page not found, loading index"); + resp->setCode(302); + resp->addHeader("Cache-Control", "no-cache"); + return resp->redirect("/"); + } + }); + + _psychicServer->on("/post", HTTP_POST, [&](PsychicRequest *request, PsychicResponse* resp) + { + String value = ""; + if(request->hasParam("page")) + { + const PsychicWebParameter* p = request->getParam("page"); + if(p->value() != "") + { + value = p->value(); + } + } + + if(value != "login") + { + int authReq = doAuthentication(request); + + switch (authReq) + { + case 0: + return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in."); + break; + case 1: + return request->requestAuthentication(DIGEST_AUTH, "Nuki Hub", "You must log in."); + break; + case 2: + resp->setCode(302); + resp->addHeader("Cache-Control", "no-cache"); + return resp->redirect("/get?page=login"); + break; + break; + case 4: + default: + break; + } + } + + if (value == "login") + { + bool loggedIn = processLogin(request, resp); + if (loggedIn) + { + resp->setCode(302); + resp->addHeader("Cache-Control", "no-cache"); + return resp->redirect("/"); + } + else + { + resp->setCode(302); + resp->addHeader("Cache-Control", "no-cache"); + return resp->redirect("/get?page=login"); + } + } + else + { + return buildWifiConnectHtml(request, resp); + } + }); + _psychicServer->on("/ssidlist", HTTP_GET, [&](PsychicRequest *request, PsychicResponse* resp) { return buildSSIDListHtml(request, resp); @@ -2440,6 +2644,34 @@ bool WebCfgServer::processTOTP(PsychicRequest *request, PsychicResponse* resp) } #ifndef NUKI_HUB_UPDATER +esp_err_t WebCfgServer::sendWebSerial(PsychicRequest* request, PsychicResponse* resp) +{ + // escaped by https://www.cescaper.com/ + resp->addHeader("Cache-Control", "public, max-age=3600"); + resp->setCode(200); + resp->setContentType("text/html"); + resp->setContent((const uint8_t *)WEBSERIAL_HTML, sizeof(WEBSERIAL_HTML)); + return resp->send(); +} + +void WebCfgServer::updateWebSerial() +{ + if (websocketHandler != nullptr) { + WebsocketMessage message; + while (xQueueReceive(wsMessages, &message, 0) == pdTRUE) + { + PsychicWebSocketClient *client = websocketHandler->getClient(message.socket); + if (client == NULL) { + Log->printf("[socket] client #%d bad, bailing\n", message.socket); + return; + } + + client->sendMessage(HTTPD_WS_TYPE_TEXT, message.buffer, message.len); + free(message.buffer); + } + } +} + esp_err_t WebCfgServer::sendSettings(PsychicRequest *request, PsychicResponse* resp, bool adminKey) { JsonDocument json; @@ -4873,10 +5105,6 @@ esp_err_t WebCfgServer::buildHtml(PsychicRequest *request, PsychicResponse* resp { response.print("
RESTART SERVICES REQUIRED TO APPLY SOME SETTINGS
"); } - if(_preferences->getBool(preference_webserial_enabled, false)) - { - response.print("
WEBSERIAL IS ENABLED, ONLY ENABLE WHEN DEBUGGING AND DISABLE ASAP
"); - } #ifdef DEBUG_NUKIHUB response.print("
RUNNING DEBUG BUILD, SWITCH TO RELEASE BUILD ASAP
"); #endif @@ -4949,7 +5177,7 @@ esp_err_t WebCfgServer::buildHtml(PsychicRequest *request, PsychicResponse* resp } if(_preferences->getBool(preference_webserial_enabled, false)) { - buildNavigationMenuEntry(&response, "Open Webserial", "/get?page=webserial"); + buildNavigationMenuEntry(&response, "Open Webserial", "/webserial"); } #ifndef CONFIG_IDF_TARGET_ESP32H2 if(_allowRestartToPortal) @@ -5387,7 +5615,7 @@ esp_err_t WebCfgServer::buildHttpSSLConfigHtml(PsychicRequest *request, PsychicR found = true; } } - + if (!found) { printTextarea(&response, "HTTPKEY", "HTTP SSL Key (*, optional)", "", 2200, true, true); @@ -5420,7 +5648,7 @@ esp_err_t WebCfgServer::buildAdvancedConfigHtml(PsychicRequest *request, Psychic response.print(_preferences->getBool(preference_enable_bootloop_reset, false) ? "Enabled" : "Disabled"); response.print(""); printCheckBox(&response, "DISNTWNOCON", "Disable Network if not connected within 60s", _preferences->getBool(preference_disable_network_not_connected, false), ""); - //printCheckBox(&response, "WEBLOG", "Enable WebSerial logging", _preferences->getBool(preference_webserial_enabled), ""); + printCheckBox(&response, "WEBLOG", "Enable WebSerial logging", _preferences->getBool(preference_webserial_enabled), ""); printCheckBox(&response, "BTLPRST", "Enable Bootloop prevention (Try to reset these settings to default on bootloop)", true, ""); printInputField(&response, "BUFFSIZE", "Char buffer size (min 4096, max 65536)", _preferences->getInt(preference_buffer_size, CHAR_BUFFER_SIZE), 6, ""); response.print("Advised minimum char buffer size based on current settings"); diff --git a/src/WebCfgServer.h b/src/WebCfgServer.h index 47fb40f..08b724e 100644 --- a/src/WebCfgServer.h +++ b/src/WebCfgServer.h @@ -44,6 +44,7 @@ class WebCfgServer public: #ifndef NUKI_HUB_UPDATER WebCfgServer(NukiWrapper* nuki, NukiOpenerWrapper* nukiOpener, NukiNetwork* network, Gpio* gpio, Preferences* preferences, bool allowRestartToPortal, uint8_t partitionType, PsychicHttpServer* psychicServer, ImportExport* importExport); + void updateWebSerial(); #else WebCfgServer(NukiNetwork* network, Preferences* preferences, bool allowRestartToPortal, uint8_t partitionType, PsychicHttpServer* psychicServer, ImportExport* importExport); #endif @@ -127,6 +128,7 @@ private: esp_err_t buildConfirmHtml(PsychicRequest *request, PsychicResponse* resp, const String &message, uint32_t redirectDelay = 5, bool redirect = false, String redirectTo = "/"); esp_err_t buildOtaHtml(PsychicRequest *request, PsychicResponse* resp, bool debug = false); esp_err_t sendCss(PsychicRequest *request, PsychicResponse* resp); + esp_err_t sendWebSerial(PsychicRequest *request, PsychicResponse* resp); esp_err_t sendFavicon(PsychicRequest *request, PsychicResponse* resp); void createSsidList(); void buildHtmlHeader(PsychicStreamResponse *response, String additionalHeader = ""); @@ -145,7 +147,7 @@ private: NukiNetwork* _network = nullptr; Preferences* _preferences = nullptr; ImportExport* _importExport; - + char _credUser[31] = {0}; char _credPassword[31] = {0}; bool _allowRestartToPortal = false; diff --git a/src/WebCfgServerConstants.h b/src/WebCfgServerConstants.h index 96f5389..bc6410b 100644 --- a/src/WebCfgServerConstants.h +++ b/src/WebCfgServerConstants.h @@ -60,3 +60,9 @@ const uint8_t favicon_32x32[] = { 0xed, 0x06, 0xb0, 0xce, 0xb5, 0xc4, 0xb4, 0x59, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82 }; + +#ifndef NUKI_HUB_UPDATER +const uint8_t WEBSERIAL_HTML[] = { +0x3c, 0x21, 0x64, 0x6f, 0x63, 0x74, 0x79, 0x70, 0x65, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0x3c, 0x6d, 0x65, 0x74, 0x61, 0x20, 0x63, 0x68, 0x61, 0x72, 0x73, 0x65, 0x74, 0x3d, 0x75, 0x74, 0x66, 0x2d, 0x38, 0x3e, 0x3c, 0x6d, 0x65, 0x74, 0x61, 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x3d, 0x22, 0x49, 0x45, 0x3d, 0x65, 0x64, 0x67, 0x65, 0x22, 0x68, 0x74, 0x74, 0x70, 0x2d, 0x65, 0x71, 0x75, 0x69, 0x76, 0x3d, 0x58, 0x2d, 0x55, 0x41, 0x2d, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x74, 0x69, 0x62, 0x6c, 0x65, 0x3e, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x57, 0x65, 0x62, 0x20, 0x43, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x65, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x3c, 0x6d, 0x65, 0x74, 0x61, 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x3d, 0x22, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x2d, 0x77, 0x69, 0x64, 0x74, 0x68, 0x2c, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x2d, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x3d, 0x31, 0x22, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x76, 0x69, 0x65, 0x77, 0x70, 0x6f, 0x72, 0x74, 0x3e, 0x3c, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x3e, 0x64, 0x69, 0x76, 0x7b, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x3a, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x7d, 0x61, 0x7b, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x3a, 0x2e, 0x34, 0x72, 0x65, 0x6d, 0x3b, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x64, 0x65, 0x63, 0x6f, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x6e, 0x6f, 0x6e, 0x65, 0x7d, 0x2a, 0x2c, 0x3a, 0x3a, 0x61, 0x66, 0x74, 0x65, 0x72, 0x2c, 0x3a, 0x3a, 0x62, 0x65, 0x66, 0x6f, 0x72, 0x65, 0x7b, 0x2d, 0x77, 0x65, 0x62, 0x6b, 0x69, 0x74, 0x2d, 0x62, 0x6f, 0x78, 0x2d, 0x73, 0x69, 0x7a, 0x69, 0x6e, 0x67, 0x3a, 0x69, 0x6e, 0x68, 0x65, 0x72, 0x69, 0x74, 0x3b, 0x62, 0x6f, 0x78, 0x2d, 0x73, 0x69, 0x7a, 0x69, 0x6e, 0x67, 0x3a, 0x69, 0x6e, 0x68, 0x65, 0x72, 0x69, 0x74, 0x7d, 0x70, 0x7b, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x3a, 0x30, 0x20, 0x30, 0x20, 0x31, 0x72, 0x65, 0x6d, 0x7d, 0x62, 0x6f, 0x64, 0x79, 0x7b, 0x6f, 0x76, 0x65, 0x72, 0x73, 0x63, 0x72, 0x6f, 0x6c, 0x6c, 0x2d, 0x62, 0x65, 0x68, 0x61, 0x76, 0x69, 0x6f, 0x72, 0x3a, 0x6e, 0x6f, 0x6e, 0x65, 0x3b, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x3a, 0x31, 0x30, 0x30, 0x25, 0x3b, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3a, 0x31, 0x30, 0x30, 0x25, 0x3b, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x3a, 0x30, 0x3b, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x30, 0x3b, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x3a, 0x2d, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2d, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2c, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2d, 0x75, 0x69, 0x2c, 0x42, 0x6c, 0x69, 0x6e, 0x6b, 0x4d, 0x61, 0x63, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x46, 0x6f, 0x6e, 0x74, 0x2c, 0x22, 0x53, 0x65, 0x67, 0x6f, 0x65, 0x20, 0x55, 0x49, 0x22, 0x2c, 0x52, 0x6f, 0x62, 0x6f, 0x74, 0x6f, 0x2c, 0x22, 0x48, 0x65, 0x6c, 0x76, 0x65, 0x74, 0x69, 0x63, 0x61, 0x20, 0x4e, 0x65, 0x75, 0x65, 0x22, 0x2c, 0x73, 0x61, 0x6e, 0x73, 0x2d, 0x73, 0x65, 0x72, 0x69, 0x66, 0x7d, 0x2e, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x7b, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x7d, 0x2e, 0x67, 0x72, 0x61, 0x79, 0x7b, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x23, 0x36, 0x36, 0x37, 0x31, 0x38, 0x39, 0x7d, 0x2e, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x7b, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x3a, 0x64, 0x72, 0x6f, 0x70, 0x2d, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x28, 0x30, 0x20, 0x34, 0x70, 0x78, 0x20, 0x33, 0x70, 0x78, 0x20, 0x72, 0x67, 0x62, 0x28, 0x30, 0x20, 0x30, 0x20, 0x30, 0x20, 0x2f, 0x20, 0x2e, 0x30, 0x37, 0x29, 0x29, 0x20, 0x64, 0x72, 0x6f, 0x70, 0x2d, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x28, 0x30, 0x20, 0x32, 0x70, 0x78, 0x20, 0x32, 0x70, 0x78, 0x20, 0x72, 0x67, 0x62, 0x28, 0x30, 0x20, 0x30, 0x20, 0x30, 0x20, 0x2f, 0x20, 0x2e, 0x30, 0x36, 0x29, 0x29, 0x7d, 0x2e, 0x77, 0x2d, 0x66, 0x75, 0x6c, 0x6c, 0x7b, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3a, 0x31, 0x30, 0x30, 0x25, 0x7d, 0x2e, 0x67, 0x72, 0x69, 0x64, 0x7b, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x3a, 0x67, 0x72, 0x69, 0x64, 0x7d, 0x2e, 0x67, 0x61, 0x70, 0x2d, 0x32, 0x7b, 0x67, 0x61, 0x70, 0x3a, 0x2e, 0x35, 0x72, 0x65, 0x6d, 0x7d, 0x2e, 0x66, 0x6c, 0x65, 0x78, 0x7b, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x3a, 0x66, 0x6c, 0x65, 0x78, 0x7d, 0x2e, 0x67, 0x72, 0x6f, 0x77, 0x7b, 0x66, 0x6c, 0x65, 0x78, 0x2d, 0x67, 0x72, 0x6f, 0x77, 0x3a, 0x31, 0x7d, 0x2e, 0x6a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x79, 0x2d, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x2d, 0x65, 0x6e, 0x64, 0x7b, 0x6a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x79, 0x2d, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x3a, 0x65, 0x6e, 0x64, 0x7d, 0x2e, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x65, 0x64, 0x7b, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x2d, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x3a, 0x2e, 0x35, 0x72, 0x65, 0x6d, 0x7d, 0x2e, 0x73, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x7b, 0x62, 0x6f, 0x78, 0x2d, 0x73, 0x69, 0x7a, 0x69, 0x6e, 0x67, 0x3a, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x2d, 0x62, 0x6f, 0x78, 0x3b, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x2d, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x23, 0x66, 0x38, 0x66, 0x39, 0x66, 0x61, 0x7d, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x7b, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x3a, 0x66, 0x6c, 0x65, 0x78, 0x3b, 0x66, 0x6c, 0x65, 0x78, 0x2d, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x3b, 0x6a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x79, 0x2d, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x3a, 0x66, 0x6c, 0x65, 0x78, 0x2d, 0x73, 0x74, 0x61, 0x72, 0x74, 0x3b, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x2d, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x3a, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3b, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x3a, 0x31, 0x30, 0x30, 0x64, 0x76, 0x68, 0x7d, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x20, 0x2e, 0x70, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x7b, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x76, 0x65, 0x3b, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x3a, 0x23, 0x66, 0x66, 0x66, 0x3b, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x2d, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x3a, 0x73, 0x6f, 0x6c, 0x69, 0x64, 0x3b, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x2d, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3a, 0x2e, 0x35, 0x72, 0x65, 0x6d, 0x3b, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x2d, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x3a, 0x31, 0x72, 0x65, 0x6d, 0x3b, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x2d, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x23, 0x66, 0x66, 0x66, 0x3b, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3a, 0x63, 0x61, 0x6c, 0x63, 0x28, 0x31, 0x30, 0x30, 0x25, 0x20, 0x2d, 0x20, 0x31, 0x72, 0x65, 0x6d, 0x29, 0x3b, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x6d, 0x65, 0x64, 0x69, 0x75, 0x6d, 0x3b, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x2d, 0x74, 0x6f, 0x70, 0x3a, 0x32, 0x2e, 0x35, 0x72, 0x65, 0x6d, 0x7d, 0x2e, 0x70, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x20, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x7b, 0x63, 0x75, 0x72, 0x73, 0x6f, 0x72, 0x3a, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x3b, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x38, 0x70, 0x78, 0x20, 0x31, 0x30, 0x70, 0x78, 0x20, 0x38, 0x70, 0x78, 0x3b, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x6d, 0x65, 0x64, 0x69, 0x75, 0x6d, 0x3b, 0x6f, 0x75, 0x74, 0x6c, 0x69, 0x6e, 0x65, 0x2d, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x3a, 0x6e, 0x6f, 0x6e, 0x65, 0x3b, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x3a, 0x30, 0x3b, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x23, 0x66, 0x66, 0x66, 0x3b, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x2d, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x23, 0x30, 0x30, 0x36, 0x37, 0x66, 0x34, 0x7d, 0x2e, 0x70, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x20, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x3a, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x7b, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x2d, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x23, 0x35, 0x61, 0x36, 0x31, 0x36, 0x39, 0x7d, 0x2e, 0x70, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x20, 0x23, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x7b, 0x6d, 0x69, 0x6e, 0x2d, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x3a, 0x33, 0x2e, 0x32, 0x35, 0x72, 0x65, 0x6d, 0x3b, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x2e, 0x35, 0x72, 0x65, 0x6d, 0x3b, 0x72, 0x65, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x76, 0x65, 0x72, 0x74, 0x69, 0x63, 0x61, 0x6c, 0x3b, 0x6f, 0x76, 0x65, 0x72, 0x73, 0x63, 0x72, 0x6f, 0x6c, 0x6c, 0x2d, 0x62, 0x65, 0x68, 0x61, 0x76, 0x69, 0x6f, 0x72, 0x3a, 0x6e, 0x6f, 0x6e, 0x65, 0x7d, 0x23, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2d, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x7b, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x61, 0x62, 0x73, 0x6f, 0x6c, 0x75, 0x74, 0x65, 0x3b, 0x74, 0x6f, 0x70, 0x3a, 0x2e, 0x35, 0x72, 0x65, 0x6d, 0x3b, 0x72, 0x69, 0x67, 0x68, 0x74, 0x3a, 0x2e, 0x35, 0x72, 0x65, 0x6d, 0x7d, 0x23, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2d, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x20, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x7b, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x2d, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x23, 0x35, 0x61, 0x36, 0x31, 0x36, 0x39, 0x7d, 0x2e, 0x61, 0x6c, 0x65, 0x72, 0x74, 0x20, 0x73, 0x70, 0x61, 0x6e, 0x7b, 0x75, 0x73, 0x65, 0x72, 0x2d, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x3a, 0x6e, 0x6f, 0x6e, 0x65, 0x3b, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x3a, 0x23, 0x66, 0x66, 0x65, 0x31, 0x34, 0x64, 0x3b, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x32, 0x70, 0x78, 0x20, 0x31, 0x30, 0x70, 0x78, 0x3b, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x3a, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x3b, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x23, 0x30, 0x30, 0x30, 0x7d, 0x2e, 0x66, 0x6f, 0x6f, 0x74, 0x65, 0x72, 0x7b, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x31, 0x72, 0x65, 0x6d, 0x20, 0x2e, 0x35, 0x72, 0x65, 0x6d, 0x3b, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x2d, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x23, 0x66, 0x66, 0x66, 0x7d, 0x2e, 0x63, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68, 0x74, 0x7b, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x2d, 0x62, 0x6f, 0x74, 0x74, 0x6f, 0x6d, 0x3a, 0x31, 0x72, 0x65, 0x6d, 0x7d, 0x2e, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x2d, 0x6c, 0x65, 0x66, 0x74, 0x7b, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x3a, 0x6c, 0x65, 0x66, 0x74, 0x7d, 0x2e, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x2d, 0x72, 0x69, 0x67, 0x68, 0x74, 0x7b, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x3a, 0x72, 0x69, 0x67, 0x68, 0x74, 0x7d, 0x3c, 0x2f, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x3e, 0x3c, 0x64, 0x69, 0x76, 0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d, 0x61, 0x69, 0x6e, 0x20, 0x73, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x22, 0x3e, 0x3c, 0x68, 0x31, 0x20, 0x69, 0x64, 0x3d, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x20, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x3d, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x3a, 0x6e, 0x6f, 0x6e, 0x65, 0x3e, 0x57, 0x65, 0x62, 0x20, 0x43, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x65, 0x3c, 0x2f, 0x68, 0x31, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x2f, 0x20, 0x3e, 0x3c, 0x69, 0x6d, 0x67, 0x20, 0x69, 0x64, 0x3d, 0x6c, 0x6f, 0x67, 0x6f, 0x20, 0x6f, 0x6e, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x3d, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4c, 0x6f, 0x67, 0x6f, 0x28, 0x29, 0x20, 0x73, 0x72, 0x63, 0x3d, 0x2f, 0x6c, 0x6f, 0x67, 0x6f, 0x3e, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x64, 0x69, 0x76, 0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x20, 0x67, 0x72, 0x69, 0x64, 0x20, 0x67, 0x61, 0x70, 0x2d, 0x32, 0x20, 0x70, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x22, 0x3e, 0x3c, 0x64, 0x69, 0x76, 0x20, 0x69, 0x64, 0x3d, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2d, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x3e, 0x3c, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x65, 0x64, 0x20, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x22, 0x6f, 0x6e, 0x63, 0x6c, 0x69, 0x63, 0x6b, 0x3d, 0x74, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x6c, 0x43, 0x6c, 0x65, 0x61, 0x6e, 0x28, 0x29, 0x3e, 0x3c, 0x73, 0x76, 0x67, 0x20, 0x61, 0x72, 0x69, 0x61, 0x2d, 0x68, 0x69, 0x64, 0x64, 0x65, 0x6e, 0x3d, 0x74, 0x72, 0x75, 0x65, 0x20, 0x64, 0x61, 0x74, 0x61, 0x2d, 0x69, 0x63, 0x6f, 0x6e, 0x3d, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x20, 0x66, 0x69, 0x6c, 0x6c, 0x3d, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x66, 0x6f, 0x63, 0x75, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x3d, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x20, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x3d, 0x31, 0x65, 0x6d, 0x20, 0x76, 0x69, 0x65, 0x77, 0x42, 0x6f, 0x78, 0x3d, 0x22, 0x36, 0x34, 0x20, 0x36, 0x34, 0x20, 0x38, 0x39, 0x36, 0x20, 0x38, 0x39, 0x36, 0x22, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x31, 0x65, 0x6d, 0x3e, 0x3c, 0x70, 0x61, 0x74, 0x68, 0x20, 0x64, 0x3d, 0x22, 0x4d, 0x38, 0x36, 0x34, 0x20, 0x32, 0x35, 0x36, 0x48, 0x37, 0x33, 0x36, 0x76, 0x2d, 0x38, 0x30, 0x63, 0x30, 0x2d, 0x33, 0x35, 0x2e, 0x33, 0x2d, 0x32, 0x38, 0x2e, 0x37, 0x2d, 0x36, 0x34, 0x2d, 0x36, 0x34, 0x2d, 0x36, 0x34, 0x48, 0x33, 0x35, 0x32, 0x63, 0x2d, 0x33, 0x35, 0x2e, 0x33, 0x20, 0x30, 0x2d, 0x36, 0x34, 0x20, 0x32, 0x38, 0x2e, 0x37, 0x2d, 0x36, 0x34, 0x20, 0x36, 0x34, 0x76, 0x38, 0x30, 0x48, 0x31, 0x36, 0x30, 0x63, 0x2d, 0x31, 0x37, 0x2e, 0x37, 0x20, 0x30, 0x2d, 0x33, 0x32, 0x20, 0x31, 0x34, 0x2e, 0x33, 0x2d, 0x33, 0x32, 0x20, 0x33, 0x32, 0x76, 0x33, 0x32, 0x63, 0x30, 0x20, 0x34, 0x2e, 0x34, 0x20, 0x33, 0x2e, 0x36, 0x20, 0x38, 0x20, 0x38, 0x20, 0x38, 0x68, 0x36, 0x30, 0x2e, 0x34, 0x6c, 0x32, 0x34, 0x2e, 0x37, 0x20, 0x35, 0x32, 0x33, 0x63, 0x31, 0x2e, 0x36, 0x20, 0x33, 0x34, 0x2e, 0x31, 0x20, 0x32, 0x39, 0x2e, 0x38, 0x20, 0x36, 0x31, 0x20, 0x36, 0x33, 0x2e, 0x39, 0x20, 0x36, 0x31, 0x68, 0x34, 0x35, 0x34, 0x63, 0x33, 0x34, 0x2e, 0x32, 0x20, 0x30, 0x20, 0x36, 0x32, 0x2e, 0x33, 0x2d, 0x32, 0x36, 0x2e, 0x38, 0x20, 0x36, 0x33, 0x2e, 0x39, 0x2d, 0x36, 0x31, 0x6c, 0x32, 0x34, 0x2e, 0x37, 0x2d, 0x35, 0x32, 0x33, 0x48, 0x38, 0x38, 0x38, 0x63, 0x34, 0x2e, 0x34, 0x20, 0x30, 0x20, 0x38, 0x2d, 0x33, 0x2e, 0x36, 0x20, 0x38, 0x2d, 0x38, 0x76, 0x2d, 0x33, 0x32, 0x63, 0x30, 0x2d, 0x31, 0x37, 0x2e, 0x37, 0x2d, 0x31, 0x34, 0x2e, 0x33, 0x2d, 0x33, 0x32, 0x2d, 0x33, 0x32, 0x2d, 0x33, 0x32, 0x7a, 0x6d, 0x2d, 0x32, 0x30, 0x30, 0x20, 0x30, 0x48, 0x33, 0x36, 0x30, 0x76, 0x2d, 0x37, 0x32, 0x68, 0x33, 0x30, 0x34, 0x76, 0x37, 0x32, 0x7a, 0x22, 0x3e, 0x3c, 0x2f, 0x70, 0x61, 0x74, 0x68, 0x3e, 0x3c, 0x2f, 0x73, 0x76, 0x67, 0x3e, 0x3c, 0x2f, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x3e, 0x20, 0x3c, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x65, 0x64, 0x20, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x22, 0x6f, 0x6e, 0x63, 0x6c, 0x69, 0x63, 0x6b, 0x3d, 0x22, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x6c, 0x6f, 0x77, 0x4c, 0x6f, 0x63, 0x6b, 0x3d, 0x21, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x6c, 0x6f, 0x77, 0x4c, 0x6f, 0x63, 0x6b, 0x22, 0x3e, 0x3c, 0x73, 0x76, 0x67, 0x20, 0x61, 0x72, 0x69, 0x61, 0x2d, 0x68, 0x69, 0x64, 0x64, 0x65, 0x6e, 0x3d, 0x74, 0x72, 0x75, 0x65, 0x20, 0x64, 0x61, 0x74, 0x61, 0x2d, 0x69, 0x63, 0x6f, 0x6e, 0x3d, 0x6c, 0x6f, 0x63, 0x6b, 0x20, 0x66, 0x69, 0x6c, 0x6c, 0x3d, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x66, 0x6f, 0x63, 0x75, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x3d, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x20, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x3d, 0x31, 0x65, 0x6d, 0x20, 0x76, 0x69, 0x65, 0x77, 0x42, 0x6f, 0x78, 0x3d, 0x22, 0x36, 0x34, 0x20, 0x36, 0x34, 0x20, 0x38, 0x39, 0x36, 0x20, 0x38, 0x39, 0x36, 0x22, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x31, 0x65, 0x6d, 0x3e, 0x3c, 0x70, 0x61, 0x74, 0x68, 0x20, 0x64, 0x3d, 0x22, 0x4d, 0x38, 0x33, 0x32, 0x20, 0x34, 0x36, 0x34, 0x68, 0x2d, 0x36, 0x38, 0x56, 0x32, 0x34, 0x30, 0x63, 0x30, 0x2d, 0x37, 0x30, 0x2e, 0x37, 0x2d, 0x35, 0x37, 0x2e, 0x33, 0x2d, 0x31, 0x32, 0x38, 0x2d, 0x31, 0x32, 0x38, 0x2d, 0x31, 0x32, 0x38, 0x48, 0x33, 0x38, 0x38, 0x63, 0x2d, 0x37, 0x30, 0x2e, 0x37, 0x20, 0x30, 0x2d, 0x31, 0x32, 0x38, 0x20, 0x35, 0x37, 0x2e, 0x33, 0x2d, 0x31, 0x32, 0x38, 0x20, 0x31, 0x32, 0x38, 0x76, 0x32, 0x32, 0x34, 0x68, 0x2d, 0x36, 0x38, 0x63, 0x2d, 0x31, 0x37, 0x2e, 0x37, 0x20, 0x30, 0x2d, 0x33, 0x32, 0x20, 0x31, 0x34, 0x2e, 0x33, 0x2d, 0x33, 0x32, 0x20, 0x33, 0x32, 0x76, 0x33, 0x38, 0x34, 0x63, 0x30, 0x20, 0x31, 0x37, 0x2e, 0x37, 0x20, 0x31, 0x34, 0x2e, 0x33, 0x20, 0x33, 0x32, 0x20, 0x33, 0x32, 0x20, 0x33, 0x32, 0x68, 0x36, 0x34, 0x30, 0x63, 0x31, 0x37, 0x2e, 0x37, 0x20, 0x30, 0x20, 0x33, 0x32, 0x2d, 0x31, 0x34, 0x2e, 0x33, 0x20, 0x33, 0x32, 0x2d, 0x33, 0x32, 0x56, 0x34, 0x39, 0x36, 0x63, 0x30, 0x2d, 0x31, 0x37, 0x2e, 0x37, 0x2d, 0x31, 0x34, 0x2e, 0x33, 0x2d, 0x33, 0x32, 0x2d, 0x33, 0x32, 0x2d, 0x33, 0x32, 0x7a, 0x4d, 0x33, 0x33, 0x32, 0x20, 0x32, 0x34, 0x30, 0x63, 0x30, 0x2d, 0x33, 0x30, 0x2e, 0x39, 0x20, 0x32, 0x35, 0x2e, 0x31, 0x2d, 0x35, 0x36, 0x20, 0x35, 0x36, 0x2d, 0x35, 0x36, 0x68, 0x32, 0x34, 0x38, 0x63, 0x33, 0x30, 0x2e, 0x39, 0x20, 0x30, 0x20, 0x35, 0x36, 0x20, 0x32, 0x35, 0x2e, 0x31, 0x20, 0x35, 0x36, 0x20, 0x35, 0x36, 0x76, 0x32, 0x32, 0x34, 0x48, 0x33, 0x33, 0x32, 0x56, 0x32, 0x34, 0x30, 0x7a, 0x6d, 0x34, 0x36, 0x30, 0x20, 0x36, 0x30, 0x30, 0x48, 0x32, 0x33, 0x32, 0x56, 0x35, 0x33, 0x36, 0x68, 0x35, 0x36, 0x30, 0x76, 0x33, 0x30, 0x34, 0x7a, 0x4d, 0x34, 0x38, 0x34, 0x20, 0x37, 0x30, 0x31, 0x76, 0x35, 0x33, 0x63, 0x30, 0x20, 0x34, 0x2e, 0x34, 0x20, 0x33, 0x2e, 0x36, 0x20, 0x38, 0x20, 0x38, 0x20, 0x38, 0x68, 0x34, 0x30, 0x63, 0x34, 0x2e, 0x34, 0x20, 0x30, 0x20, 0x38, 0x2d, 0x33, 0x2e, 0x36, 0x20, 0x38, 0x2d, 0x38, 0x76, 0x2d, 0x35, 0x33, 0x61, 0x34, 0x38, 0x2e, 0x30, 0x31, 0x20, 0x34, 0x38, 0x2e, 0x30, 0x31, 0x20, 0x30, 0x20, 0x31, 0x30, 0x2d, 0x35, 0x36, 0x20, 0x30, 0x7a, 0x22, 0x3e, 0x3c, 0x2f, 0x70, 0x61, 0x74, 0x68, 0x3e, 0x3c, 0x2f, 0x73, 0x76, 0x67, 0x3e, 0x3c, 0x2f, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x3e, 0x20, 0x3c, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x65, 0x64, 0x20, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x22, 0x6f, 0x6e, 0x63, 0x6c, 0x69, 0x63, 0x6b, 0x3d, 0x22, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x3d, 0x21, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, 0x3e, 0x3c, 0x73, 0x76, 0x67, 0x20, 0x61, 0x72, 0x69, 0x61, 0x2d, 0x68, 0x69, 0x64, 0x64, 0x65, 0x6e, 0x3d, 0x74, 0x72, 0x75, 0x65, 0x20, 0x64, 0x61, 0x74, 0x61, 0x2d, 0x69, 0x63, 0x6f, 0x6e, 0x3d, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x2d, 0x63, 0x69, 0x72, 0x63, 0x6c, 0x65, 0x20, 0x66, 0x69, 0x6c, 0x6c, 0x3d, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x66, 0x6f, 0x63, 0x75, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x3d, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x20, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x3d, 0x31, 0x65, 0x6d, 0x20, 0x76, 0x69, 0x65, 0x77, 0x42, 0x6f, 0x78, 0x3d, 0x22, 0x36, 0x34, 0x20, 0x36, 0x34, 0x20, 0x38, 0x39, 0x36, 0x20, 0x38, 0x39, 0x36, 0x22, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x31, 0x65, 0x6d, 0x3e, 0x3c, 0x70, 0x61, 0x74, 0x68, 0x20, 0x64, 0x3d, 0x22, 0x4d, 0x35, 0x31, 0x32, 0x20, 0x36, 0x34, 0x43, 0x32, 0x36, 0x34, 0x2e, 0x36, 0x20, 0x36, 0x34, 0x20, 0x36, 0x34, 0x20, 0x32, 0x36, 0x34, 0x2e, 0x36, 0x20, 0x36, 0x34, 0x20, 0x35, 0x31, 0x32, 0x73, 0x32, 0x30, 0x30, 0x2e, 0x36, 0x20, 0x34, 0x34, 0x38, 0x20, 0x34, 0x34, 0x38, 0x20, 0x34, 0x34, 0x38, 0x20, 0x34, 0x34, 0x38, 0x2d, 0x32, 0x30, 0x30, 0x2e, 0x36, 0x20, 0x34, 0x34, 0x38, 0x2d, 0x34, 0x34, 0x38, 0x53, 0x37, 0x35, 0x39, 0x2e, 0x34, 0x20, 0x36, 0x34, 0x20, 0x35, 0x31, 0x32, 0x20, 0x36, 0x34, 0x7a, 0x6d, 0x30, 0x20, 0x38, 0x32, 0x30, 0x63, 0x2d, 0x32, 0x30, 0x35, 0x2e, 0x34, 0x20, 0x30, 0x2d, 0x33, 0x37, 0x32, 0x2d, 0x31, 0x36, 0x36, 0x2e, 0x36, 0x2d, 0x33, 0x37, 0x32, 0x2d, 0x33, 0x37, 0x32, 0x73, 0x31, 0x36, 0x36, 0x2e, 0x36, 0x2d, 0x33, 0x37, 0x32, 0x20, 0x33, 0x37, 0x32, 0x2d, 0x33, 0x37, 0x32, 0x20, 0x33, 0x37, 0x32, 0x20, 0x31, 0x36, 0x36, 0x2e, 0x36, 0x20, 0x33, 0x37, 0x32, 0x20, 0x33, 0x37, 0x32, 0x2d, 0x31, 0x36, 0x36, 0x2e, 0x36, 0x20, 0x33, 0x37, 0x32, 0x2d, 0x33, 0x37, 0x32, 0x20, 0x33, 0x37, 0x32, 0x7a, 0x22, 0x3e, 0x3c, 0x2f, 0x70, 0x61, 0x74, 0x68, 0x3e, 0x3c, 0x70, 0x61, 0x74, 0x68, 0x20, 0x64, 0x3d, 0x22, 0x4d, 0x36, 0x38, 0x36, 0x2e, 0x37, 0x20, 0x36, 0x33, 0x38, 0x2e, 0x36, 0x4c, 0x35, 0x34, 0x34, 0x2e, 0x31, 0x20, 0x35, 0x33, 0x35, 0x2e, 0x35, 0x56, 0x32, 0x38, 0x38, 0x63, 0x30, 0x2d, 0x34, 0x2e, 0x34, 0x2d, 0x33, 0x2e, 0x36, 0x2d, 0x38, 0x2d, 0x38, 0x2d, 0x38, 0x48, 0x34, 0x38, 0x38, 0x63, 0x2d, 0x34, 0x2e, 0x34, 0x20, 0x30, 0x2d, 0x38, 0x20, 0x33, 0x2e, 0x36, 0x2d, 0x38, 0x20, 0x38, 0x76, 0x32, 0x37, 0x35, 0x2e, 0x34, 0x63, 0x30, 0x20, 0x32, 0x2e, 0x36, 0x20, 0x31, 0x2e, 0x32, 0x20, 0x35, 0x20, 0x33, 0x2e, 0x33, 0x20, 0x36, 0x2e, 0x35, 0x6c, 0x31, 0x36, 0x35, 0x2e, 0x34, 0x20, 0x31, 0x32, 0x30, 0x2e, 0x36, 0x63, 0x33, 0x2e, 0x36, 0x20, 0x32, 0x2e, 0x36, 0x20, 0x38, 0x2e, 0x36, 0x20, 0x31, 0x2e, 0x38, 0x20, 0x31, 0x31, 0x2e, 0x32, 0x2d, 0x31, 0x2e, 0x37, 0x6c, 0x32, 0x38, 0x2e, 0x36, 0x2d, 0x33, 0x39, 0x63, 0x32, 0x2e, 0x36, 0x2d, 0x33, 0x2e, 0x37, 0x20, 0x31, 0x2e, 0x38, 0x2d, 0x38, 0x2e, 0x37, 0x2d, 0x31, 0x2e, 0x38, 0x2d, 0x31, 0x31, 0x2e, 0x32, 0x7a, 0x22, 0x3e, 0x3c, 0x2f, 0x70, 0x61, 0x74, 0x68, 0x3e, 0x3c, 0x2f, 0x73, 0x76, 0x67, 0x3e, 0x3c, 0x2f, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0x3c, 0x74, 0x65, 0x78, 0x74, 0x61, 0x72, 0x65, 0x61, 0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x65, 0x64, 0x20, 0x77, 0x2d, 0x66, 0x75, 0x6c, 0x6c, 0x22, 0x63, 0x6f, 0x6c, 0x73, 0x3d, 0x33, 0x30, 0x20, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x20, 0x69, 0x64, 0x3d, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x20, 0x72, 0x6f, 0x77, 0x73, 0x3d, 0x34, 0x30, 0x20, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3d, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x65, 0x78, 0x74, 0x61, 0x72, 0x65, 0x61, 0x3e, 0x3c, 0x64, 0x69, 0x76, 0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x67, 0x61, 0x70, 0x2d, 0x32, 0x20, 0x67, 0x72, 0x69, 0x64, 0x20, 0x66, 0x6c, 0x65, 0x78, 0x20, 0x77, 0x2d, 0x66, 0x75, 0x6c, 0x6c, 0x22, 0x69, 0x64, 0x3d, 0x74, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x6c, 0x3e, 0x3c, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x65, 0x64, 0x20, 0x67, 0x72, 0x6f, 0x77, 0x22, 0x69, 0x64, 0x3d, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2d, 0x74, 0x65, 0x78, 0x74, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x63, 0x6d, 0x64, 0x3e, 0x3c, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x65, 0x64, 0x20, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x20, 0x67, 0x72, 0x69, 0x64, 0x20, 0x6a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x79, 0x2d, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x2d, 0x65, 0x6e, 0x64, 0x22, 0x69, 0x64, 0x3d, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2d, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x3e, 0x53, 0x45, 0x4e, 0x44, 0x3c, 0x2f, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0x3c, 0x68, 0x31, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0x3c, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x3e, 0x6c, 0x65, 0x74, 0x20, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x20, 0x3d, 0x20, 0x60, 0x77, 0x73, 0x3a, 0x2f, 0x2f, 0x24, 0x7b, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x2e, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x68, 0x6f, 0x73, 0x74, 0x7d, 0x2f, 0x77, 0x73, 0x60, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x77, 0x65, 0x62, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x74, 0x65, 0x78, 0x74, 0x41, 0x72, 0x65, 0x61, 0x20, 0x3d, 0x20, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x67, 0x65, 0x74, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x42, 0x79, 0x49, 0x64, 0x28, 0x22, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x22, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x6c, 0x6f, 0x77, 0x4c, 0x6f, 0x63, 0x6b, 0x20, 0x3d, 0x20, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x20, 0x3d, 0x20, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x70, 0x69, 0x6e, 0x67, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x20, 0x3d, 0x20, 0x5b, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x49, 0x64, 0x78, 0x20, 0x3d, 0x20, 0x30, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4c, 0x6f, 0x67, 0x6f, 0x28, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x67, 0x65, 0x74, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x42, 0x79, 0x49, 0x64, 0x28, 0x22, 0x6c, 0x6f, 0x67, 0x6f, 0x22, 0x29, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x28, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x67, 0x65, 0x74, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x42, 0x79, 0x49, 0x64, 0x28, 0x22, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x22, 0x29, 0x2e, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x2e, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x20, 0x3d, 0x20, 0x22, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x69, 0x6e, 0x69, 0x74, 0x57, 0x65, 0x62, 0x50, 0x61, 0x67, 0x65, 0x28, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x67, 0x65, 0x74, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x42, 0x79, 0x49, 0x64, 0x28, 0x22, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2d, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x22, 0x29, 0x2e, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x20, 0x3d, 0x20, 0x74, 0x72, 0x75, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x67, 0x65, 0x74, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x42, 0x79, 0x49, 0x64, 0x28, 0x22, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2d, 0x74, 0x65, 0x78, 0x74, 0x22, 0x29, 0x2e, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x20, 0x3d, 0x20, 0x74, 0x72, 0x75, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x6e, 0x69, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x28, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x6e, 0x69, 0x74, 0x57, 0x65, 0x62, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x28, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x6e, 0x69, 0x74, 0x42, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x28, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x74, 0x72, 0x61, 0x70, 0x4b, 0x65, 0x79, 0x50, 0x72, 0x65, 0x73, 0x73, 0x28, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x69, 0x6e, 0x69, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x28, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x20, 0x6a, 0x73, 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x20, 0x3d, 0x20, 0x6a, 0x73, 0x6f, 0x6e, 0x20, 0x3f, 0x20, 0x4a, 0x53, 0x4f, 0x4e, 0x2e, 0x70, 0x61, 0x72, 0x73, 0x65, 0x28, 0x6a, 0x73, 0x6f, 0x6e, 0x29, 0x20, 0x3a, 0x20, 0x5b, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x49, 0x64, 0x78, 0x20, 0x3d, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x69, 0x6e, 0x69, 0x74, 0x57, 0x65, 0x62, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x28, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x28, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x28, 0x70, 0x69, 0x6e, 0x67, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x70, 0x69, 0x6e, 0x67, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x20, 0x3d, 0x20, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x20, 0x3d, 0x20, 0x73, 0x65, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x28, 0x28, 0x29, 0x20, 0x3d, 0x3e, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x6c, 0x57, 0x72, 0x69, 0x74, 0x65, 0x28, 0x22, 0x5b, 0x57, 0x65, 0x62, 0x53, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x5d, 0x20, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x2e, 0x22, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x77, 0x65, 0x62, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0x28, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x6e, 0x69, 0x74, 0x57, 0x65, 0x62, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x28, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x2c, 0x20, 0x33, 0x30, 0x30, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x6c, 0x57, 0x72, 0x69, 0x74, 0x65, 0x28, 0x22, 0x5b, 0x57, 0x65, 0x62, 0x53, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x5d, 0x20, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6e, 0x67, 0x2e, 0x2e, 0x2e, 0x22, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x77, 0x65, 0x62, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x20, 0x3d, 0x20, 0x6e, 0x65, 0x77, 0x20, 0x57, 0x65, 0x62, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x28, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x77, 0x65, 0x62, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x6f, 0x6e, 0x6f, 0x70, 0x65, 0x6e, 0x20, 0x3d, 0x20, 0x6f, 0x6e, 0x4f, 0x70, 0x65, 0x6e, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x77, 0x65, 0x62, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x6f, 0x6e, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0x20, 0x3d, 0x20, 0x6f, 0x6e, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x77, 0x65, 0x62, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x6f, 0x6e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x20, 0x3d, 0x20, 0x6f, 0x6e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x77, 0x65, 0x62, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x6f, 0x6e, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x6f, 0x6e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x69, 0x6e, 0x69, 0x74, 0x42, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x28, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x67, 0x65, 0x74, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x42, 0x79, 0x49, 0x64, 0x28, 0x22, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2d, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x22, 0x29, 0x2e, 0x61, 0x64, 0x64, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x65, 0x72, 0x28, 0x22, 0x63, 0x6c, 0x69, 0x63, 0x6b, 0x22, 0x2c, 0x20, 0x73, 0x65, 0x6e, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x74, 0x72, 0x61, 0x70, 0x4b, 0x65, 0x79, 0x50, 0x72, 0x65, 0x73, 0x73, 0x28, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x67, 0x65, 0x74, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x42, 0x79, 0x49, 0x64, 0x28, 0x22, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2d, 0x74, 0x65, 0x78, 0x74, 0x22, 0x29, 0x2e, 0x61, 0x64, 0x64, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x65, 0x72, 0x28, 0x22, 0x6b, 0x65, 0x79, 0x70, 0x72, 0x65, 0x73, 0x73, 0x22, 0x2c, 0x20, 0x28, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x29, 0x20, 0x3d, 0x3e, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x20, 0x3d, 0x3d, 0x3d, 0x20, 0x22, 0x45, 0x6e, 0x74, 0x65, 0x72, 0x22, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x28, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x67, 0x65, 0x74, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x42, 0x79, 0x49, 0x64, 0x28, 0x22, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2d, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x22, 0x29, 0x2e, 0x63, 0x6c, 0x69, 0x63, 0x6b, 0x28, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x61, 0x64, 0x64, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x65, 0x72, 0x28, 0x22, 0x6b, 0x65, 0x79, 0x64, 0x6f, 0x77, 0x6e, 0x22, 0x2c, 0x20, 0x28, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x29, 0x20, 0x3d, 0x3e, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x26, 0x26, 0x20, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x69, 0x64, 0x20, 0x3d, 0x3d, 0x3d, 0x20, 0x27, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2d, 0x74, 0x65, 0x78, 0x74, 0x27, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x20, 0x3d, 0x3d, 0x3d, 0x20, 0x22, 0x41, 0x72, 0x72, 0x6f, 0x77, 0x55, 0x70, 0x22, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x49, 0x64, 0x78, 0x2d, 0x2d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x49, 0x64, 0x78, 0x20, 0x3c, 0x20, 0x30, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x49, 0x64, 0x78, 0x20, 0x3d, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x20, 0x3e, 0x20, 0x30, 0x20, 0x3f, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x20, 0x2d, 0x20, 0x31, 0x20, 0x3a, 0x20, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x49, 0x64, 0x78, 0x20, 0x3e, 0x3d, 0x20, 0x30, 0x20, 0x26, 0x26, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x49, 0x64, 0x78, 0x20, 0x3c, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x67, 0x65, 0x74, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x42, 0x79, 0x49, 0x64, 0x28, 0x22, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2d, 0x74, 0x65, 0x78, 0x74, 0x22, 0x29, 0x2e, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x20, 0x3d, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x5b, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x49, 0x64, 0x78, 0x5d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x20, 0x69, 0x66, 0x20, 0x28, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x20, 0x3d, 0x3d, 0x3d, 0x20, 0x22, 0x41, 0x72, 0x72, 0x6f, 0x77, 0x44, 0x6f, 0x77, 0x6e, 0x22, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x49, 0x64, 0x78, 0x2b, 0x2b, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x49, 0x64, 0x78, 0x20, 0x3e, 0x3d, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x49, 0x64, 0x78, 0x20, 0x3d, 0x20, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x49, 0x64, 0x78, 0x20, 0x3e, 0x3d, 0x20, 0x30, 0x20, 0x26, 0x26, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x49, 0x64, 0x78, 0x20, 0x3c, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x67, 0x65, 0x74, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x42, 0x79, 0x49, 0x64, 0x28, 0x22, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2d, 0x74, 0x65, 0x78, 0x74, 0x22, 0x29, 0x2e, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x20, 0x3d, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x5b, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x49, 0x64, 0x78, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6f, 0x6e, 0x4f, 0x70, 0x65, 0x6e, 0x28, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x28, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x6c, 0x57, 0x72, 0x69, 0x74, 0x65, 0x28, 0x22, 0x5b, 0x57, 0x65, 0x62, 0x53, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x5d, 0x20, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x65, 0x64, 0x2e, 0x2e, 0x2e, 0x22, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x67, 0x65, 0x74, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x42, 0x79, 0x49, 0x64, 0x28, 0x22, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2d, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x22, 0x29, 0x2e, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x20, 0x3d, 0x20, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x67, 0x65, 0x74, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x42, 0x79, 0x49, 0x64, 0x28, 0x22, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2d, 0x74, 0x65, 0x78, 0x74, 0x22, 0x29, 0x2e, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x20, 0x3d, 0x20, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6f, 0x6e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x28, 0x65, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x65, 0x2e, 0x6c, 0x6f, 0x67, 0x28, 0x22, 0x5b, 0x57, 0x65, 0x62, 0x53, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x5d, 0x20, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x21, 0x22, 0x2c, 0x20, 0x65, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x77, 0x65, 0x62, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0x28, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6f, 0x6e, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x28, 0x65, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x65, 0x2e, 0x6c, 0x6f, 0x67, 0x28, 0x22, 0x5b, 0x57, 0x65, 0x62, 0x53, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x5d, 0x20, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0x64, 0x2e, 0x22, 0x2c, 0x20, 0x65, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6f, 0x6e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x28, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x64, 0x61, 0x74, 0x61, 0x20, 0x3d, 0x3d, 0x20, 0x27, 0x70, 0x6f, 0x6e, 0x67, 0x27, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x28, 0x70, 0x69, 0x6e, 0x67, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x70, 0x69, 0x6e, 0x67, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x20, 0x3d, 0x20, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x6c, 0x57, 0x72, 0x69, 0x74, 0x65, 0x28, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x64, 0x61, 0x74, 0x61, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x6c, 0x57, 0x72, 0x69, 0x74, 0x65, 0x28, 0x72, 0x61, 0x77, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x6e, 0x6f, 0x77, 0x20, 0x3d, 0x20, 0x6e, 0x65, 0x77, 0x20, 0x44, 0x61, 0x74, 0x65, 0x28, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x61, 0x77, 0x20, 0x3d, 0x20, 0x22, 0x5b, 0x22, 0x20, 0x2b, 0x20, 0x6e, 0x6f, 0x77, 0x2e, 0x74, 0x6f, 0x4c, 0x6f, 0x63, 0x61, 0x6c, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x28, 0x29, 0x20, 0x2b, 0x20, 0x22, 0x5d, 0x20, 0x22, 0x20, 0x2b, 0x20, 0x72, 0x61, 0x77, 0x20, 0x2b, 0x20, 0x22, 0x5c, 0x6e, 0x22, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x74, 0x65, 0x78, 0x74, 0x41, 0x72, 0x65, 0x61, 0x2e, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x20, 0x2b, 0x3d, 0x20, 0x72, 0x61, 0x77, 0x20, 0x2b, 0x20, 0x22, 0x5c, 0x6e, 0x22, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x21, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x6c, 0x6f, 0x77, 0x4c, 0x6f, 0x63, 0x6b, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x74, 0x65, 0x78, 0x74, 0x41, 0x72, 0x65, 0x61, 0x2e, 0x73, 0x63, 0x72, 0x6f, 0x6c, 0x6c, 0x54, 0x6f, 0x70, 0x20, 0x3d, 0x20, 0x74, 0x65, 0x78, 0x74, 0x41, 0x72, 0x65, 0x61, 0x2e, 0x73, 0x63, 0x72, 0x6f, 0x6c, 0x6c, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x6c, 0x43, 0x6c, 0x65, 0x61, 0x6e, 0x28, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x74, 0x65, 0x78, 0x74, 0x41, 0x72, 0x65, 0x61, 0x2e, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x20, 0x3d, 0x20, 0x22, 0x22, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x74, 0x65, 0x78, 0x74, 0x41, 0x72, 0x65, 0x61, 0x2e, 0x73, 0x63, 0x72, 0x6f, 0x6c, 0x6c, 0x54, 0x6f, 0x70, 0x20, 0x3d, 0x20, 0x74, 0x65, 0x78, 0x74, 0x41, 0x72, 0x65, 0x61, 0x2e, 0x73, 0x63, 0x72, 0x6f, 0x6c, 0x6c, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x73, 0x65, 0x6e, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x28, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x63, 0x6d, 0x64, 0x20, 0x3d, 0x20, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x67, 0x65, 0x74, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x42, 0x79, 0x49, 0x64, 0x28, 0x22, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2d, 0x74, 0x65, 0x78, 0x74, 0x22, 0x29, 0x2e, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x65, 0x2e, 0x6c, 0x6f, 0x67, 0x28, 0x27, 0x73, 0x65, 0x6e, 0x64, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x3a, 0x20, 0x27, 0x2c, 0x20, 0x63, 0x6d, 0x64, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x77, 0x65, 0x62, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x73, 0x65, 0x6e, 0x64, 0x28, 0x63, 0x6d, 0x64, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x70, 0x75, 0x73, 0x68, 0x28, 0x63, 0x6d, 0x64, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x65, 0x2e, 0x6c, 0x6f, 0x67, 0x28, 0x27, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x20, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x20, 0x27, 0x2c, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x20, 0x3e, 0x20, 0x32, 0x30, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x65, 0x2e, 0x6c, 0x6f, 0x67, 0x28, 0x27, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x20, 0x63, 0x6c, 0x65, 0x61, 0x6e, 0x75, 0x70, 0x27, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x63, 0x65, 0x28, 0x30, 0x2c, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x20, 0x2d, 0x20, 0x32, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x65, 0x2e, 0x6c, 0x6f, 0x67, 0x28, 0x27, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x20, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x20, 0x27, 0x2c, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x49, 0x64, 0x78, 0x20, 0x3d, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x67, 0x65, 0x74, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x42, 0x79, 0x49, 0x64, 0x28, 0x22, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2d, 0x74, 0x65, 0x78, 0x74, 0x22, 0x29, 0x2e, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x20, 0x3d, 0x20, 0x22, 0x22, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x20, 0x3d, 0x20, 0x4a, 0x53, 0x4f, 0x4e, 0x2e, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x69, 0x66, 0x79, 0x28, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x73, 0x65, 0x74, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x28, 0x28, 0x29, 0x20, 0x3d, 0x3e, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x21, 0x70, 0x69, 0x6e, 0x67, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x20, 0x26, 0x26, 0x20, 0x77, 0x65, 0x62, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x72, 0x65, 0x61, 0x64, 0x79, 0x53, 0x74, 0x61, 0x74, 0x65, 0x20, 0x3d, 0x3d, 0x20, 0x57, 0x65, 0x62, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x4f, 0x50, 0x45, 0x4e, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x70, 0x69, 0x6e, 0x67, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x20, 0x3d, 0x20, 0x73, 0x65, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x28, 0x28, 0x29, 0x20, 0x3d, 0x3e, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x6c, 0x57, 0x72, 0x69, 0x74, 0x65, 0x28, 0x22, 0x5b, 0x57, 0x65, 0x62, 0x53, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x5d, 0x20, 0x50, 0x69, 0x6e, 0x67, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x2e, 0x22, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x77, 0x65, 0x62, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0x28, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x6e, 0x69, 0x74, 0x57, 0x65, 0x62, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x28, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x2c, 0x20, 0x33, 0x30, 0x30, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x77, 0x65, 0x62, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x73, 0x65, 0x6e, 0x64, 0x28, 0x22, 0x70, 0x69, 0x6e, 0x67, 0x22, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x2c, 0x20, 0x32, 0x30, 0x30, 0x30, 0x29, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x2e, 0x61, 0x64, 0x64, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x65, 0x72, 0x28, 0x22, 0x44, 0x4f, 0x4d, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x4c, 0x6f, 0x61, 0x64, 0x65, 0x64, 0x22, 0x2c, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x28, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x6e, 0x69, 0x74, 0x57, 0x65, 0x62, 0x50, 0x61, 0x67, 0x65, 0x28, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x2c, 0x20, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x29, 0x3b, 0x3c, 0x2f, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x3e +}; +#endif \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 46dc1b1..24505f5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -45,13 +45,6 @@ bool nuki_hub_https_server_enabled = false; #include "NimBLEDevice.h" #include "ImportExport.h" -/* -#ifdef DEBUG_NUKIHUB -#include -#include -#endif -*/ - NukiNetworkLock* networkLock = nullptr; NukiNetworkOpener* networkOpener = nullptr; BleScanner::Scanner* bleScanner = nullptr; @@ -94,6 +87,8 @@ char log_print_buffer[1024]; PsychicHttpServer* psychicServer = nullptr; PsychicHttpServer* psychicServerRedirect = nullptr; PsychicHttpsServer* psychicSSLServer = nullptr; +PsychicWebSocketHandler* websocketHandler = nullptr; + NukiNetwork* network = nullptr; WebCfgServer* webCfgServer = nullptr; WebCfgServer* webCfgServerSSL = nullptr; @@ -118,6 +113,7 @@ bool webSSLStarted = false; bool lockStarted = false; bool openerStarted = false; bool bleScannerStarted = false; +bool webSerialEnabled = false; uint8_t partitionType = -1; int lastHTTPeventId = -1; @@ -260,13 +256,17 @@ void cbSyncTime(struct timeval *tv) { void startWebServer() { bool failed = true; - - if (!nuki_hub_https_server_enabled) { + + webSerialEnabled = preferences->getBool(preference_webserial_enabled, false); + + if (!nuki_hub_https_server_enabled) + { Log->println("Not running on PSRAM enabled device"); } else { - if (!SPIFFS.begin(true)) { + if (!SPIFFS.begin(true)) + { Log->println("SPIFFS Mount Failed"); } else @@ -286,7 +286,8 @@ void startWebServer() cert[filesize] = '\0'; File file2 = SPIFFS.open("/http_ssl.key"); - if (!file2 || file2.isDirectory()) { + if (!file2 || file2.isDirectory()) + { Log->println("http_ssl.key not found"); } else @@ -602,6 +603,15 @@ void networkTask(void *pvParameters) } else { + if(connected && webSerialEnabled && (webSSLStarted || webStarted)) + { + webCfgServerSSL->updateWebSerial(); + if (esp_task_wdt_status(NULL) == ESP_OK) { + esp_task_wdt_reset(); + } + vTaskDelay(50 / portTICK_PERIOD_MS); + } + if(connected && lockStarted) { rebootLock = networkLock->update(); @@ -1304,9 +1314,6 @@ void setup() Log->print("Nuki Hub build "); Log->println(NUKI_HUB_BUILD); - Log->println(preferences->getString(preference_cred_user)); - Log->println(preferences->getString(preference_cred_password)); - uint32_t devIdOpener = preferences->getUInt(preference_device_id_opener); deviceIdLock = new NukiDeviceId(preferences, preference_device_id_lock); @@ -1380,18 +1387,6 @@ void setup() { startWebServer(); } - /* -#ifdef DEBUG_NUKIHUB - else psychicServer->onNotFound([](PsychicRequest* request) { return request->redirect("/webserial"); }); - - if(preferences->getBool(preference_webserial_enabled, false)) - { - WebSerial.setAuthentication(preferences->getString(preference_cred_user), preferences->getString(preference_cred_password)); - WebSerial.begin(psychicServer); - WebSerial.setBuffer(1024); - } -#endif - */ } #endif diff --git a/src/networkDevices/WifiDevice.cpp b/src/networkDevices/WifiDevice.cpp index e96ce11..4f1ff93 100644 --- a/src/networkDevices/WifiDevice.cpp +++ b/src/networkDevices/WifiDevice.cpp @@ -37,14 +37,22 @@ void WifiDevice::initialize() { Log->println(String("Attempting to connect to saved SSID ") + String(ssid)); _openAP = false; + if(_preferences->getBool(preference_find_best_rssi, false)) + { + scan(false, true); + } + else + { + WiFi.mode(WIFI_STA); + connect(); + } } else { Log->println("No SSID or Wifi password saved, opening AP"); _openAP = true; + scan(false, true); } - - scan(false, true); } else { @@ -133,6 +141,15 @@ void WifiDevice::openAP() bool WifiDevice::connect() { + int loop = 0; + while (!_wifiClientStarted && loop < 50) { + if (esp_task_wdt_status(NULL) == ESP_OK) { + esp_task_wdt_reset(); + } + vTaskDelay(100 / portTICK_PERIOD_MS); + loop++; + } + int bestConnection = -1; if(_preferences->getBool(preference_find_best_rssi, false)) @@ -180,10 +197,17 @@ bool WifiDevice::connect() WiFi.config(_ipConfiguration->ipAddress(), _ipConfiguration->dnsServer(), _ipConfiguration->defaultGateway(), _ipConfiguration->subnet()); } - WiFi.begin(ssid, pass); + if (bestConnection == -1) + { + WiFi.begin(ssid, pass); + } + else + { + WiFi.begin(ssid, pass, WiFi.channel(bestConnection), WiFi.BSSID(bestConnection), 1); + } Log->print("WiFi connecting"); - int loop = 0; + loop = 0; while(!isConnected() && loop < 600) { Log->print(".");