apply astylerc

This commit is contained in:
technyon
2025-08-13 17:04:20 +02:00
parent b575f23df5
commit b6cfea25f5
35 changed files with 2613 additions and 2403 deletions

View File

@@ -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-07-21"
#define NUKI_HUB_DATE "2025-08-13"
#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"

View File

@@ -125,7 +125,7 @@ void Gpio::init()
void Gpio::setPins()
{
loadPinConfiguration();
bool hasInputPin = false;
if (_inst->_preferences->getBool(preference_cred_bypass_boot_btn_enabled, false))

View File

@@ -85,52 +85,52 @@ private:
GpioAction IRAM_ATTR getGpioAction(const PinRole& role) const;
static void IRAM_ATTR isrOnTimer();
#if defined(CONFIG_IDF_TARGET_ESP32C3)
#if defined(CONFIG_IDF_TARGET_ESP32C3)
//Based on https://docs.espressif.com/projects/esp-idf/en/latest/esp32c3/api-reference/peripherals/gpio.html and https://www.espressif.com/sites/default/files/documentation/esp32-c3_datasheet_en.pdf
const std::vector<uint8_t> _availablePins = { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 18, 19, 20, 21 };
#elif defined(CONFIG_IDF_TARGET_ESP32S3)
#elif defined(CONFIG_IDF_TARGET_ESP32S3)
//Based on https://github.com/atomic14/esp32-s3-pinouts?tab=readme-ov-file and https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/api-reference/peripherals/gpio.html and https://www.espressif.com/sites/default/files/documentation/esp32-s3_datasheet_en.pdf
const std::vector<uint8_t> _availablePins = { 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 21, 38, 39, 40, 41, 42 };
#elif defined(CONFIG_IDF_TARGET_ESP32C5)
#elif defined(CONFIG_IDF_TARGET_ESP32C5)
//Based on https://docs.espressif.com/projects/esp-idf/en/latest/esp32c5/api-reference/peripherals/gpio.html and https://www.espressif.com/sites/default/files/documentation/esp32-c5_datasheet_en.pdf
const std::vector<uint8_t> _availablePins = { 0, 1, 3, 4, 5, 6, 8, 9, 10, 11, 12, 15, 23, 24, 26 };
#elif defined(CONFIG_IDF_TARGET_ESP32C6)
#elif defined(CONFIG_IDF_TARGET_ESP32C6)
//Based on https://docs.espressif.com/projects/esp-idf/en/latest/esp32c6/api-reference/peripherals/gpio.html and https://www.espressif.com/sites/default/files/documentation/esp32-c6_datasheet_en.pdf
const std::vector<uint8_t> _availablePins = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23 };
#elif defined(CONFIG_IDF_TARGET_ESP32P4)
#elif defined(CONFIG_IDF_TARGET_ESP32P4)
//Based on https://docs.espressif.com/projects/esp-idf/en/latest/esp32p4/api-reference/peripherals/gpio.html
const std::vector<uint8_t> _availablePins = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33 };
#elif defined(CONFIG_IDF_TARGET_ESP32H2)
#elif defined(CONFIG_IDF_TARGET_ESP32H2)
//Based on https://docs.espressif.com/projects/esp-idf/en/latest/esp32h2/api-reference/peripherals/gpio.html and https://www.espressif.com/sites/default/files/documentation/esp32-h2_datasheet_en.pdf
const std::vector<uint8_t> _availablePins = { 0, 1, 2, 3, 4, 5, 8, 9, 10, 11, 12, 13, 14, 22, 23, 24, 25, 26, 27 };
#else
#else
//Based on https://randomnerdtutorials.com/esp32-pinout-reference-gpios/
const std::vector<uint8_t> _availablePins = { 2, 4, 5, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 32, 33 };
#endif
#endif
const std::vector<PinRole> _allRoles =
{
PinRole::Disabled,
PinRole::InputLock,
PinRole::InputUnlock,
PinRole::InputUnlatch,
PinRole::InputLockNgo,
PinRole::InputLockNgoUnlatch,
PinRole::InputElectricStrikeActuation,
PinRole::InputActivateRTO,
PinRole::InputActivateCM,
PinRole::InputDeactivateRtoCm,
PinRole::InputDeactivateRTO,
PinRole::InputDeactivateCM,
PinRole::OutputHighLocked,
PinRole::OutputHighUnlocked,
PinRole::OutputHighRtoActive,
PinRole::OutputHighCmActive,
PinRole::OutputHighRtoOrCmActive,
PinRole::GeneralInputPullDown,
PinRole::GeneralInputPullUp,
PinRole::GeneralOutput,
PinRole::Ethernet
};
{
PinRole::Disabled,
PinRole::InputLock,
PinRole::InputUnlock,
PinRole::InputUnlatch,
PinRole::InputLockNgo,
PinRole::InputLockNgoUnlatch,
PinRole::InputElectricStrikeActuation,
PinRole::InputActivateRTO,
PinRole::InputActivateCM,
PinRole::InputDeactivateRtoCm,
PinRole::InputDeactivateRTO,
PinRole::InputDeactivateCM,
PinRole::OutputHighLocked,
PinRole::OutputHighUnlocked,
PinRole::OutputHighRtoActive,
PinRole::OutputHighCmActive,
PinRole::OutputHighRtoOrCmActive,
PinRole::GeneralInputPullDown,
PinRole::GeneralInputPullUp,
PinRole::GeneralOutput,
PinRole::Ethernet
};
std::vector<PinEntry> _pinConfiguration;
@@ -140,7 +140,7 @@ private:
std::vector<uint8_t> _triggerState;
hw_timer_t* timer = nullptr;
bool _first = true;
Preferences* _preferences = nullptr;

View File

@@ -25,7 +25,8 @@ HomeAssistantDiscovery::HomeAssistantDiscovery(NetworkDevice* device, Preference
char uidString[20];
itoa(_preferences->getUInt(preference_device_id_lock, 0), uidString, 10);
removeHASSConfig(uidString);
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(3000 / portTICK_PERIOD_MS);
@@ -41,13 +42,15 @@ HomeAssistantDiscovery::HomeAssistantDiscovery(NetworkDevice* device, Preference
char uidString[20];
itoa(_preferences->getUInt(preference_device_id_lock, 0), uidString, 10);
removeHASSConfig(uidString);
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(3000 / portTICK_PERIOD_MS);
itoa(savedDevId, uidString, 10);
removeHASSConfig(uidString);
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(3000 / portTICK_PERIOD_MS);
@@ -102,7 +105,8 @@ void HomeAssistantDiscovery::setupHASS(int type, uint32_t nukiId, char* nukiName
void HomeAssistantDiscovery::disableHASS()
{
removeHASSConfig(_nukiHubUidString);
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(3000 / portTICK_PERIOD_MS);
@@ -113,7 +117,8 @@ void HomeAssistantDiscovery::disableHASS()
{
itoa(_preferences->getUInt(preference_nuki_id_lock, 0), uidString, 16);
removeHASSConfig(uidString);
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(3000 / portTICK_PERIOD_MS);
@@ -122,7 +127,8 @@ void HomeAssistantDiscovery::disableHASS()
{
itoa(_preferences->getUInt(preference_nuki_id_opener, 0), uidString, 16);
removeHASSConfig(uidString);
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(3000 / portTICK_PERIOD_MS);

View File

@@ -24,7 +24,7 @@ public:
const String& entityCat = "",
const String& commandTopic = "",
std::vector<std::pair<char*, char*>> additionalEntries = {}
);
);
private:
void publishHASSConfig(char *deviceType, const char *baseTopic, char *name, char *uidString, const char *softwareVersion, const char *hardwareVersion, const bool& hasDoorSensor, const bool& hasKeypad, const bool& publishAuthData, char *lockAction, char *unlockAction, char *openAction);
void publishHASSDeviceConfig(char* deviceType, const char* baseTopic, char* name, char* uidString, const char *softwareVersion, const char *hardwareVersion, const char* availabilityTopic, const bool& hasKeypad, char* lockAction, char* unlockAction, char* openAction);
@@ -54,17 +54,17 @@ private:
const String& entityCat = "",
const String& commandTopic = "",
std::vector<std::pair<char*, char*>> additionalEntries = {}
);
);
NetworkDevice* _device = nullptr;
Preferences* _preferences = nullptr;
String _baseTopic;
String _hostname;
JsonDocument _uidToName;
char _nukiHubUidString[20];
char* _buffer;
const size_t _bufferSize;
};

View File

@@ -7,7 +7,7 @@
#include <TOTP-RC6236-generator.hpp>
ImportExport::ImportExport(Preferences *preferences)
: _preferences(preferences)
: _preferences(preferences)
{
readSettings();
}
@@ -151,7 +151,8 @@ int ImportExport::checkDuoAuth(PsychicRequest *request)
}
}
if (request->hasParam("id")) {
if (request->hasParam("id"))
{
const PsychicWebParameter* p = request->getParam("id");
String id = p->value();
DuoAuthLib duoAuth;
@@ -337,13 +338,15 @@ bool ImportExport::checkBypass(String bypass)
void ImportExport::exportHttpsJson(JsonDocument &json)
{
if (!SPIFFS.begin(true)) {
if (!SPIFFS.begin(true))
{
Log->println("SPIFFS Mount Failed");
}
else
{
File file = SPIFFS.open("/http_ssl.crt");
if (!file || file.isDirectory()) {
if (!file || file.isDirectory())
{
Log->println("http_ssl.crt not found");
}
else
@@ -359,13 +362,15 @@ void ImportExport::exportHttpsJson(JsonDocument &json)
}
}
if (!SPIFFS.begin(true)) {
if (!SPIFFS.begin(true))
{
Log->println("SPIFFS Mount Failed");
}
else
{
File file = SPIFFS.open("/http_ssl.key");
if (!file || file.isDirectory()) {
if (!file || file.isDirectory())
{
Log->println("http_ssl.key not found");
}
else
@@ -384,13 +389,15 @@ void ImportExport::exportHttpsJson(JsonDocument &json)
void ImportExport::exportMqttsJson(JsonDocument &json)
{
if (!SPIFFS.begin(true)) {
if (!SPIFFS.begin(true))
{
Log->println("SPIFFS Mount Failed");
}
else
{
File file = SPIFFS.open("/mqtt_ssl.ca");
if (!file || file.isDirectory()) {
if (!file || file.isDirectory())
{
Log->println("mqtt_ssl.ca not found");
}
else
@@ -406,13 +413,15 @@ void ImportExport::exportMqttsJson(JsonDocument &json)
}
}
if (!SPIFFS.begin(true)) {
if (!SPIFFS.begin(true))
{
Log->println("SPIFFS Mount Failed");
}
else
{
File file = SPIFFS.open("/mqtt_ssl.crt");
if (!file || file.isDirectory()) {
if (!file || file.isDirectory())
{
Log->println("mqtt_ssl.crt not found");
}
else
@@ -428,13 +437,15 @@ void ImportExport::exportMqttsJson(JsonDocument &json)
}
}
if (!SPIFFS.begin(true)) {
if (!SPIFFS.begin(true))
{
Log->println("SPIFFS Mount Failed");
}
else
{
File file = SPIFFS.open("/mqtt_ssl.key");
if (!file || file.isDirectory()) {
if (!file || file.isDirectory())
{
Log->println("mqtt_ssl.key not found");
}
else
@@ -479,13 +490,13 @@ void ImportExport::exportNukiHubJson(JsonDocument &json, bool redacted, bool pai
continue;
}
if(strcmp(key, preference_admin_secret) == 0)
{
continue;
}
if(!redacted) if(std::find(redactedPrefs.begin(), redactedPrefs.end(), key) != redactedPrefs.end())
{
continue;
}
if(!redacted) if(std::find(redactedPrefs.begin(), redactedPrefs.end(), key) != redactedPrefs.end())
{
continue;
}
if(!_preferences->isKey(key))
{
json[key] = "";
@@ -909,7 +920,8 @@ JsonDocument ImportExport::importJson(JsonDocument &doc)
nukiBlePref.end();
if(!doc["mqtt_ssl.ca"].isNull())
{
if (!SPIFFS.begin(true)) {
if (!SPIFFS.begin(true))
{
Log->println("SPIFFS Mount Failed");
json["mqtt_ssl.ca"] = "error";
}
@@ -918,7 +930,8 @@ JsonDocument ImportExport::importJson(JsonDocument &doc)
if(doc["mqtt_ssl.ca"].as<String>().length() > 0)
{
File file = SPIFFS.open("/mqtt_ssl.ca", FILE_WRITE);
if (!file) {
if (!file)
{
Log->println("Failed to open /mqtt_ssl.ca for writing");
json["mqtt_ssl.ca"] = "error";
}
@@ -938,7 +951,8 @@ JsonDocument ImportExport::importJson(JsonDocument &doc)
}
else
{
if (!SPIFFS.remove("/mqtt_ssl.ca")) {
if (!SPIFFS.remove("/mqtt_ssl.ca"))
{
Log->println("Failed to delete /mqtt_ssl.ca");
json["mqtt_ssl.crt"] = "error";
}
@@ -951,7 +965,8 @@ JsonDocument ImportExport::importJson(JsonDocument &doc)
}
if(!doc["mqtt_ssl.crt"].isNull())
{
if (!SPIFFS.begin(true)) {
if (!SPIFFS.begin(true))
{
Log->println("SPIFFS Mount Failed");
json["mqtt_ssl.crt"] = "error";
}
@@ -960,7 +975,8 @@ JsonDocument ImportExport::importJson(JsonDocument &doc)
if(doc["mqtt_ssl.crt"].as<String>().length() > 0)
{
File file = SPIFFS.open("/mqtt_ssl.crt", FILE_WRITE);
if (!file) {
if (!file)
{
Log->println("Failed to open /mqtt_ssl.crt for writing");
json["mqtt_ssl.crt"] = "error";
}
@@ -980,7 +996,8 @@ JsonDocument ImportExport::importJson(JsonDocument &doc)
}
else
{
if (!SPIFFS.remove("/mqtt_ssl.crt")) {
if (!SPIFFS.remove("/mqtt_ssl.crt"))
{
Log->println("Failed to delete /mqtt_ssl.crt");
json["mqtt_ssl.crt"] = "error";
}
@@ -993,7 +1010,8 @@ JsonDocument ImportExport::importJson(JsonDocument &doc)
}
if(!doc["mqtt_ssl.key"].isNull())
{
if (!SPIFFS.begin(true)) {
if (!SPIFFS.begin(true))
{
Log->println("SPIFFS Mount Failed");
json["mqtt_ssl.key"] = "error";
}
@@ -1002,7 +1020,8 @@ JsonDocument ImportExport::importJson(JsonDocument &doc)
if(doc["mqtt_ssl.key"].as<String>().length() > 0)
{
File file = SPIFFS.open("/mqtt_ssl.key", FILE_WRITE);
if (!file) {
if (!file)
{
Log->println("Failed to open /mqtt_ssl.key for writing");
json["mqtt_ssl.key"] = "error";
}
@@ -1022,7 +1041,8 @@ JsonDocument ImportExport::importJson(JsonDocument &doc)
}
else
{
if (!SPIFFS.remove("/mqtt_ssl.key")) {
if (!SPIFFS.remove("/mqtt_ssl.key"))
{
Log->println("Failed to delete /mqtt_ssl.key");
}
else
@@ -1034,7 +1054,8 @@ JsonDocument ImportExport::importJson(JsonDocument &doc)
}
if(!doc["http_ssl.crt"].isNull())
{
if (!SPIFFS.begin(true)) {
if (!SPIFFS.begin(true))
{
Log->println("SPIFFS Mount Failed");
json["http_ssl.crt"] = "error";
}
@@ -1043,7 +1064,8 @@ JsonDocument ImportExport::importJson(JsonDocument &doc)
if(doc["http_ssl.crt"].as<String>().length() > 0)
{
File file = SPIFFS.open("/http_ssl.crt", FILE_WRITE);
if (!file) {
if (!file)
{
Log->println("Failed to open /http_ssl.crt for writing");
json["http_ssl.crt"] = "error";
}
@@ -1063,7 +1085,8 @@ JsonDocument ImportExport::importJson(JsonDocument &doc)
}
else
{
if (!SPIFFS.remove("/http_ssl.crt")) {
if (!SPIFFS.remove("/http_ssl.crt"))
{
Log->println("Failed to delete /http_ssl.crt");
json["http_ssl.crt"] = "error";
}
@@ -1076,7 +1099,8 @@ JsonDocument ImportExport::importJson(JsonDocument &doc)
}
if(!doc["http_ssl.key"].isNull())
{
if (!SPIFFS.begin(true)) {
if (!SPIFFS.begin(true))
{
Log->println("SPIFFS Mount Failed");
json["http_ssl.key"] = "error";
}
@@ -1085,7 +1109,8 @@ JsonDocument ImportExport::importJson(JsonDocument &doc)
if(doc["http_ssl.key"].as<String>().length() > 0)
{
File file = SPIFFS.open("/http_ssl.key", FILE_WRITE);
if (!file) {
if (!file)
{
Log->println("Failed to open /http_ssl.key for writing");
json["http_ssl.key"] = "error";
}
@@ -1105,7 +1130,8 @@ JsonDocument ImportExport::importJson(JsonDocument &doc)
}
else
{
if (!SPIFFS.remove("/http_ssl.key")) {
if (!SPIFFS.remove("/http_ssl.key"))
{
Log->println("Failed to delete /http_ssl.key");
json["http_ssl.key"] = "error";
}

View File

@@ -139,13 +139,13 @@ private:
mqtt_topic_query_config, mqtt_topic_query_lockstate, mqtt_topic_query_keypad, mqtt_topic_query_battery, mqtt_topic_query_lockstate_command_result,
mqtt_topic_battery_level, mqtt_topic_battery_critical, mqtt_topic_battery_charging, mqtt_topic_battery_voltage, mqtt_topic_battery_drain,
mqtt_topic_battery_max_turn_current, mqtt_topic_battery_lock_distance, mqtt_topic_battery_keypad_critical, mqtt_topic_battery_doorsensor_critical,
mqtt_topic_battery_basic_json,mqtt_topic_battery_advanced_json, mqtt_topic_keypad, mqtt_topic_keypad_codes, mqtt_topic_keypad_command_action,
mqtt_topic_battery_basic_json,mqtt_topic_battery_advanced_json, mqtt_topic_keypad, mqtt_topic_keypad_codes, mqtt_topic_keypad_command_action,
mqtt_topic_keypad_command_id, mqtt_topic_keypad_command_name, mqtt_topic_keypad_command_code, mqtt_topic_keypad_command_enabled, mqtt_topic_keypad_command_result,
mqtt_topic_keypad_json, mqtt_topic_keypad_json_action, mqtt_topic_keypad_json_command_result, mqtt_topic_timecontrol, mqtt_topic_timecontrol_entries,
mqtt_topic_timecontrol_json, mqtt_topic_timecontrol_action, mqtt_topic_timecontrol_command_result, mqtt_topic_auth, mqtt_topic_auth_entries,
mqtt_topic_auth_json, mqtt_topic_auth_action, mqtt_topic_auth_command_result, mqtt_topic_info_hardware_version, mqtt_topic_info_firmware_version,
mqtt_topic_info_nuki_hub_version, mqtt_topic_info_nuki_hub_build, mqtt_topic_info_nuki_hub_latest, mqtt_topic_info_nuki_hub_ip, mqtt_topic_reset,
mqtt_topic_update, mqtt_topic_webserver_state, mqtt_topic_webserver_action, mqtt_topic_uptime, mqtt_topic_wifi_rssi, mqtt_topic_log, mqtt_topic_freeheap,
mqtt_topic_keypad_json, mqtt_topic_keypad_json_action, mqtt_topic_keypad_json_command_result, mqtt_topic_timecontrol, mqtt_topic_timecontrol_entries,
mqtt_topic_timecontrol_json, mqtt_topic_timecontrol_action, mqtt_topic_timecontrol_command_result, mqtt_topic_auth, mqtt_topic_auth_entries,
mqtt_topic_auth_json, mqtt_topic_auth_action, mqtt_topic_auth_command_result, mqtt_topic_info_hardware_version, mqtt_topic_info_firmware_version,
mqtt_topic_info_nuki_hub_version, mqtt_topic_info_nuki_hub_build, mqtt_topic_info_nuki_hub_latest, mqtt_topic_info_nuki_hub_ip, mqtt_topic_reset,
mqtt_topic_update, mqtt_topic_webserver_state, mqtt_topic_webserver_action, mqtt_topic_uptime, mqtt_topic_wifi_rssi, mqtt_topic_log, mqtt_topic_freeheap,
mqtt_topic_restart_reason_fw, mqtt_topic_restart_reason_esp, mqtt_topic_mqtt_connection_state, mqtt_topic_network_device, mqtt_topic_hybrid_state
};
public:

View File

@@ -49,9 +49,9 @@ void NukiNetwork::setupDevice()
if(hardwareDetect == 0)
{
#ifndef CONFIG_IDF_TARGET_ESP32H2
#ifndef CONFIG_IDF_TARGET_ESP32H2
hardwareDetect = 1;
#else
#else
hardwareDetect = 11;
_preferences->putInt(preference_network_custom_addr, 1);
_preferences->putInt(preference_network_custom_cs, 8);
@@ -61,13 +61,13 @@ void NukiNetwork::setupDevice()
_preferences->putInt(preference_network_custom_miso, 12);
_preferences->putInt(preference_network_custom_mosi, 13);
_preferences->putBool(preference_ntw_reconfigure, true);
#endif
#endif
_preferences->putInt(preference_network_hardware, hardwareDetect);
}
if(wifiFallback == true)
{
#ifndef CONFIG_IDF_TARGET_ESP32H2
#ifndef CONFIG_IDF_TARGET_ESP32H2
if(!_firstBootAfterDeviceChange)
{
Log->println("Failed to connect to network. Wi-Fi fallback is disabled, rebooting.");
@@ -78,7 +78,7 @@ void NukiNetwork::setupDevice()
Log->println("Switching to Wi-Fi device as fallback.");
_networkDeviceType = NetworkDeviceType::WiFi;
#else
#else
int custEth = _preferences->getInt(preference_network_custom_phy, 0);
if(custEth<3)
@@ -91,7 +91,7 @@ void NukiNetwork::setupDevice()
}
_preferences->putInt(preference_network_custom_phy, custEth);
_preferences->putBool(preference_ntw_reconfigure, true);
#endif
#endif
}
else
{
@@ -103,9 +103,9 @@ void NukiNetwork::setupDevice()
Log->print("Network device: ");
Log->println(_device->deviceName());
#ifndef NUKI_HUB_UPDATER
#ifndef NUKI_HUB_UPDATER
_hadiscovery = new HomeAssistantDiscovery(_device, _preferences, _buffer, _bufferSize);
#endif
#endif
}
void NukiNetwork::reconfigureDevice()
@@ -156,11 +156,11 @@ bool NukiNetwork::isConnected()
bool NukiNetwork::mqttConnected()
{
#ifndef NUKI_HUB_UPDATER
#ifndef NUKI_HUB_UPDATER
return _device->mqttConnected();
#else
#else
return false;
#endif
#endif
}
bool NukiNetwork::wifiConnected()
@@ -217,8 +217,8 @@ bool NukiNetwork::update()
void NukiNetwork::initialize()
{
readSettings();
setMQTTConnectionSettings();
setMQTTConnectionSettings();
_gpio->addCallback([this](const GpioAction& action, const int& pin)
{
gpioActionCallback(action, pin);
@@ -345,12 +345,12 @@ void NukiNetwork::setMQTTConnectionSettings()
if(_preferences->getString(preference_mqtt_hass_discovery, "") != "" && !_preferences->getBool(preference_mqtt_hass_enabled, false))
{
_preferences->putBool(preference_mqtt_hass_enabled, true);
}
}
memset(_mqttBrokerAddr, 0, sizeof(_mqttBrokerAddr));
memset(_mqttUser, 0, sizeof(_mqttUser));
memset(_mqttPass, 0, sizeof(_mqttPass));
String brokerAddr = _preferences->getString(preference_mqtt_broker);
strcpy(_mqttBrokerAddr, brokerAddr.c_str());
@@ -387,7 +387,7 @@ void NukiNetwork::setMQTTConnectionSettings()
Log->print(":");
Log->println(_mqttPort);
#ifndef NUKI_HUB_UPDATER
#ifndef NUKI_HUB_UPDATER
_device->mqttOnConnect([&](bool sessionPresent)
{
onMqttConnect(sessionPresent);
@@ -396,7 +396,7 @@ void NukiNetwork::setMQTTConnectionSettings()
{
onMqttDisconnect(reason);
});
#endif
#endif
}
int NukiNetwork::getRestartServices()
@@ -476,7 +476,8 @@ bool NukiNetwork::update()
bool success = reconnect();
if(!success)
{
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(2000 / portTICK_PERIOD_MS);
@@ -488,7 +489,8 @@ bool NukiNetwork::update()
if(forceEnableWebServer && !_webEnabled)
{
forceEnableWebServer = false;
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(200 / portTICK_PERIOD_MS);
@@ -498,7 +500,8 @@ bool NukiNetwork::update()
{
forceEnableWebServer = false;
}
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(2000 / portTICK_PERIOD_MS);
@@ -513,13 +516,15 @@ bool NukiNetwork::update()
forceEnableWebServer = true;
}
Log->println("Network timeout has been reached, restarting ...");
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(200 / portTICK_PERIOD_MS);
restartEsp(RestartReason::NetworkTimeoutWatchdog);
}
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(2000 / portTICK_PERIOD_MS);
@@ -713,9 +718,9 @@ bool NukiNetwork::reconnect(bool force)
_device->mqttRestart();
setMQTTConnectionSettings();
}
force = false;
if(strcmp(_mqttBrokerAddr, "") == 0)
{
Log->println("MQTT Broker not configured, aborting connection attempt.");
@@ -751,7 +756,8 @@ bool NukiNetwork::reconnect(bool force)
while(!_connectReplyReceived && espMillis() < timeout)
{
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(50 / portTICK_PERIOD_MS);
@@ -767,7 +773,8 @@ bool NukiNetwork::reconnect(bool force)
Log->println("MQTT connected");
_mqttConnectedTs = millis();
_mqttConnectionState = 1;
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(100 / portTICK_PERIOD_MS);
@@ -1015,7 +1022,8 @@ void NukiNetwork::onMqttDataReceived(const char* topic, byte* payload, const uns
{
Log->println("Restart requested via MQTT.");
clearWifiFallback();
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(200 / portTICK_PERIOD_MS);
@@ -1071,7 +1079,8 @@ void NukiNetwork::onMqttDataReceived(const char* topic, byte* payload, const uns
_preferences->putString(preference_ota_updater_url, GITHUB_LATEST_UPDATER_BINARY_URL);
_preferences->putString(preference_ota_main_url, GITHUB_LATEST_RELEASE_BINARY_URL);
Log->println("Updating to latest release version.");
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(200 / portTICK_PERIOD_MS);
@@ -1089,7 +1098,8 @@ void NukiNetwork::onMqttDataReceived(const char* topic, byte* payload, const uns
_preferences->putString(preference_ota_updater_url, GITHUB_BETA_UPDATER_BINARY_URL);
_preferences->putString(preference_ota_main_url, GITHUB_BETA_RELEASE_BINARY_URL);
Log->println("Updating to latest beta version.");
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(200 / portTICK_PERIOD_MS);
@@ -1107,7 +1117,8 @@ void NukiNetwork::onMqttDataReceived(const char* topic, byte* payload, const uns
_preferences->putString(preference_ota_updater_url, GITHUB_MASTER_UPDATER_BINARY_URL);
_preferences->putString(preference_ota_main_url, GITHUB_MASTER_RELEASE_BINARY_URL);
Log->println("Updating to latest developmemt version.");
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(200 / portTICK_PERIOD_MS);
@@ -1125,7 +1136,8 @@ void NukiNetwork::onMqttDataReceived(const char* topic, byte* payload, const uns
_preferences->putString(preference_ota_updater_url, GITHUB_LATEST_UPDATER_BINARY_URL);
_preferences->putString(preference_ota_main_url, GITHUB_LATEST_RELEASE_BINARY_URL);
Log->println("Updating to latest release version.");
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(200 / portTICK_PERIOD_MS);
@@ -1165,7 +1177,8 @@ void NukiNetwork::onMqttDataReceived(const char* topic, byte* payload, const uns
_preferences->putBool(preference_webserver_enabled, false);
}
clearWifiFallback();
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(200 / portTICK_PERIOD_MS);
@@ -1197,7 +1210,8 @@ void NukiNetwork::onMqttDataReceived(const char* topic, byte* payload, const uns
{
String jsonTotp = doc["totp"];
if (!_importExport->checkTOTP(&jsonTotp)) {
if (!_importExport->checkTOTP(&jsonTotp))
{
publishString(_maintenancePathPrefix, mqtt_topic_nuki_hub_config_action_command_result, "{\"error\": \"totpIncorrect\"}", false);
publishString(_maintenancePathPrefix, mqtt_topic_nuki_hub_config_action, "--", true);
return;
@@ -1219,7 +1233,8 @@ void NukiNetwork::onMqttDataReceived(const char* topic, byte* payload, const uns
while (duoResult == 2)
{
duoResult = _importExport->checkDuoApprove();
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(2000 / portTICK_PERIOD_MS);
@@ -1339,7 +1354,8 @@ void NukiNetwork::onMqttDataReceived(const char* topic, byte* payload, const uns
serializeJson(json, _buffer, _bufferSize);
publishString(_maintenancePathPrefix, mqtt_topic_nuki_hub_config_json, _buffer, false);
publishString(_maintenancePathPrefix, mqtt_topic_nuki_hub_config_action, "--", true);
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(200 / portTICK_PERIOD_MS);
@@ -1479,10 +1495,10 @@ void NukiNetwork::removeTopic(const String& mqttPath, const String& mqttTopic)
path.concat(mqttTopic);
publish(path.c_str(), "", true);
#ifdef DEBUG_NUKIHUB
#ifdef DEBUG_NUKIHUB
Log->print("Removing MQTT topic: ");
Log->println(path.c_str());
#endif
#endif
}
void NukiNetwork::setupHASS(int type, uint32_t nukiId, char* nukiName, const char* firmwareVersion, const char* hardwareVersion, bool hasDoorSensor, bool hasKeypad)

View File

@@ -43,9 +43,9 @@ public:
NetworkDevice* device();
#ifdef NUKI_HUB_UPDATER
#ifdef NUKI_HUB_UPDATER
explicit NukiNetwork(Preferences* preferences);
#else
#else
explicit NukiNetwork(Preferences* preferences, Gpio* gpio, char* buffer, size_t bufferSize, ImportExport* importExport);
void registerMqttReceiver(MqttReceiver* receiver);
@@ -72,20 +72,20 @@ public:
void setupHASS(int type, uint32_t nukiId, char* nukiName, const char* firmwareVersion, const char* hardwareVersion, bool hasDoorSensor, bool hasKeypad);
void disableHASS();
void publishHassTopic(const String& mqttDeviceType,
const String& mqttDeviceName,
const String& uidString,
const String& uidStringPostfix,
const String& displayName,
const String& name,
const String& baseTopic,
const String& stateTopic,
const String& deviceType,
const String& deviceClass,
const String& stateClass,
const String& entityCat,
const String& commandTopic,
std::vector<std::pair<char*, char*>> additionalEntries
);
const String& mqttDeviceName,
const String& uidString,
const String& uidStringPostfix,
const String& displayName,
const String& name,
const String& baseTopic,
const String& stateTopic,
const String& deviceType,
const String& deviceClass,
const String& stateClass,
const String& entityCat,
const String& commandTopic,
std::vector<std::pair<char*, char*>> additionalEntries
);
void removeHassTopic(const String& mqttDeviceType, const String& mqttDeviceName, const String& uidString);
int mqttConnectionState(); // 0 = not connected; 1 = connected; 2 = connected and mqtt processed
@@ -93,11 +93,11 @@ public:
bool pathEquals(const char* prefix, const char* path, const char* referencePath);
uint16_t subscribe(const char* topic, uint8_t qos);
void addReconnectedCallback(std::function<void()> reconnectedCallback);
#endif
#endif
private:
void setupDevice();
void setMQTTConnectionSettings();
static NukiNetwork* _inst;
const char* _latestVersion;
@@ -115,7 +115,7 @@ private:
bool _firstBootAfterDeviceChange = false;
bool _webEnabled = true;
#ifndef NUKI_HUB_UPDATER
#ifndef NUKI_HUB_UPDATER
static void onMqttDataReceivedCallback(const espMqttClientTypes::MessageProperties& properties, const char* topic, const uint8_t* payload, size_t len, size_t index, size_t total);
void onMqttDataReceived(const espMqttClientTypes::MessageProperties& properties, const char* topic, const uint8_t* payload, size_t& len, size_t& index, size_t& total);
void onMqttDataReceived(const char* topic, byte* payload, const unsigned int length);
@@ -173,5 +173,5 @@ private:
const size_t _bufferSize;
int8_t _lastRssi = 127;
#endif
#endif
};

View File

@@ -164,8 +164,8 @@ bool NukiNetworkLock::update()
wdt_hal_context_t rtc_wdt_ctx = RWDT_HAL_CONTEXT_DEFAULT();
wdt_hal_write_protect_disable(&rtc_wdt_ctx);
wdt_hal_feed(&rtc_wdt_ctx);
wdt_hal_write_protect_enable(&rtc_wdt_ctx);
wdt_hal_write_protect_enable(&rtc_wdt_ctx);
bool ret = false;
if(_nukiOfficial->hasOffStateToPublish())
@@ -426,7 +426,7 @@ void NukiNetworkLock::publishKeyTurnerState(const NukiLock::KeyTurnerState& keyT
lockstateToString((NukiLock::LockState)_nukiOfficial->getOffState(), str);
json["lock_state"] = str;
}
if(strcmp(str, "undefined") == 0)
{
_nukiPublisher->publishString(mqtt_topic_lock_availability, "offline", true);

View File

@@ -135,8 +135,8 @@ void NukiNetworkOpener::update()
wdt_hal_context_t rtc_wdt_ctx = RWDT_HAL_CONTEXT_DEFAULT();
wdt_hal_write_protect_disable(&rtc_wdt_ctx);
wdt_hal_feed(&rtc_wdt_ctx);
wdt_hal_write_protect_enable(&rtc_wdt_ctx);
wdt_hal_write_protect_enable(&rtc_wdt_ctx);
if(_resetRingStateTs != 0 && espMillis() >= _resetRingStateTs)
{
_resetRingStateTs = 0;
@@ -353,7 +353,7 @@ void NukiNetworkOpener::publishKeyTurnerState(const NukiOpener::OpenerState& key
publishState(keyTurnerState);
}
}
if(strcmp(str, "undefined") == 0)
{
_nukiPublisher->publishString(mqtt_topic_lock_availability, "offline", true);

View File

@@ -228,59 +228,59 @@ void NukiOfficial::onOfficialUpdateReceived(const char *topic, const char *value
switch(offContext)
{
case 0:
_publisher->publishString(mqtt_topic_lock_lock_action_context, "keypadBackKey", true);
break;
case 1:
_publisher->publishString(mqtt_topic_lock_lock_action_context, "keypadCode", true);
break;
case 2:
_publisher->publishString(mqtt_topic_lock_lock_action_context, "keypadFingerprint", true);
break;
default:
_publisher->publishString(mqtt_topic_lock_lock_action_context, "", true);
break;
case 0:
_publisher->publishString(mqtt_topic_lock_lock_action_context, "keypadBackKey", true);
break;
case 1:
_publisher->publishString(mqtt_topic_lock_lock_action_context, "keypadCode", true);
break;
case 2:
_publisher->publishString(mqtt_topic_lock_lock_action_context, "keypadFingerprint", true);
break;
default:
_publisher->publishString(mqtt_topic_lock_lock_action_context, "", true);
break;
}
}
else
{
_authId = offAuthId;
switch(offTrigger)
{
case 0:
if (offContext == 1)
{
_publisher->publishString(mqtt_topic_lock_lock_action_context, "autoUnlock", true);
}
else
{
_publisher->publishString(mqtt_topic_lock_lock_action_context, "", true);
}
break;
case 2:
if (offContext > 0)
{
_publisher->publishString(mqtt_topic_lock_lock_action_context, String("button") + String(offContext) + "press", true);
}
else
{
_publisher->publishString(mqtt_topic_lock_lock_action_context, "", true);
}
break;
case 3:
if (offContext > 0)
{
_publisher->publishString(mqtt_topic_lock_lock_action_context, String("fob") + String(offContext) + "press", true);
}
else
{
_publisher->publishString(mqtt_topic_lock_lock_action_context, "", true);
}
break;
default:
case 0:
if (offContext == 1)
{
_publisher->publishString(mqtt_topic_lock_lock_action_context, "autoUnlock", true);
}
else
{
_publisher->publishString(mqtt_topic_lock_lock_action_context, "", true);
break;
}
break;
case 2:
if (offContext > 0)
{
_publisher->publishString(mqtt_topic_lock_lock_action_context, String("button") + String(offContext) + "press", true);
}
else
{
_publisher->publishString(mqtt_topic_lock_lock_action_context, "", true);
}
break;
case 3:
if (offContext > 0)
{
_publisher->publishString(mqtt_topic_lock_lock_action_context, String("fob") + String(offContext) + "press", true);
}
else
{
_publisher->publishString(mqtt_topic_lock_lock_action_context, "", true);
}
break;
default:
_publisher->publishString(mqtt_topic_lock_lock_action_context, "", true);
break;
}
}
_hasAuthId = true;

View File

@@ -80,9 +80,9 @@ void NukiOpenerWrapper::readSettings()
if(pwrLvl >= 9)
{
#if defined(CONFIG_IDF_TARGET_ESP32)
#if defined(CONFIG_IDF_TARGET_ESP32)
powerLevel = ESP_PWR_LVL_P9;
#else
#else
if(pwrLvl >= 20)
{
powerLevel = ESP_PWR_LVL_P20;
@@ -103,7 +103,7 @@ void NukiOpenerWrapper::readSettings()
{
powerLevel = ESP_PWR_LVL_P9;
}
#endif
#endif
}
else if(pwrLvl >= 6)
{
@@ -247,7 +247,8 @@ void NukiOpenerWrapper::update()
}
else
{
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(200 / portTICK_PERIOD_MS);
@@ -268,7 +269,8 @@ void NukiOpenerWrapper::update()
Log->print("No BLE beacon received from the opener for ");
Log->print((ts - lastReceivedBeaconTs) / 1000);
Log->println(" seconds, signalling to restart BLE controller.");
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(200 / portTICK_PERIOD_MS);
@@ -304,7 +306,8 @@ void NukiOpenerWrapper::update()
_network->publishRetry(std::to_string(retryCount + 1));
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(_retryDelay / portTICK_PERIOD_MS);
@@ -340,10 +343,11 @@ void NukiOpenerWrapper::update()
_nextLockStateUpdateTs = ts + _intervalLockstate * 1000;
_statusUpdated = updateKeyTurnerState();
_network->publishStatusUpdated(_statusUpdated);
if(_statusUpdated)
{
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(500 / portTICK_PERIOD_MS);
@@ -615,7 +619,8 @@ void NukiOpenerWrapper::updateBatteryState()
{
Log->print("Querying opener battery state: ");
result = _nukiOpener.requestBatteryReport(&_batteryReport);
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(250 / portTICK_PERIOD_MS);
@@ -790,7 +795,8 @@ void NukiOpenerWrapper::updateAuthData(bool retrieved)
if(result == Nuki::CmdResult::Success)
{
_waitAuthLogUpdateTs = espMillis() + 5000;
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(100 / portTICK_PERIOD_MS);
@@ -1020,7 +1026,8 @@ void NukiOpenerWrapper::updateAuth(bool retrieved)
{
Log->print("Querying opener authorization: ");
result = _nukiOpener.retrieveAuthorizationEntries(0, _preferences->getInt(preference_auth_max_entries, MAX_AUTH));
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(250 / portTICK_PERIOD_MS);
@@ -3062,7 +3069,8 @@ void NukiOpenerWrapper::onKeypadJsonCommandReceived(const char *value)
if(resultKp == Nuki::CmdResult::Success)
{
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(5000 / portTICK_PERIOD_MS);
@@ -3431,7 +3439,8 @@ void NukiOpenerWrapper::onTimeControlCommandReceived(const char *value)
if(resultTc == Nuki::CmdResult::Success)
{
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(5000 / portTICK_PERIOD_MS);
@@ -3890,7 +3899,8 @@ void NukiOpenerWrapper::onAuthCommandReceived(const char *value)
if(resultAuth == Nuki::CmdResult::Success)
{
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(5000 / portTICK_PERIOD_MS);

View File

@@ -85,9 +85,9 @@ void NukiWrapper::readSettings()
if(pwrLvl >= 9)
{
#if defined(CONFIG_IDF_TARGET_ESP32)
#if defined(CONFIG_IDF_TARGET_ESP32)
powerLevel = ESP_PWR_LVL_P9;
#else
#else
if(pwrLvl >= 20)
{
powerLevel = ESP_PWR_LVL_P20;
@@ -108,7 +108,7 @@ void NukiWrapper::readSettings()
{
powerLevel = ESP_PWR_LVL_P9;
}
#endif
#endif
}
else if(pwrLvl >= 6)
{
@@ -263,7 +263,8 @@ void NukiWrapper::update(bool reboot)
}
else
{
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(200 / portTICK_PERIOD_MS);
@@ -284,7 +285,8 @@ void NukiWrapper::update(bool reboot)
Log->print("No BLE beacon received from the lock for ");
Log->print((ts - lastReceivedBeaconTs) / 1000);
Log->println(" seconds, signalling to restart BLE controller.");
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(200 / portTICK_PERIOD_MS);
@@ -324,7 +326,8 @@ void NukiWrapper::update(bool reboot)
_network->publishRetry(std::to_string(retryCount + 1));
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(_retryDelay / portTICK_PERIOD_MS);
@@ -364,10 +367,11 @@ void NukiWrapper::update(bool reboot)
_nextLockStateUpdateTs = ts + _intervalLockstate * 1000;
_statusUpdated = updateKeyTurnerState();
_network->publishStatusUpdated(_statusUpdated);
if(_statusUpdated)
{
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(500 / portTICK_PERIOD_MS);
@@ -821,8 +825,10 @@ void NukiWrapper::updateDebug()
Log->print("Result: ");
Log->println(result);
count = 0;
while (count < 5) {
if (esp_task_wdt_status(NULL) == ESP_OK) {
while (count < 5)
{
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(1000 / portTICK_PERIOD_MS);
@@ -843,8 +849,10 @@ void NukiWrapper::updateDebug()
Log->println(result);
count = 0;
while (count < 15) {
if (esp_task_wdt_status(NULL) == ESP_OK) {
while (count < 15)
{
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(1000 / portTICK_PERIOD_MS);
@@ -865,8 +873,10 @@ void NukiWrapper::updateDebug()
Log->println(result);
count = 0;
while (count < 20) {
if (esp_task_wdt_status(NULL) == ESP_OK) {
while (count < 20)
{
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(1000 / portTICK_PERIOD_MS);
@@ -879,14 +889,14 @@ void NukiWrapper::updateDebug()
Log->print("WifiScan entries: ");
Log->println(wifiScanEntries.size());
Log->println("Debug command complete");
Log->println("Running debug command - getAccessoryInfo, type = 4");
result = (Nuki::CmdResult)-1;
result = _nukiLock.getAccessoryInfo(4);
Log->print("Result: ");
Log->println(result);
Log->println("Debug command complete");
Log->println("Running debug command - getAccessoryInfo, type = 5");
result = (Nuki::CmdResult)-1;
result = _nukiLock.getAccessoryInfo(5);
@@ -900,7 +910,7 @@ void NukiWrapper::updateDebug()
Log->print("Result: ");
Log->println(result);
Log->println("Debug command complete");
/*
CheckKeypadCode = 0x006E keypadCode (int), (nonce, PIN)
@@ -948,7 +958,8 @@ void NukiWrapper::updateAuthData(bool retrieved)
if(result == Nuki::CmdResult::Success)
{
_waitAuthLogUpdateTs = espMillis() + 5000;
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(100 / portTICK_PERIOD_MS);
@@ -1176,7 +1187,8 @@ void NukiWrapper::updateAuth(bool retrieved)
{
Log->print("Querying lock authorization: ");
result = _nukiLock.retrieveAuthorizationEntries(0, _preferences->getInt(preference_auth_max_entries, MAX_AUTH));
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(250 / portTICK_PERIOD_MS);
@@ -3312,7 +3324,8 @@ void NukiWrapper::onKeypadJsonCommandReceived(const char *value)
if(resultKp == Nuki::CmdResult::Success)
{
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(5000 / portTICK_PERIOD_MS);
@@ -3682,7 +3695,8 @@ void NukiWrapper::onTimeControlCommandReceived(const char *value)
if(resultTc == Nuki::CmdResult::Success)
{
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(5000 / portTICK_PERIOD_MS);
@@ -3901,7 +3915,8 @@ void NukiWrapper::onAuthCommandReceived(const char *value)
if(idExists)
{
result = _nukiLock.deleteAuthorizationEntry(authId);
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(250 / portTICK_PERIOD_MS);
@@ -4124,7 +4139,8 @@ void NukiWrapper::onAuthCommandReceived(const char *value)
}
result = _nukiLock.addAuthorizationEntry(entry);
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(250 / portTICK_PERIOD_MS);
@@ -4150,7 +4166,8 @@ void NukiWrapper::onAuthCommandReceived(const char *value)
if(resultAuth == Nuki::CmdResult::Success)
{
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(5000 / portTICK_PERIOD_MS);
@@ -4296,7 +4313,8 @@ void NukiWrapper::onAuthCommandReceived(const char *value)
}
result = _nukiLock.updateAuthorizationEntry(entry);
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(250 / portTICK_PERIOD_MS);
@@ -4411,7 +4429,8 @@ void NukiWrapper::readConfig()
{
++retryCount;
Log->println("Failed to retrieve lock config, retrying in 1s");
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(1000 / portTICK_PERIOD_MS);
@@ -4442,7 +4461,8 @@ void NukiWrapper::readAdvancedConfig()
{
++retryCount;
Log->println("Failed to retrieve lock advanced config, retrying in 1s");
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(1000 / portTICK_PERIOD_MS);
@@ -4457,9 +4477,9 @@ void NukiWrapper::readAdvancedConfig()
bool NukiWrapper::hasDoorSensor() const
{
return (_forceDoorsensor ||
_keyTurnerState.doorSensorState == Nuki::DoorSensorState::DoorClosed ||
_keyTurnerState.doorSensorState == Nuki::DoorSensorState::DoorOpened ||
_keyTurnerState.doorSensorState == Nuki::DoorSensorState::Calibrating);
_keyTurnerState.doorSensorState == Nuki::DoorSensorState::DoorClosed ||
_keyTurnerState.doorSensorState == Nuki::DoorSensorState::DoorOpened ||
_keyTurnerState.doorSensorState == Nuki::DoorSensorState::Calibrating);
}
const BLEAddress NukiWrapper::getBleAddress() const

View File

@@ -148,7 +148,7 @@ private:
uint _maxKeypadCodeCount = 0;
uint _maxTimeControlEntryCount = 0;
uint _maxAuthEntryCount = 0;
uint8_t _restartController = 0;
uint8_t _restartController = 0;
int _nrOfRetries = 0;
int _retryDelay = 0;
int _retryConfigCount = 0;

View File

@@ -189,9 +189,9 @@
inline void initPreferences(Preferences* preferences)
{
#ifdef NUKI_HUB_UPDATER
#ifdef NUKI_HUB_UPDATER
return;
#else
#else
bool firstStart = !preferences->getBool(preference_started_before);
if(firstStart)
@@ -283,7 +283,7 @@ inline void initPreferences(Preferences* preferences)
preferences->putInt(preference_cred_session_lifetime_totp, 3600);
preferences->putInt(preference_cred_session_lifetime_totp_remember, 720);
preferences->putInt(preference_cred_bypass_gpio_high, -1);
preferences->putInt(preference_cred_bypass_gpio_low, -1);
preferences->putInt(preference_cred_bypass_gpio_low, -1);
#ifndef CONFIG_IDF_TARGET_ESP32H2
WiFi.begin();
@@ -300,7 +300,10 @@ inline void initPreferences(Preferences* preferences)
Log->print("Current config version: ");
Log->println(NUKI_HUB_VERSION_INT);
if(lastConfigVer >= NUKI_HUB_VERSION_INT && lastConfigVer < 20000) return;
if(lastConfigVer >= NUKI_HUB_VERSION_INT && lastConfigVer < 20000)
{
return;
}
if (lastConfigVer < 834)
{
@@ -317,93 +320,93 @@ inline void initPreferences(Preferences* preferences)
switch(preferences->getInt(preference_access_level, 10))
{
case 0:
{
preferences->putBool(preference_keypad_control_enabled, true);
uint32_t aclPrefs[17] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
preferences->putBytes(preference_acl, (byte*)(&aclPrefs), sizeof(aclPrefs));
uint32_t basicLockConfigAclPrefs[16] = {0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0};
preferences->putBytes(preference_conf_lock_basic_acl, (byte*)(&basicLockConfigAclPrefs), sizeof(basicLockConfigAclPrefs));
uint32_t basicOpenerConfigAclPrefs[14] = {0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0};
preferences->putBytes(preference_conf_opener_basic_acl, (byte*)(&basicOpenerConfigAclPrefs), sizeof(basicOpenerConfigAclPrefs));
uint32_t advancedLockConfigAclPrefs[25] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0};
preferences->putBytes(preference_conf_lock_advanced_acl, (byte*)(&advancedLockConfigAclPrefs), sizeof(advancedLockConfigAclPrefs));
uint32_t advancedOpenerConfigAclPrefs[21] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0};
preferences->putBytes(preference_conf_opener_advanced_acl, (byte*)(&advancedOpenerConfigAclPrefs), sizeof(advancedOpenerConfigAclPrefs));
break;
}
case 1:
{
preferences->putBool(preference_keypad_control_enabled, false);
uint32_t aclPrefs[17] = {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0};
preferences->putBytes(preference_acl, (byte*)(&aclPrefs), sizeof(aclPrefs));
uint32_t basicLockConfigAclPrefs[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
preferences->putBytes(preference_conf_lock_basic_acl, (byte*)(&basicLockConfigAclPrefs), sizeof(basicLockConfigAclPrefs));
uint32_t basicOpenerConfigAclPrefs[14] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
preferences->putBytes(preference_conf_opener_basic_acl, (byte*)(&basicOpenerConfigAclPrefs), sizeof(basicOpenerConfigAclPrefs));
uint32_t advancedLockConfigAclPrefs[25] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
preferences->putBytes(preference_conf_lock_advanced_acl, (byte*)(&advancedLockConfigAclPrefs), sizeof(advancedLockConfigAclPrefs));
uint32_t advancedOpenerConfigAclPrefs[21] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
preferences->putBytes(preference_conf_opener_advanced_acl, (byte*)(&advancedOpenerConfigAclPrefs), sizeof(advancedOpenerConfigAclPrefs));
break;
}
case 2:
{
preferences->putBool(preference_keypad_control_enabled, false);
uint32_t aclPrefs[17] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
preferences->putBytes(preference_acl, (byte*)(&aclPrefs), sizeof(aclPrefs));
uint32_t basicLockConfigAclPrefs[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
preferences->putBytes(preference_conf_lock_basic_acl, (byte*)(&basicLockConfigAclPrefs), sizeof(basicLockConfigAclPrefs));
uint32_t basicOpenerConfigAclPrefs[14] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
preferences->putBytes(preference_conf_opener_basic_acl, (byte*)(&basicOpenerConfigAclPrefs), sizeof(basicOpenerConfigAclPrefs));
uint32_t advancedLockConfigAclPrefs[25] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
preferences->putBytes(preference_conf_lock_advanced_acl, (byte*)(&advancedLockConfigAclPrefs), sizeof(advancedLockConfigAclPrefs));
uint32_t advancedOpenerConfigAclPrefs[21] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
preferences->putBytes(preference_conf_opener_advanced_acl, (byte*)(&advancedOpenerConfigAclPrefs), sizeof(advancedOpenerConfigAclPrefs));
break;
}
case 3:
{
preferences->putBool(preference_keypad_control_enabled, false);
uint32_t aclPrefs[17] = {1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0};
preferences->putBytes(preference_acl, (byte*)(&aclPrefs), sizeof(aclPrefs));
uint32_t basicLockConfigAclPrefs[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
preferences->putBytes(preference_conf_lock_basic_acl, (byte*)(&basicLockConfigAclPrefs), sizeof(basicLockConfigAclPrefs));
uint32_t basicOpenerConfigAclPrefs[14] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
preferences->putBytes(preference_conf_opener_basic_acl, (byte*)(&basicOpenerConfigAclPrefs), sizeof(basicOpenerConfigAclPrefs));
uint32_t advancedLockConfigAclPrefs[25] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
preferences->putBytes(preference_conf_lock_advanced_acl, (byte*)(&advancedLockConfigAclPrefs), sizeof(advancedLockConfigAclPrefs));
uint32_t advancedOpenerConfigAclPrefs[21] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
preferences->putBytes(preference_conf_opener_advanced_acl, (byte*)(&advancedOpenerConfigAclPrefs), sizeof(advancedOpenerConfigAclPrefs));
break;
}
default:
{
preferences->putBool(preference_keypad_control_enabled, true);
uint32_t aclPrefs[17] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
preferences->putBytes(preference_acl, (byte*)(&aclPrefs), sizeof(aclPrefs));
uint32_t basicLockConfigAclPrefs[16] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
preferences->putBytes(preference_conf_lock_basic_acl, (byte*)(&basicLockConfigAclPrefs), sizeof(basicLockConfigAclPrefs));
uint32_t basicOpenerConfigAclPrefs[14] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
preferences->putBytes(preference_conf_opener_basic_acl, (byte*)(&basicOpenerConfigAclPrefs), sizeof(basicOpenerConfigAclPrefs));
uint32_t advancedLockConfigAclPrefs[25] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
preferences->putBytes(preference_conf_lock_advanced_acl, (byte*)(&advancedLockConfigAclPrefs), sizeof(advancedLockConfigAclPrefs));
uint32_t advancedOpenerConfigAclPrefs[21] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
preferences->putBytes(preference_conf_opener_advanced_acl, (byte*)(&advancedOpenerConfigAclPrefs), sizeof(advancedOpenerConfigAclPrefs));
break;
}
case 0:
{
preferences->putBool(preference_keypad_control_enabled, true);
uint32_t aclPrefs[17] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
preferences->putBytes(preference_acl, (byte*)(&aclPrefs), sizeof(aclPrefs));
uint32_t basicLockConfigAclPrefs[16] = {0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0};
preferences->putBytes(preference_conf_lock_basic_acl, (byte*)(&basicLockConfigAclPrefs), sizeof(basicLockConfigAclPrefs));
uint32_t basicOpenerConfigAclPrefs[14] = {0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0};
preferences->putBytes(preference_conf_opener_basic_acl, (byte*)(&basicOpenerConfigAclPrefs), sizeof(basicOpenerConfigAclPrefs));
uint32_t advancedLockConfigAclPrefs[25] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0};
preferences->putBytes(preference_conf_lock_advanced_acl, (byte*)(&advancedLockConfigAclPrefs), sizeof(advancedLockConfigAclPrefs));
uint32_t advancedOpenerConfigAclPrefs[21] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0};
preferences->putBytes(preference_conf_opener_advanced_acl, (byte*)(&advancedOpenerConfigAclPrefs), sizeof(advancedOpenerConfigAclPrefs));
break;
}
case 1:
{
preferences->putBool(preference_keypad_control_enabled, false);
uint32_t aclPrefs[17] = {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0};
preferences->putBytes(preference_acl, (byte*)(&aclPrefs), sizeof(aclPrefs));
uint32_t basicLockConfigAclPrefs[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
preferences->putBytes(preference_conf_lock_basic_acl, (byte*)(&basicLockConfigAclPrefs), sizeof(basicLockConfigAclPrefs));
uint32_t basicOpenerConfigAclPrefs[14] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
preferences->putBytes(preference_conf_opener_basic_acl, (byte*)(&basicOpenerConfigAclPrefs), sizeof(basicOpenerConfigAclPrefs));
uint32_t advancedLockConfigAclPrefs[25] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
preferences->putBytes(preference_conf_lock_advanced_acl, (byte*)(&advancedLockConfigAclPrefs), sizeof(advancedLockConfigAclPrefs));
uint32_t advancedOpenerConfigAclPrefs[21] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
preferences->putBytes(preference_conf_opener_advanced_acl, (byte*)(&advancedOpenerConfigAclPrefs), sizeof(advancedOpenerConfigAclPrefs));
break;
}
case 2:
{
preferences->putBool(preference_keypad_control_enabled, false);
uint32_t aclPrefs[17] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
preferences->putBytes(preference_acl, (byte*)(&aclPrefs), sizeof(aclPrefs));
uint32_t basicLockConfigAclPrefs[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
preferences->putBytes(preference_conf_lock_basic_acl, (byte*)(&basicLockConfigAclPrefs), sizeof(basicLockConfigAclPrefs));
uint32_t basicOpenerConfigAclPrefs[14] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
preferences->putBytes(preference_conf_opener_basic_acl, (byte*)(&basicOpenerConfigAclPrefs), sizeof(basicOpenerConfigAclPrefs));
uint32_t advancedLockConfigAclPrefs[25] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
preferences->putBytes(preference_conf_lock_advanced_acl, (byte*)(&advancedLockConfigAclPrefs), sizeof(advancedLockConfigAclPrefs));
uint32_t advancedOpenerConfigAclPrefs[21] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
preferences->putBytes(preference_conf_opener_advanced_acl, (byte*)(&advancedOpenerConfigAclPrefs), sizeof(advancedOpenerConfigAclPrefs));
break;
}
case 3:
{
preferences->putBool(preference_keypad_control_enabled, false);
uint32_t aclPrefs[17] = {1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0};
preferences->putBytes(preference_acl, (byte*)(&aclPrefs), sizeof(aclPrefs));
uint32_t basicLockConfigAclPrefs[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
preferences->putBytes(preference_conf_lock_basic_acl, (byte*)(&basicLockConfigAclPrefs), sizeof(basicLockConfigAclPrefs));
uint32_t basicOpenerConfigAclPrefs[14] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
preferences->putBytes(preference_conf_opener_basic_acl, (byte*)(&basicOpenerConfigAclPrefs), sizeof(basicOpenerConfigAclPrefs));
uint32_t advancedLockConfigAclPrefs[25] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
preferences->putBytes(preference_conf_lock_advanced_acl, (byte*)(&advancedLockConfigAclPrefs), sizeof(advancedLockConfigAclPrefs));
uint32_t advancedOpenerConfigAclPrefs[21] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
preferences->putBytes(preference_conf_opener_advanced_acl, (byte*)(&advancedOpenerConfigAclPrefs), sizeof(advancedOpenerConfigAclPrefs));
break;
}
default:
{
preferences->putBool(preference_keypad_control_enabled, true);
uint32_t aclPrefs[17] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
preferences->putBytes(preference_acl, (byte*)(&aclPrefs), sizeof(aclPrefs));
uint32_t basicLockConfigAclPrefs[16] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
preferences->putBytes(preference_conf_lock_basic_acl, (byte*)(&basicLockConfigAclPrefs), sizeof(basicLockConfigAclPrefs));
uint32_t basicOpenerConfigAclPrefs[14] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
preferences->putBytes(preference_conf_opener_basic_acl, (byte*)(&basicOpenerConfigAclPrefs), sizeof(basicOpenerConfigAclPrefs));
uint32_t advancedLockConfigAclPrefs[25] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
preferences->putBytes(preference_conf_lock_advanced_acl, (byte*)(&advancedLockConfigAclPrefs), sizeof(advancedLockConfigAclPrefs));
uint32_t advancedOpenerConfigAclPrefs[21] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
preferences->putBytes(preference_conf_opener_advanced_acl, (byte*)(&advancedOpenerConfigAclPrefs), sizeof(advancedOpenerConfigAclPrefs));
break;
}
}
}
if (lastConfigVer < 901)
{
Log->println("Migration 9.01");
#if defined(CONFIG_IDF_TARGET_ESP32S3)
#if defined(CONFIG_IDF_TARGET_ESP32S3)
if (preferences->getInt(preference_network_hardware) == 3)
{
preferences->putInt(preference_network_hardware, 10);
}
#endif
#endif
if (preferences->getInt(preference_network_hardware) == 2)
{
preferences->putInt(preference_network_hardware, 3);
@@ -429,13 +432,15 @@ inline void initPreferences(Preferences* preferences)
if (caLength > 1)
{
if (!SPIFFS.begin(true)) {
if (!SPIFFS.begin(true))
{
Log->println("SPIFFS Mount Failed");
}
else
{
File file = SPIFFS.open("/mqtt_ssl.ca", FILE_WRITE);
if (!file) {
if (!file)
{
Log->println("Failed to open /mqtt_ssl.ca for writing");
}
else
@@ -455,13 +460,15 @@ inline void initPreferences(Preferences* preferences)
if (crtLength > 1)
{
if (!SPIFFS.begin(true)) {
if (!SPIFFS.begin(true))
{
Log->println("SPIFFS Mount Failed");
}
else
{
File file = SPIFFS.open("/mqtt_ssl.crt", FILE_WRITE);
if (!file) {
if (!file)
{
Log->println("Failed to open /mqtt_ssl.crt for writing");
}
else
@@ -480,13 +487,15 @@ inline void initPreferences(Preferences* preferences)
if (keyLength > 1)
{
if (!SPIFFS.begin(true)) {
if (!SPIFFS.begin(true))
{
Log->println("SPIFFS Mount Failed");
}
else
{
File file = SPIFFS.open("/mqtt_ssl.key", FILE_WRITE);
if (!file) {
if (!file)
{
Log->println("Failed to open /mqtt_ssl.key for writing");
}
else
@@ -510,7 +519,7 @@ inline void initPreferences(Preferences* preferences)
restartEsp(RestartReason::OTACompleted);
}
}
#endif
#endif
}
class DebugPreferences
@@ -565,7 +574,7 @@ private:
preference_keypad_check_code_enabled, preference_disable_network_not_connected, preference_find_best_rssi, preference_cred_bypass_boot_btn_enabled,
preference_debug_connect, preference_debug_communication, preference_debug_readable_data, preference_debug_hex_data, preference_debug_command,
preference_lock_force_id, preference_lock_force_doorsensor, preference_lock_force_keypad, preference_opener_force_id, preference_opener_force_keypad, preference_mqtt_ssl_enabled,
preference_hybrid_reboot_on_disconnect, preference_lock_gemini_enabled, preference_enable_debug_mode, preference_cred_duo_enabled, preference_cred_duo_approval,
preference_hybrid_reboot_on_disconnect, preference_lock_gemini_enabled, preference_enable_debug_mode, preference_cred_duo_enabled, preference_cred_duo_approval,
preference_publish_config, preference_config_from_mqtt
};
std::vector<char*> _bytePrefs =

View File

@@ -69,62 +69,62 @@ inline static String getRestartReason()
{
switch(currentRestartReason)
{
case RestartReason::RequestedViaMqtt:
return "RequestedViaMqtt";
case RestartReason::RequestedViaWebServer:
return "RequestedViaWebServer";
case RestartReason::RequestedViaSerial:
return "RequestedViaSerial";
case RestartReason::ReconfigureWebServer:
return "ReconfigureWebServer";
case RestartReason::BLEError:
return "BLEError";
case RestartReason::BLEBeaconWatchdog:
return "BLEBeaconWatchdog";
case RestartReason::RestartOnDisconnectWatchdog:
return "RestartOnDisconnectWatchdog";
case RestartReason::RestartIntervalWatchdog:
return "RestartIntervalWatchdog";
case RestartReason::NetworkTimeoutWatchdog:
return "NetworkTimeoutWatchdog";
case RestartReason::WifiInitFailed:
return "WifiInitFailed";
case RestartReason::ReconfigureWifi:
return "ReconfigureWifi";
case RestartReason::ReconfigureETH:
return "ReconfigureETH";
case RestartReason::NetworkDeviceCriticalFailure:
return "NetworkDeviceCriticalFailure";
case RestartReason::NetworkDeviceCriticalFailureNoWifiFallback:
return "NetworkDeviceCriticalFailureNoWifiFallback";
case RestartReason::ConfigurationUpdated:
return "ConfigurationUpdated";
case RestartReason::GpioConfigurationUpdated:
return "GpioConfigurationUpdated";
case RestartReason::RestartTimer:
return "RestartTimer";
case RestartReason::OTACompleted:
return "OTACompleted";
case RestartReason::OTATimeout:
return "OTATimeout";
case RestartReason::OTAAborted:
return "OTAAborted";
case RestartReason::OTAUnknownState:
return "OTAUnknownState";
case RestartReason::OTAReboot:
return "RebootToOTA";
case RestartReason::ImportCompleted:
return "ConfigImportCompleted";
case RestartReason::DeviceUnpaired:
return "DeviceUnpaired";
case RestartReason::NukiHubReset:
return "NukiHubFactoryReset";
case RestartReason::DisableNetworkIfNotConnected:
return "NetworkDisabledOnNotConnected";
case RestartReason::NotApplicable:
return "NotApplicable";
default:
return "Unknown: " + restartReason;
case RestartReason::RequestedViaMqtt:
return "RequestedViaMqtt";
case RestartReason::RequestedViaWebServer:
return "RequestedViaWebServer";
case RestartReason::RequestedViaSerial:
return "RequestedViaSerial";
case RestartReason::ReconfigureWebServer:
return "ReconfigureWebServer";
case RestartReason::BLEError:
return "BLEError";
case RestartReason::BLEBeaconWatchdog:
return "BLEBeaconWatchdog";
case RestartReason::RestartOnDisconnectWatchdog:
return "RestartOnDisconnectWatchdog";
case RestartReason::RestartIntervalWatchdog:
return "RestartIntervalWatchdog";
case RestartReason::NetworkTimeoutWatchdog:
return "NetworkTimeoutWatchdog";
case RestartReason::WifiInitFailed:
return "WifiInitFailed";
case RestartReason::ReconfigureWifi:
return "ReconfigureWifi";
case RestartReason::ReconfigureETH:
return "ReconfigureETH";
case RestartReason::NetworkDeviceCriticalFailure:
return "NetworkDeviceCriticalFailure";
case RestartReason::NetworkDeviceCriticalFailureNoWifiFallback:
return "NetworkDeviceCriticalFailureNoWifiFallback";
case RestartReason::ConfigurationUpdated:
return "ConfigurationUpdated";
case RestartReason::GpioConfigurationUpdated:
return "GpioConfigurationUpdated";
case RestartReason::RestartTimer:
return "RestartTimer";
case RestartReason::OTACompleted:
return "OTACompleted";
case RestartReason::OTATimeout:
return "OTATimeout";
case RestartReason::OTAAborted:
return "OTAAborted";
case RestartReason::OTAUnknownState:
return "OTAUnknownState";
case RestartReason::OTAReboot:
return "RebootToOTA";
case RestartReason::ImportCompleted:
return "ConfigImportCompleted";
case RestartReason::DeviceUnpaired:
return "DeviceUnpaired";
case RestartReason::NukiHubReset:
return "NukiHubFactoryReset";
case RestartReason::DisableNetworkIfNotConnected:
return "NetworkDisabledOnNotConnected";
case RestartReason::NotApplicable:
return "NotApplicable";
default:
return "Unknown: " + restartReason;
}
}
@@ -133,30 +133,30 @@ inline static String getEspRestartReason()
esp_reset_reason_t reason = esp_reset_reason();
switch(reason)
{
case esp_reset_reason_t::ESP_RST_UNKNOWN:
return "ESP_RST_UNKNOWN: Reset reason can not be determined.";
case esp_reset_reason_t::ESP_RST_POWERON:
return "ESP_RST_POWERON: Reset due to power-on event.";
case esp_reset_reason_t::ESP_RST_EXT:
return "ESP_RST_EXT: Reset by external pin";
case esp_reset_reason_t::ESP_RST_SW:
return "ESP_RST_SW: Software reset via esp_restart.";
case esp_reset_reason_t::ESP_RST_PANIC:
return "ESP_RST_PANIC: Software reset due to exception/panic.";
case esp_reset_reason_t::ESP_RST_INT_WDT:
return "ESP_RST_INT_WDT: Reset (software or hardware) due to interrupt watchdog";
case esp_reset_reason_t::ESP_RST_TASK_WDT:
return "ESP_RST_TASK_WDT: Reset due to task watchdog.";
case esp_reset_reason_t::ESP_RST_WDT:
return "ESP_RST_WDT: Reset due to other watchdogs.";
case esp_reset_reason_t::ESP_RST_DEEPSLEEP:
return "ESP_RST_DEEPSLEEP: Reset after exiting deep sleep mode.";
case esp_reset_reason_t::ESP_RST_BROWNOUT:
return "ESP_RST_BROWNOUT: Brownout reset (software or hardware)";
case esp_reset_reason_t::ESP_RST_SDIO:
return "ESP_RST_SDIO: Reset over SDIO.";
default:
return "Unknown: " + (int)reason;
case esp_reset_reason_t::ESP_RST_UNKNOWN:
return "ESP_RST_UNKNOWN: Reset reason can not be determined.";
case esp_reset_reason_t::ESP_RST_POWERON:
return "ESP_RST_POWERON: Reset due to power-on event.";
case esp_reset_reason_t::ESP_RST_EXT:
return "ESP_RST_EXT: Reset by external pin";
case esp_reset_reason_t::ESP_RST_SW:
return "ESP_RST_SW: Software reset via esp_restart.";
case esp_reset_reason_t::ESP_RST_PANIC:
return "ESP_RST_PANIC: Software reset due to exception/panic.";
case esp_reset_reason_t::ESP_RST_INT_WDT:
return "ESP_RST_INT_WDT: Reset (software or hardware) due to interrupt watchdog";
case esp_reset_reason_t::ESP_RST_TASK_WDT:
return "ESP_RST_TASK_WDT: Reset due to task watchdog.";
case esp_reset_reason_t::ESP_RST_WDT:
return "ESP_RST_WDT: Reset due to other watchdogs.";
case esp_reset_reason_t::ESP_RST_DEEPSLEEP:
return "ESP_RST_DEEPSLEEP: Reset after exiting deep sleep mode.";
case esp_reset_reason_t::ESP_RST_BROWNOUT:
return "ESP_RST_BROWNOUT: Brownout reset (software or hardware)";
case esp_reset_reason_t::ESP_RST_SDIO:
return "ESP_RST_SDIO: Reset over SDIO.";
default:
return "Unknown: " + (int)reason;
}
}

View File

@@ -4,8 +4,8 @@
#include "hal/wdt_hal.h"
SerialReader::SerialReader(ImportExport *importExport, NukiNetwork* network)
: _importExport(importExport),
_network(network)
: _importExport(importExport),
_network(network)
{
}
@@ -16,7 +16,7 @@ void SerialReader::update()
wdt_hal_write_protect_disable(&rtc_wdt_ctx);
wdt_hal_feed(&rtc_wdt_ctx);
wdt_hal_write_protect_enable(&rtc_wdt_ctx);
if(Serial.available())
{
String line = Serial.readStringUntil('\n');

File diff suppressed because it is too large Load Diff

View File

@@ -42,18 +42,18 @@ extern TaskHandle_t networkTaskHandle;
class WebCfgServer
{
public:
#ifndef NUKI_HUB_UPDATER
#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
#else
WebCfgServer(NukiNetwork* network, Preferences* preferences, bool allowRestartToPortal, uint8_t partitionType, PsychicHttpServer* psychicServer, ImportExport* importExport);
#endif
#endif
~WebCfgServer() = default;
void initialize();
private:
#ifndef NUKI_HUB_UPDATER
#ifndef NUKI_HUB_UPDATER
esp_err_t sendSettings(PsychicRequest *request, PsychicResponse* resp, bool adminKey = false);
bool processArgs(PsychicRequest *request, PsychicResponse* resp, String& message);
bool processImport(PsychicRequest *request, PsychicResponse* resp, String& message);
@@ -70,9 +70,9 @@ private:
esp_err_t buildAdvancedConfigHtml(PsychicRequest *request, PsychicResponse* resp);
esp_err_t buildNukiConfigHtml(PsychicRequest *request, PsychicResponse* resp);
esp_err_t buildGpioConfigHtml(PsychicRequest *request, PsychicResponse* resp);
#ifndef CONFIG_IDF_TARGET_ESP32H2
#ifndef CONFIG_IDF_TARGET_ESP32H2
esp_err_t buildConfigureWifiHtml(PsychicRequest *request, PsychicResponse* resp);
#endif
#endif
esp_err_t buildInfoHtml(PsychicRequest *request, PsychicResponse* resp);
esp_err_t buildCustomNetworkConfigHtml(PsychicRequest *request, PsychicResponse* resp);
esp_err_t processUnpair(PsychicRequest *request, PsychicResponse* resp, bool opener);
@@ -85,12 +85,12 @@ private:
const std::vector<std::pair<String, String>> getNetworkDetectionOptions() const;
const std::vector<std::pair<String, String>> getGpioOptions() const;
const std::vector<std::pair<String, String>> getNetworkCustomPHYOptions() const;
#if defined(CONFIG_IDF_TARGET_ESP32) || defined(CONFIG_IDF_TARGET_ESP32P4)
#if defined(CONFIG_IDF_TARGET_ESP32) || defined(CONFIG_IDF_TARGET_ESP32P4)
const std::vector<std::pair<String, String>> getNetworkCustomCLKOptions() const;
#endif
#ifdef NUKI_HUB_HTTPS_SERVER
#endif
#ifdef NUKI_HUB_HTTPS_SERVER
void createSSLCertificate();
#endif
#endif
const String getPreselectionForGpio(const uint8_t& pin) const;
const String pinStateToString(const NukiPinState& value) const;
@@ -102,7 +102,7 @@ private:
bool _brokerConfigured = false;
bool _rebootRequired = false;
int _restartServicesRequired = 0;
#endif
#endif
std::vector<String> _ssidList;
std::vector<int> _rssiList;
@@ -135,11 +135,11 @@ private:
void waitAndProcess(const bool blocking, const uint32_t duration);
esp_err_t handleOtaUpload(PsychicRequest *request, const String& filename, uint64_t index, uint8_t *data, size_t len, bool final);
void printCheckBox(PsychicStreamResponse *response, const char* token, const char* description, const bool value, const char* htmlClass);
#ifndef CONFIG_IDF_TARGET_ESP32H2
#ifndef CONFIG_IDF_TARGET_ESP32H2
esp_err_t buildWifiConnectHtml(PsychicRequest *request, PsychicResponse* resp);
bool processWiFi(PsychicRequest *request, PsychicResponse* resp, String& message);
#endif
#endif
void printInputField(PsychicStreamResponse *response, const char* token, const char* description, const char* value, const size_t& maxLength, const char* args, const bool& isPassword = false, const bool& showLengthRestriction = false);
void printInputField(PsychicStreamResponse *response, const char* token, const char* description, const int value, size_t maxLength, const char* args);
@@ -147,7 +147,7 @@ private:
NukiNetwork* _network = nullptr;
Preferences* _preferences = nullptr;
ImportExport* _importExport;
char _credUser[31] = {0};
char _credPassword[31] = {0};
bool _allowRestartToPortal = false;

View File

@@ -1,17 +1,20 @@
#pragma once
// converted to char array by bin2array
const char stylecss[] = {
#include "webServerConstants/style.h"
const char stylecss[] =
{
#include "webServerConstants/style.h"
};
// converted to char array by bin2array
const uint8_t favicon_32x32[] = {
#include "webServerConstants/favicon-32x32.h"
const uint8_t favicon_32x32[] =
{
#include "webServerConstants/favicon-32x32.h"
};
#ifndef NUKI_HUB_UPDATER
const uint8_t WEBSERIAL_HTML[] = {
#include "webServerConstants/webSerial.h"
const uint8_t WEBSERIAL_HTML[] =
{
#include "webServerConstants/webSerial.h"
};
#endif

View File

@@ -17,6 +17,6 @@ enum class NetworkDeviceType
LilyGO_T_ETH_Lite_S3,
Waveshare_ESP32_P4_NANO,
Waveshare_ESP32_P4_Module_DEV_KIT,
ESP32_P4_Function_EV_Board,
ESP32_P4_Function_EV_Board,
CUSTOM
};

View File

@@ -157,11 +157,11 @@ void setReroute()
{
esp_log_set_vprintf(_log_vprintf);
#ifdef DEBUG_NUKIHUB
#ifdef DEBUG_NUKIHUB
esp_log_level_set("*", ESP_LOG_DEBUG);
esp_log_level_set("nvs", ESP_LOG_INFO);
esp_log_level_set("wifi", ESP_LOG_INFO);
#else
#else
/*
esp_log_level_set("*", ESP_LOG_NONE);
esp_log_level_set("httpd", ESP_LOG_ERROR);
@@ -175,7 +175,7 @@ void setReroute()
esp_log_level_set("nvs", ESP_LOG_ERROR);
esp_log_level_set("wifi", ESP_LOG_ERROR);
*/
#endif
#endif
if(preferences->getBool(preference_mqtt_log_enabled))
{
@@ -193,12 +193,12 @@ uint8_t checkPartition()
Log->println(running_partition->subtype);
#if !defined(CONFIG_IDF_TARGET_ESP32C5) && !defined(CONFIG_IDF_TARGET_ESP32P4)
#if !defined(CONFIG_IDF_TARGET_ESP32C5) && !defined(CONFIG_IDF_TARGET_ESP32P4)
if(running_partition->size == 1966080)
{
return 0; //OLD PARTITION TABLE
}
#endif
#endif
if(running_partition->subtype == ESP_PARTITION_SUBTYPE_APP_OTA_0)
{
@@ -210,69 +210,79 @@ uint8_t checkPartition()
}
}
void listDir(fs::FS &fs, const char *dirname, uint8_t levels) {
Serial.printf("Listing directory: %s\r\n", dirname);
void listDir(fs::FS &fs, const char *dirname, uint8_t levels)
{
Serial.printf("Listing directory: %s\r\n", dirname);
File root = fs.open(dirname);
if (!root) {
Serial.println("- failed to open directory");
return;
}
if (!root.isDirectory()) {
Serial.println(" - not a directory");
return;
}
File file = root.openNextFile();
while (file) {
if (file.isDirectory()) {
Serial.print(" DIR : ");
Serial.println(file.name());
if (levels) {
listDir(fs, file.path(), levels - 1);
}
} else {
Serial.print(" FILE: ");
Serial.print(file.name());
Serial.print("\tSIZE: ");
Serial.println(file.size());
}
if (file.size() > (int)(SPIFFS.totalBytes() * 0.4))
File root = fs.open(dirname);
if (!root)
{
SPIFFS.remove((String)"/" + file.name());
Serial.println("- failed to open directory");
return;
}
if (!root.isDirectory())
{
Serial.println(" - not a directory");
return;
}
file = root.openNextFile();
}
File file = root.openNextFile();
while (file)
{
if (file.isDirectory())
{
Serial.print(" DIR : ");
Serial.println(file.name());
if (levels)
{
listDir(fs, file.path(), levels - 1);
}
}
else
{
Serial.print(" FILE: ");
Serial.print(file.name());
Serial.print("\tSIZE: ");
Serial.println(file.size());
}
if (file.size() > (int)(SPIFFS.totalBytes() * 0.4))
{
SPIFFS.remove((String)"/" + file.name());
}
file = root.openNextFile();
}
}
void cbSyncTime(struct timeval *tv) {
Log->println("NTP time synced");
timeSynced = true;
void cbSyncTime(struct timeval *tv)
{
Log->println("NTP time synced");
timeSynced = true;
}
#ifndef NUKI_HUB_UPDATER
void startWebServer()
{
bool failed = true;
webSerialEnabled = preferences->getBool(preference_webserial_enabled, false);
if (!nuki_hub_https_server_enabled)
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
{
File file = SPIFFS.open("/http_ssl.crt");
if (!file || file.isDirectory()) {
if (!file || file.isDirectory())
{
Log->println("http_ssl.crt not found");
}
else
@@ -286,7 +296,7 @@ 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");
}
@@ -302,7 +312,8 @@ void startWebServer()
psychicServerRedirect = new PsychicHttpServer();
psychicServerRedirect->config.ctrl_port = 20424;
psychicServerRedirect->onNotFound([](PsychicRequest* request, PsychicResponse* response) {
psychicServerRedirect->onNotFound([](PsychicRequest* request, PsychicResponse* response)
{
String url = "https://" + request->host() + request->url();
if (preferences->getString(preference_https_fqdn, "") != "")
{
@@ -320,7 +331,8 @@ void startWebServer()
psychicSSLServer->config.stack_size = HTTPD_TASK_SIZE;
webCfgServerSSL = new WebCfgServer(nuki, nukiOpener, network, gpio, preferences, network->networkDeviceType() == NetworkDeviceType::WiFi, partitionType, psychicSSLServer, importExport);
webCfgServerSSL->initialize();
psychicSSLServer->onNotFound([](PsychicRequest* request, PsychicResponse* response) {
psychicSSLServer->onNotFound([](PsychicRequest* request, PsychicResponse* response)
{
return response->redirect("/");
});
psychicSSLServer->begin();
@@ -337,7 +349,8 @@ void startWebServer()
psychicServer->config.stack_size = HTTPD_TASK_SIZE;
webCfgServer = new WebCfgServer(nuki, nukiOpener, network, gpio, preferences, network->networkDeviceType() == NetworkDeviceType::WiFi, partitionType, psychicServer, importExport);
webCfgServer->initialize();
psychicServer->onNotFound([](PsychicRequest* request, PsychicResponse* response) {
psychicServer->onNotFound([](PsychicRequest* request, PsychicResponse* response)
{
return response->redirect("/");
});
psychicServer->begin();
@@ -439,7 +452,7 @@ void restartServices(bool reconnect)
nukiOpener = nullptr;
if (reconnect)
{
openerStarted = false;
openerStarted = false;
delete networkOpener;
networkOpener = nullptr;
}
@@ -456,13 +469,15 @@ void restartServices(bool reconnect)
Log->println("Scanner nulled from main");
}
if (BLEDevice::isInitialized()) {
if (BLEDevice::isInitialized())
{
Log->println("Deinit BLE device");
BLEDevice::deinit(false);
Log->println("Deinit BLE device done");
}
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(2000 / portTICK_PERIOD_MS);
@@ -508,7 +523,8 @@ void restartServices(bool reconnect)
}
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(2000 / portTICK_PERIOD_MS);
@@ -559,7 +575,8 @@ void networkTask(void *pvParameters)
}
#endif
network->update();
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(50 / portTICK_PERIOD_MS);
@@ -595,7 +612,7 @@ void networkTask(void *pvParameters)
if (restartServ == 1)
{
restartServices(false);
restartServices(false);
}
else if (restartServ == 2)
{
@@ -606,16 +623,18 @@ void networkTask(void *pvParameters)
if(connected && webSerialEnabled && (webSSLStarted || webStarted))
{
webCfgServerSSL->updateWebSerial();
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(50 / portTICK_PERIOD_MS);
}
if(connected && lockStarted)
{
rebootLock = networkLock->update();
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(50 / portTICK_PERIOD_MS);
@@ -624,7 +643,8 @@ void networkTask(void *pvParameters)
if(connected && openerStarted)
{
networkOpener->update();
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(50 / portTICK_PERIOD_MS);
@@ -649,8 +669,9 @@ void networkTask(void *pvParameters)
restartEsp(RestartReason::RestartTimer);
}
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(50 / portTICK_PERIOD_MS);
@@ -674,23 +695,26 @@ static void print_all_tasks_info(void)
Log->printf("\n--------------------------------------------------------------------------------\n");
Log->printf("PRINTING ALL TASKS INFO\n");
Log->printf("--------------------------------------------------------------------------------\n");
for (size_t task_idx = 0; task_idx < tasks_stat.task_count; task_idx++) {
for (size_t task_idx = 0; task_idx < tasks_stat.task_count; task_idx++)
{
task_stat_t task_stat = tasks_stat.stat_arr[task_idx];
Log->printf("%s: %s: Peak Usage %" PRIu16 ", Current Usage %" PRIu16 "\n", task_stat.name,
task_stat.is_alive ? "ALIVE " : "DELETED",
task_stat.overall_peak_usage,
task_stat.overall_current_usage);
task_stat.is_alive ? "ALIVE " : "DELETED",
task_stat.overall_peak_usage,
task_stat.overall_current_usage);
for (size_t heap_idx = 0; heap_idx < task_stat.heap_count; heap_idx++) {
for (size_t heap_idx = 0; heap_idx < task_stat.heap_count; heap_idx++)
{
heap_stat_t heap_stat = task_stat.heap_stat[heap_idx];
Log->printf(" %s: Caps: %" PRIu32 ". Size %" PRIu16 ", Current Usage %" PRIu16 ", Peak Usage %" PRIu16 ", alloc count %" PRIu16 "\n", heap_stat.name,
heap_stat.caps,
heap_stat.size,
heap_stat.current_usage,
heap_stat.peak_usage,
heap_stat.alloc_count);
heap_stat.caps,
heap_stat.size,
heap_stat.current_usage,
heap_stat.peak_usage,
heap_stat.alloc_count);
for (size_t alloc_idx = 0; alloc_idx < heap_stat.alloc_count; alloc_idx++) {
for (size_t alloc_idx = 0; alloc_idx < heap_stat.alloc_count; alloc_idx++)
{
heap_task_block_t alloc_stat = heap_stat.alloc_stat[alloc_idx];
Log->printf(" %p: Size: %" PRIu32 "\n", alloc_stat.address, alloc_stat.size);
}
@@ -704,25 +728,27 @@ static void print_all_tasks_info(void)
void nukiTask(void *pvParameters)
{
esp_task_wdt_add(NULL);
if (preferences->getBool(preference_mqtt_ssl_enabled, false))
{
#if defined(CONFIG_SOC_SPIRAM_SUPPORTED) && defined(CONFIG_SPIRAM)
#if defined(CONFIG_SOC_SPIRAM_SUPPORTED) && defined(CONFIG_SPIRAM)
if (esp_psram_get_size() <= 0)
{
Log->println("Waiting 20 seconds to start BLE because of MQTT SSL");
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(20000 / portTICK_PERIOD_MS);
}
#else
#else
Log->println("Waiting 20 seconds to start BLE because of MQTT SSL");
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(20000 / portTICK_PERIOD_MS);
#endif
#endif
}
int64_t nukiLoopTs = 0;
bool whiteListed = false;
@@ -733,17 +759,19 @@ void nukiTask(void *pvParameters)
if(bleScannerStarted)
{
bleScanner->update();
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(20 / portTICK_PERIOD_MS);
}
bool needsPairing = (lockStarted && !nuki->isPaired()) || (openerStarted && !nukiOpener->isPaired());
if (needsPairing)
{
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(2500 / portTICK_PERIOD_MS);
@@ -833,7 +861,8 @@ void nukiTask(void *pvParameters)
Log->println("nukiTask is running");
nukiLoopTs = espMillis();
}
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(50 / portTICK_PERIOD_MS);
@@ -886,30 +915,30 @@ esp_err_t _http_event_handler(esp_http_client_event_t *evt)
Log->println("");
switch (evt->event_id)
{
case HTTP_EVENT_ERROR:
Log->println("HTTP_EVENT_ERROR");
break;
case HTTP_EVENT_ON_CONNECTED:
Log->print("HTTP_EVENT_ON_CONNECTED");
break;
case HTTP_EVENT_HEADER_SENT:
Log->print("HTTP_EVENT_HEADER_SENT");
break;
case HTTP_EVENT_ON_HEADER:
Log->print("HTTP_EVENT_ON_HEADER");
break;
case HTTP_EVENT_ON_DATA:
Log->print("HTTP_EVENT_ON_DATA");
break;
case HTTP_EVENT_ON_FINISH:
Log->println("HTTP_EVENT_ON_FINISH");
break;
case HTTP_EVENT_DISCONNECTED:
Log->println("HTTP_EVENT_DISCONNECTED");
break;
case HTTP_EVENT_REDIRECT:
Log->print("HTTP_EVENT_REDIRECT");
break;
case HTTP_EVENT_ERROR:
Log->println("HTTP_EVENT_ERROR");
break;
case HTTP_EVENT_ON_CONNECTED:
Log->print("HTTP_EVENT_ON_CONNECTED");
break;
case HTTP_EVENT_HEADER_SENT:
Log->print("HTTP_EVENT_HEADER_SENT");
break;
case HTTP_EVENT_ON_HEADER:
Log->print("HTTP_EVENT_ON_HEADER");
break;
case HTTP_EVENT_ON_DATA:
Log->print("HTTP_EVENT_ON_DATA");
break;
case HTTP_EVENT_ON_FINISH:
Log->println("HTTP_EVENT_ON_FINISH");
break;
case HTTP_EVENT_DISCONNECTED:
Log->println("HTTP_EVENT_DISCONNECTED");
break;
case HTTP_EVENT_REDIRECT:
Log->print("HTTP_EVENT_REDIRECT");
break;
}
}
else
@@ -928,7 +957,7 @@ esp_err_t _http_event_handler(esp_http_client_event_t *evt)
void otaTask(void *pvParameter)
{
esp_task_wdt_add(NULL);
partitionType = checkPartition();
String updateUrl;
@@ -982,7 +1011,8 @@ void otaTask(void *pvParameter)
{
Log->println("Firmware upgrade failed, retrying in 5 seconds");
retryCount++;
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(5000 / portTICK_PERIOD_MS);
@@ -990,7 +1020,8 @@ void otaTask(void *pvParameter)
}
while (1)
{
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(1000 / portTICK_PERIOD_MS);
@@ -1040,7 +1071,8 @@ void setupTasks(bool ota)
void logCoreDump()
{
coredumpPrinted = false;
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(500 / portTICK_PERIOD_MS);
@@ -1066,7 +1098,8 @@ void logCoreDump()
else
{
file = SPIFFS.open("/coredump.hex", FILE_WRITE);
if (!file) {
if (!file)
{
Log->println("Failed to open /coredump.hex for writing");
}
else
@@ -1106,14 +1139,16 @@ void logCoreDump()
}
Serial.printf("%s", str_dst);
if (file) {
if (file)
{
file.printf("%s", str_dst);
}
}
Serial.println("");
if (file) {
if (file)
{
file.println("");
file.close();
}
@@ -1132,15 +1167,15 @@ void logCoreDump()
void setup()
{
#if defined(CONFIG_SOC_SPIRAM_SUPPORTED) && defined(CONFIG_SPIRAM)
#ifndef FORCE_NUKI_HUB_HTTPS_SERVER
#if defined(CONFIG_SOC_SPIRAM_SUPPORTED) && defined(CONFIG_SPIRAM)
#ifndef FORCE_NUKI_HUB_HTTPS_SERVER
if(esp_psram_get_size() <= 0)
{
nuki_hub_https_server_enabled = false;
}
#endif
#endif
#endif
#endif
//Set Log level to error for all TAGS
esp_log_level_set("*", ESP_LOG_ERROR);
//Set Log level to none for mqtt TAG
@@ -1149,13 +1184,13 @@ void setup()
Serial.begin(115200);
Log = &Serial;
#if !defined(NUKI_HUB_UPDATER) && !defined(CONFIG_IDF_TARGET_ESP32C5)
#if !defined(NUKI_HUB_UPDATER) && !defined(CONFIG_IDF_TARGET_ESP32C5)
stdout = funopen(NULL, NULL, &write_fn, NULL, NULL);
static char linebuf[1024];
setvbuf(stdout, linebuf, _IOLBF, sizeof(linebuf));
esp_rom_install_channel_putc(1, &ets_putc_handler);
//ets_install_putc1(&ets_putc_handler);
#endif
#endif
preferences = new Preferences();
preferences->begin("nukihub", false);
@@ -1165,7 +1200,7 @@ void setup()
if(esp_reset_reason() == esp_reset_reason_t::ESP_RST_PANIC ||
esp_reset_reason() == esp_reset_reason_t::ESP_RST_INT_WDT ||
esp_reset_reason() == esp_reset_reason_t::ESP_RST_TASK_WDT)
//|| esp_reset_reason() == esp_reset_reason_t::ESP_RST_WDT)
//|| esp_reset_reason() == esp_reset_reason_t::ESP_RST_WDT)
{
logCoreDump();
}
@@ -1221,18 +1256,21 @@ void setup()
{
bool failed = true;
if (!nuki_hub_https_server_enabled) {
if (!nuki_hub_https_server_enabled)
{
Log->println("Not running on HTTPS server enabled device");
}
else
{
if (!SPIFFS.begin(true)) {
if (!SPIFFS.begin(true))
{
Log->println("SPIFFS Mount Failed");
}
else
{
File file = SPIFFS.open("/http_ssl.crt");
if (!file || file.isDirectory()) {
if (!file || file.isDirectory())
{
Log->println("http_ssl.crt not found");
}
else
@@ -1246,7 +1284,8 @@ void setup()
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
@@ -1261,7 +1300,8 @@ void setup()
psychicServer = new PsychicHttpServer();
psychicServer->config.ctrl_port = 20424;
psychicServer->onNotFound([](PsychicRequest* request, PsychicResponse* response) {
psychicServer->onNotFound([](PsychicRequest* request, PsychicResponse* response)
{
String url = "https://" + request->host() + request->url();
if (preferences->getString(preference_https_fqdn, "") != "")
{
@@ -1279,7 +1319,8 @@ void setup()
psychicSSLServer->config.stack_size = HTTPD_TASK_SIZE;
webCfgServerSSL = new WebCfgServer(network, preferences, network->networkDeviceType() == NetworkDeviceType::WiFi, partitionType, psychicSSLServer, importExport);
webCfgServerSSL->initialize();
psychicSSLServer->onNotFound([](PsychicRequest* request, PsychicResponse* response) {
psychicSSLServer->onNotFound([](PsychicRequest* request, PsychicResponse* response)
{
return response->redirect("/");
});
psychicSSLServer->begin();
@@ -1296,7 +1337,8 @@ void setup()
psychicServer->config.stack_size = HTTPD_TASK_SIZE;
webCfgServer = new WebCfgServer(network, preferences, network->networkDeviceType() == NetworkDeviceType::WiFi, partitionType, psychicServer, importExport);
webCfgServer->initialize();
psychicServer->onNotFound([](PsychicRequest* request, PsychicResponse* response) {
psychicServer->onNotFound([](PsychicRequest* request, PsychicResponse* response)
{
return response->redirect("/");
});
psychicServer->begin();
@@ -1313,7 +1355,7 @@ void setup()
Log->println(NUKI_HUB_VERSION);
Log->print("Nuki Hub build ");
Log->println(NUKI_HUB_BUILD);
uint32_t devIdOpener = preferences->getUInt(preference_device_id_opener);
deviceIdLock = new NukiDeviceId(preferences, preference_device_id_lock);

View File

@@ -69,7 +69,8 @@ const String EthernetDevice::deviceName() const
void EthernetDevice::initialize()
{
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(250 / portTICK_PERIOD_MS);
@@ -79,7 +80,8 @@ void EthernetDevice::initialize()
Log->println("Failed to initialize ethernet hardware");
Log->println("Network device has a critical failure, enable fallback to Wi-Fi and reboot.");
wifiFallback = true;
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(200 / portTICK_PERIOD_MS);
@@ -108,11 +110,11 @@ void EthernetDevice::initialize()
// https://github.com/arendst/Tasmota/commit/f8fbe153000591727e40b5007e0de78c33833131
// https://github.com/arendst/Tasmota/commit/f8fbe153000591727e40b5007e0de78c33833131#diff-32fc0eefbf488dd507b3bef52189bbe37158737aba6f96fe98a8746dc5021955R417
uint32_t pkg_version = bootloader_common_get_chip_ver_pkg();
#if defined(CONFIG_SOC_SPIRAM_SUPPORTED) && defined(CONFIG_SPIRAM)
#if defined(CONFIG_SOC_SPIRAM_SUPPORTED) && defined(CONFIG_SPIRAM)
if(esp_psram_get_size() <= 0 && pkg_version <= 3)
#else
#else
if(pkg_version <= 3)
#endif
#endif
{
esp_gpio_revoke(0xFFFFFFFFFFFFFFFF);
}
@@ -147,7 +149,8 @@ void EthernetDevice::initialize()
Log->println("Failed to initialize ethernet hardware");
Log->println("Network device has a critical failure, enable fallback to Wi-Fi and reboot.");
wifiFallback = true;
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(200 / portTICK_PERIOD_MS);
@@ -232,7 +235,8 @@ void EthernetDevice::onNetworkEvent(arduino_event_id_t event, arduino_event_info
void EthernetDevice::reconfigure()
{
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(200 / portTICK_PERIOD_MS);

View File

@@ -17,28 +17,28 @@ class EthernetDevice : public NetworkDevice
public:
EthernetDevice(const String& hostname,
Preferences* preferences,
const IPConfiguration* ipConfiguration,
const std::string& deviceName,
uint8_t phy_addr = ETH_PHY_ADDR_LAN8720,
int power = ETH_PHY_POWER_LAN8720,
int mdc = ETH_PHY_MDC_LAN8720,
int mdio = ETH_PHY_MDIO_LAN8720,
eth_phy_type_t ethtype = ETH_PHY_TYPE_LAN8720,
eth_clock_mode_t clock_mode = ETH_CLK_MODE_LAN8720);
Preferences* preferences,
const IPConfiguration* ipConfiguration,
const std::string& deviceName,
uint8_t phy_addr = ETH_PHY_ADDR_LAN8720,
int power = ETH_PHY_POWER_LAN8720,
int mdc = ETH_PHY_MDC_LAN8720,
int mdio = ETH_PHY_MDIO_LAN8720,
eth_phy_type_t ethtype = ETH_PHY_TYPE_LAN8720,
eth_clock_mode_t clock_mode = ETH_CLK_MODE_LAN8720);
EthernetDevice(const String& hostname,
Preferences* preferences,
const IPConfiguration* ipConfiguration,
const std::string& deviceName,
uint8_t phy_addr,
int cs,
int irq,
int rst,
int spi_sck,
int spi_miso,
int spi_mosi,
eth_phy_type_t ethtype);
Preferences* preferences,
const IPConfiguration* ipConfiguration,
const std::string& deviceName,
uint8_t phy_addr,
int cs,
int irq,
int rst,
int spi_sck,
int spi_miso,
int spi_mosi,
eth_phy_type_t ethtype);
const String deviceName() const override;

View File

@@ -1,9 +1,10 @@
#pragma once
#if !defined(CONFIG_IDF_TARGET_ESP32) && !defined(CONFIG_IDF_TARGET_ESP32P4)
typedef enum {
typedef enum
{
ETH_CLOCK_GPIO0_IN = 0,
ETH_CLOCK_GPIO0_OUT = 1,
ETH_CLOCK_GPIO0_OUT = 1,
ETH_CLOCK_GPIO16_OUT = 2,
ETH_CLOCK_GPIO17_OUT = 3
} eth_clock_mode_t;

View File

@@ -11,15 +11,18 @@
void NetworkDevice::init()
{
_useEncryption = false;
if(_preferences->getBool(preference_mqtt_ssl_enabled, false)) {
if (!SPIFFS.begin(true)) {
if(_preferences->getBool(preference_mqtt_ssl_enabled, false))
{
if (!SPIFFS.begin(true))
{
Log->println("SPIFFS Mount Failed");
}
else
{
File file = SPIFFS.open("/mqtt_ssl.ca");
if (!file || file.isDirectory()) {
if (!file || file.isDirectory())
{
Log->println("mqtt_ssl.ca not found");
}
else
@@ -47,7 +50,8 @@ void NetworkDevice::init()
File file2 = SPIFFS.open("/mqtt_ssl.crt");
File file3 = SPIFFS.open("/mqtt_ssl.key");
if (!file2 || file2.isDirectory() || !file3 || file3.isDirectory()) {
if (!file2 || file2.isDirectory() || !file3 || file3.isDirectory())
{
Log->println("mqtt_ssl.crt or mqtt_ssl.key not found");
}
else

View File

@@ -9,9 +9,9 @@ class NetworkDevice
{
public:
explicit NetworkDevice(const String& hostname, Preferences* preferences, const IPConfiguration* ipConfiguration)
: _hostname(hostname),
_preferences(preferences),
_ipConfiguration(ipConfiguration)
: _hostname(hostname),
_preferences(preferences),
_ipConfiguration(ipConfiguration)
{}
virtual const String deviceName() const = 0;
@@ -28,7 +28,7 @@ public:
virtual String localIP() = 0;
virtual String BSSIDstr() = 0;
#ifndef NUKI_HUB_UPDATER
#ifndef NUKI_HUB_UPDATER
virtual bool isEncrypted();
virtual bool mqttConnect();
virtual bool mqttDisconnect(bool force);
@@ -39,35 +39,35 @@ public:
virtual uint16_t mqttPublish(const char* topic, uint8_t qos, bool retain, const char* payload);
virtual uint16_t mqttPublish(const char* topic, uint8_t qos, bool retain, const uint8_t* payload, size_t length);
virtual uint16_t mqttSubscribe(const char* topic, uint8_t qos);
virtual void mqttSetServer(const char* host, uint16_t port);
virtual void mqttSetClientId(const char* clientId);
virtual void mqttSetCleanSession(bool cleanSession);
virtual void mqttSetKeepAlive(uint16_t keepAlive);
virtual void mqttSetWill(const char* topic, uint8_t qos, bool retain, const char* payload);
virtual void mqttSetCredentials(const char* username, const char* password);
virtual void mqttOnMessage(espMqttClientTypes::OnMessageCallback callback);
virtual void mqttOnConnect(espMqttClientTypes::OnConnectCallback callback);
virtual void mqttOnDisconnect(espMqttClientTypes::OnDisconnectCallback callback);
#endif
#endif
protected:
const IPConfiguration* _ipConfiguration = nullptr;
Preferences* _preferences = nullptr;
#ifndef NUKI_HUB_UPDATER
#ifndef NUKI_HUB_UPDATER
espMqttClient *_mqttClient = nullptr;
espMqttClientSecure *_mqttClientSecure = nullptr;
void init();
MqttClient *getMqttClient() const;
bool _useEncryption = false;
bool _mqttEnabled = true;
bool _mqttInternal = false;
char* _path;
#endif
#endif
const String _hostname;
};

View File

@@ -21,7 +21,8 @@ const String WifiDevice::deviceName() const
void WifiDevice::initialize()
{
if (_hostname != "fakep4forhosted") {
if (_hostname != "fakep4forhosted")
{
ssid = _preferences->getString(preference_wifi_ssid, "");
ssid.trim();
pass = _preferences->getString(preference_wifi_pass, "");
@@ -61,8 +62,10 @@ void WifiDevice::initialize()
WiFi.disconnect();
int loop = 0;
while (!_wifiClientStarted && loop < 50) {
if (esp_task_wdt_status(NULL) == ESP_OK) {
while (!_wifiClientStarted && loop < 50)
{
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(100 / portTICK_PERIOD_MS);
@@ -85,8 +88,10 @@ void WifiDevice::scan(bool passive, bool async)
}
int loop = 0;
while (!_wifiClientStarted && loop < 50) {
if (esp_task_wdt_status(NULL) == ESP_OK) {
while (!_wifiClientStarted && loop < 50)
{
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(100 / portTICK_PERIOD_MS);
@@ -122,12 +127,14 @@ void WifiDevice::openAP()
Log->println("Starting AP with SSID NukiHub and Password NukiHubESP32");
_startAP = false;
WiFi.mode(WIFI_AP);
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(500 / portTICK_PERIOD_MS);
WiFi.softAPsetHostname(_hostname.c_str());
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(500 / portTICK_PERIOD_MS);
@@ -142,8 +149,10 @@ void WifiDevice::openAP()
bool WifiDevice::connect()
{
int loop = 0;
while (!_wifiClientStarted && loop < 50) {
if (esp_task_wdt_status(NULL) == ESP_OK) {
while (!_wifiClientStarted && loop < 50)
{
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(100 / portTICK_PERIOD_MS);
@@ -210,8 +219,9 @@ bool WifiDevice::connect()
loop = 0;
while(!isConnected() && loop < 600)
{
Log->print(".");
if (esp_task_wdt_status(NULL) == ESP_OK) {
Log->print(".");
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(25 / portTICK_PERIOD_MS);
@@ -226,7 +236,8 @@ bool WifiDevice::connect()
if(_preferences->getBool(preference_restart_on_disconnect, false) && (espMillis() > 60000))
{
Log->println("Restart on disconnect watchdog triggered, rebooting");
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(100 / portTICK_PERIOD_MS);
@@ -253,7 +264,8 @@ void WifiDevice::reconfigure()
{
_preferences->putString(preference_wifi_ssid, "");
_preferences->putString(preference_wifi_pass, "");
if (esp_task_wdt_status(NULL) == ESP_OK) {
if (esp_task_wdt_status(NULL) == ESP_OK)
{
esp_task_wdt_reset();
}
vTaskDelay(200 / portTICK_PERIOD_MS);
@@ -305,9 +317,10 @@ bool WifiDevice::isApOpen()
void WifiDevice::onWifiEvent(const WiFiEvent_t &event, const WiFiEventInfo_t &info)
{
Log->printf("[WiFi-event] event: %d\n", event);
Log->printf("[WiFi-event] event: %d\n", event);
switch (event) {
switch (event)
{
case ARDUINO_EVENT_WIFI_READY:
Log->println("WiFi interface ready");
break;
@@ -404,5 +417,5 @@ void WifiDevice::onWifiEvent(const WiFiEvent_t &event, const WiFiEventInfo_t &in
break;
default:
break;
}
}
}

View File

@@ -21,7 +21,7 @@ public:
virtual bool isApOpen();
int8_t signalStrength() override;
String localIP() override;
String BSSIDstr() override;

View File

@@ -11,224 +11,224 @@
NetworkDevice *NetworkDeviceInstantiator::Create(NetworkDeviceType networkDeviceType, String hostname, Preferences *preferences, IPConfiguration *ipConfiguration)
{
NetworkDevice* device = nullptr;
#if defined(CONFIG_IDF_TARGET_ESP32P4)
#if defined(CONFIG_IDF_TARGET_ESP32P4)
bool fakedevice = true;
#endif
#endif
switch (networkDeviceType)
{
case NetworkDeviceType::W5500:
device = new EthernetDevice(hostname, preferences, ipConfiguration, "Generic W5500",
ETH_PHY_ADDR_W5500,
ETH_PHY_CS_GENERIC_W5500,
ETH_PHY_IRQ_GENERIC_W5500,
ETH_PHY_RST_GENERIC_W5500,
ETH_PHY_SPI_SCK_GENERIC_W5500,
ETH_PHY_SPI_MISO_GENERIC_W5500,
ETH_PHY_SPI_MOSI_GENERIC_W5500,
ETH_PHY_W5500);
break;
case NetworkDeviceType::W5500M5:
device = new EthernetDevice(hostname, preferences, ipConfiguration, "M5Stack Atom POE",
ETH_PHY_ADDR_W5500,
ETH_PHY_CS_M5_W5500,
ETH_PHY_IRQ_M5_W5500,
ETH_PHY_RST_M5_W5500,
ETH_PHY_SPI_SCK_M5_W5500,
ETH_PHY_SPI_MISO_M5_W5500,
ETH_PHY_SPI_MOSI_M5_W5500,
ETH_PHY_W5500);
break;
case NetworkDeviceType::W5500M5S3:
device = new EthernetDevice(hostname, preferences, ipConfiguration, "M5Stack Atom POE S3",
ETH_PHY_ADDR_W5500,
ETH_PHY_CS_M5_W5500_S3,
ETH_PHY_IRQ_M5_W5500,
ETH_PHY_RST_M5_W5500,
ETH_PHY_SPI_SCK_M5_W5500_S3,
ETH_PHY_SPI_MISO_M5_W5500_S3,
ETH_PHY_SPI_MOSI_M5_W5500_S3,
ETH_PHY_W5500);
break;
case NetworkDeviceType::Waveshare_ESP32_S3_ETH:
device = new EthernetDevice(hostname, preferences, ipConfiguration, "Waveshare ESP32-S3-ETH / ESP32-S3-ETH-POE",
ETH_ADDR_WAVESHARE_ESP32_S3_ETH,
ETH_PHY_SPI_CS_WAVESHARE_ESP32_S3_ETH,
ETH_PHY_SPI_IRQ_WAVESHARE_ESP32_S3_ETH,
ETH_PHY_SPI_RST_WAVESHARE_ESP32_S3_ETH,
ETH_PHY_SPI_SCK_WAVESHARE_ESP32_S3_ETH,
ETH_PHY_SPI_MISO_WAVESHARE_ESP32_S3_ETH,
ETH_PHY_SPI_MOSI_WAVESHARE_ESP32_S3_ETH,
ETH_PHY_W5500);
break;
case NetworkDeviceType::ETH01_Evo:
device = new EthernetDevice(hostname, preferences, ipConfiguration, "ETH01-Evo",
ETH_PHY_ADDR_ETH01EVO,
ETH_PHY_CS_ETH01EVO,
ETH_PHY_IRQ_ETH01EVO,
ETH_PHY_RST_ETH01EVO,
ETH_PHY_SPI_SCK_ETH01EVO,
ETH_PHY_SPI_MISO_ETH01EVO,
ETH_PHY_SPI_MOSI_ETH01EVO,
ETH_PHY_TYPE_DM9051);
break;
case NetworkDeviceType::LilyGO_T_ETH_ELite:
device = new EthernetDevice(hostname, preferences, ipConfiguration, "LilyGO T-ETH ELite",
ETH_PHY_ADDR_W5500,
ETH_PHY_CS_ELITE_W5500,
ETH_PHY_IRQ_ELITE_W5500,
ETH_PHY_RST_ELITE_W5500,
ETH_PHY_SPI_SCK_ELITE_W5500,
ETH_PHY_SPI_MISO_ELITE_W5500,
ETH_PHY_SPI_MOSI_ELITE_W5500,
ETH_PHY_W5500);
break;
case NetworkDeviceType::LilyGO_T_ETH_Lite_S3:
device = new EthernetDevice(hostname, preferences, ipConfiguration, "LilyGO T-ETH-Lite-ESP32S3",
ETH_PHY_ADDR_W5500,
ETH_PHY_CS_ETHLITES3_W5500,
ETH_PHY_IRQ_ETHLITES3_W5500,
ETH_PHY_RST_ETHLITES3_W5500,
ETH_PHY_SPI_SCK_ETHLITES3_W5500,
ETH_PHY_SPI_MISO_ETHLITES3_W5500,
ETH_PHY_SPI_MOSI_ETHLITES3_W5500,
ETH_PHY_W5500);
break;
#if defined(CONFIG_IDF_TARGET_ESP32P4)
case NetworkDeviceType::Waveshare_ESP32_P4_NANO:
device = new EthernetDevice(hostname, preferences, ipConfiguration, "Waveshare ESP32-P4-NANO",
1,
51,
31,
52,
ETH_PHY_IP101,
ETH_CLOCK_GPIO0_IN);
break;
case NetworkDeviceType::Waveshare_ESP32_P4_Module_DEV_KIT:
device = new EthernetDevice(hostname, preferences, ipConfiguration, "Waveshare ESP32-P4-Module-DEV-KIT",
1,
51,
31,
52,
ETH_PHY_IP101,
ETH_CLOCK_GPIO0_IN);
break;
case NetworkDeviceType::ESP32_P4_Function_EV_Board:
device = new EthernetDevice(hostname, preferences, ipConfiguration, "ESP32-P4-Function-EV-Board",
1,
51,
31,
52,
ETH_PHY_IP101,
ETH_CLOCK_GPIO0_IN);
break;
#endif
case NetworkDeviceType::CUSTOM:
case NetworkDeviceType::W5500:
device = new EthernetDevice(hostname, preferences, ipConfiguration, "Generic W5500",
ETH_PHY_ADDR_W5500,
ETH_PHY_CS_GENERIC_W5500,
ETH_PHY_IRQ_GENERIC_W5500,
ETH_PHY_RST_GENERIC_W5500,
ETH_PHY_SPI_SCK_GENERIC_W5500,
ETH_PHY_SPI_MISO_GENERIC_W5500,
ETH_PHY_SPI_MOSI_GENERIC_W5500,
ETH_PHY_W5500);
break;
case NetworkDeviceType::W5500M5:
device = new EthernetDevice(hostname, preferences, ipConfiguration, "M5Stack Atom POE",
ETH_PHY_ADDR_W5500,
ETH_PHY_CS_M5_W5500,
ETH_PHY_IRQ_M5_W5500,
ETH_PHY_RST_M5_W5500,
ETH_PHY_SPI_SCK_M5_W5500,
ETH_PHY_SPI_MISO_M5_W5500,
ETH_PHY_SPI_MOSI_M5_W5500,
ETH_PHY_W5500);
break;
case NetworkDeviceType::W5500M5S3:
device = new EthernetDevice(hostname, preferences, ipConfiguration, "M5Stack Atom POE S3",
ETH_PHY_ADDR_W5500,
ETH_PHY_CS_M5_W5500_S3,
ETH_PHY_IRQ_M5_W5500,
ETH_PHY_RST_M5_W5500,
ETH_PHY_SPI_SCK_M5_W5500_S3,
ETH_PHY_SPI_MISO_M5_W5500_S3,
ETH_PHY_SPI_MOSI_M5_W5500_S3,
ETH_PHY_W5500);
break;
case NetworkDeviceType::Waveshare_ESP32_S3_ETH:
device = new EthernetDevice(hostname, preferences, ipConfiguration, "Waveshare ESP32-S3-ETH / ESP32-S3-ETH-POE",
ETH_ADDR_WAVESHARE_ESP32_S3_ETH,
ETH_PHY_SPI_CS_WAVESHARE_ESP32_S3_ETH,
ETH_PHY_SPI_IRQ_WAVESHARE_ESP32_S3_ETH,
ETH_PHY_SPI_RST_WAVESHARE_ESP32_S3_ETH,
ETH_PHY_SPI_SCK_WAVESHARE_ESP32_S3_ETH,
ETH_PHY_SPI_MISO_WAVESHARE_ESP32_S3_ETH,
ETH_PHY_SPI_MOSI_WAVESHARE_ESP32_S3_ETH,
ETH_PHY_W5500);
break;
case NetworkDeviceType::ETH01_Evo:
device = new EthernetDevice(hostname, preferences, ipConfiguration, "ETH01-Evo",
ETH_PHY_ADDR_ETH01EVO,
ETH_PHY_CS_ETH01EVO,
ETH_PHY_IRQ_ETH01EVO,
ETH_PHY_RST_ETH01EVO,
ETH_PHY_SPI_SCK_ETH01EVO,
ETH_PHY_SPI_MISO_ETH01EVO,
ETH_PHY_SPI_MOSI_ETH01EVO,
ETH_PHY_TYPE_DM9051);
break;
case NetworkDeviceType::LilyGO_T_ETH_ELite:
device = new EthernetDevice(hostname, preferences, ipConfiguration, "LilyGO T-ETH ELite",
ETH_PHY_ADDR_W5500,
ETH_PHY_CS_ELITE_W5500,
ETH_PHY_IRQ_ELITE_W5500,
ETH_PHY_RST_ELITE_W5500,
ETH_PHY_SPI_SCK_ELITE_W5500,
ETH_PHY_SPI_MISO_ELITE_W5500,
ETH_PHY_SPI_MOSI_ELITE_W5500,
ETH_PHY_W5500);
break;
case NetworkDeviceType::LilyGO_T_ETH_Lite_S3:
device = new EthernetDevice(hostname, preferences, ipConfiguration, "LilyGO T-ETH-Lite-ESP32S3",
ETH_PHY_ADDR_W5500,
ETH_PHY_CS_ETHLITES3_W5500,
ETH_PHY_IRQ_ETHLITES3_W5500,
ETH_PHY_RST_ETHLITES3_W5500,
ETH_PHY_SPI_SCK_ETHLITES3_W5500,
ETH_PHY_SPI_MISO_ETHLITES3_W5500,
ETH_PHY_SPI_MOSI_ETHLITES3_W5500,
ETH_PHY_W5500);
break;
#if defined(CONFIG_IDF_TARGET_ESP32P4)
case NetworkDeviceType::Waveshare_ESP32_P4_NANO:
device = new EthernetDevice(hostname, preferences, ipConfiguration, "Waveshare ESP32-P4-NANO",
1,
51,
31,
52,
ETH_PHY_IP101,
ETH_CLOCK_GPIO0_IN);
break;
case NetworkDeviceType::Waveshare_ESP32_P4_Module_DEV_KIT:
device = new EthernetDevice(hostname, preferences, ipConfiguration, "Waveshare ESP32-P4-Module-DEV-KIT",
1,
51,
31,
52,
ETH_PHY_IP101,
ETH_CLOCK_GPIO0_IN);
break;
case NetworkDeviceType::ESP32_P4_Function_EV_Board:
device = new EthernetDevice(hostname, preferences, ipConfiguration, "ESP32-P4-Function-EV-Board",
1,
51,
31,
52,
ETH_PHY_IP101,
ETH_CLOCK_GPIO0_IN);
break;
#endif
case NetworkDeviceType::CUSTOM:
{
int custPHY = preferences->getInt(preference_network_custom_phy, 0);
if(custPHY >= 1 && custPHY <= 3)
{
int custPHY = preferences->getInt(preference_network_custom_phy, 0);
std::string custName;
eth_phy_type_t custEthtype;
if(custPHY >= 1 && custPHY <= 3)
switch(custPHY)
{
std::string custName;
eth_phy_type_t custEthtype;
switch(custPHY)
{
case 1:
custName = "Custom (W5500)";
custEthtype = ETH_PHY_W5500;
break;
case 2:
custName = "Custom (DN9051)";
custEthtype = ETH_PHY_DM9051;
break;
case 3:
custName = "Custom (KSZ8851SNL)";
custEthtype = ETH_PHY_KSZ8851;
break;
default:
custName = "Custom (W5500)";
custEthtype = ETH_PHY_W5500;
break;
}
device = new EthernetDevice(hostname, preferences, ipConfiguration, custName,
preferences->getInt(preference_network_custom_addr, -1),
preferences->getInt(preference_network_custom_cs, -1),
preferences->getInt(preference_network_custom_irq, -1),
preferences->getInt(preference_network_custom_rst, -1),
preferences->getInt(preference_network_custom_sck, -1),
preferences->getInt(preference_network_custom_miso, -1),
preferences->getInt(preference_network_custom_mosi, -1),
custEthtype);
case 1:
custName = "Custom (W5500)";
custEthtype = ETH_PHY_W5500;
break;
case 2:
custName = "Custom (DN9051)";
custEthtype = ETH_PHY_DM9051;
break;
case 3:
custName = "Custom (KSZ8851SNL)";
custEthtype = ETH_PHY_KSZ8851;
break;
default:
custName = "Custom (W5500)";
custEthtype = ETH_PHY_W5500;
break;
}
device = new EthernetDevice(hostname, preferences, ipConfiguration, custName,
preferences->getInt(preference_network_custom_addr, -1),
preferences->getInt(preference_network_custom_cs, -1),
preferences->getInt(preference_network_custom_irq, -1),
preferences->getInt(preference_network_custom_rst, -1),
preferences->getInt(preference_network_custom_sck, -1),
preferences->getInt(preference_network_custom_miso, -1),
preferences->getInt(preference_network_custom_mosi, -1),
custEthtype);
}
#if defined(CONFIG_IDF_TARGET_ESP32) || defined(CONFIG_IDF_TARGET_ESP32P4)
else if(custPHY >= 4 && custPHY <= 9)
{
int custCLKpref = preferences->getInt(preference_network_custom_clk, 0);
else if(custPHY >= 4 && custPHY <= 9)
{
int custCLKpref = preferences->getInt(preference_network_custom_clk, 0);
std::string custName = NetworkUtil::GetCustomEthernetDeviceName(custPHY);
eth_phy_type_t custEthtype = NetworkUtil::GetCustomEthernetType(custPHY);
eth_clock_mode_t custCLK = NetworkUtil::GetCustomClock(custCLKpref);
std::string custName = NetworkUtil::GetCustomEthernetDeviceName(custPHY);
eth_phy_type_t custEthtype = NetworkUtil::GetCustomEthernetType(custPHY);
eth_clock_mode_t custCLK = NetworkUtil::GetCustomClock(custCLKpref);
device = new EthernetDevice(hostname, preferences, ipConfiguration, custName,
preferences->getInt(preference_network_custom_addr, -1),
preferences->getInt(preference_network_custom_pwr, -1),
preferences->getInt(preference_network_custom_mdc, -1),
preferences->getInt(preference_network_custom_mdio, -1),
custEthtype,
custCLK);
}
device = new EthernetDevice(hostname, preferences, ipConfiguration, custName,
preferences->getInt(preference_network_custom_addr, -1),
preferences->getInt(preference_network_custom_pwr, -1),
preferences->getInt(preference_network_custom_mdc, -1),
preferences->getInt(preference_network_custom_mdio, -1),
custEthtype,
custCLK);
}
#endif
#ifndef CONFIG_IDF_TARGET_ESP32H2
else
{
device = new WifiDevice(hostname, preferences, ipConfiguration);
#if defined(CONFIG_IDF_TARGET_ESP32P4)
fakedevice = false;
#endif
}
else
{
device = new WifiDevice(hostname, preferences, ipConfiguration);
#if defined(CONFIG_IDF_TARGET_ESP32P4)
fakedevice = false;
#endif
}
break;
#endif
}
break;
#if defined(CONFIG_IDF_TARGET_ESP32)
case NetworkDeviceType::M5STACK_PoESP32_Unit:
device = new EthernetDevice(hostname, preferences, ipConfiguration, "M5STACK PoESP32 Unit",
ETH_PHY_ADDR_M5_POESP32,
ETH_PHY_POWER_M5_POESP32,
ETH_PHY_MDC_M5_POESP32,
ETH_PHY_MDIO_M5_POESP32,
ETH_CLK_MODE_M5_TYPE,
ETH_CLK_MODE_M5_POESP32);
break;
case NetworkDeviceType::Olimex_LAN8720:
device = new EthernetDevice(hostname, preferences, ipConfiguration, "Olimex (LAN8720)", ETH_PHY_ADDR_LAN8720, 12, ETH_PHY_MDC_LAN8720, ETH_PHY_MDIO_LAN8720, ETH_PHY_TYPE_LAN8720, ETH_CLOCK_GPIO17_OUT);
break;
case NetworkDeviceType::WT32_LAN8720:
device = new EthernetDevice(hostname, preferences, ipConfiguration, "WT32-ETH01", 1, 16);
break;
case NetworkDeviceType::GL_S10:
device = new EthernetDevice(hostname, preferences, ipConfiguration, "GL-S10", 1, 5, ETH_PHY_MDC_LAN8720, ETH_PHY_MDIO_LAN8720, ETH_PHY_IP101, ETH_CLOCK_GPIO0_IN);
break;
case NetworkDeviceType::LilyGO_T_ETH_POE:
device = new EthernetDevice(hostname, preferences, ipConfiguration, "LilyGO T-ETH-POE", 0, -1, ETH_PHY_MDC_LAN8720, ETH_PHY_MDIO_LAN8720, ETH_PHY_TYPE_LAN8720, ETH_CLOCK_GPIO17_OUT);
break;
case NetworkDeviceType::M5STACK_PoESP32_Unit:
device = new EthernetDevice(hostname, preferences, ipConfiguration, "M5STACK PoESP32 Unit",
ETH_PHY_ADDR_M5_POESP32,
ETH_PHY_POWER_M5_POESP32,
ETH_PHY_MDC_M5_POESP32,
ETH_PHY_MDIO_M5_POESP32,
ETH_CLK_MODE_M5_TYPE,
ETH_CLK_MODE_M5_POESP32);
break;
case NetworkDeviceType::Olimex_LAN8720:
device = new EthernetDevice(hostname, preferences, ipConfiguration, "Olimex (LAN8720)", ETH_PHY_ADDR_LAN8720, 12, ETH_PHY_MDC_LAN8720, ETH_PHY_MDIO_LAN8720, ETH_PHY_TYPE_LAN8720, ETH_CLOCK_GPIO17_OUT);
break;
case NetworkDeviceType::WT32_LAN8720:
device = new EthernetDevice(hostname, preferences, ipConfiguration, "WT32-ETH01", 1, 16);
break;
case NetworkDeviceType::GL_S10:
device = new EthernetDevice(hostname, preferences, ipConfiguration, "GL-S10", 1, 5, ETH_PHY_MDC_LAN8720, ETH_PHY_MDIO_LAN8720, ETH_PHY_IP101, ETH_CLOCK_GPIO0_IN);
break;
case NetworkDeviceType::LilyGO_T_ETH_POE:
device = new EthernetDevice(hostname, preferences, ipConfiguration, "LilyGO T-ETH-POE", 0, -1, ETH_PHY_MDC_LAN8720, ETH_PHY_MDIO_LAN8720, ETH_PHY_TYPE_LAN8720, ETH_CLOCK_GPIO17_OUT);
break;
#endif
#ifndef CONFIG_IDF_TARGET_ESP32H2
case NetworkDeviceType::WiFi:
device = new WifiDevice(hostname, preferences, ipConfiguration);
#if defined(CONFIG_IDF_TARGET_ESP32P4)
fakedevice = false;
#endif
break;
default:
device = new WifiDevice(hostname, preferences, ipConfiguration);
#if defined(CONFIG_IDF_TARGET_ESP32P4)
fakedevice = false;
#endif
break;
case NetworkDeviceType::WiFi:
device = new WifiDevice(hostname, preferences, ipConfiguration);
#if defined(CONFIG_IDF_TARGET_ESP32P4)
fakedevice = false;
#endif
break;
default:
device = new WifiDevice(hostname, preferences, ipConfiguration);
#if defined(CONFIG_IDF_TARGET_ESP32P4)
fakedevice = false;
#endif
break;
#else
default:
default:
device = new EthernetDevice(hostname, preferences, ipConfiguration, "Custom (W5500)",
preferences->getInt(preference_network_custom_addr, -1),
preferences->getInt(preference_network_custom_cs, -1),
@@ -242,8 +242,9 @@ NetworkDevice *NetworkDeviceInstantiator::Create(NetworkDeviceType networkDevice
#endif
}
#if defined(CONFIG_IDF_TARGET_ESP32P4)
if (fakedevice) {
#if defined(CONFIG_IDF_TARGET_ESP32P4)
if (fakedevice)
{
Log->println("Create dummy WiFi device for Hosted on P4");
NetworkDevice* device2 = nullptr;
device2 = new WifiDevice("fakep4forhosted", preferences, ipConfiguration);
@@ -251,7 +252,7 @@ NetworkDevice *NetworkDeviceInstantiator::Create(NetworkDeviceType networkDevice
delete device2;
device2 = NULL;
}
#endif
#endif
return device;
}

View File

@@ -43,7 +43,7 @@ NetworkDeviceType NetworkUtil::GetDeviceTypeFromPreference(int hardwareDetect, i
case 16:
return NetworkDeviceType::Waveshare_ESP32_P4_Module_DEV_KIT;
case 17:
return NetworkDeviceType::ESP32_P4_Function_EV_Board;
return NetworkDeviceType::ESP32_P4_Function_EV_Board;
default:
Log->println("Unknown hardware selected, falling back to Wi-Fi.");
return NetworkDeviceType::WiFi;

View File

@@ -25,100 +25,113 @@ SOFTWARE.
#include "SSLCert.hpp"
SSLCert::SSLCert(uint16_t certLength, uint16_t pkLength, String keyPEM, String certPEM):
_certLength(certLength),
_pkLength(pkLength),
_keyPEM(keyPEM),
_certPEM(certPEM) {
_certLength(certLength),
_pkLength(pkLength),
_keyPEM(keyPEM),
_certPEM(certPEM)
{
}
SSLCert::~SSLCert() {
// TODO Auto-generated destructor stub
SSLCert::~SSLCert()
{
// TODO Auto-generated destructor stub
}
uint16_t SSLCert::getCertLength() {
return _certLength;
uint16_t SSLCert::getCertLength()
{
return _certLength;
}
uint16_t SSLCert::getPKLength() {
return _pkLength;
uint16_t SSLCert::getPKLength()
{
return _pkLength;
}
String SSLCert::getKeyPEM() {
return _keyPEM;
String SSLCert::getKeyPEM()
{
return _keyPEM;
}
String SSLCert::getCertPEM() {
return _certPEM;
String SSLCert::getCertPEM()
{
return _certPEM;
}
void SSLCert::setPK(String keyPEM) {
_keyPEM = keyPEM;
_pkLength = keyPEM.length();
void SSLCert::setPK(String keyPEM)
{
_keyPEM = keyPEM;
_pkLength = keyPEM.length();
}
void SSLCert::setCert(String certPEM) {
_certPEM = certPEM;
_certLength = certPEM.length();
void SSLCert::setCert(String certPEM)
{
_certPEM = certPEM;
_certLength = certPEM.length();
}
void SSLCert::clear() {
_certLength = 0;
_pkLength = 0;
void SSLCert::clear()
{
_certLength = 0;
_pkLength = 0;
_keyPEM = "";
_certPEM = "";
_keyPEM = "";
_certPEM = "";
}
/**
* Returns the CN value from a DN, or "" if it cannot be found
*/
static std::string get_cn(std::string dn) {
size_t cnStart = dn.find("CN=");
if (cnStart == std::string::npos) {
return "";
}
cnStart += 3;
size_t cnStop = dn.find(",", cnStart);
if (cnStop == std::string::npos) {
cnStop = dn.length();
}
return dn.substr(cnStart, cnStop - cnStart);
static std::string get_cn(std::string dn)
{
size_t cnStart = dn.find("CN=");
if (cnStart == std::string::npos)
{
return "";
}
cnStart += 3;
size_t cnStop = dn.find(",", cnStart);
if (cnStop == std::string::npos)
{
cnStop = dn.length();
}
return dn.substr(cnStart, cnStop - cnStart);
}
/**
* Sets the DN as subjectAltName extension in the certificate
*/
static int add_subject_alt_name(mbedtls_x509write_cert *crt, std::string &cn) {
size_t bufsize = cn.length() + 8; // some additional space for tags and length fields
uint8_t buf[bufsize];
uint8_t *p = &buf[bufsize - 1];
uint8_t *start = buf;
int length = 0;
int ret; // used by MBEDTLS macro
static int add_subject_alt_name(mbedtls_x509write_cert *crt, std::string &cn)
{
size_t bufsize = cn.length() + 8; // some additional space for tags and length fields
uint8_t buf[bufsize];
uint8_t *p = &buf[bufsize - 1];
uint8_t *start = buf;
int length = 0;
int ret; // used by MBEDTLS macro
// The ASN structure that we will construct as parameter for write_crt_set_extension is as follows:
// | 0x30 = Sequence | length | 0x82 = dNSName, context-specific | length | cn0 | cn1 | cn2 | cn3 | .. | cnn |
// ↑ : ↑ `-------------v------------------´:
// | : `-------------------´ :
// | `----------v------------------------------------------------------------------´
// `---------------´
// Let's encrypt has useful infos: https://letsencrypt.org/docs/a-warm-welcome-to-asn1-and-der/#choice-and-any-encoding
MBEDTLS_ASN1_CHK_ADD(length,
mbedtls_asn1_write_raw_buffer(&p, start, (uint8_t*)cn.c_str(), cn.length()));
MBEDTLS_ASN1_CHK_ADD(length,
mbedtls_asn1_write_len(&p, start, length));
MBEDTLS_ASN1_CHK_ADD(length,
mbedtls_asn1_write_tag(&p, start, MBEDTLS_ASN1_CONTEXT_SPECIFIC | 0x02)); // 0x02 = dNSName
MBEDTLS_ASN1_CHK_ADD(length,
mbedtls_asn1_write_len(&p, start, length));
MBEDTLS_ASN1_CHK_ADD(length,
mbedtls_asn1_write_tag(&p, start, MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ));
return mbedtls_x509write_crt_set_extension( crt,
MBEDTLS_OID_SUBJECT_ALT_NAME, MBEDTLS_OID_SIZE(MBEDTLS_OID_SUBJECT_ALT_NAME),
0, // not critical
p, length);
// The ASN structure that we will construct as parameter for write_crt_set_extension is as follows:
// | 0x30 = Sequence | length | 0x82 = dNSName, context-specific | length | cn0 | cn1 | cn2 | cn3 | .. | cnn |
// ↑ : ↑ `-------------v------------------´:
// | : `-------------------´ :
// | `----------v------------------------------------------------------------------´
// `---------------´
// Let's encrypt has useful infos: https://letsencrypt.org/docs/a-warm-welcome-to-asn1-and-der/#choice-and-any-encoding
MBEDTLS_ASN1_CHK_ADD(length,
mbedtls_asn1_write_raw_buffer(&p, start, (uint8_t*)cn.c_str(), cn.length()));
MBEDTLS_ASN1_CHK_ADD(length,
mbedtls_asn1_write_len(&p, start, length));
MBEDTLS_ASN1_CHK_ADD(length,
mbedtls_asn1_write_tag(&p, start, MBEDTLS_ASN1_CONTEXT_SPECIFIC | 0x02)); // 0x02 = dNSName
MBEDTLS_ASN1_CHK_ADD(length,
mbedtls_asn1_write_len(&p, start, length));
MBEDTLS_ASN1_CHK_ADD(length,
mbedtls_asn1_write_tag(&p, start, MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ));
return mbedtls_x509write_crt_set_extension( crt,
MBEDTLS_OID_SUBJECT_ALT_NAME, MBEDTLS_OID_SIZE(MBEDTLS_OID_SUBJECT_ALT_NAME),
0, // not critical
p, length);
}
/**
@@ -128,78 +141,84 @@ static int add_subject_alt_name(mbedtls_x509write_cert *crt, std::string &cn) {
*
* Based on programs/pkey/gen_key.c
*/
static int gen_key(SSLCert &certCtx, SSLKeySize keySize) {
static int gen_key(SSLCert &certCtx, SSLKeySize keySize)
{
// Initialize the entropy source
mbedtls_entropy_context entropy;
mbedtls_entropy_init( &entropy );
// Initialize the entropy source
mbedtls_entropy_context entropy;
mbedtls_entropy_init( &entropy );
// Initialize the RNG
mbedtls_ctr_drbg_context ctr_drbg;
mbedtls_ctr_drbg_init( &ctr_drbg );
int rngRes = mbedtls_ctr_drbg_seed(
&ctr_drbg, mbedtls_entropy_func, &entropy,
NULL, 0
);
if (rngRes != 0) {
mbedtls_entropy_free( &entropy );
return HTTPS_SERVER_ERROR_KEYGEN_RNG;
}
// Initialize the RNG
mbedtls_ctr_drbg_context ctr_drbg;
mbedtls_ctr_drbg_init( &ctr_drbg );
int rngRes = mbedtls_ctr_drbg_seed(
&ctr_drbg, mbedtls_entropy_func, &entropy,
NULL, 0
);
if (rngRes != 0)
{
mbedtls_entropy_free( &entropy );
return HTTPS_SERVER_ERROR_KEYGEN_RNG;
}
// Initialize the private key
mbedtls_pk_context key;
mbedtls_pk_init( &key );
int resPkSetup = mbedtls_pk_setup( &key, mbedtls_pk_info_from_type( MBEDTLS_PK_RSA ) );
if ( resPkSetup != 0) {
// Initialize the private key
mbedtls_pk_context key;
mbedtls_pk_init( &key );
int resPkSetup = mbedtls_pk_setup( &key, mbedtls_pk_info_from_type( MBEDTLS_PK_RSA ) );
if ( resPkSetup != 0)
{
mbedtls_ctr_drbg_free( &ctr_drbg );
mbedtls_entropy_free( &entropy );
return HTTPS_SERVER_ERROR_KEYGEN_SETUP_PK;
}
// Actual key generation
int resPkGen = mbedtls_rsa_gen_key(
mbedtls_pk_rsa( key ),
mbedtls_ctr_drbg_random,
&ctr_drbg,
keySize,
65537
);
if ( resPkGen != 0)
{
mbedtls_pk_free( &key );
mbedtls_ctr_drbg_free( &ctr_drbg );
mbedtls_entropy_free( &entropy );
return HTTPS_SERVER_ERROR_KEYGEN_GEN_PK;
}
// Free the entropy source and the RNG as they are no longer needed
mbedtls_ctr_drbg_free( &ctr_drbg );
mbedtls_entropy_free( &entropy );
return HTTPS_SERVER_ERROR_KEYGEN_SETUP_PK;
}
// Actual key generation
int resPkGen = mbedtls_rsa_gen_key(
mbedtls_pk_rsa( key ),
mbedtls_ctr_drbg_random,
&ctr_drbg,
keySize,
65537
);
if ( resPkGen != 0) {
// Allocate the space on the heap, as stack size is quite limited
unsigned char * output_buf = new unsigned char[4096];
if (output_buf == NULL)
{
mbedtls_pk_free( &key );
return HTTPS_SERVER_ERROR_KEY_OUT_OF_MEM;
}
memset(output_buf, 0, 4096);
// Write the key to the temporary buffer and determine its length
int resPkWrite = mbedtls_pk_write_key_pem( &key, output_buf, 4096 );
if (resPkWrite < 0)
{
delete[] output_buf;
mbedtls_pk_free( &key );
return HTTPS_SERVER_ERROR_KEY_WRITE_PK;
}
// Clean up the temporary buffer and clear the key context
mbedtls_pk_free( &key );
mbedtls_ctr_drbg_free( &ctr_drbg );
mbedtls_entropy_free( &entropy );
return HTTPS_SERVER_ERROR_KEYGEN_GEN_PK;
}
// Free the entropy source and the RNG as they are no longer needed
mbedtls_ctr_drbg_free( &ctr_drbg );
mbedtls_entropy_free( &entropy );
// Set the private key in the context
certCtx.setPK((char*)output_buf);
// Allocate the space on the heap, as stack size is quite limited
unsigned char * output_buf = new unsigned char[4096];
if (output_buf == NULL) {
mbedtls_pk_free( &key );
return HTTPS_SERVER_ERROR_KEY_OUT_OF_MEM;
}
memset(output_buf, 0, 4096);
// Write the key to the temporary buffer and determine its length
int resPkWrite = mbedtls_pk_write_key_pem( &key, output_buf, 4096 );
if (resPkWrite < 0) {
delete[] output_buf;
mbedtls_pk_free( &key );
return HTTPS_SERVER_ERROR_KEY_WRITE_PK;
}
// Clean up the temporary buffer and clear the key context
mbedtls_pk_free( &key );
// Set the private key in the context
certCtx.setPK((char*)output_buf);
delete[] output_buf;
return 0;
return 0;
}
static int parse_serial_decimal_format(unsigned char *obuf, size_t obufmax,
@@ -214,21 +233,25 @@ static int parse_serial_decimal_format(unsigned char *obuf, size_t obufmax,
errno = 0;
dec = strtoull(ibuf, &end_ptr, 10);
if ((errno != 0) || (end_ptr == ibuf)) {
if ((errno != 0) || (end_ptr == ibuf))
{
return -1;
}
*len = 0;
while (remaining_bytes > 0) {
if (obufmax < (*len + 1)) {
while (remaining_bytes > 0)
{
if (obufmax < (*len + 1))
{
return -1;
}
val = (dec >> ((remaining_bytes - 1) * 8)) & 0xFF;
/* Skip leading zeros */
if ((val != 0) || (*len != 0)) {
if ((val != 0) || (*len != 0))
{
*p = val;
(*len)++;
p++;
@@ -248,150 +271,165 @@ static int parse_serial_decimal_format(unsigned char *obuf, size_t obufmax,
* Based on programs/x509/cert_write.c
*/
static int cert_write(SSLCert &certCtx, std::string dn, std::string validityFrom, std::string validityTo) {
int funcRes = 0;
int stepRes = 0;
static int cert_write(SSLCert &certCtx, std::string dn, std::string validityFrom, std::string validityTo)
{
int funcRes = 0;
int stepRes = 0;
mbedtls_entropy_context entropy;
mbedtls_ctr_drbg_context ctr_drbg;
mbedtls_pk_context key;
mbedtls_x509write_cert crt;
unsigned char * primary_buffer;
unsigned char *certOffset;
unsigned char * output_buffer;
size_t certLength;
const char *serial = "peer";
size_t serial_len;
mbedtls_entropy_context entropy;
mbedtls_ctr_drbg_context ctr_drbg;
mbedtls_pk_context key;
mbedtls_x509write_cert crt;
unsigned char * primary_buffer;
unsigned char *certOffset;
unsigned char * output_buffer;
size_t certLength;
const char *serial = "peer";
size_t serial_len;
// Make a C-friendly version of the distinguished name
char dn_cstr[dn.length()+1];
strcpy(dn_cstr, dn.c_str());
// Make a C-friendly version of the distinguished name
char dn_cstr[dn.length()+1];
strcpy(dn_cstr, dn.c_str());
std::string cn = get_cn(dn);
if (cn == "") {
return HTTPS_SERVER_ERROR_CERTGEN_CN;
}
std::string cn = get_cn(dn);
if (cn == "")
{
return HTTPS_SERVER_ERROR_CERTGEN_CN;
}
// Initialize the entropy source
mbedtls_entropy_init( &entropy );
// Initialize the entropy source
mbedtls_entropy_init( &entropy );
// Initialize the RNG
mbedtls_ctr_drbg_init( &ctr_drbg );
stepRes = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy, NULL, 0 );
if (stepRes != 0) {
funcRes = HTTPS_SERVER_ERROR_CERTGEN_RNG;
goto error_after_entropy;
}
// Initialize the RNG
mbedtls_ctr_drbg_init( &ctr_drbg );
stepRes = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy, NULL, 0 );
if (stepRes != 0)
{
funcRes = HTTPS_SERVER_ERROR_CERTGEN_RNG;
goto error_after_entropy;
}
mbedtls_pk_init( &key );
mbedtls_pk_init( &key );
stepRes = mbedtls_pk_parse_key( &key, (const unsigned char *)certCtx.getKeyPEM().c_str(), certCtx.getPKLength() + 1, NULL, 0, mbedtls_ctr_drbg_random, &ctr_drbg);
if (stepRes != 0) {
funcRes = HTTPS_SERVER_ERROR_CERTGEN_READKEY;
goto error_after_key;
}
stepRes = mbedtls_pk_parse_key( &key, (const unsigned char *)certCtx.getKeyPEM().c_str(), certCtx.getPKLength() + 1, NULL, 0, mbedtls_ctr_drbg_random, &ctr_drbg);
if (stepRes != 0)
{
funcRes = HTTPS_SERVER_ERROR_CERTGEN_READKEY;
goto error_after_key;
}
// Start configuring the certificate
mbedtls_x509write_crt_init( &crt );
// Set version and hash algorithm
mbedtls_x509write_crt_set_version( &crt, MBEDTLS_X509_CRT_VERSION_3 );
mbedtls_x509write_crt_set_md_alg( &crt, MBEDTLS_MD_SHA256 );
// Start configuring the certificate
mbedtls_x509write_crt_init( &crt );
// Set version and hash algorithm
mbedtls_x509write_crt_set_version( &crt, MBEDTLS_X509_CRT_VERSION_3 );
mbedtls_x509write_crt_set_md_alg( &crt, MBEDTLS_MD_SHA256 );
// Set the keys (same key as we self-sign)
mbedtls_x509write_crt_set_subject_key( &crt, &key );
mbedtls_x509write_crt_set_issuer_key( &crt, &key );
// Set the keys (same key as we self-sign)
mbedtls_x509write_crt_set_subject_key( &crt, &key );
mbedtls_x509write_crt_set_issuer_key( &crt, &key );
// Set issuer and subject (same, as we self-sign)
stepRes = mbedtls_x509write_crt_set_subject_name( &crt, dn_cstr );
if (stepRes != 0) {
funcRes = HTTPS_SERVER_ERROR_CERTGEN_NAME;
goto error_after_cert;
}
stepRes = mbedtls_x509write_crt_set_issuer_name( &crt, dn_cstr );
if (stepRes != 0) {
funcRes = HTTPS_SERVER_ERROR_CERTGEN_NAME;
goto error_after_cert;
}
// Set issuer and subject (same, as we self-sign)
stepRes = mbedtls_x509write_crt_set_subject_name( &crt, dn_cstr );
if (stepRes != 0)
{
funcRes = HTTPS_SERVER_ERROR_CERTGEN_NAME;
goto error_after_cert;
}
stepRes = mbedtls_x509write_crt_set_issuer_name( &crt, dn_cstr );
if (stepRes != 0)
{
funcRes = HTTPS_SERVER_ERROR_CERTGEN_NAME;
goto error_after_cert;
}
// Set the validity of the certificate. At the moment, it's fixed from 2019 to end of 2029.
stepRes = mbedtls_x509write_crt_set_validity( &crt, validityFrom.c_str(), validityTo.c_str());
if (stepRes != 0) {
funcRes = HTTPS_SERVER_ERROR_CERTGEN_VALIDITY;
goto error_after_cert;
}
// Set the validity of the certificate. At the moment, it's fixed from 2019 to end of 2029.
stepRes = mbedtls_x509write_crt_set_validity( &crt, validityFrom.c_str(), validityTo.c_str());
if (stepRes != 0)
{
funcRes = HTTPS_SERVER_ERROR_CERTGEN_VALIDITY;
goto error_after_cert;
}
// Make this a CA certificate
stepRes = mbedtls_x509write_crt_set_basic_constraints( &crt, 1, 0 );
if (stepRes != 0) {
funcRes = HTTPS_SERVER_ERROR_CERTGEN_VALIDITY;
goto error_after_cert;
}
// Make this a CA certificate
stepRes = mbedtls_x509write_crt_set_basic_constraints( &crt, 1, 0 );
if (stepRes != 0)
{
funcRes = HTTPS_SERVER_ERROR_CERTGEN_VALIDITY;
goto error_after_cert;
}
stepRes = add_subject_alt_name( &crt, cn );
if (stepRes != 0) {
funcRes = HTTPS_SERVER_ERROR_CERTGEN_NAME;
goto error_after_cert;
}
stepRes = add_subject_alt_name( &crt, cn );
if (stepRes != 0)
{
funcRes = HTTPS_SERVER_ERROR_CERTGEN_NAME;
goto error_after_cert;
}
// Initialize the serial number
stepRes = mbedtls_x509write_crt_set_serial_raw( &crt, (unsigned char *)serial, strlen(serial) );
if (stepRes != 0) {
funcRes = HTTPS_SERVER_ERROR_CERTGEN_SERIAL;
goto error_after_cert_serial;
}
// Initialize the serial number
stepRes = mbedtls_x509write_crt_set_serial_raw( &crt, (unsigned char *)serial, strlen(serial) );
if (stepRes != 0)
{
funcRes = HTTPS_SERVER_ERROR_CERTGEN_SERIAL;
goto error_after_cert_serial;
}
// Create buffer to write the certificate
primary_buffer = new unsigned char[4096];
if (primary_buffer == NULL) {
funcRes = HTTPS_SERVER_ERROR_CERTGEN_OUT_OF_MEM;
goto error_after_cert_serial;
}
// Create buffer to write the certificate
primary_buffer = new unsigned char[4096];
if (primary_buffer == NULL)
{
funcRes = HTTPS_SERVER_ERROR_CERTGEN_OUT_OF_MEM;
goto error_after_cert_serial;
}
// Write the actual certificate
stepRes = mbedtls_x509write_crt_pem(&crt, primary_buffer, 4096, mbedtls_ctr_drbg_random, &ctr_drbg );
if (stepRes < 0) {
funcRes = HTTPS_SERVER_ERROR_CERTGEN_WRITE;
goto error_after_primary_buffer;
}
// Write the actual certificate
stepRes = mbedtls_x509write_crt_pem(&crt, primary_buffer, 4096, mbedtls_ctr_drbg_random, &ctr_drbg );
if (stepRes < 0)
{
funcRes = HTTPS_SERVER_ERROR_CERTGEN_WRITE;
goto error_after_primary_buffer;
}
// Configure the cert in the context
certCtx.setCert((char*)primary_buffer);
// Configure the cert in the context
certCtx.setCert((char*)primary_buffer);
// Run through the cleanup process
// Run through the cleanup process
error_after_primary_buffer:
delete[] primary_buffer;
delete[] primary_buffer;
error_after_cert_serial:
error_after_cert:
mbedtls_x509write_crt_free( &crt );
mbedtls_x509write_crt_free( &crt );
error_after_key:
mbedtls_pk_free(&key);
mbedtls_pk_free(&key);
error_after_entropy:
mbedtls_ctr_drbg_free( &ctr_drbg );
mbedtls_entropy_free( &entropy );
return funcRes;
mbedtls_ctr_drbg_free( &ctr_drbg );
mbedtls_entropy_free( &entropy );
return funcRes;
}
int createSelfSignedCert(SSLCert &certCtx, SSLKeySize keySize, std::string dn, std::string validFrom, std::string validUntil) {
int createSelfSignedCert(SSLCert &certCtx, SSLKeySize keySize, std::string dn, std::string validFrom, std::string validUntil)
{
// Add the private key
int keyRes = gen_key(certCtx, keySize);
if (keyRes != 0) {
// Key-generation failed, return the failure code
return keyRes;
}
// Add the private key
int keyRes = gen_key(certCtx, keySize);
if (keyRes != 0)
{
// Key-generation failed, return the failure code
return keyRes;
}
// Add the self-signed certificate
int certRes = cert_write(certCtx, dn, validFrom, validUntil);
if (certRes != 0) {
// Cert writing failed, reset the pk and return failure code
certCtx.setPK("");
return certRes;
}
// Add the self-signed certificate
int certRes = cert_write(certCtx, dn, validFrom, validUntil);
if (certRes != 0)
{
// Cert writing failed, reset the pk and return failure code
certCtx.setPK("");
return certRes;
}
// If all went well, return 0
return 0;
// If all went well, return 0
return 0;
}

View File

@@ -1,363 +1,344 @@
0x2f, 0x2a, 0x0d, 0x0a, 0x65, 0x73, 0x63, 0x61, 0x70, 0x65, 0x64, 0x20, 0x62, 0x79, 0x20, 0x68,
0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x63, 0x65, 0x73, 0x63, 0x61,
0x70, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x0d, 0x0a, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65,
0x3a, 0x20, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x63, 0x64, 0x6e, 0x2e, 0x6a, 0x73,
0x64, 0x65, 0x6c, 0x69, 0x76, 0x72, 0x2e, 0x6e, 0x65, 0x74, 0x2f, 0x6e, 0x70, 0x6d, 0x2f, 0x40,
0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x64, 0x65, 0x76, 0x2f, 0x6e, 0x65, 0x77, 0x2e, 0x63,
0x73, 0x73, 0x40, 0x31, 0x2e, 0x31, 0x2e, 0x32, 0x2f, 0x6e, 0x65, 0x77, 0x2e, 0x6d, 0x69, 0x6e,
0x2e, 0x63, 0x73, 0x73, 0x0d, 0x0a, 0x2a, 0x2f, 0x0d, 0x0a, 0x0d, 0x0a, 0x2f, 0x2a, 0x0d, 0x0a,
0x20, 0x2a, 0x20, 0x55, 0x73, 0x61, 0x67, 0x65, 0x3a, 0x0d, 0x0a, 0x20, 0x2a, 0x20, 0x43, 0x6f,
0x6d, 0x70, 0x61, 0x63, 0x74, 0x20, 0x2f, 0x20, 0x6d, 0x69, 0x6e, 0x69, 0x66, 0x79, 0x20, 0x74,
0x68, 0x69, 0x73, 0x20, 0x63, 0x6f, 0x64, 0x65, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x61, 0x6e,
0x79, 0x20, 0x74, 0x6f, 0x6f, 0x6c, 0x0d, 0x0a, 0x20, 0x2a, 0x20, 0x43, 0x6f, 0x70, 0x79, 0x20,
0x6f, 0x6e, 0x65, 0x2d, 0x6c, 0x69, 0x6e, 0x65, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x20,
0x74, 0x6f, 0x20, 0x73, 0x72, 0x63, 0x2f, 0x57, 0x65, 0x62, 0x43, 0x66, 0x67, 0x53, 0x65, 0x72,
0x76, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x73, 0x2e, 0x68, 0x20, 0x61,
0x73, 0x20, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x63, 0x73, 0x73, 0x0d, 0x0a, 0x20, 0x2a, 0x20, 0x54,
0x4f, 0x44, 0x4f, 0x3a, 0x20, 0x61, 0x75, 0x74, 0x6f, 0x6d, 0x61, 0x74, 0x65, 0x20, 0x74, 0x68,
0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x20, 0x75, 0x70, 0x6f, 0x6e, 0x20,
0x62, 0x75, 0x69, 0x6c, 0x64, 0x69, 0x6e, 0x67, 0x20, 0x3a, 0x29, 0x0d, 0x0a, 0x2a, 0x2f, 0x0d,
0x0a, 0x0d, 0x0a, 0x3a, 0x72, 0x6f, 0x6f, 0x74, 0x20, 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x61, 0x6e, 0x73, 0x3a, 0x20,
0x27, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x27, 0x2c, 0x2d, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2d, 0x73,
0x79, 0x73, 0x74, 0x65, 0x6d, 0x2c, 0x42, 0x6c, 0x69, 0x6e, 0x6b, 0x4d, 0x61, 0x63, 0x53, 0x79,
0x73, 0x74, 0x65, 0x6d, 0x46, 0x6f, 0x6e, 0x74, 0x2c, 0x27, 0x53, 0x65, 0x67, 0x6f, 0x65, 0x20,
0x55, 0x49, 0x27, 0x2c, 0x52, 0x6f, 0x62, 0x6f, 0x74, 0x6f, 0x2c, 0x4f, 0x78, 0x79, 0x67, 0x65,
0x6e, 0x2c, 0x55, 0x62, 0x75, 0x6e, 0x74, 0x75, 0x2c, 0x43, 0x61, 0x6e, 0x74, 0x61, 0x72, 0x65,
0x6c, 0x6c, 0x2c, 0x27, 0x4f, 0x70, 0x65, 0x6e, 0x20, 0x53, 0x61, 0x6e, 0x73, 0x27, 0x2c, 0x27,
0x48, 0x65, 0x6c, 0x76, 0x65, 0x74, 0x69, 0x63, 0x61, 0x20, 0x4e, 0x65, 0x75, 0x65, 0x27, 0x2c,
0x73, 0x61, 0x6e, 0x73, 0x2d, 0x73, 0x65, 0x72, 0x69, 0x66, 0x2c, 0x27, 0x41, 0x70, 0x70, 0x6c,
0x65, 0x20, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x45, 0x6d, 0x6f, 0x6a, 0x69, 0x27, 0x2c, 0x27,
0x53, 0x65, 0x67, 0x6f, 0x65, 0x20, 0x55, 0x49, 0x20, 0x45, 0x6d, 0x6f, 0x6a, 0x69, 0x27, 0x2c,
0x27, 0x53, 0x65, 0x67, 0x6f, 0x65, 0x20, 0x55, 0x49, 0x20, 0x53, 0x79, 0x6d, 0x62, 0x6f, 0x6c,
0x27, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x66, 0x6f, 0x6e,
0x74, 0x2d, 0x6d, 0x6f, 0x6e, 0x6f, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x61, 0x73,
0x2c, 0x6d, 0x6f, 0x6e, 0x61, 0x63, 0x6f, 0x2c, 0x27, 0x55, 0x62, 0x75, 0x6e, 0x74, 0x75, 0x20,
0x4d, 0x6f, 0x6e, 0x6f, 0x27, 0x2c, 0x27, 0x4c, 0x69, 0x62, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f,
0x6e, 0x20, 0x4d, 0x6f, 0x6e, 0x6f, 0x27, 0x2c, 0x27, 0x43, 0x6f, 0x75, 0x72, 0x69, 0x65, 0x72,
0x20, 0x4e, 0x65, 0x77, 0x27, 0x2c, 0x43, 0x6f, 0x75, 0x72, 0x69, 0x65, 0x72, 0x2c, 0x6d, 0x6f,
0x6e, 0x6f, 0x73, 0x70, 0x61, 0x63, 0x65, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x2d,
0x6e, 0x63, 0x2d, 0x74, 0x78, 0x2d, 0x31, 0x3a, 0x20, 0x23, 0x30, 0x30, 0x30, 0x3b, 0x0d, 0x0a,
0x2f, 0x2a, 0x0a, 0x65, 0x73, 0x63, 0x61, 0x70, 0x65, 0x64, 0x20, 0x62, 0x79, 0x20, 0x68, 0x74,
0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x63, 0x65, 0x73, 0x63, 0x61, 0x70,
0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x0a, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x3a, 0x20,
0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x63, 0x64, 0x6e, 0x2e, 0x6a, 0x73, 0x64, 0x65,
0x6c, 0x69, 0x76, 0x72, 0x2e, 0x6e, 0x65, 0x74, 0x2f, 0x6e, 0x70, 0x6d, 0x2f, 0x40, 0x65, 0x78,
0x61, 0x6d, 0x70, 0x6c, 0x65, 0x64, 0x65, 0x76, 0x2f, 0x6e, 0x65, 0x77, 0x2e, 0x63, 0x73, 0x73,
0x40, 0x31, 0x2e, 0x31, 0x2e, 0x32, 0x2f, 0x6e, 0x65, 0x77, 0x2e, 0x6d, 0x69, 0x6e, 0x2e, 0x63,
0x73, 0x73, 0x0a, 0x2a, 0x2f, 0x0a, 0x0a, 0x2f, 0x2a, 0x0a, 0x20, 0x2a, 0x20, 0x55, 0x73, 0x61,
0x67, 0x65, 0x3a, 0x0a, 0x20, 0x2a, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x63, 0x74, 0x20, 0x2f,
0x20, 0x6d, 0x69, 0x6e, 0x69, 0x66, 0x79, 0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 0x63, 0x6f, 0x64,
0x65, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x61, 0x6e, 0x79, 0x20, 0x74, 0x6f, 0x6f, 0x6c, 0x0a,
0x20, 0x2a, 0x20, 0x43, 0x6f, 0x70, 0x79, 0x20, 0x6f, 0x6e, 0x65, 0x2d, 0x6c, 0x69, 0x6e, 0x65,
0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x20, 0x74, 0x6f, 0x20, 0x73, 0x72, 0x63, 0x2f, 0x57,
0x65, 0x62, 0x43, 0x66, 0x67, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x73, 0x74,
0x61, 0x6e, 0x74, 0x73, 0x2e, 0x68, 0x20, 0x61, 0x73, 0x20, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x63,
0x73, 0x73, 0x0a, 0x20, 0x2a, 0x20, 0x54, 0x4f, 0x44, 0x4f, 0x3a, 0x20, 0x61, 0x75, 0x74, 0x6f,
0x6d, 0x61, 0x74, 0x65, 0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73,
0x73, 0x20, 0x75, 0x70, 0x6f, 0x6e, 0x20, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x69, 0x6e, 0x67, 0x20,
0x3a, 0x29, 0x0a, 0x2a, 0x2f, 0x0a, 0x0a, 0x3a, 0x72, 0x6f, 0x6f, 0x74, 0x20, 0x7b, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x61, 0x6e,
0x73, 0x3a, 0x20, 0x27, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x27, 0x2c, 0x2d, 0x61, 0x70, 0x70, 0x6c,
0x65, 0x2d, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2c, 0x42, 0x6c, 0x69, 0x6e, 0x6b, 0x4d, 0x61,
0x63, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x46, 0x6f, 0x6e, 0x74, 0x2c, 0x27, 0x53, 0x65, 0x67,
0x6f, 0x65, 0x20, 0x55, 0x49, 0x27, 0x2c, 0x52, 0x6f, 0x62, 0x6f, 0x74, 0x6f, 0x2c, 0x4f, 0x78,
0x79, 0x67, 0x65, 0x6e, 0x2c, 0x55, 0x62, 0x75, 0x6e, 0x74, 0x75, 0x2c, 0x43, 0x61, 0x6e, 0x74,
0x61, 0x72, 0x65, 0x6c, 0x6c, 0x2c, 0x27, 0x4f, 0x70, 0x65, 0x6e, 0x20, 0x53, 0x61, 0x6e, 0x73,
0x27, 0x2c, 0x27, 0x48, 0x65, 0x6c, 0x76, 0x65, 0x74, 0x69, 0x63, 0x61, 0x20, 0x4e, 0x65, 0x75,
0x65, 0x27, 0x2c, 0x73, 0x61, 0x6e, 0x73, 0x2d, 0x73, 0x65, 0x72, 0x69, 0x66, 0x2c, 0x27, 0x41,
0x70, 0x70, 0x6c, 0x65, 0x20, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x45, 0x6d, 0x6f, 0x6a, 0x69,
0x27, 0x2c, 0x27, 0x53, 0x65, 0x67, 0x6f, 0x65, 0x20, 0x55, 0x49, 0x20, 0x45, 0x6d, 0x6f, 0x6a,
0x69, 0x27, 0x2c, 0x27, 0x53, 0x65, 0x67, 0x6f, 0x65, 0x20, 0x55, 0x49, 0x20, 0x53, 0x79, 0x6d,
0x62, 0x6f, 0x6c, 0x27, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x66,
0x6f, 0x6e, 0x74, 0x2d, 0x6d, 0x6f, 0x6e, 0x6f, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x73, 0x6f, 0x6c,
0x61, 0x73, 0x2c, 0x6d, 0x6f, 0x6e, 0x61, 0x63, 0x6f, 0x2c, 0x27, 0x55, 0x62, 0x75, 0x6e, 0x74,
0x75, 0x20, 0x4d, 0x6f, 0x6e, 0x6f, 0x27, 0x2c, 0x27, 0x4c, 0x69, 0x62, 0x65, 0x72, 0x61, 0x74,
0x69, 0x6f, 0x6e, 0x20, 0x4d, 0x6f, 0x6e, 0x6f, 0x27, 0x2c, 0x27, 0x43, 0x6f, 0x75, 0x72, 0x69,
0x65, 0x72, 0x20, 0x4e, 0x65, 0x77, 0x27, 0x2c, 0x43, 0x6f, 0x75, 0x72, 0x69, 0x65, 0x72, 0x2c,
0x6d, 0x6f, 0x6e, 0x6f, 0x73, 0x70, 0x61, 0x63, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2d,
0x2d, 0x6e, 0x63, 0x2d, 0x74, 0x78, 0x2d, 0x31, 0x3a, 0x20, 0x23, 0x30, 0x30, 0x30, 0x3b, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x74, 0x78, 0x2d, 0x32, 0x3a, 0x20, 0x23,
0x31, 0x61, 0x31, 0x61, 0x31, 0x61, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x2d, 0x6e,
0x63, 0x2d, 0x62, 0x67, 0x2d, 0x31, 0x3a, 0x20, 0x23, 0x66, 0x66, 0x66, 0x3b, 0x0d, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x62, 0x67, 0x2d, 0x32, 0x3a, 0x20, 0x23, 0x66,
0x36, 0x66, 0x38, 0x66, 0x61, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x2d, 0x6e, 0x63,
0x2d, 0x62, 0x67, 0x2d, 0x33, 0x3a, 0x20, 0x23, 0x65, 0x35, 0x65, 0x37, 0x65, 0x62, 0x3b, 0x0d,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x6c, 0x6b, 0x2d, 0x31, 0x3a, 0x20,
0x23, 0x30, 0x30, 0x37, 0x30, 0x66, 0x33, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x2d,
0x6e, 0x63, 0x2d, 0x6c, 0x6b, 0x2d, 0x32, 0x3a, 0x20, 0x23, 0x30, 0x33, 0x36, 0x36, 0x64, 0x36,
0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x6c, 0x6b, 0x2d, 0x74,
0x78, 0x3a, 0x20, 0x23, 0x66, 0x66, 0x66, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x2d,
0x6e, 0x63, 0x2d, 0x61, 0x63, 0x2d, 0x31, 0x3a, 0x20, 0x23, 0x37, 0x39, 0x66, 0x66, 0x65, 0x31,
0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x61, 0x63, 0x2d, 0x74,
0x78, 0x3a, 0x20, 0x23, 0x30, 0x63, 0x34, 0x30, 0x34, 0x37, 0x0d, 0x0a, 0x7d, 0x0d, 0x0a, 0x0d,
0x0a, 0x40, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x28, 0x70, 0x72, 0x65, 0x66, 0x65, 0x72, 0x73, 0x2d,
0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x2d, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x3a, 0x20, 0x64, 0x61,
0x72, 0x6b, 0x29, 0x20, 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x3a, 0x72, 0x6f, 0x6f, 0x74,
0x20, 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x2d, 0x6e, 0x63,
0x2d, 0x74, 0x78, 0x2d, 0x31, 0x3a, 0x23, 0x66, 0x66, 0x66, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x74, 0x78, 0x2d, 0x32, 0x3a, 0x20,
0x23, 0x65, 0x65, 0x65, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x2d,
0x2d, 0x6e, 0x63, 0x2d, 0x62, 0x67, 0x2d, 0x31, 0x3a, 0x20, 0x23, 0x30, 0x30, 0x30, 0x3b, 0x0d,
0x31, 0x61, 0x31, 0x61, 0x31, 0x61, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x2d, 0x6e, 0x63,
0x2d, 0x62, 0x67, 0x2d, 0x31, 0x3a, 0x20, 0x23, 0x66, 0x66, 0x66, 0x3b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x62, 0x67, 0x2d, 0x32, 0x3a, 0x20, 0x23, 0x66, 0x36, 0x66,
0x38, 0x66, 0x61, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x62, 0x67,
0x2d, 0x33, 0x3a, 0x20, 0x23, 0x65, 0x35, 0x65, 0x37, 0x65, 0x62, 0x3b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x6c, 0x6b, 0x2d, 0x31, 0x3a, 0x20, 0x23, 0x30, 0x30, 0x37,
0x30, 0x66, 0x33, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x6c, 0x6b,
0x2d, 0x32, 0x3a, 0x20, 0x23, 0x30, 0x33, 0x36, 0x36, 0x64, 0x36, 0x3b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x6c, 0x6b, 0x2d, 0x74, 0x78, 0x3a, 0x20, 0x23, 0x66, 0x66,
0x66, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x61, 0x63, 0x2d, 0x31,
0x3a, 0x20, 0x23, 0x37, 0x39, 0x66, 0x66, 0x65, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2d,
0x2d, 0x6e, 0x63, 0x2d, 0x61, 0x63, 0x2d, 0x74, 0x78, 0x3a, 0x20, 0x23, 0x30, 0x63, 0x34, 0x30,
0x34, 0x37, 0x0a, 0x7d, 0x0a, 0x0a, 0x40, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x28, 0x70, 0x72, 0x65,
0x66, 0x65, 0x72, 0x73, 0x2d, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x2d, 0x73, 0x63, 0x68, 0x65, 0x6d,
0x65, 0x3a, 0x20, 0x64, 0x61, 0x72, 0x6b, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x3a,
0x72, 0x6f, 0x6f, 0x74, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x2d,
0x2d, 0x6e, 0x63, 0x2d, 0x74, 0x78, 0x2d, 0x31, 0x3a, 0x23, 0x66, 0x66, 0x66, 0x3b, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x74, 0x78, 0x2d, 0x32,
0x3a, 0x20, 0x23, 0x65, 0x65, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x62, 0x67, 0x2d, 0x31, 0x3a, 0x20, 0x23, 0x30, 0x30, 0x30, 0x3b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x62, 0x67,
0x2d, 0x32, 0x3a, 0x20, 0x23, 0x31, 0x31, 0x31, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x62, 0x67, 0x2d, 0x33, 0x3a, 0x20, 0x23, 0x32,
0x32, 0x32, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x2d, 0x6e,
0x63, 0x2d, 0x6c, 0x6b, 0x2d, 0x31, 0x3a, 0x20, 0x23, 0x33, 0x32, 0x39, 0x31, 0x66, 0x66, 0x3b,
0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x6c,
0x6b, 0x2d, 0x32, 0x3a, 0x20, 0x23, 0x30, 0x30, 0x37, 0x30, 0x66, 0x33, 0x3b, 0x0d, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x6c, 0x6b, 0x2d, 0x74,
0x78, 0x3a, 0x20, 0x23, 0x66, 0x66, 0x66, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x61, 0x63, 0x2d, 0x31, 0x3a, 0x20, 0x23, 0x37, 0x39,
0x32, 0x38, 0x63, 0x61, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x2d,
0x2d, 0x6e, 0x63, 0x2d, 0x61, 0x63, 0x2d, 0x74, 0x78, 0x3a, 0x20, 0x23, 0x66, 0x66, 0x66, 0x0d,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0d, 0x0a, 0x7d, 0x0d, 0x0a, 0x0d, 0x0a, 0x2a, 0x20, 0x7b,
0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x3a, 0x20, 0x30, 0x3b,
0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x20, 0x30,
0x0d, 0x0a, 0x7d, 0x0d, 0x0a, 0x0d, 0x0a, 0x69, 0x6d, 0x67, 0x2c, 0x69, 0x6e, 0x70, 0x75, 0x74,
0x2c, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2c, 0x70, 0x2c, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x2c,
0x74, 0x65, 0x78, 0x74, 0x61, 0x72, 0x65, 0x61, 0x2c, 0x75, 0x6c, 0x20, 0x7b, 0x0d, 0x0a, 0x20,
0x2d, 0x32, 0x3a, 0x20, 0x23, 0x31, 0x31, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x62, 0x67, 0x2d, 0x33, 0x3a, 0x20, 0x23, 0x32, 0x32,
0x32, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x2d, 0x6e, 0x63, 0x2d,
0x6c, 0x6b, 0x2d, 0x31, 0x3a, 0x20, 0x23, 0x33, 0x32, 0x39, 0x31, 0x66, 0x66, 0x3b, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x6c, 0x6b, 0x2d, 0x32,
0x3a, 0x20, 0x23, 0x30, 0x30, 0x37, 0x30, 0x66, 0x33, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x6c, 0x6b, 0x2d, 0x74, 0x78, 0x3a, 0x20, 0x23,
0x66, 0x66, 0x66, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x2d, 0x6e,
0x63, 0x2d, 0x61, 0x63, 0x2d, 0x31, 0x3a, 0x20, 0x23, 0x37, 0x39, 0x32, 0x38, 0x63, 0x61, 0x3b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x61, 0x63,
0x2d, 0x74, 0x78, 0x3a, 0x20, 0x23, 0x66, 0x66, 0x66, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a,
0x7d, 0x0a, 0x0a, 0x2a, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6d, 0x61, 0x72, 0x67, 0x69,
0x6e, 0x3a, 0x20, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e,
0x67, 0x3a, 0x20, 0x30, 0x0a, 0x7d, 0x0a, 0x0a, 0x69, 0x6d, 0x67, 0x2c, 0x69, 0x6e, 0x70, 0x75,
0x74, 0x2c, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2c, 0x70, 0x2c, 0x74, 0x61, 0x62, 0x6c, 0x65,
0x2c, 0x74, 0x65, 0x78, 0x74, 0x61, 0x72, 0x65, 0x61, 0x2c, 0x75, 0x6c, 0x20, 0x7b, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x2d, 0x62, 0x6f, 0x74, 0x74, 0x6f, 0x6d,
0x3a, 0x20, 0x31, 0x72, 0x65, 0x6d, 0x0d, 0x0a, 0x7d, 0x0d, 0x0a, 0x0d, 0x0a, 0x62, 0x75, 0x74,
0x74, 0x6f, 0x6e, 0x2c, 0x68, 0x74, 0x6d, 0x6c, 0x2c, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x2c, 0x73,
0x65, 0x6c, 0x65, 0x63, 0x74, 0x20, 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6f, 0x6e,
0x74, 0x2d, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x3a, 0x20, 0x76, 0x61, 0x72, 0x28, 0x2d, 0x2d,
0x6e, 0x63, 0x2d, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x61, 0x6e, 0x73, 0x29, 0x0d, 0x0a, 0x7d,
0x0d, 0x0a, 0x0d, 0x0a, 0x62, 0x6f, 0x64, 0x79, 0x20, 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x3a, 0x20, 0x30, 0x20, 0x61, 0x75, 0x74, 0x6f, 0x3b, 0x0d,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x6d, 0x61, 0x78, 0x2d, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3a, 0x20,
0x37, 0x35, 0x30, 0x70, 0x78, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x70, 0x61, 0x64, 0x64,
0x69, 0x6e, 0x67, 0x3a, 0x20, 0x32, 0x72, 0x65, 0x6d, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x2d, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x3a, 0x20, 0x36,
0x70, 0x78, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x76, 0x65, 0x72, 0x66, 0x6c, 0x6f,
0x77, 0x2d, 0x78, 0x3a, 0x20, 0x68, 0x69, 0x64, 0x64, 0x65, 0x6e, 0x3b, 0x0d, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x77, 0x6f, 0x72, 0x64, 0x2d, 0x62, 0x72, 0x65, 0x61, 0x6b, 0x3a, 0x20, 0x6e, 0x6f,
0x72, 0x6d, 0x61, 0x6c, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x76, 0x65, 0x72, 0x66,
0x6c, 0x6f, 0x77, 0x2d, 0x77, 0x72, 0x61, 0x70, 0x3a, 0x20, 0x61, 0x6e, 0x79, 0x77, 0x68, 0x65,
0x72, 0x65, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f,
0x75, 0x6e, 0x64, 0x3a, 0x20, 0x76, 0x61, 0x72, 0x28, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x62, 0x67,
0x2d, 0x31, 0x29, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3a,
0x3a, 0x20, 0x31, 0x72, 0x65, 0x6d, 0x0a, 0x7d, 0x0a, 0x0a, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e,
0x2c, 0x68, 0x74, 0x6d, 0x6c, 0x2c, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x2c, 0x73, 0x65, 0x6c, 0x65,
0x63, 0x74, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x66, 0x61,
0x6d, 0x69, 0x6c, 0x79, 0x3a, 0x20, 0x76, 0x61, 0x72, 0x28, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x66,
0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x61, 0x6e, 0x73, 0x29, 0x0a, 0x7d, 0x0a, 0x0a, 0x62, 0x6f, 0x64,
0x79, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x3a, 0x20,
0x30, 0x20, 0x61, 0x75, 0x74, 0x6f, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6d, 0x61, 0x78, 0x2d,
0x77, 0x69, 0x64, 0x74, 0x68, 0x3a, 0x20, 0x37, 0x35, 0x30, 0x70, 0x78, 0x3b, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x20, 0x32, 0x72, 0x65, 0x6d, 0x3b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x2d, 0x72, 0x61, 0x64, 0x69,
0x75, 0x73, 0x3a, 0x20, 0x36, 0x70, 0x78, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x76, 0x65,
0x72, 0x66, 0x6c, 0x6f, 0x77, 0x2d, 0x78, 0x3a, 0x20, 0x68, 0x69, 0x64, 0x64, 0x65, 0x6e, 0x3b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x77, 0x6f, 0x72, 0x64, 0x2d, 0x62, 0x72, 0x65, 0x61, 0x6b, 0x3a,
0x20, 0x6e, 0x6f, 0x72, 0x6d, 0x61, 0x6c, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x76, 0x65,
0x72, 0x66, 0x6c, 0x6f, 0x77, 0x2d, 0x77, 0x72, 0x61, 0x70, 0x3a, 0x20, 0x61, 0x6e, 0x79, 0x77,
0x68, 0x65, 0x72, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72,
0x6f, 0x75, 0x6e, 0x64, 0x3a, 0x20, 0x76, 0x61, 0x72, 0x28, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x62,
0x67, 0x2d, 0x31, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3a,
0x20, 0x76, 0x61, 0x72, 0x28, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x74, 0x78, 0x2d, 0x32, 0x29, 0x3b,
0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a,
0x20, 0x31, 0x2e, 0x30, 0x33, 0x72, 0x65, 0x6d, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6c,
0x69, 0x6e, 0x65, 0x2d, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x3a, 0x20, 0x31, 0x2e, 0x35, 0x0d,
0x0a, 0x7d, 0x0d, 0x0a, 0x0d, 0x0a, 0x3a, 0x3a, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f,
0x6e, 0x20, 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f,
0x75, 0x6e, 0x64, 0x3a, 0x20, 0x76, 0x61, 0x72, 0x28, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x61, 0x63,
0x2d, 0x31, 0x29, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3a,
0x20, 0x76, 0x61, 0x72, 0x28, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x61, 0x63, 0x2d, 0x74, 0x78, 0x29,
0x0d, 0x0a, 0x7d, 0x0d, 0x0a, 0x0d, 0x0a, 0x68, 0x31, 0x2c, 0x68, 0x32, 0x2c, 0x68, 0x33, 0x2c,
0x68, 0x34, 0x2c, 0x68, 0x35, 0x2c, 0x68, 0x36, 0x20, 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x6c, 0x69, 0x6e, 0x65, 0x2d, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x3a, 0x20, 0x31, 0x3b, 0x0d,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x20, 0x76, 0x61, 0x72, 0x28,
0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x74, 0x78, 0x2d, 0x31, 0x29, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x2d, 0x74, 0x6f, 0x70, 0x3a, 0x20, 0x2e, 0x38,
0x37, 0x35, 0x72, 0x65, 0x6d, 0x0d, 0x0a, 0x7d, 0x0d, 0x0a, 0x0d, 0x0a, 0x68, 0x31, 0x2c, 0x68,
0x32, 0x2c, 0x68, 0x33, 0x20, 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f,
0x72, 0x3a, 0x20, 0x76, 0x61, 0x72, 0x28, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x74, 0x78, 0x2d, 0x31,
0x29, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x2d,
0x62, 0x6f, 0x74, 0x74, 0x6f, 0x6d, 0x3a, 0x20, 0x32, 0x70, 0x78, 0x3b, 0x0d, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x2d, 0x62, 0x6f, 0x74, 0x74, 0x6f, 0x6d, 0x3a,
0x20, 0x38, 0x70, 0x78, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65,
0x72, 0x2d, 0x62, 0x6f, 0x74, 0x74, 0x6f, 0x6d, 0x3a, 0x20, 0x31, 0x70, 0x78, 0x20, 0x73, 0x6f,
0x6c, 0x69, 0x64, 0x20, 0x76, 0x61, 0x72, 0x28, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x62, 0x67, 0x2d,
0x32, 0x29, 0x0d, 0x0a, 0x7d, 0x0d, 0x0a, 0x0d, 0x0a, 0x68, 0x34, 0x2c, 0x68, 0x35, 0x2c, 0x68,
0x36, 0x20, 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x2d,
0x62, 0x6f, 0x74, 0x74, 0x6f, 0x6d, 0x3a, 0x20, 0x2e, 0x33, 0x72, 0x65, 0x6d, 0x0d, 0x0a, 0x7d,
0x0d, 0x0a, 0x0d, 0x0a, 0x68, 0x31, 0x20, 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6f,
0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x20, 0x32, 0x2e, 0x32, 0x35, 0x72, 0x65, 0x6d,
0x0d, 0x0a, 0x7d, 0x0d, 0x0a, 0x0d, 0x0a, 0x68, 0x32, 0x20, 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x20, 0x31, 0x2e, 0x38, 0x35,
0x72, 0x65, 0x6d, 0x0d, 0x0a, 0x7d, 0x0d, 0x0a, 0x0d, 0x0a, 0x68, 0x33, 0x20, 0x7b, 0x0d, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x20, 0x31,
0x2e, 0x35, 0x35, 0x72, 0x65, 0x6d, 0x0d, 0x0a, 0x7d, 0x0d, 0x0a, 0x0d, 0x0a, 0x68, 0x34, 0x20,
0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65,
0x3a, 0x20, 0x31, 0x2e, 0x32, 0x35, 0x72, 0x65, 0x6d, 0x0d, 0x0a, 0x7d, 0x0d, 0x0a, 0x0d, 0x0a,
0x68, 0x35, 0x20, 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73,
0x69, 0x7a, 0x65, 0x3a, 0x20, 0x31, 0x72, 0x65, 0x6d, 0x0d, 0x0a, 0x7d, 0x0d, 0x0a, 0x0d, 0x0a,
0x68, 0x36, 0x20, 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73,
0x69, 0x7a, 0x65, 0x3a, 0x20, 0x2e, 0x38, 0x37, 0x35, 0x72, 0x65, 0x6d, 0x0d, 0x0a, 0x7d, 0x0d,
0x0a, 0x0d, 0x0a, 0x61, 0x20, 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f,
0x72, 0x3a, 0x20, 0x76, 0x61, 0x72, 0x28, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x6c, 0x6b, 0x2d, 0x31,
0x29, 0x0d, 0x0a, 0x7d, 0x0d, 0x0a, 0x0d, 0x0a, 0x61, 0x3a, 0x68, 0x6f, 0x76, 0x65, 0x72, 0x20,
0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x20, 0x76, 0x61,
0x72, 0x28, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x6c, 0x6b, 0x2d, 0x32, 0x29, 0x20, 0x21, 0x69, 0x6d,
0x70, 0x6f, 0x72, 0x74, 0x61, 0x6e, 0x74, 0x3b, 0x0d, 0x0a, 0x7d, 0x0d, 0x0a, 0x0d, 0x0a, 0x61,
0x62, 0x62, 0x72, 0x20, 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x75, 0x72, 0x73, 0x6f,
0x72, 0x3a, 0x20, 0x68, 0x65, 0x6c, 0x70, 0x0d, 0x0a, 0x7d, 0x0d, 0x0a, 0x0d, 0x0a, 0x61, 0x62,
0x62, 0x72, 0x3a, 0x68, 0x6f, 0x76, 0x65, 0x72, 0x20, 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x63, 0x75, 0x72, 0x73, 0x6f, 0x72, 0x3a, 0x20, 0x68, 0x65, 0x6c, 0x70, 0x0d, 0x0a, 0x7d, 0x0d,
0x0a, 0x0d, 0x0a, 0x61, 0x20, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x2c, 0x62, 0x75, 0x74, 0x74,
0x6f, 0x6e, 0x2c, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x5b, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x62, 0x75,
0x74, 0x74, 0x6f, 0x6e, 0x5d, 0x2c, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x5b, 0x74, 0x79, 0x70, 0x65,
0x3d, 0x72, 0x65, 0x73, 0x65, 0x74, 0x5d, 0x2c, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x5b, 0x74, 0x79,
0x70, 0x65, 0x3d, 0x73, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x5d, 0x20, 0x7b, 0x0d, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x20, 0x31, 0x72, 0x65,
0x6d, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x3a,
0x20, 0x69, 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x2d, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x3b, 0x0d, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x20, 0x36, 0x70, 0x78,
0x20, 0x31, 0x32, 0x70, 0x78, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x65, 0x78, 0x74,
0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a, 0x20, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3b, 0x0d,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x64, 0x65, 0x63, 0x6f, 0x72, 0x61,
0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x6e, 0x6f, 0x6e, 0x65, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x77, 0x68, 0x69, 0x74, 0x65, 0x2d, 0x73, 0x70, 0x61, 0x63, 0x65, 0x3a, 0x20, 0x6e, 0x6f,
0x77, 0x72, 0x61, 0x70, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x62, 0x61, 0x63, 0x6b, 0x67,
0x72, 0x6f, 0x75, 0x6e, 0x64, 0x3a, 0x20, 0x76, 0x61, 0x72, 0x28, 0x2d, 0x2d, 0x6e, 0x63, 0x2d,
0x6c, 0x6b, 0x2d, 0x31, 0x29, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f,
0x72, 0x3a, 0x20, 0x76, 0x61, 0x72, 0x28, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x6c, 0x6b, 0x2d, 0x74,
0x78, 0x29, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x3a,
0x20, 0x30, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x2d,
0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x3a, 0x20, 0x34, 0x70, 0x78, 0x3b, 0x0d, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x62, 0x6f, 0x78, 0x2d, 0x73, 0x69, 0x7a, 0x69, 0x6e, 0x67, 0x3a, 0x20, 0x62, 0x6f,
0x72, 0x64, 0x65, 0x72, 0x2d, 0x62, 0x6f, 0x78, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63,
0x75, 0x72, 0x73, 0x6f, 0x72, 0x3a, 0x20, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x3b, 0x0d,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x20, 0x76, 0x61, 0x72, 0x28,
0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x6c, 0x6b, 0x2d, 0x74, 0x78, 0x29, 0x0d, 0x0a, 0x7d, 0x0d, 0x0a,
0x0d, 0x0a, 0x61, 0x20, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x5b, 0x64, 0x69, 0x73, 0x61, 0x62,
0x6c, 0x65, 0x64, 0x5d, 0x2c, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x5b, 0x64, 0x69, 0x73, 0x61,
0x62, 0x6c, 0x65, 0x64, 0x5d, 0x2c, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x5b, 0x74, 0x79, 0x70, 0x65,
0x3d, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x5d, 0x5b, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65,
0x64, 0x5d, 0x2c, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x5b, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x72, 0x65,
0x73, 0x65, 0x74, 0x5d, 0x5b, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x5d, 0x2c, 0x69,
0x6e, 0x70, 0x75, 0x74, 0x5b, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x73, 0x75, 0x62, 0x6d, 0x69, 0x74,
0x5d, 0x5b, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x5d, 0x20, 0x7b, 0x0d, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x63, 0x75, 0x72, 0x73, 0x6f, 0x72, 0x3a, 0x20, 0x64, 0x65, 0x66, 0x61, 0x75,
0x6c, 0x74, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79,
0x3a, 0x20, 0x2e, 0x35, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x75, 0x72, 0x73, 0x6f,
0x72, 0x3a, 0x20, 0x6e, 0x6f, 0x74, 0x2d, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x0d, 0x0a,
0x7d, 0x0d, 0x0a, 0x0d, 0x0a, 0x2e, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x3a, 0x66, 0x6f, 0x63,
0x75, 0x73, 0x2c, 0x2e, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x3a, 0x68, 0x6f, 0x76, 0x65, 0x72,
0x2c, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x3a, 0x66, 0x6f, 0x63, 0x75, 0x73, 0x2c, 0x62, 0x75,
0x74, 0x74, 0x6f, 0x6e, 0x3a, 0x68, 0x6f, 0x76, 0x65, 0x72, 0x2c, 0x69, 0x6e, 0x70, 0x75, 0x74,
0x5b, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x5d, 0x3a, 0x66, 0x6f,
0x63, 0x75, 0x73, 0x2c, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x5b, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x62,
0x75, 0x74, 0x74, 0x6f, 0x6e, 0x5d, 0x3a, 0x68, 0x6f, 0x76, 0x65, 0x72, 0x2c, 0x69, 0x6e, 0x70,
0x75, 0x74, 0x5b, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x72, 0x65, 0x73, 0x65, 0x74, 0x5d, 0x3a, 0x66,
0x6f, 0x63, 0x75, 0x73, 0x2c, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x5b, 0x74, 0x79, 0x70, 0x65, 0x3d,
0x72, 0x65, 0x73, 0x65, 0x74, 0x5d, 0x3a, 0x68, 0x6f, 0x76, 0x65, 0x72, 0x2c, 0x69, 0x6e, 0x70,
0x75, 0x74, 0x5b, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x73, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x5d, 0x3a,
0x66, 0x6f, 0x63, 0x75, 0x73, 0x2c, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x5b, 0x74, 0x79, 0x70, 0x65,
0x3d, 0x73, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x5d, 0x3a, 0x68, 0x6f, 0x76, 0x65, 0x72, 0x20, 0x7b,
0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64,
0x3a, 0x20, 0x76, 0x61, 0x72, 0x28, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x6c, 0x6b, 0x2d, 0x32, 0x29,
0x0d, 0x0a, 0x7d, 0x0d, 0x0a, 0x0d, 0x0a, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x7b, 0x0d, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x2d, 0x63, 0x6f, 0x6c, 0x6c, 0x61,
0x70, 0x73, 0x65, 0x3a, 0x20, 0x63, 0x6f, 0x6c, 0x6c, 0x61, 0x70, 0x73, 0x65, 0x3b, 0x0d, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3a, 0x20, 0x31, 0x30, 0x30, 0x25, 0x0d,
0x0a, 0x7d, 0x0d, 0x0a, 0x0d, 0x0a, 0x74, 0x64, 0x2c, 0x74, 0x68, 0x20, 0x7b, 0x0d, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x3a, 0x20, 0x31, 0x70, 0x78, 0x20, 0x73,
0x6f, 0x6c, 0x69, 0x64, 0x20, 0x76, 0x61, 0x72, 0x28, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x62, 0x67,
0x2d, 0x33, 0x29, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x61,
0x6c, 0x69, 0x67, 0x6e, 0x3a, 0x20, 0x6c, 0x65, 0x66, 0x74, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x20, 0x2e, 0x35, 0x72, 0x65, 0x6d, 0x0d,
0x0a, 0x7d, 0x0d, 0x0a, 0x0d, 0x0a, 0x74, 0x68, 0x20, 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x3a, 0x20, 0x76, 0x61, 0x72, 0x28,
0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x62, 0x67, 0x2d, 0x32, 0x29, 0x0d, 0x0a, 0x7d, 0x0d, 0x0a, 0x0d,
0x0a, 0x74, 0x72, 0x3a, 0x6e, 0x74, 0x68, 0x2d, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x28, 0x65, 0x76,
0x65, 0x6e, 0x29, 0x20, 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x62, 0x61, 0x63, 0x6b, 0x67,
0x72, 0x6f, 0x75, 0x6e, 0x64, 0x3a, 0x20, 0x76, 0x61, 0x72, 0x28, 0x2d, 0x2d, 0x6e, 0x63, 0x2d,
0x62, 0x67, 0x2d, 0x32, 0x29, 0x0d, 0x0a, 0x7d, 0x0d, 0x0a, 0x0d, 0x0a, 0x74, 0x65, 0x78, 0x74,
0x61, 0x72, 0x65, 0x61, 0x20, 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6d, 0x61, 0x78, 0x2d,
0x77, 0x69, 0x64, 0x74, 0x68, 0x3a, 0x20, 0x31, 0x30, 0x30, 0x25, 0x0d, 0x0a, 0x7d, 0x0d, 0x0a,
0x0d, 0x0a, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x2c, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x2c, 0x74,
0x65, 0x78, 0x74, 0x61, 0x72, 0x65, 0x61, 0x20, 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x70,
0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x20, 0x36, 0x70, 0x78, 0x20, 0x31, 0x32, 0x70, 0x78,
0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x2d, 0x62, 0x6f,
0x74, 0x74, 0x6f, 0x6d, 0x3a, 0x20, 0x2e, 0x35, 0x72, 0x65, 0x6d, 0x3b, 0x0d, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x3a, 0x20, 0x76, 0x61,
0x72, 0x28, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x62, 0x67, 0x2d, 0x32, 0x29, 0x3b, 0x0d, 0x0a, 0x20,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x20,
0x31, 0x2e, 0x30, 0x33, 0x72, 0x65, 0x6d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x69, 0x6e,
0x65, 0x2d, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x3a, 0x20, 0x31, 0x2e, 0x35, 0x0a, 0x7d, 0x0a,
0x0a, 0x3a, 0x3a, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x7b, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x3a, 0x20, 0x76,
0x61, 0x72, 0x28, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x61, 0x63, 0x2d, 0x31, 0x29, 0x3b, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x20, 0x76, 0x61, 0x72, 0x28, 0x2d, 0x2d,
0x6e, 0x63, 0x2d, 0x74, 0x78, 0x2d, 0x32, 0x29, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x62,
0x6f, 0x72, 0x64, 0x65, 0x72, 0x3a, 0x20, 0x31, 0x70, 0x78, 0x20, 0x73, 0x6f, 0x6c, 0x69, 0x64,
0x20, 0x76, 0x61, 0x72, 0x28, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x62, 0x67, 0x2d, 0x33, 0x29, 0x3b,
0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x2d, 0x72, 0x61, 0x64,
0x69, 0x75, 0x73, 0x3a, 0x20, 0x34, 0x70, 0x78, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x62,
0x6f, 0x78, 0x2d, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x3a, 0x20, 0x6e, 0x6f, 0x6e, 0x65, 0x3b,
0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x62, 0x6f, 0x78, 0x2d, 0x73, 0x69, 0x7a, 0x69, 0x6e, 0x67,
0x3a, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x2d, 0x62, 0x6f, 0x78, 0x0d, 0x0a, 0x7d, 0x0d,
0x0a, 0x0d, 0x0a, 0x69, 0x6d, 0x67, 0x20, 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6d, 0x61,
0x78, 0x2d, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3a, 0x20, 0x31, 0x30, 0x30, 0x25, 0x0d, 0x0a, 0x7d,
0x0d, 0x0a, 0x0d, 0x0a, 0x74, 0x64, 0x3e, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x20, 0x7b, 0x0d, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x2d, 0x74, 0x6f, 0x70, 0x3a, 0x20,
0x30, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x2d, 0x62,
0x6f, 0x74, 0x74, 0x6f, 0x6d, 0x3a, 0x20, 0x30, 0x0d, 0x0a, 0x7d, 0x0d, 0x0a, 0x0d, 0x0a, 0x74,
0x64, 0x3e, 0x74, 0x65, 0x78, 0x74, 0x61, 0x72, 0x65, 0x61, 0x20, 0x7b, 0x0d, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x2d, 0x74, 0x6f, 0x70, 0x3a, 0x20, 0x30, 0x3b,
0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x2d, 0x62, 0x6f, 0x74,
0x74, 0x6f, 0x6d, 0x3a, 0x20, 0x30, 0x0d, 0x0a, 0x7d, 0x0d, 0x0a, 0x0d, 0x0a, 0x74, 0x64, 0x3e,
0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x20, 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6d, 0x61,
0x72, 0x67, 0x69, 0x6e, 0x2d, 0x74, 0x6f, 0x70, 0x3a, 0x20, 0x30, 0x3b, 0x0d, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x2d, 0x62, 0x6f, 0x74, 0x74, 0x6f, 0x6d, 0x3a,
0x20, 0x30, 0x0d, 0x0a, 0x7d, 0x0d, 0x0a, 0x0d, 0x0a, 0x2e, 0x77, 0x61, 0x72, 0x6e, 0x69, 0x6e,
0x67, 0x20, 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x20,
0x72, 0x65, 0x64, 0x0d, 0x0a, 0x7d, 0x0d, 0x0a, 0x0d, 0x0a, 0x40, 0x6d, 0x65, 0x64, 0x69, 0x61,
0x20, 0x6f, 0x6e, 0x6c, 0x79, 0x20, 0x73, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x20, 0x61, 0x6e, 0x64,
0x20, 0x28, 0x6d, 0x61, 0x78, 0x2d, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3a, 0x20, 0x36, 0x30, 0x30,
0x70, 0x78, 0x29, 0x20, 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2e, 0x61, 0x64, 0x61, 0x70,
0x74, 0x20, 0x74, 0x64, 0x20, 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x3a, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x0d, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x7d, 0x0d, 0x0a, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2e, 0x61, 0x64, 0x61,
0x70, 0x74, 0x20, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x5b, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x74, 0x65,
0x78, 0x74, 0x5d, 0x2c, 0x2e, 0x61, 0x64, 0x61, 0x70, 0x74, 0x20, 0x69, 0x6e, 0x70, 0x75, 0x74,
0x5b, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x5d, 0x2c,
0x2e, 0x61, 0x64, 0x61, 0x70, 0x74, 0x20, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x5b, 0x74, 0x79, 0x70,
0x65, 0x3d, 0x73, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x5d, 0x2c, 0x2e, 0x61, 0x64, 0x61, 0x70, 0x74,
0x20, 0x74, 0x65, 0x78, 0x74, 0x61, 0x72, 0x65, 0x61, 0x2c, 0x2e, 0x61, 0x64, 0x61, 0x70, 0x74,
0x20, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x20, 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3a, 0x20, 0x31, 0x30, 0x30, 0x25, 0x0d, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x7d, 0x0d, 0x0a, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2e, 0x61, 0x64,
0x61, 0x70, 0x74, 0x20, 0x74, 0x64, 0x3a, 0x68, 0x61, 0x73, 0x28, 0x69, 0x6e, 0x70, 0x75, 0x74,
0x5b, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x62, 0x6f, 0x78, 0x5d, 0x29,
0x20, 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x74, 0x65, 0x78, 0x74,
0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a, 0x20, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x0d, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x7d, 0x0d, 0x0a, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2e, 0x61, 0x64,
0x61, 0x70, 0x74, 0x20, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x5b, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x63,
0x68, 0x65, 0x63, 0x6b, 0x62, 0x6f, 0x78, 0x5d, 0x20, 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3a, 0x20, 0x31, 0x2e, 0x35, 0x65, 0x6d,
0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x68, 0x65, 0x69, 0x67, 0x68,
0x74, 0x3a, 0x20, 0x31, 0x2e, 0x35, 0x65, 0x6d, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0d,
0x0a, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2e, 0x61, 0x64, 0x61, 0x70, 0x74, 0x20, 0x74, 0x61,
0x62, 0x6c, 0x65, 0x20, 0x74, 0x64, 0x3a, 0x66, 0x69, 0x72, 0x73, 0x74, 0x2d, 0x63, 0x68, 0x69,
0x6c, 0x64, 0x20, 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x62, 0x6f,
0x72, 0x64, 0x65, 0x72, 0x2d, 0x62, 0x6f, 0x74, 0x74, 0x6f, 0x6d, 0x3a, 0x20, 0x30, 0x0d, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x7d, 0x0d, 0x0a, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2e, 0x61, 0x64,
0x61, 0x70, 0x74, 0x20, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x74, 0x64, 0x3a, 0x6c, 0x61, 0x73,
0x74, 0x2d, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x20, 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x2d, 0x74, 0x6f, 0x70, 0x3a, 0x20, 0x30,
0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0d, 0x0a, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x23,
0x74, 0x62, 0x6c, 0x6e, 0x61, 0x76, 0x20, 0x61, 0x20, 0x6c, 0x69, 0x3e, 0x73, 0x70, 0x61, 0x6e,
0x20, 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6d, 0x61, 0x78, 0x2d,
0x77, 0x69, 0x64, 0x74, 0x68, 0x3a, 0x20, 0x31, 0x34, 0x30, 0x70, 0x78, 0x0d, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x7d, 0x0d, 0x0a, 0x7d, 0x0d, 0x0a, 0x0d, 0x0a, 0x23, 0x74, 0x62, 0x6c, 0x6e, 0x61,
0x76, 0x20, 0x61, 0x20, 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65,
0x72, 0x3a, 0x20, 0x30, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65,
0x72, 0x2d, 0x62, 0x6f, 0x74, 0x74, 0x6f, 0x6d, 0x3a, 0x20, 0x31, 0x70, 0x78, 0x20, 0x73, 0x6f,
0x6c, 0x69, 0x64, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61,
0x79, 0x3a, 0x20, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66,
0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x20, 0x31, 0x72, 0x65, 0x6d, 0x3b, 0x0d,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74,
0x3a, 0x20, 0x62, 0x6f, 0x6c, 0x64, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x70, 0x61, 0x64,
0x64, 0x69, 0x6e, 0x67, 0x3a, 0x20, 0x2e, 0x36, 0x72, 0x65, 0x6d, 0x20, 0x30, 0x3b, 0x0d, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x6c, 0x69, 0x6e, 0x65, 0x2d, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x3a,
0x20, 0x31, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x20,
0x76, 0x61, 0x72, 0x28, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x74, 0x78, 0x2d, 0x31, 0x29, 0x3b, 0x0d,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x64, 0x65, 0x63, 0x6f, 0x72, 0x61,
0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x6e, 0x6f, 0x6e, 0x65, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x3a, 0x20, 0x6c, 0x69, 0x6e,
0x65, 0x61, 0x72, 0x2d, 0x67, 0x72, 0x61, 0x64, 0x69, 0x65, 0x6e, 0x74, 0x28, 0x74, 0x6f, 0x20,
0x6c, 0x65, 0x66, 0x74, 0x2c, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74,
0x20, 0x35, 0x30, 0x25, 0x2c, 0x72, 0x67, 0x62, 0x61, 0x28, 0x32, 0x35, 0x35, 0x2c, 0x32, 0x35,
0x35, 0x2c, 0x32, 0x35, 0x35, 0x2c, 0x30, 0x2e, 0x34, 0x29, 0x20, 0x35, 0x30, 0x25, 0x29, 0x20,
0x72, 0x69, 0x67, 0x68, 0x74, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x62, 0x61, 0x63, 0x6b,
0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x20, 0x32, 0x30, 0x30,
0x25, 0x20, 0x31, 0x30, 0x30, 0x25, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x72, 0x61,
0x6e, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x61, 0x6c, 0x6c, 0x20, 0x2e, 0x32, 0x73,
0x20, 0x65, 0x61, 0x73, 0x65, 0x0d, 0x0a, 0x7d, 0x0d, 0x0a, 0x0d, 0x0a, 0x23, 0x74, 0x62, 0x6c,
0x6e, 0x61, 0x76, 0x20, 0x61, 0x20, 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x62, 0x61, 0x63,
0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x3a, 0x20, 0x6c, 0x69, 0x6e, 0x65, 0x61, 0x72, 0x2d,
0x67, 0x72, 0x61, 0x64, 0x69, 0x65, 0x6e, 0x74, 0x28, 0x74, 0x6f, 0x20, 0x6c, 0x65, 0x66, 0x74,
0x2c, 0x76, 0x61, 0x72, 0x28, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x62, 0x67, 0x2d, 0x32, 0x29, 0x20,
0x35, 0x30, 0x25, 0x2c, 0x72, 0x67, 0x62, 0x61, 0x28, 0x32, 0x35, 0x35, 0x2c, 0x32, 0x35, 0x35,
0x2c, 0x32, 0x35, 0x35, 0x2c, 0x30, 0x2e, 0x34, 0x29, 0x20, 0x35, 0x30, 0x25, 0x29, 0x20, 0x72,
0x69, 0x67, 0x68, 0x74, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x62, 0x61, 0x63, 0x6b, 0x67,
0x72, 0x6f, 0x75, 0x6e, 0x64, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x20, 0x32, 0x30, 0x30, 0x25,
0x20, 0x31, 0x30, 0x30, 0x25, 0x0d, 0x0a, 0x7d, 0x0d, 0x0a, 0x0d, 0x0a, 0x23, 0x74, 0x62, 0x6c,
0x6e, 0x61, 0x76, 0x20, 0x61, 0x3a, 0x68, 0x6f, 0x76, 0x65, 0x72, 0x20, 0x7b, 0x0d, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x2d, 0x70, 0x6f,
0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x6c, 0x65, 0x66, 0x74, 0x3b, 0x0d, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x61,
0x6c, 0x6c, 0x20, 0x2e, 0x34, 0x35, 0x73, 0x20, 0x65, 0x61, 0x73, 0x65, 0x0d, 0x0a, 0x7d, 0x0d,
0x0a, 0x0d, 0x0a, 0x23, 0x74, 0x62, 0x6c, 0x6e, 0x61, 0x76, 0x20, 0x61, 0x3a, 0x61, 0x63, 0x74,
0x69, 0x76, 0x65, 0x20, 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x62, 0x61, 0x63, 0x6b, 0x67,
0x6e, 0x63, 0x2d, 0x61, 0x63, 0x2d, 0x74, 0x78, 0x29, 0x0a, 0x7d, 0x0a, 0x0a, 0x68, 0x31, 0x2c,
0x68, 0x32, 0x2c, 0x68, 0x33, 0x2c, 0x68, 0x34, 0x2c, 0x68, 0x35, 0x2c, 0x68, 0x36, 0x20, 0x7b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x69, 0x6e, 0x65, 0x2d, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74,
0x3a, 0x20, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x20,
0x76, 0x61, 0x72, 0x28, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x74, 0x78, 0x2d, 0x31, 0x29, 0x3b, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x2d, 0x74, 0x6f, 0x70, 0x3a,
0x20, 0x2e, 0x38, 0x37, 0x35, 0x72, 0x65, 0x6d, 0x0a, 0x7d, 0x0a, 0x0a, 0x68, 0x31, 0x2c, 0x68,
0x32, 0x2c, 0x68, 0x33, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72,
0x3a, 0x20, 0x76, 0x61, 0x72, 0x28, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x74, 0x78, 0x2d, 0x31, 0x29,
0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x2d, 0x62, 0x6f,
0x74, 0x74, 0x6f, 0x6d, 0x3a, 0x20, 0x32, 0x70, 0x78, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6d,
0x61, 0x72, 0x67, 0x69, 0x6e, 0x2d, 0x62, 0x6f, 0x74, 0x74, 0x6f, 0x6d, 0x3a, 0x20, 0x38, 0x70,
0x78, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x2d, 0x62, 0x6f,
0x74, 0x74, 0x6f, 0x6d, 0x3a, 0x20, 0x31, 0x70, 0x78, 0x20, 0x73, 0x6f, 0x6c, 0x69, 0x64, 0x20,
0x76, 0x61, 0x72, 0x28, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x62, 0x67, 0x2d, 0x32, 0x29, 0x0a, 0x7d,
0x0a, 0x0a, 0x68, 0x34, 0x2c, 0x68, 0x35, 0x2c, 0x68, 0x36, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x2d, 0x62, 0x6f, 0x74, 0x74, 0x6f, 0x6d, 0x3a, 0x20,
0x2e, 0x33, 0x72, 0x65, 0x6d, 0x0a, 0x7d, 0x0a, 0x0a, 0x68, 0x31, 0x20, 0x7b, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x20, 0x32, 0x2e, 0x32,
0x35, 0x72, 0x65, 0x6d, 0x0a, 0x7d, 0x0a, 0x0a, 0x68, 0x32, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x20, 0x31, 0x2e, 0x38, 0x35,
0x72, 0x65, 0x6d, 0x0a, 0x7d, 0x0a, 0x0a, 0x68, 0x33, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x20, 0x31, 0x2e, 0x35, 0x35, 0x72,
0x65, 0x6d, 0x0a, 0x7d, 0x0a, 0x0a, 0x68, 0x34, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66,
0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x20, 0x31, 0x2e, 0x32, 0x35, 0x72, 0x65,
0x6d, 0x0a, 0x7d, 0x0a, 0x0a, 0x68, 0x35, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6f,
0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x20, 0x31, 0x72, 0x65, 0x6d, 0x0a, 0x7d, 0x0a,
0x0a, 0x68, 0x36, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73,
0x69, 0x7a, 0x65, 0x3a, 0x20, 0x2e, 0x38, 0x37, 0x35, 0x72, 0x65, 0x6d, 0x0a, 0x7d, 0x0a, 0x0a,
0x61, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x20, 0x76,
0x61, 0x72, 0x28, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x6c, 0x6b, 0x2d, 0x31, 0x29, 0x0a, 0x7d, 0x0a,
0x0a, 0x61, 0x3a, 0x68, 0x6f, 0x76, 0x65, 0x72, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63,
0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x20, 0x76, 0x61, 0x72, 0x28, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x6c,
0x6b, 0x2d, 0x32, 0x29, 0x20, 0x21, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x61, 0x6e, 0x74, 0x3b,
0x0a, 0x7d, 0x0a, 0x0a, 0x61, 0x62, 0x62, 0x72, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63,
0x75, 0x72, 0x73, 0x6f, 0x72, 0x3a, 0x20, 0x68, 0x65, 0x6c, 0x70, 0x0a, 0x7d, 0x0a, 0x0a, 0x61,
0x62, 0x62, 0x72, 0x3a, 0x68, 0x6f, 0x76, 0x65, 0x72, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x63, 0x75, 0x72, 0x73, 0x6f, 0x72, 0x3a, 0x20, 0x68, 0x65, 0x6c, 0x70, 0x0a, 0x7d, 0x0a, 0x0a,
0x61, 0x20, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x2c, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x2c,
0x69, 0x6e, 0x70, 0x75, 0x74, 0x5b, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x62, 0x75, 0x74, 0x74, 0x6f,
0x6e, 0x5d, 0x2c, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x5b, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x72, 0x65,
0x73, 0x65, 0x74, 0x5d, 0x2c, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x5b, 0x74, 0x79, 0x70, 0x65, 0x3d,
0x73, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x5d, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6f,
0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x20, 0x31, 0x72, 0x65, 0x6d, 0x3b, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x3a, 0x20, 0x69, 0x6e, 0x6c, 0x69,
0x6e, 0x65, 0x2d, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x70, 0x61,
0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x20, 0x36, 0x70, 0x78, 0x20, 0x31, 0x32, 0x70, 0x78, 0x3b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a,
0x20, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x65, 0x78,
0x74, 0x2d, 0x64, 0x65, 0x63, 0x6f, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x6e, 0x6f,
0x6e, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x77, 0x68, 0x69, 0x74, 0x65, 0x2d, 0x73, 0x70,
0x61, 0x63, 0x65, 0x3a, 0x20, 0x6e, 0x6f, 0x77, 0x72, 0x61, 0x70, 0x3b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x3a, 0x20, 0x76, 0x61, 0x72,
0x28, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x6c, 0x6b, 0x2d, 0x31, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x20, 0x76, 0x61, 0x72, 0x28, 0x2d, 0x2d, 0x6e, 0x63,
0x2d, 0x6c, 0x6b, 0x2d, 0x74, 0x78, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x62, 0x6f, 0x72,
0x64, 0x65, 0x72, 0x3a, 0x20, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x62, 0x6f, 0x72, 0x64,
0x65, 0x72, 0x2d, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x3a, 0x20, 0x34, 0x70, 0x78, 0x3b, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x62, 0x6f, 0x78, 0x2d, 0x73, 0x69, 0x7a, 0x69, 0x6e, 0x67, 0x3a, 0x20,
0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x2d, 0x62, 0x6f, 0x78, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x63, 0x75, 0x72, 0x73, 0x6f, 0x72, 0x3a, 0x20, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x3b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x20, 0x76, 0x61, 0x72, 0x28,
0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x6c, 0x6b, 0x2d, 0x74, 0x78, 0x29, 0x0a, 0x7d, 0x0a, 0x0a, 0x61,
0x20, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x5b, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x64,
0x5d, 0x2c, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x5b, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65,
0x64, 0x5d, 0x2c, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x5b, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x62, 0x75,
0x74, 0x74, 0x6f, 0x6e, 0x5d, 0x5b, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x5d, 0x2c,
0x69, 0x6e, 0x70, 0x75, 0x74, 0x5b, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x72, 0x65, 0x73, 0x65, 0x74,
0x5d, 0x5b, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x5d, 0x2c, 0x69, 0x6e, 0x70, 0x75,
0x74, 0x5b, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x73, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x5d, 0x5b, 0x64,
0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x5d, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63,
0x75, 0x72, 0x73, 0x6f, 0x72, 0x3a, 0x20, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x3b, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x6f, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x3a, 0x20, 0x2e, 0x35, 0x3b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x75, 0x72, 0x73, 0x6f, 0x72, 0x3a, 0x20, 0x6e, 0x6f, 0x74,
0x2d, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x0a, 0x7d, 0x0a, 0x0a, 0x2e, 0x62, 0x75, 0x74,
0x74, 0x6f, 0x6e, 0x3a, 0x66, 0x6f, 0x63, 0x75, 0x73, 0x2c, 0x2e, 0x62, 0x75, 0x74, 0x74, 0x6f,
0x6e, 0x3a, 0x68, 0x6f, 0x76, 0x65, 0x72, 0x2c, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x3a, 0x66,
0x6f, 0x63, 0x75, 0x73, 0x2c, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x3a, 0x68, 0x6f, 0x76, 0x65,
0x72, 0x2c, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x5b, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x62, 0x75, 0x74,
0x74, 0x6f, 0x6e, 0x5d, 0x3a, 0x66, 0x6f, 0x63, 0x75, 0x73, 0x2c, 0x69, 0x6e, 0x70, 0x75, 0x74,
0x5b, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x5d, 0x3a, 0x68, 0x6f,
0x76, 0x65, 0x72, 0x2c, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x5b, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x72,
0x65, 0x73, 0x65, 0x74, 0x5d, 0x3a, 0x66, 0x6f, 0x63, 0x75, 0x73, 0x2c, 0x69, 0x6e, 0x70, 0x75,
0x74, 0x5b, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x72, 0x65, 0x73, 0x65, 0x74, 0x5d, 0x3a, 0x68, 0x6f,
0x76, 0x65, 0x72, 0x2c, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x5b, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x73,
0x75, 0x62, 0x6d, 0x69, 0x74, 0x5d, 0x3a, 0x66, 0x6f, 0x63, 0x75, 0x73, 0x2c, 0x69, 0x6e, 0x70,
0x75, 0x74, 0x5b, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x73, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x5d, 0x3a,
0x68, 0x6f, 0x76, 0x65, 0x72, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x62, 0x61, 0x63, 0x6b,
0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x3a, 0x20, 0x76, 0x61, 0x72, 0x28, 0x2d, 0x2d, 0x6e, 0x63,
0x2d, 0x6c, 0x6b, 0x2d, 0x32, 0x29, 0x0a, 0x7d, 0x0a, 0x0a, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x20,
0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x2d, 0x63, 0x6f, 0x6c,
0x6c, 0x61, 0x70, 0x73, 0x65, 0x3a, 0x20, 0x63, 0x6f, 0x6c, 0x6c, 0x61, 0x70, 0x73, 0x65, 0x3b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3a, 0x20, 0x31, 0x30, 0x30, 0x25,
0x0a, 0x7d, 0x0a, 0x0a, 0x74, 0x64, 0x2c, 0x74, 0x68, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x3a, 0x20, 0x31, 0x70, 0x78, 0x20, 0x73, 0x6f, 0x6c, 0x69,
0x64, 0x20, 0x76, 0x61, 0x72, 0x28, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x62, 0x67, 0x2d, 0x33, 0x29,
0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e,
0x3a, 0x20, 0x6c, 0x65, 0x66, 0x74, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x70, 0x61, 0x64, 0x64,
0x69, 0x6e, 0x67, 0x3a, 0x20, 0x2e, 0x35, 0x72, 0x65, 0x6d, 0x0a, 0x7d, 0x0a, 0x0a, 0x74, 0x68,
0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e,
0x64, 0x3a, 0x20, 0x76, 0x61, 0x72, 0x28, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x62, 0x67, 0x2d, 0x32,
0x29, 0x0a, 0x7d, 0x0a, 0x0a, 0x74, 0x72, 0x3a, 0x6e, 0x74, 0x68, 0x2d, 0x63, 0x68, 0x69, 0x6c,
0x64, 0x28, 0x65, 0x76, 0x65, 0x6e, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x62, 0x61,
0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x3a, 0x20, 0x76, 0x61, 0x72, 0x28, 0x2d, 0x2d,
0x6e, 0x63, 0x2d, 0x62, 0x67, 0x2d, 0x32, 0x29, 0x0a, 0x7d, 0x0a, 0x0a, 0x74, 0x65, 0x78, 0x74,
0x61, 0x72, 0x65, 0x61, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6d, 0x61, 0x78, 0x2d, 0x77,
0x69, 0x64, 0x74, 0x68, 0x3a, 0x20, 0x31, 0x30, 0x30, 0x25, 0x0a, 0x7d, 0x0a, 0x0a, 0x69, 0x6e,
0x70, 0x75, 0x74, 0x2c, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x2c, 0x74, 0x65, 0x78, 0x74, 0x61,
0x72, 0x65, 0x61, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e,
0x67, 0x3a, 0x20, 0x36, 0x70, 0x78, 0x20, 0x31, 0x32, 0x70, 0x78, 0x3b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x2d, 0x62, 0x6f, 0x74, 0x74, 0x6f, 0x6d, 0x3a, 0x20,
0x2e, 0x35, 0x72, 0x65, 0x6d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x62, 0x61, 0x63, 0x6b, 0x67,
0x72, 0x6f, 0x75, 0x6e, 0x64, 0x3a, 0x20, 0x76, 0x61, 0x72, 0x28, 0x2d, 0x2d, 0x6e, 0x63, 0x2d,
0x6c, 0x6b, 0x2d, 0x31, 0x29, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x72, 0x61, 0x6e,
0x62, 0x67, 0x2d, 0x32, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72,
0x3a, 0x20, 0x76, 0x61, 0x72, 0x28, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x74, 0x78, 0x2d, 0x32, 0x29,
0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x3a, 0x20, 0x31, 0x70,
0x78, 0x20, 0x73, 0x6f, 0x6c, 0x69, 0x64, 0x20, 0x76, 0x61, 0x72, 0x28, 0x2d, 0x2d, 0x6e, 0x63,
0x2d, 0x62, 0x67, 0x2d, 0x33, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x62, 0x6f, 0x72, 0x64,
0x65, 0x72, 0x2d, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x3a, 0x20, 0x34, 0x70, 0x78, 0x3b, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x62, 0x6f, 0x78, 0x2d, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x3a, 0x20,
0x6e, 0x6f, 0x6e, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x62, 0x6f, 0x78, 0x2d, 0x73, 0x69,
0x7a, 0x69, 0x6e, 0x67, 0x3a, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x2d, 0x62, 0x6f, 0x78,
0x0a, 0x7d, 0x0a, 0x0a, 0x69, 0x6d, 0x67, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6d, 0x61,
0x78, 0x2d, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3a, 0x20, 0x31, 0x30, 0x30, 0x25, 0x0a, 0x7d, 0x0a,
0x0a, 0x74, 0x64, 0x3e, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x2d, 0x74, 0x6f, 0x70, 0x3a, 0x20, 0x30, 0x3b, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x2d, 0x62, 0x6f, 0x74, 0x74, 0x6f, 0x6d,
0x3a, 0x20, 0x30, 0x0a, 0x7d, 0x0a, 0x0a, 0x74, 0x64, 0x3e, 0x74, 0x65, 0x78, 0x74, 0x61, 0x72,
0x65, 0x61, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x2d,
0x74, 0x6f, 0x70, 0x3a, 0x20, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6d, 0x61, 0x72, 0x67,
0x69, 0x6e, 0x2d, 0x62, 0x6f, 0x74, 0x74, 0x6f, 0x6d, 0x3a, 0x20, 0x30, 0x0a, 0x7d, 0x0a, 0x0a,
0x74, 0x64, 0x3e, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x2d, 0x74, 0x6f, 0x70, 0x3a, 0x20, 0x30, 0x3b, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x2d, 0x62, 0x6f, 0x74, 0x74, 0x6f, 0x6d,
0x3a, 0x20, 0x30, 0x0a, 0x7d, 0x0a, 0x0a, 0x2e, 0x77, 0x61, 0x72, 0x6e, 0x69, 0x6e, 0x67, 0x20,
0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x20, 0x72, 0x65, 0x64,
0x0a, 0x7d, 0x0a, 0x0a, 0x40, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x20, 0x6f, 0x6e, 0x6c, 0x79, 0x20,
0x73, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x28, 0x6d, 0x61, 0x78, 0x2d,
0x77, 0x69, 0x64, 0x74, 0x68, 0x3a, 0x20, 0x36, 0x30, 0x30, 0x70, 0x78, 0x29, 0x20, 0x7b, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x2e, 0x61, 0x64, 0x61, 0x70, 0x74, 0x20, 0x74, 0x64, 0x20, 0x7b, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x3a,
0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x2e, 0x61, 0x64, 0x61, 0x70, 0x74, 0x20, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x5b, 0x74, 0x79,
0x70, 0x65, 0x3d, 0x74, 0x65, 0x78, 0x74, 0x5d, 0x2c, 0x2e, 0x61, 0x64, 0x61, 0x70, 0x74, 0x20,
0x69, 0x6e, 0x70, 0x75, 0x74, 0x5b, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x70, 0x61, 0x73, 0x73, 0x77,
0x6f, 0x72, 0x64, 0x5d, 0x2c, 0x2e, 0x61, 0x64, 0x61, 0x70, 0x74, 0x20, 0x69, 0x6e, 0x70, 0x75,
0x74, 0x5b, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x73, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x5d, 0x2c, 0x2e,
0x61, 0x64, 0x61, 0x70, 0x74, 0x20, 0x74, 0x65, 0x78, 0x74, 0x61, 0x72, 0x65, 0x61, 0x2c, 0x2e,
0x61, 0x64, 0x61, 0x70, 0x74, 0x20, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x20, 0x7b, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3a, 0x20, 0x31, 0x30,
0x30, 0x25, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2e, 0x61,
0x64, 0x61, 0x70, 0x74, 0x20, 0x74, 0x64, 0x3a, 0x68, 0x61, 0x73, 0x28, 0x69, 0x6e, 0x70, 0x75,
0x74, 0x5b, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x62, 0x6f, 0x78, 0x5d,
0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x74, 0x65, 0x78, 0x74,
0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a, 0x20, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x7d, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2e, 0x61, 0x64, 0x61, 0x70, 0x74,
0x20, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x5b, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x63, 0x68, 0x65, 0x63,
0x6b, 0x62, 0x6f, 0x78, 0x5d, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x77, 0x69, 0x64, 0x74, 0x68, 0x3a, 0x20, 0x31, 0x2e, 0x35, 0x65, 0x6d, 0x3b, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x3a, 0x20, 0x31, 0x2e,
0x35, 0x65, 0x6d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2e,
0x61, 0x64, 0x61, 0x70, 0x74, 0x20, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x74, 0x64, 0x3a, 0x66,
0x69, 0x72, 0x73, 0x74, 0x2d, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x2d, 0x62, 0x6f, 0x74, 0x74,
0x6f, 0x6d, 0x3a, 0x20, 0x30, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x2e, 0x61, 0x64, 0x61, 0x70, 0x74, 0x20, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x74, 0x64,
0x3a, 0x6c, 0x61, 0x73, 0x74, 0x2d, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x20, 0x7b, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x2d, 0x74, 0x6f, 0x70,
0x3a, 0x20, 0x30, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x23,
0x74, 0x62, 0x6c, 0x6e, 0x61, 0x76, 0x20, 0x61, 0x20, 0x6c, 0x69, 0x3e, 0x73, 0x70, 0x61, 0x6e,
0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6d, 0x61, 0x78, 0x2d, 0x77,
0x69, 0x64, 0x74, 0x68, 0x3a, 0x20, 0x31, 0x34, 0x30, 0x70, 0x78, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x7d, 0x0a, 0x7d, 0x0a, 0x0a, 0x23, 0x74, 0x62, 0x6c, 0x6e, 0x61, 0x76, 0x20, 0x61, 0x20, 0x7b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x3a, 0x20, 0x30, 0x3b, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x2d, 0x62, 0x6f, 0x74, 0x74, 0x6f,
0x6d, 0x3a, 0x20, 0x31, 0x70, 0x78, 0x20, 0x73, 0x6f, 0x6c, 0x69, 0x64, 0x3b, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x3a, 0x20, 0x62, 0x6c, 0x6f, 0x63, 0x6b,
0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a,
0x20, 0x31, 0x72, 0x65, 0x6d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d,
0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x3a, 0x20, 0x62, 0x6f, 0x6c, 0x64, 0x3b, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x20, 0x2e, 0x36, 0x72, 0x65, 0x6d,
0x20, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x69, 0x6e, 0x65, 0x2d, 0x68, 0x65, 0x69,
0x67, 0x68, 0x74, 0x3a, 0x20, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f,
0x72, 0x3a, 0x20, 0x76, 0x61, 0x72, 0x28, 0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x74, 0x78, 0x2d, 0x31,
0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x64, 0x65, 0x63, 0x6f,
0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x6e, 0x6f, 0x6e, 0x65, 0x3b, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x3a, 0x20, 0x6c, 0x69,
0x6e, 0x65, 0x61, 0x72, 0x2d, 0x67, 0x72, 0x61, 0x64, 0x69, 0x65, 0x6e, 0x74, 0x28, 0x74, 0x6f,
0x20, 0x6c, 0x65, 0x66, 0x74, 0x2c, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x61, 0x72, 0x65, 0x6e,
0x74, 0x20, 0x35, 0x30, 0x25, 0x2c, 0x72, 0x67, 0x62, 0x61, 0x28, 0x32, 0x35, 0x35, 0x2c, 0x32,
0x35, 0x35, 0x2c, 0x32, 0x35, 0x35, 0x2c, 0x30, 0x2e, 0x34, 0x29, 0x20, 0x35, 0x30, 0x25, 0x29,
0x20, 0x72, 0x69, 0x67, 0x68, 0x74, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x62, 0x61, 0x63, 0x6b,
0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x20, 0x32, 0x30, 0x30,
0x25, 0x20, 0x31, 0x30, 0x30, 0x25, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x72, 0x61, 0x6e,
0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x61, 0x6c, 0x6c, 0x20, 0x2e, 0x32, 0x73, 0x20,
0x65, 0x61, 0x73, 0x65, 0x0a, 0x7d, 0x0a, 0x0a, 0x23, 0x74, 0x62, 0x6c, 0x6e, 0x61, 0x76, 0x20,
0x61, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75,
0x6e, 0x64, 0x3a, 0x20, 0x6c, 0x69, 0x6e, 0x65, 0x61, 0x72, 0x2d, 0x67, 0x72, 0x61, 0x64, 0x69,
0x65, 0x6e, 0x74, 0x28, 0x74, 0x6f, 0x20, 0x6c, 0x65, 0x66, 0x74, 0x2c, 0x76, 0x61, 0x72, 0x28,
0x2d, 0x2d, 0x6e, 0x63, 0x2d, 0x62, 0x67, 0x2d, 0x32, 0x29, 0x20, 0x35, 0x30, 0x25, 0x2c, 0x72,
0x67, 0x62, 0x61, 0x28, 0x32, 0x35, 0x35, 0x2c, 0x32, 0x35, 0x35, 0x2c, 0x32, 0x35, 0x35, 0x2c,
0x30, 0x2e, 0x34, 0x29, 0x20, 0x35, 0x30, 0x25, 0x29, 0x20, 0x72, 0x69, 0x67, 0x68, 0x74, 0x3b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x2d,
0x73, 0x69, 0x7a, 0x65, 0x3a, 0x20, 0x32, 0x30, 0x30, 0x25, 0x20, 0x31, 0x30, 0x30, 0x25, 0x0a,
0x7d, 0x0a, 0x0a, 0x23, 0x74, 0x62, 0x6c, 0x6e, 0x61, 0x76, 0x20, 0x61, 0x3a, 0x68, 0x6f, 0x76,
0x65, 0x72, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f,
0x75, 0x6e, 0x64, 0x2d, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x6c, 0x65,
0x66, 0x74, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x69, 0x74, 0x69,
0x6f, 0x6e, 0x3a, 0x20, 0x61, 0x6c, 0x6c, 0x20, 0x2e, 0x34, 0x35, 0x73, 0x20, 0x65, 0x61, 0x73,
0x65, 0x0a, 0x7d, 0x0a, 0x0a, 0x23, 0x74, 0x62, 0x6c, 0x6e, 0x61, 0x76, 0x20, 0x61, 0x3a, 0x61,
0x63, 0x74, 0x69, 0x76, 0x65, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x62, 0x61, 0x63, 0x6b,
0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x3a, 0x20, 0x76, 0x61, 0x72, 0x28, 0x2d, 0x2d, 0x6e, 0x63,
0x2d, 0x6c, 0x6b, 0x2d, 0x31, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x72, 0x61, 0x6e,
0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x61, 0x6c, 0x6c, 0x20, 0x2e, 0x31, 0x35, 0x73,
0x20, 0x65, 0x61, 0x73, 0x65, 0x0d, 0x0a, 0x7d, 0x0d, 0x0a, 0x0d, 0x0a, 0x23, 0x74, 0x62, 0x6c,
0x6e, 0x61, 0x76, 0x20, 0x61, 0x20, 0x6c, 0x69, 0x20, 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x6c, 0x69, 0x73, 0x74, 0x2d, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x3a, 0x20, 0x6e, 0x6f, 0x6e, 0x65,
0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x20,
0x2e, 0x35, 0x72, 0x65, 0x6d, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x64, 0x69, 0x73, 0x70,
0x6c, 0x61, 0x79, 0x3a, 0x20, 0x69, 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x2d, 0x62, 0x6c, 0x6f, 0x63,
0x6b, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3a, 0x20, 0x31,
0x30, 0x30, 0x25, 0x0d, 0x0a, 0x7d, 0x0d, 0x0a, 0x0d, 0x0a, 0x23, 0x74, 0x62, 0x6c, 0x6e, 0x61,
0x76, 0x20, 0x61, 0x20, 0x6c, 0x69, 0x3e, 0x73, 0x70, 0x61, 0x6e, 0x20, 0x7b, 0x0d, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x3a, 0x20, 0x72, 0x69, 0x67, 0x68, 0x74, 0x3b,
0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e,
0x3a, 0x20, 0x72, 0x69, 0x67, 0x68, 0x74, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6d, 0x61,
0x72, 0x67, 0x69, 0x6e, 0x2d, 0x72, 0x69, 0x67, 0x68, 0x74, 0x3a, 0x20, 0x31, 0x30, 0x70, 0x78,
0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x20, 0x23, 0x66,
0x37, 0x30, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x77, 0x65,
0x69, 0x67, 0x68, 0x74, 0x3a, 0x20, 0x31, 0x30, 0x30, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x20, 0x65, 0x61, 0x73, 0x65, 0x0a, 0x7d, 0x0a, 0x0a, 0x23, 0x74, 0x62, 0x6c, 0x6e, 0x61, 0x76,
0x20, 0x61, 0x20, 0x6c, 0x69, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x69, 0x73, 0x74,
0x2d, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x3a, 0x20, 0x6e, 0x6f, 0x6e, 0x65, 0x3b, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x20, 0x2e, 0x35, 0x72, 0x65, 0x6d,
0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x3a, 0x20, 0x69,
0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x2d, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x3b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3a, 0x20, 0x31, 0x30, 0x30, 0x25, 0x0a, 0x7d, 0x0a, 0x0a,
0x23, 0x74, 0x62, 0x6c, 0x6e, 0x61, 0x76, 0x20, 0x61, 0x20, 0x6c, 0x69, 0x3e, 0x73, 0x70, 0x61,
0x6e, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x3a, 0x20, 0x72,
0x69, 0x67, 0x68, 0x74, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x61,
0x6c, 0x69, 0x67, 0x6e, 0x3a, 0x20, 0x72, 0x69, 0x67, 0x68, 0x74, 0x3b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x2d, 0x72, 0x69, 0x67, 0x68, 0x74, 0x3a, 0x20, 0x31,
0x30, 0x70, 0x78, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x20,
0x23, 0x66, 0x37, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x77,
0x65, 0x69, 0x67, 0x68, 0x74, 0x3a, 0x20, 0x31, 0x30, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x3a, 0x20, 0x69, 0x74, 0x61, 0x6c,
0x69, 0x63, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79,
0x3a, 0x20, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x0d, 0x0a, 0x7d, 0x0d, 0x0a, 0x0d, 0x0a, 0x2e, 0x74,
0x64, 0x62, 0x74, 0x6e, 0x20, 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x65, 0x78, 0x74,
0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a, 0x20, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3b, 0x0d,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x72, 0x74, 0x69, 0x63, 0x61, 0x6c, 0x2d, 0x61, 0x6c,
0x69, 0x67, 0x6e, 0x3a, 0x20, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x0d, 0x0a, 0x7d, 0x0d, 0x0a,
0x0d, 0x0a, 0x2e, 0x6e, 0x61, 0x76, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x20, 0x7b, 0x0d, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x3a, 0x20, 0x6c, 0x65, 0x66, 0x74, 0x3b, 0x0d,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x6d, 0x61, 0x78, 0x2d, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3a, 0x20,
0x33, 0x37, 0x35, 0x70, 0x78, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x77, 0x69, 0x64, 0x74,
0x68, 0x3a, 0x20, 0x31, 0x30, 0x30, 0x25, 0x0d, 0x0a, 0x7d,
0x69, 0x63, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x3a,
0x20, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x0a, 0x7d, 0x0a, 0x0a, 0x2e, 0x74, 0x64, 0x62, 0x74, 0x6e,
0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69, 0x67,
0x6e, 0x3a, 0x20, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76,
0x65, 0x72, 0x74, 0x69, 0x63, 0x61, 0x6c, 0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a, 0x20, 0x6d,
0x69, 0x64, 0x64, 0x6c, 0x65, 0x0a, 0x7d, 0x0a, 0x0a, 0x2e, 0x6e, 0x61, 0x76, 0x65, 0x6e, 0x74,
0x72, 0x79, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x3a, 0x20,
0x6c, 0x65, 0x66, 0x74, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6d, 0x61, 0x78, 0x2d, 0x77, 0x69,
0x64, 0x74, 0x68, 0x3a, 0x20, 0x33, 0x37, 0x35, 0x70, 0x78, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x77, 0x69, 0x64, 0x74, 0x68, 0x3a, 0x20, 0x31, 0x30, 0x30, 0x25, 0x0a, 0x7d,

File diff suppressed because it is too large Load Diff