From 78b76394007dfe1e62cfab3dfc75cbed4d6d7c97 Mon Sep 17 00:00:00 2001 From: Sebastien Date: Fri, 11 Sep 2020 16:15:31 -0400 Subject: [PATCH] WIP - User Interface improvements --- components/platform_console/cmd_i2ctools.c | 65 +- components/platform_console/cmd_system.c | 4 +- components/services/accessors.c | 238 +- components/services/accessors.h | 11 + components/wifi-manager/code.js | 2307 +++++++++-------- .../wifi-manager/http_server_handlers.c | 11 +- .../wifi-manager/index.development.html | 399 +++ components/wifi-manager/index.html | 386 +-- main/esp_app_main.c | 2 +- 9 files changed, 1848 insertions(+), 1575 deletions(-) create mode 100644 components/wifi-manager/index.development.html diff --git a/components/platform_console/cmd_i2ctools.c b/components/platform_console/cmd_i2ctools.c index 1ba7b08e..30f97fba 100644 --- a/components/platform_console/cmd_i2ctools.c +++ b/components/platform_console/cmd_i2ctools.c @@ -97,9 +97,9 @@ static struct { static struct { struct arg_str *name; struct arg_str *driver; + struct arg_int *address; struct arg_int *width; struct arg_int *height; - struct arg_int *address; struct arg_lit *rotate; struct arg_lit *hflip; struct arg_lit *vflip; @@ -108,22 +108,7 @@ static struct { struct arg_lit *clear; struct arg_end *end; } i2cdisp_args; -char * gpio_list = NULL; -const char * get_gpio_list(){ - if(!gpio_list){ - gpio_list = malloc(GPIO_PIN_COUNT*3+1); - memset(gpio_list,0x00,GPIO_PIN_COUNT*3+1); - for(int i = 0;ihdr.longopts?gpio->hdr.longopts:gpio->hdr.glossary; @@ -1024,21 +1009,21 @@ cJSON * i2c_set_display_cb(){ static void register_i2c_set_display(){ char * supported_drivers = display_get_supported_drivers(); - i2cdisp_args.address = arg_int0("a", "address", "", "Set the device address, default 60"); - i2cdisp_args.width = arg_int0("w", "width", "", "Set the display width"); - i2cdisp_args.height = arg_int0("h", "height", "", "Set the display height"); - i2cdisp_args.name = arg_str0("t", "type", "", "Display type, I2C or SPI. Default I2C"); - i2cdisp_args.driver = arg_str0("d", "driver", supported_drivers?supported_drivers:"", "Set the display driver name. Default SSD1306"); + i2cdisp_args.address = arg_int0("a", "address", "", "I2C address (default 60)"); + i2cdisp_args.width = arg_int0("w", "width", "", "Width"); + i2cdisp_args.height = arg_int0("h", "height", "", "Height"); + i2cdisp_args.name = arg_str0("t", "type", "", "Interface (default I2C)"); + i2cdisp_args.driver = arg_str0("d", "driver", supported_drivers?supported_drivers:"", "Driver (default SSD1306)"); i2cdisp_args.clear = arg_lit0(NULL, "clear", "clear configuration and return"); - i2cdisp_args.hflip = arg_lit0(NULL, "hf", "Flip picture horizontally"); - i2cdisp_args.vflip = arg_lit0(NULL, "vf", "Flip picture vertically"); - i2cdisp_args.rotate = arg_lit0("r", "rotate", "Rotate the picture 180 deg"); - i2cdisp_args.back = arg_int0("b", "back", get_gpio_list(),"Backlight GPIO (if applicable)"); - i2cdisp_args.speed = arg_int0("s", "speed", "","Default speed is 8000000 (8MHz) for SPI and 250000 for I2C. The SPI interface can work up to 26MHz~40MHz"); + i2cdisp_args.hflip = arg_lit0(NULL, "hf", "Flip horizontally"); + i2cdisp_args.vflip = arg_lit0(NULL, "vf", "Flip vertically"); + i2cdisp_args.rotate = arg_lit0("r", "rotate", "Rotate 180 degrees"); + i2cdisp_args.back = arg_int0("b", "back", "","Backlight GPIO (if applicable)"); + i2cdisp_args.speed = arg_int0("s", "speed", "","Bus Speed (Default 8000000 for SPI, 250000 for I2C). SPI interface can work up to 26MHz~40MHz"); i2cdisp_args.end = arg_end(8); const esp_console_cmd_t i2c_set_display= { .command = "setdisplay", - .help="Sets the display options", + .help="Display", .hint = NULL, .func = &do_i2c_set_display, .argtable = &i2cdisp_args @@ -1193,15 +1178,15 @@ cJSON * spiconfig_cb(){ static void register_spiconfig(void) { - spiconfig_args.clear = arg_lit0(NULL, "clear", "clear configuration"); - spiconfig_args.clk = arg_int0("k", "clock", get_gpio_list(), "Set the gpio for SPI clock"); - spiconfig_args.data = arg_int0("d","data", get_gpio_list(),"Set the gpio for SPI data"); - spiconfig_args.dc = arg_int0("c","dc", get_gpio_list(), "Set the gpio for SPI dc"); - spiconfig_args.host= arg_int0("h", "host", "int", "Set the SPI host number to use"); + spiconfig_args.clear = arg_lit0(NULL, "clear", "Clear configuration"); + spiconfig_args.clk = arg_int0("k", "clock", "", "Clock GPIO"); + spiconfig_args.data = arg_int0("d","data", "","Data GPIO"); + spiconfig_args.dc = arg_int0("c","dc", "", "DC GPIO"); + spiconfig_args.host= arg_int0("h", "host", "int", "SPI Host Number"); spiconfig_args.end = arg_end(4); const esp_console_cmd_t spiconfig_cmd = { .command = "spiconfig", - .help = "Config SPI bus", + .help = "SPI Bus Parameters", .hint = NULL, .func = &do_spiconfig_cmd, .argtable = &spiconfig_args @@ -1211,16 +1196,16 @@ static void register_spiconfig(void) } static void register_i2cconfig(void) { - i2cconfig_args.clear = arg_lit0(NULL, "clear", "clear configuration"); - i2cconfig_args.port = arg_int0("p", "port", "0|1", "Set the I2C bus port number"); - i2cconfig_args.freq = arg_int0("f", "freq", "int", "Set the frequency(Hz) of I2C bus. e.g. 100000"); - i2cconfig_args.sda = arg_int0("d", "sda", get_gpio_list(), "Set the gpio for I2C SDA. e.g. 19"); - i2cconfig_args.scl = arg_int0("c", "scl", get_gpio_list(), "Set the gpio for I2C SCL. e.g. 18"); - i2cconfig_args.load = arg_lit0("l", "load", "load existing configuration and return"); + i2cconfig_args.clear = arg_lit0(NULL, "clear", "Clear configuration"); + i2cconfig_args.port = arg_int0("p", "port", "0|1", "Port"); + i2cconfig_args.freq = arg_int0("f", "freq", "int", "Frequency (Hz) e.g. 100000"); + i2cconfig_args.sda = arg_int0("d", "sda", "", "SDA GPIO. e.g. 19"); + i2cconfig_args.scl = arg_int0("c", "scl", "", "SCL GPIO. e.g. 18"); + i2cconfig_args.load = arg_lit0("l", "load", "Load Existing Configuration"); i2cconfig_args.end = arg_end(4); const esp_console_cmd_t i2cconfig_cmd = { .command = "i2cconfig", - .help = "Config I2C bus", + .help = "I2C Bus Parameters", .hint = NULL, .func = &do_i2cconfig_cmd, .argtable = &i2cconfig_args diff --git a/components/platform_console/cmd_system.c b/components/platform_console/cmd_system.c index fe0c6920..4835bf8f 100644 --- a/components/platform_console/cmd_system.c +++ b/components/platform_console/cmd_system.c @@ -451,11 +451,11 @@ static void register_heap() static void register_setdevicename() { char * default_host_name = config_alloc_get_str("host_name",NULL,"Squeezelite"); - name_args.name = arg_str0("n", "name", default_host_name, "Device name"); + name_args.name = arg_str0("n", "name", default_host_name, "New Name"); name_args.end = arg_end(8); const esp_console_cmd_t set_name= { .command = "setname", - .help="Sets the name of the device (host, bluetooth, etc)", + .help="Device Name", .hint = NULL, .func = &setdevicename, .argtable = &name_args diff --git a/components/services/accessors.c b/components/services/accessors.c index c8fee533..578263e4 100644 --- a/components/services/accessors.c +++ b/components/services/accessors.c @@ -15,12 +15,23 @@ #include "accessors.h" #include "globdefs.h" #include "display.h" +#include "display.h" +#include "cJSON.h" +#include "driver/gpio.h" +#include "stdbool.h" +#include "driver/adc.h" static const char *TAG = "services"; static const char *i2c_name="I2C"; static const char *spi_name="SPI"; - +static cJSON * gpio_list=NULL; #define min(a,b) (((a) < (b)) ? (a) : (b)) +#ifndef QUOTE + #define QUOTE(name) #name +#endif +#ifndef STR + #define STR(macro) QUOTE(macro) +#endif /**************************************************************************************** * @@ -154,3 +165,228 @@ void parse_set_GPIO(void (*cb)(int gpio, char *value)) { free(nvs_item); } + +/**************************************************************************************** + * + */ +cJSON * get_gpio_entry(const char * name, const char * prefix, int gpio, bool fixed){ + cJSON * entry = cJSON_CreateObject(); + cJSON_AddNumberToObject(entry,"gpio",gpio); + cJSON_AddStringToObject(entry,"name",name); + cJSON_AddStringToObject(entry,"group",prefix); + cJSON_AddBoolToObject(entry,"fixed",fixed); + return entry; +} + +/**************************************************************************************** + * + */ +cJSON * get_GPIO_list() { + cJSON * list = cJSON_CreateArray(); + char *nvs_item, *p, type[16]; + int gpio; + + if ((nvs_item = config_alloc_get(NVS_TYPE_STR, "set_GPIO")) == NULL) return list; + + p = nvs_item; + + do { + if (sscanf(p, "%d=%15[^,]", &gpio, type) > 0 && (GPIO_IS_VALID_GPIO(gpio) || gpio==GPIO_NUM_NC)){ + cJSON_AddItemToArray(list,get_gpio_entry(type,"gpio", gpio, false)); + } + p = strchr(p, ','); + } while (p++); + + free(nvs_item); + + return list; +} + +/**************************************************************************************** + * + */ +cJSON * get_GPIO_from_string(const char * nvs_item, const char * prefix, cJSON * list, bool fixed){ + cJSON * llist = list; + int gpio=0,offset=0,soffset=0,ret1=0,sret=0; + + if(!llist){ + llist = cJSON_CreateArray(); + } + const char *p=NULL; + char type[16]; + int slen=strlen(nvs_item)+1; + char * buf1=malloc(slen); + char * buf2=malloc(slen); + ESP_LOGD(TAG,"Parsing string %s",nvs_item); + p = strchr(nvs_item, ':'); + p=p?p+1:nvs_item; + while((((ret1=sscanf(p, "%[^=]=%d%n", type,&gpio,&offset)) ==2) || ((sret=sscanf(p, "%[^=]=%[^, ],%n", buf1,buf2,&soffset)) > 0 )) && (offset || soffset)){ + if(ret1==2 && (GPIO_IS_VALID_GPIO(gpio) || gpio==GPIO_NUM_NC)){ + cJSON_AddItemToArray(list,get_gpio_entry(type,prefix,gpio,fixed)); + p+=offset; + } else { + p+=soffset; + } + + while(*p==' ' || *p==',') p++; + gpio=-1; + } + free(buf1); + free(buf2); + return llist; + +} + +/**************************************************************************************** + * + */ +cJSON * get_GPIO_from_nvs(const char * item, const char * prefix, cJSON * list, bool fixed){ + char * nvs_item=NULL; + cJSON * llist=list; + if ((nvs_item = config_alloc_get(NVS_TYPE_STR, item)) == NULL) return list; + llist = get_GPIO_from_string(nvs_item,prefix,list, fixed); + free(nvs_item); + return llist; +} + +/**************************************************************************************** + * + */ +esp_err_t get_gpio_structure(cJSON * gpio_entry, gpio_entry_t ** gpio){ + esp_err_t err = ESP_OK; + *gpio = malloc(sizeof(gpio_entry_t)); + //gpio,name,fixed + cJSON * val = cJSON_GetObjectItem(gpio_entry,"gpio"); + if(val){ + (*gpio)->gpio= (int)val->valuedouble; + } + else { + ESP_LOGE(TAG,"gpio pin not found"); + err=ESP_FAIL; + } + val = cJSON_GetObjectItem(gpio_entry,"name"); + if(val){ + (*gpio)->name= strdup(cJSON_GetStringValue(val)); + } + else { + ESP_LOGE(TAG,"gpio name value not found"); + err=ESP_FAIL; + } + val = cJSON_GetObjectItem(gpio_entry,"group"); + if(val){ + (*gpio)->group= strdup(cJSON_GetStringValue(val)); + } + else { + ESP_LOGE(TAG,"gpio group value not found"); + err=ESP_FAIL; + } + val = cJSON_GetObjectItem(gpio_entry,"fixed"); + if(val){ + (*gpio)->fixed= cJSON_IsTrue(val); + } + else { + ESP_LOGE(TAG,"gpio fixed indicator not found"); + err=ESP_FAIL; + } + + return err; +} + +/**************************************************************************************** + * + */ +esp_err_t free_gpio_entry( gpio_entry_t ** gpio) { + if(* gpio){ + free((* gpio)->name); + free((* gpio)->group); + free(* gpio); + * gpio=NULL; + return ESP_OK; + } + return ESP_FAIL; +} + +/**************************************************************************************** + * + */ +gpio_entry_t * get_gpio_by_no(int gpionum, bool refresh){ + cJSON * gpio_header=NULL; + gpio_entry_t * gpio=NULL; + if(refresh){ + get_gpio_list(); + } + cJSON_ArrayForEach(gpio_header,gpio_list) + { + if(get_gpio_structure(gpio_header, &gpio)==ESP_OK && gpio->gpio==gpionum){ + ESP_LOGD(TAG,"Found GPIO: %s=%d %s", gpio->name,gpio->gpio,gpio->fixed?"(FIXED)":"(VARIABLE)"); + } + } + return gpio; +} + +/**************************************************************************************** + * + */ +gpio_entry_t * get_gpio_by_name(char * name,char * group, bool refresh){ + cJSON * gpio_header=NULL; + if(refresh){ + get_gpio_list(); + } + gpio_entry_t * gpio=NULL; + cJSON_ArrayForEach(gpio_header,gpio_list) + { + if(get_gpio_structure(gpio_header, &gpio)==ESP_OK && strcasecmp(gpio->name,name)&& strcasecmp(gpio->group,group)){ + ESP_LOGD(TAG,"Found GPIO: %s=%d %s", gpio->name,gpio->gpio,gpio->fixed?"(FIXED)":"(VARIABLE)"); + } + } + return gpio; +} + +/**************************************************************************************** + * + */ +cJSON * get_gpio_list() { + gpio_num_t gpio_num; + if(gpio_list){ + cJSON_free(gpio_list); + } + gpio_list = get_GPIO_list(); + +#ifndef CONFIG_BAT_LOCKED + char *bat_config = config_alloc_get_default(NVS_TYPE_STR, "bat_config", NULL, 0); + if (bat_config) { + char *p; + int channel; + if ((p = strcasestr(bat_config, "channel") ) != NULL) + { + channel = atoi(strchr(p, '=') + 1); + if(channel != -1){ + if(adc1_pad_get_io_num(channel,&gpio_num )==ESP_OK){ + cJSON_AddItemToArray(gpio_list,get_gpio_entry("bat","",gpio_num,false)); + } + } + } + free(bat_config); + } +#else + if(adc1_pad_get_io_num(CONFIG_BAT_CHANNEL,&gpio_num )==ESP_OK){ + cJSON_AddItemToArray(list,get_gpio_entry("bat","",gpio_num,true)); + } +#endif + gpio_list = get_GPIO_from_nvs("i2c_config","i2c", gpio_list, false); + gpio_list = get_GPIO_from_nvs("spi_config","spi", gpio_list, false); + + char *spdif_config = config_alloc_get_str("spdif_config", CONFIG_SPDIF_CONFIG, "bck=" STR(CONFIG_SPDIF_BCK_IO) + ",ws=" STR(CONFIG_SPDIF_WS_IO) ",do=" STR(CONFIG_SPDIF_DO_IO)); + + gpio_list=get_GPIO_from_string(spdif_config,"spdif", gpio_list, (strlen(CONFIG_SPDIF_CONFIG)>0 || CONFIG_SPDIF_DO_IO>0 )); + char *dac_config = config_alloc_get_str("dac_config", CONFIG_DAC_CONFIG, "model=i2s,bck=" STR(CONFIG_I2S_BCK_IO) + ",ws=" STR(CONFIG_I2S_WS_IO) ",do=" STR(CONFIG_I2S_DO_IO) + ",sda=" STR(CONFIG_I2C_SDA) ",scl=" STR(CONFIG_I2C_SCL) + ",mute=" STR(CONFIG_MUTE_GPIO)); + + gpio_list=get_GPIO_from_string(dac_config,"dac", gpio_list, (strlen(CONFIG_DAC_CONFIG)>0 || CONFIG_I2S_DO_IO>0 )); + free(spdif_config); + free(dac_config); + return gpio_list; +} diff --git a/components/services/accessors.h b/components/services/accessors.h index 69e9c6c8..85446c85 100644 --- a/components/services/accessors.h +++ b/components/services/accessors.h @@ -31,3 +31,14 @@ esp_err_t config_spi_set(const spi_bus_config_t * config, int host, int dc) const i2c_config_t * config_i2c_get(int * i2c_port); const spi_bus_config_t * config_spi_get(spi_host_device_t * spi_host); void parse_set_GPIO(void (*cb)(int gpio, char *value)); + +typedef struct { + bool fixed; + char * name; + char * group; + int gpio; +} gpio_entry_t; +esp_err_t free_gpio_entry( gpio_entry_t ** gpio); +gpio_entry_t * get_gpio_by_name(char * name,char * group, bool refresh); +gpio_entry_t * get_gpio_by_no(int gpionum, bool refresh); +cJSON * get_gpio_list(); diff --git a/components/wifi-manager/code.js b/components/wifi-manager/code.js index 03db2a2f..52e1d32f 100644 --- a/components/wifi-manager/code.js +++ b/components/wifi-manager/code.js @@ -1,51 +1,64 @@ // First, checks if it isn't implemented yet. if (!String.prototype.format) { - String.prototype.format = function() { - var args = arguments; - return this.replace(/{(\d+)}/g, function(match, number) { - return typeof args[number] != 'undefined' - ? args[number] - : match - ; - }); - }; + String.prototype.format = function() { + var args = arguments; + return this.replace(/{(\d+)}/g, function(match, number) { + return typeof args[number] != 'undefined' ? + args[number] : + match; + }); + }; } var nvs_type_t = { - NVS_TYPE_U8 : 0x01, /*!< Type uint8_t */ - NVS_TYPE_I8 : 0x11, /*!< Type int8_t */ - NVS_TYPE_U16 : 0x02, /*!< Type uint16_t */ - NVS_TYPE_I16 : 0x12, /*!< Type int16_t */ - NVS_TYPE_U32 : 0x04, /*!< Type uint32_t */ - NVS_TYPE_I32 : 0x14, /*!< Type int32_t */ - NVS_TYPE_U64 : 0x08, /*!< Type uint64_t */ - NVS_TYPE_I64 : 0x18, /*!< Type int64_t */ - NVS_TYPE_STR : 0x21, /*!< Type string */ - NVS_TYPE_BLOB : 0x42, /*!< Type blob */ - NVS_TYPE_ANY : 0xff /*!< Must be last */ -} ; + NVS_TYPE_U8: 0x01, + /*!< Type uint8_t */ + NVS_TYPE_I8: 0x11, + /*!< Type int8_t */ + NVS_TYPE_U16: 0x02, + /*!< Type uint16_t */ + NVS_TYPE_I16: 0x12, + /*!< Type int16_t */ + NVS_TYPE_U32: 0x04, + /*!< Type uint32_t */ + NVS_TYPE_I32: 0x14, + /*!< Type int32_t */ + NVS_TYPE_U64: 0x08, + /*!< Type uint64_t */ + NVS_TYPE_I64: 0x18, + /*!< Type int64_t */ + NVS_TYPE_STR: 0x21, + /*!< Type string */ + NVS_TYPE_BLOB: 0x42, + /*!< Type blob */ + NVS_TYPE_ANY: 0xff /*!< Must be last */ +}; var task_state_t = { - 0 : "eRunning", /*!< A task is querying the state of itself, so must be running. */ - 1 : "eReady", /*!< The task being queried is in a read or pending ready list. */ - 2 : "eBlocked", /*!< The task being queried is in the Blocked state. */ - 3 : "eSuspended", /*!< The task being queried is in the Suspended state, or is in the Blocked state with an infinite time out. */ - 4 : "eDeleted" + 0: "eRunning", + /*!< A task is querying the state of itself, so must be running. */ + 1: "eReady", + /*!< The task being queried is in a read or pending ready list. */ + 2: "eBlocked", + /*!< The task being queried is in the Blocked state. */ + 3: "eSuspended", + /*!< The task being queried is in the Suspended state, or is in the Blocked state with an infinite time out. */ + 4: "eDeleted" } var escapeHTML = function(unsafe) { - return unsafe.replace(/[&<"']/g, function(m) { - switch (m) { - case '&': - return '&'; - case '<': - return '<'; - case '"': - return '"'; - default: - return '''; - } - }); - }; + return unsafe.replace(/[&<"']/g, function(m) { + switch (m) { + case '&': + return '&'; + case '<': + return '<'; + case '"': + return '"'; + default: + return '''; + } + }); +}; var releaseURL = 'https://api.github.com/repos/sle118/squeezelite-esp32/releases'; var recovery = false; var enableAPTimer = true; @@ -54,814 +67,831 @@ var commandHeader = 'squeezelite -b 500:2000 -d all=info -C 30 -W'; var pname, ver, otapct, otadsc; var blockAjax = false; var blockFlashButton = false; -var dblclickCounter=0; +var dblclickCounter = 0; var apList = null; var selectedSSID = ""; -var refreshAPInterval = null; +var refreshAPInterval = null; var checkStatusInterval = null; var StatusIntervalActive = false; var RefreshAPIIntervalActive = false; -var LastRecoveryState=null; -var LastCommandsState=null; +var LastRecoveryState = null; +var LastCommandsState = null; var output = ''; + function delay_msg(t, v) { - return new Promise(function(resolve) { - setTimeout(resolve.bind(null, v), t) - }); + return new Promise(function(resolve) { + setTimeout(resolve.bind(null, v), t) + }); +} + +Promise.prototype.delay = function(t) { + return this.then(function(v) { + return delay_msg(t, v); + }); +} + +function stopCheckStatusInterval() { + if (checkStatusInterval != null) { + clearTimeout(checkStatusInterval); + checkStatusInterval = null; } + StatusIntervalActive = false; +} - Promise.prototype.delay = function(t) { - return this.then(function(v) { - return delay_msg(t, v); - }); +function stopRefreshAPInterval() { + if (refreshAPInterval != null) { + clearTimeout(refreshAPInterval); + refreshAPInterval = null; } -function stopCheckStatusInterval(){ - if(checkStatusInterval != null){ - clearTimeout(checkStatusInterval); - checkStatusInterval = null; - } - StatusIntervalActive = false; + RefreshAPIIntervalActive = false; } -function stopRefreshAPInterval(){ - if(refreshAPInterval != null){ - clearTimeout(refreshAPInterval); - refreshAPInterval = null; - } - RefreshAPIIntervalActive = false; +function startCheckStatusInterval() { + StatusIntervalActive = true; + checkStatusInterval = setTimeout(checkStatus, 3000); } -function startCheckStatusInterval(){ - StatusIntervalActive = true; - checkStatusInterval = setTimeout(checkStatus, 3000); +function startRefreshAPInterval() { + RefreshAPIIntervalActive = true; + refreshAPInterval = setTimeout(refreshAP(false), 4500); // leave enough time for the initial scan } -function startRefreshAPInterval(){ - RefreshAPIIntervalActive = true; - refreshAPInterval = setTimeout(refreshAP(false), 4500); // leave enough time for the initial scan +function RepeatCheckStatusInterval() { + if (StatusIntervalActive) + startCheckStatusInterval(); } -function RepeatCheckStatusInterval(){ - if(StatusIntervalActive) - startCheckStatusInterval(); +function RepeatRefreshAPInterval() { + if (RefreshAPIIntervalActive) + startRefreshAPInterval(); } -function RepeatRefreshAPInterval(){ - if(RefreshAPIIntervalActive) - startRefreshAPInterval(); -} -function getConfigJson(slimMode){ +function getConfigJson(slimMode) { var config = {}; - $("input.nvs").each(function() { - var key = $(this)[0].id; - var val = $(this).val(); - if(!slimMode){ - var nvs_type = parseInt($(this)[0].attributes.nvs_type.nodeValue,10); - if (key != '') { - config[key] = {}; - if(nvs_type == nvs_type_t.NVS_TYPE_U8 - || nvs_type == nvs_type_t.NVS_TYPE_I8 - || nvs_type == nvs_type_t.NVS_TYPE_U16 - || nvs_type == nvs_type_t.NVS_TYPE_I16 - || nvs_type == nvs_type_t.NVS_TYPE_U32 - || nvs_type == nvs_type_t.NVS_TYPE_I32 - || nvs_type == nvs_type_t.NVS_TYPE_U64 - || nvs_type == nvs_type_t.NVS_TYPE_I64) { - config[key].value = parseInt(val); - } - else { - config[key].value = val; - } - config[key].type = nvs_type; - } - } - else { - config[key] = val; - } - }); - var key = $("#nvs-new-key").val(); - var val = $("#nvs-new-value").val(); - if (key != '') { - if(!slimMode){ - config[key] = {}; - config[key].value = val; - config[key].type = 33; - } - else { - config[key] = val; - } - } - return config; + $("input.nvs").each(function() { + var key = $(this)[0].id; + var val = $(this).val(); + if (!slimMode) { + var nvs_type = parseInt($(this)[0].attributes.nvs_type.nodeValue, 10); + if (key != '') { + config[key] = {}; + if (nvs_type == nvs_type_t.NVS_TYPE_U8 || + nvs_type == nvs_type_t.NVS_TYPE_I8 || + nvs_type == nvs_type_t.NVS_TYPE_U16 || + nvs_type == nvs_type_t.NVS_TYPE_I16 || + nvs_type == nvs_type_t.NVS_TYPE_U32 || + nvs_type == nvs_type_t.NVS_TYPE_I32 || + nvs_type == nvs_type_t.NVS_TYPE_U64 || + nvs_type == nvs_type_t.NVS_TYPE_I64) { + config[key].value = parseInt(val); + } else { + config[key].value = val; + } + config[key].type = nvs_type; + } + } else { + config[key] = val; + } + }); + var key = $("#nvs-new-key").val(); + var val = $("#nvs-new-value").val(); + if (key != '') { + if (!slimMode) { + config[key] = {}; + config[key].value = val; + config[key].type = 33; + } else { + config[key] = val; + } } + return config; +} - - function onFileLoad(elementId, event) { - var data={}; - try{ - data = JSON.parse(elementId.srcElement.result); - } - catch (e){ - alert('Parsing failed!\r\n '+ e); - } - $("input.nvs").each(function() { - var key = $(this)[0].id; - var val = $(this).val(); - if(data[key]){ - if(data[key] != val){ - console.log("Changed "& key & " " & val & "==>" & data[key]); - $(this).val(data[key]); - } - } - else { - console.log("Value " & key & " missing from file"); - } - }); - +function onFileLoad(elementId, event) { + var data = {}; + try { + data = JSON.parse(elementId.srcElement.result); + } catch (e) { + alert('Parsing failed!\r\n ' + e); } - - - function onChooseFile(event, onLoadFileHandler) { - if (typeof window.FileReader !== 'function') - throw ("The file API isn't supported on this browser."); - let input = event.target; - if (!input) - throw ("The browser does not properly implement the event object"); - if (!input.files) - throw ("This browser does not support the `files` property of the file input."); - if (!input.files[0]) - return undefined; - let file = input.files[0]; - let fr = new FileReader(); - fr.onload = onLoadFileHandler; - fr.readAsText(file); - input.value=""; - } - $(document).ready(function(){ - $("input#show-commands")[0].checked=LastCommandsState==1?true:false; - $('a[href^="#tab-commands"]').hide(); - $("#load-nvs").click(function () { - $("#nvsfilename").trigger('click'); + $("input.nvs").each(function() { + var key = $(this)[0].id; + var val = $(this).val(); + if (data[key]) { + if (data[key] != val) { + console.log("Changed " & key & " " & val & "==>" & data[key]); + $(this).val(data[key]); + } + } else { + console.log("Value " & key & " missing from file"); + } + }); + +} + +function onChooseFile(event, onLoadFileHandler) { + if (typeof window.FileReader !== 'function') + throw ("The file API isn't supported on this browser."); + input = event.target; + if (!input) + throw ("The browser does not properly implement the event object"); + if (!input.files) + throw ("This browser does not support the `files` property of the file input."); + if (!input.files[0]) + return undefined; + file = input.files[0]; + fr = new FileReader(); + fr.onload = onLoadFileHandler; + fr.readAsText(file); + input.value = ""; +} +$(document).ready(function() { + $("input#show-commands")[0].checked = LastCommandsState == 1 ? true : false; + $('a[href^="#tab-commands"]').hide(); + $("#load-nvs").click(function() { + $("#nvsfilename").trigger('click'); + }); + $("#wifi-status").on("click", ".ape", function() { + $("#wifi").slideUp("fast", function() {}); + $("#connect-details").slideDown("fast", function() {}); + }); + + $("#manual_add").on("click", ".ape", function() { + selectedSSID = $(this).text(); + $("#ssid-pwd").text(selectedSSID); + $("#wifi").slideUp("fast", function() {}); + $("#connect_manual").slideDown("fast", function() {}); + $("#connect").slideUp("fast", function() {}); + + //update wait screen + $("#loading").show(); + $("#connect-success").hide(); + $("#connect-fail").hide(); + }); + + $("#wifi-list").on("click", ".ape", function() { + selectedSSID = $(this).text(); + $("#ssid-pwd").text(selectedSSID); + $("#wifi").slideUp("fast", function() {}); + $("#connect_manual").slideUp("fast", function() {}); + $("#connect").slideDown("fast", function() {}); + + //update wait screen + $("#loading").show(); + $("#connect-success").hide(); + $("#connect-fail").hide(); + }); + + $("#cancel").on("click", function() { + selectedSSID = ""; + $("#connect").slideUp("fast", function() {}); + $("#connect_manual").slideUp("fast", function() {}); + $("#wifi").slideDown("fast", function() {}); + }); + + $("#manual_cancel").on("click", function() { + selectedSSID = ""; + $("#connect").slideUp("fast", function() {}); + $("#connect_manual").slideUp("fast", function() {}); + $("#wifi").slideDown("fast", function() {}); + }); + + $("#join").on("click", function() { + performConnect(); + }); + + $("#manual_join").on("click", function() { + performConnect($(this).data('connect')); + }); + + $("#ok-details").on("click", function() { + $("#connect-details").slideUp("fast", function() {}); + $("#wifi").slideDown("fast", function() {}); + + }); + + $("#ok-credits").on("click", function() { + $("#credits").slideUp("fast", function() {}); + $("#app").slideDown("fast", function() {}); + }); + + $("#acredits").on("click", function(event) { + event.preventDefault(); + $("#app").slideUp("fast", function() {}); + $("#credits").slideDown("fast", function() {}); + }); + + $("#ok-connect").on("click", function() { + $("#connect-wait").slideUp("fast", function() {}); + $("#wifi").slideDown("fast", function() {}); + }); + + $("#disconnect").on("click", function() { + $("#connect-details-wrap").addClass('blur'); + $("#diag-disconnect").slideDown("fast", function() {}); + }); + + $("#no-disconnect").on("click", function() { + $("#diag-disconnect").slideUp("fast", function() {}); + $("#connect-details-wrap").removeClass('blur'); + }); + + $("#yes-disconnect").on("click", function() { + stopCheckStatusInterval(); + selectedSSID = ""; + + $("#diag-disconnect").slideUp("fast", function() {}); + $("#connect-details-wrap").removeClass('blur'); + + $.ajax({ + url: '/connect.json', + dataType: 'text', + method: 'DELETE', + cache: false, + contentType: 'application/json; charset=utf-8', + data: JSON.stringify({ + 'timestamp': Date.now() + }) + }); - $("#wifi-status").on("click", ".ape", function() { - $( "#wifi" ).slideUp( "fast", function() {}); - $( "#connect-details" ).slideDown( "fast", function() {}); - }); - $("#manual_add").on("click", ".ape", function() { - selectedSSID = $(this).text(); - $( "#ssid-pwd" ).text(selectedSSID); - $( "#wifi" ).slideUp( "fast", function() {}); - $( "#connect_manual" ).slideDown( "fast", function() {}); - $( "#connect" ).slideUp( "fast", function() {}); + startCheckStatusInterval(); - //update wait screen - $( "#loading" ).show(); - $( "#connect-success" ).hide(); - $( "#connect-fail" ).hide(); - }); + $("#connect-details").slideUp("fast", function() {}); + $("#wifi").slideDown("fast", function() {}) + }); - $("#wifi-list").on("click", ".ape", function() { - selectedSSID = $(this).text(); - $( "#ssid-pwd" ).text(selectedSSID); - $( "#wifi" ).slideUp( "fast", function() {}); - $( "#connect_manual" ).slideUp( "fast", function() {}); - $( "#connect" ).slideDown( "fast", function() {}); + $("input#show-commands").on("click", function() { + this.checked = this.checked ? 1 : 0; + if (this.checked) { + $('a[href^="#tab-commands"]').show(); + LastCommandsState = 1; + } else { + LastCommandsState = 0; + $('a[href^="#tab-commands"]').hide(); + } + }); - //update wait screen - $( "#loading" ).show(); - $( "#connect-success" ).hide(); - $( "#connect-fail" ).hide(); - }); + $("input#show-nvs").on("click", function() { + this.checked = this.checked ? 1 : 0; + if (this.checked) { + $('a[href^="#tab-nvs"]').show(); + } else { + $('a[href^="#tab-nvs"]').hide(); + } - $("#cancel").on("click", function() { - selectedSSID = ""; - $( "#connect" ).slideUp( "fast", function() {}); - $( "#connect_manual" ).slideUp( "fast", function() {}); - $( "#wifi" ).slideDown( "fast", function() {}); - }); + }); - $("#manual_cancel").on("click", function() { - selectedSSID = ""; - $( "#connect" ).slideUp( "fast", function() {}); - $( "#connect_manual" ).slideUp( "fast", function() {}); - $( "#wifi" ).slideDown( "fast", function() {}); - }); + $("input#autoexec-cb").on("click", function() { + var data = { + 'timestamp': Date.now() + }; + autoexec = (this.checked) ? "1" : "0"; + data['config'] = {}; + data['config'] = { + autoexec: { + value: autoexec, + type: 33 + } + } - $("#join").on("click", function() { - performConnect(); - }); + showMessage('please wait for the ESP32 to reboot', 'MESSAGING_WARNING'); + $.ajax({ + url: '/config.json', + dataType: 'text', + method: 'POST', + cache: false, + // headers: { "X-Custom-autoexec": autoexec }, + contentType: 'application/json; charset=utf-8', + data: JSON.stringify(data), - $("#manual_join").on("click", function() { - performConnect($(this).data('connect')); - }); + error: function(xhr, ajaxOptions, thrownError) { + console.log(xhr.status); + console.log(thrownError); + if (thrownError != '') showMessage(thrownError, 'MESSAGING_ERROR'); + }, + complete: function(response) { + //var returnedResponse = JSON.parse(response.responseText); + console.log(response.responseText); + console.log('sent config JSON with headers:', autoexec); + console.log('now triggering reboot'); + $.ajax({ + url: '/reboot_ota.json', + dataType: 'text', + method: 'POST', + cache: false, + contentType: 'application/json; charset=utf-8', + data: JSON.stringify({ + 'timestamp': Date.now() + }), + error: function(xhr, ajaxOptions, thrownError) { + console.log(xhr.status); + console.log(thrownError); + if (thrownError != '') showMessage(thrownError, 'MESSAGING_ERROR'); + }, + complete: function(response) { + console.log('reboot call completed'); + } + }); + } + }); + }); - $("#ok-details").on("click", function() { - $( "#connect-details" ).slideUp( "fast", function() {}); - $( "#wifi" ).slideDown( "fast", function() {}); + $("input#save-autoexec1").on("click", function() { + var data = { + 'timestamp': Date.now() + }; + autoexec1 = $("#autoexec1").val(); + data['config'] = {}; + data['config'] = { + autoexec1: { + value: autoexec1, + type: 33 + } + } - }); + $.ajax({ + url: '/config.json', + dataType: 'text', + method: 'POST', + cache: false, + // headers: { "X-Custom-autoexec1": autoexec1 }, + contentType: 'application/json; charset=utf-8', + data: JSON.stringify(data), + error: function(xhr, ajaxOptions, thrownError) { + console.log(xhr.status); + console.log(thrownError); + if (thrownError != '') showMessage(thrownError, 'MESSAGING_ERROR'); + } + }); + console.log('sent config JSON with headers:', autoexec1); + console.log('sent data:', JSON.stringify(data)); + }); - $("#ok-credits").on("click", function() { - $( "#credits" ).slideUp( "fast", function() {}); - $( "#app" ).slideDown( "fast", function() {}); - }); - - $("#acredits").on("click", function(event) { - event.preventDefault(); - $( "#app" ).slideUp( "fast", function() {}); - $( "#credits" ).slideDown( "fast", function() {}); - }); - - $("#ok-connect").on("click", function() { - $( "#connect-wait" ).slideUp( "fast", function() {}); - $( "#wifi" ).slideDown( "fast", function() {}); - }); - - $("#disconnect").on("click", function() { - $( "#connect-details-wrap" ).addClass('blur'); - $( "#diag-disconnect" ).slideDown( "fast", function() {}); - }); - - $("#no-disconnect").on("click", function() { - $( "#diag-disconnect" ).slideUp( "fast", function() {}); - $( "#connect-details-wrap" ).removeClass('blur'); - }); - - $("#yes-disconnect").on("click", function() { - stopCheckStatusInterval(); - selectedSSID = ""; - - $( "#diag-disconnect" ).slideUp( "fast", function() {}); - $( "#connect-details-wrap" ).removeClass('blur'); - - $.ajax({ - url: '/connect.json', - dataType: 'text', - method: 'DELETE', - cache: false, - contentType: 'application/json; charset=utf-8', - data: JSON.stringify({ 'timestamp': Date.now()}) - - }); - - startCheckStatusInterval(); - - $( "#connect-details" ).slideUp( "fast", function() {}); - $( "#wifi" ).slideDown( "fast", function() {}) - }); - - $("input#show-commands").on("click", function() { - this.checked=this.checked?1:0; - if(this.checked){ - $('a[href^="#tab-commands"]').show(); - LastCommandsState = 1; - } else { - LastCommandsState = 0; - $('a[href^="#tab-commands"]').hide(); - } - }); - - $("input#show-nvs").on("click", function() { - this.checked=this.checked?1:0; - if(this.checked){ - $('a[href^="#tab-nvs"]').show(); - } else { - $('a[href^="#tab-nvs"]').hide(); - } - - }); - - $("input#autoexec-cb").on("click", function() { - var data = { 'timestamp': Date.now() }; - autoexec = (this.checked)?"1":"0"; - data['config'] = {}; - data['config'] = { - autoexec : { - value : autoexec, - type : 33 - } - } - - - showMessage('please wait for the ESP32 to reboot', 'MESSAGING_WARNING'); - $.ajax({ - url: '/config.json', - dataType: 'text', - method: 'POST', - cache: false, -// headers: { "X-Custom-autoexec": autoexec }, - contentType: 'application/json; charset=utf-8', - data: JSON.stringify(data), - - error: function (xhr, ajaxOptions, thrownError) { - console.log(xhr.status); - console.log(thrownError); - if (thrownError != '') showMessage(thrownError, 'MESSAGING_ERROR'); - }, - complete: function(response) { - //var returnedResponse = JSON.parse(response.responseText); - console.log(response.responseText); - console.log('sent config JSON with headers:', autoexec); - console.log('now triggering reboot'); - $.ajax({ - url: '/reboot_ota.json', - dataType: 'text', - method: 'POST', - cache: false, - contentType: 'application/json; charset=utf-8', - data: JSON.stringify({ 'timestamp': Date.now()}), - error: function (xhr, ajaxOptions, thrownError) { - console.log(xhr.status); - console.log(thrownError); - if (thrownError != '') showMessage(thrownError, 'MESSAGING_ERROR'); - }, - complete: function(response) { - console.log('reboot call completed'); - } - }); - } - }); - }); - - $("input#save-autoexec1").on("click", function() { - var data = { 'timestamp': Date.now() }; - autoexec1 = $("#autoexec1").val(); - data['config'] = {}; - data['config'] = { - autoexec1 : { - value : autoexec1, - type : 33 - } - } - - $.ajax({ - url: '/config.json', - dataType: 'text', - method: 'POST', - cache: false, -// headers: { "X-Custom-autoexec1": autoexec1 }, - contentType: 'application/json; charset=utf-8', - data: JSON.stringify(data), - error: function (xhr, ajaxOptions, thrownError) { - console.log(xhr.status); - console.log(thrownError); - if (thrownError != '') showMessage(thrownError, 'MESSAGING_ERROR'); - } - }); - console.log('sent config JSON with headers:', autoexec1); - console.log('sent data:', JSON.stringify(data)); - }); - - $("input#save-gpio").on("click", function() { - var data = { 'timestamp': Date.now() }; - var config = {}; - - var headers = {}; - $("input.gpio").each(function() { - var id = $(this)[0].id; - var pin = $(this).val(); - if (pin != '') { - config[id] = {}; - config[id].value = pin; - config[id].type = nvs_type_t.NVS_TYPE_STR; - } - }); - data['config'] = config; - $.ajax({ - url: '/config.json', - dataType: 'text', - method: 'POST', - cache: false, - headers: headers, - contentType: 'application/json; charset=utf-8', - data: JSON.stringify(data), - error: function (xhr, ajaxOptions, thrownError) { - console.log(xhr.status); - console.log(thrownError); - if (thrownError != '') showMessage(thrownError, 'MESSAGING_ERROR'); - } - }); - console.log('sent config JSON with headers:', JSON.stringify(headers)); - console.log('sent config JSON with data:', JSON.stringify(data)); - }); + $("input#save-gpio").on("click", function() { + var data = { + 'timestamp': Date.now() + }; + var config = {}; + var headers = {}; + $("input.gpio").each(function() { + var id = $(this)[0].id; + var pin = $(this).val(); + if (pin != '') { + config[id] = {}; + config[id].value = pin; + config[id].type = nvs_type_t.NVS_TYPE_STR; + } + }); + data['config'] = config; + $.ajax({ + url: '/config.json', + dataType: 'text', + method: 'POST', + cache: false, + headers: headers, + contentType: 'application/json; charset=utf-8', + data: JSON.stringify(data), + error: function(xhr, ajaxOptions, thrownError) { + console.log(xhr.status); + console.log(thrownError); + if (thrownError != '') showMessage(thrownError, 'MESSAGING_ERROR'); + } + }); + console.log('sent config JSON with headers:', JSON.stringify(headers)); + console.log('sent config JSON with data:', JSON.stringify(data)); + }); $("#save-as-nvs").on("click", function() { - var data = { 'timestamp': Date.now() }; - var config = getConfigJson(true); - const a = document.createElement("a"); - a.href = URL.createObjectURL( - new Blob([JSON.stringify(config, null, 2)], { - type: "text/plain" - })); - a.setAttribute("download", "nvs_config" + Date.now() +"json"); - document.body.appendChild(a); - a.click(); - document.body.removeChild(a); - console.log('sent config JSON with headers:', JSON.stringify(headers)); - console.log('sent config JSON with data:', JSON.stringify(data)); - }); - - $("#save-nvs").on("click", function() { - var headers = {}; - var data = { 'timestamp': Date.now() }; - var config = getConfigJson(false); - data['config'] = config; - $.ajax({ - url: '/config.json', - dataType: 'text', - method: 'POST', - cache: false, - headers: headers, - contentType: 'application/json; charset=utf-8', - data : JSON.stringify(data), - error: function (xhr, ajaxOptions, thrownError) { - console.log(xhr.status); - console.log(thrownError); - if (thrownError != '') showMessage(thrownError, 'MESSAGING_ERROR'); - } - }); - console.log('sent config JSON with headers:', JSON.stringify(headers)); - console.log('sent config JSON with data:', JSON.stringify(data)); - }); - $("#fwUpload").on("click", function() { - var upload_path = "/flash.json"; - var fileInput = document.getElementById("flashfilename").files; - if (fileInput.length == 0) { - alert("No file selected!"); - } else { - var file = fileInput[0]; - var xhttp = new XMLHttpRequest(); - xhttp.onreadystatechange = function() { - if (xhttp.readyState == 4) { - if (xhttp.status == 200) { - showMessage(xhttp.responseText, 'MESSAGING_INFO') - } else if (xhttp.status == 0) { - showMessage("Upload connection was closed abruptly!", 'MESSAGING_ERROR'); - } else { - showMessage(xhttp.status + " Error!\n" + xhttp.responseText, 'MESSAGING_ERROR'); - } - } - }; - xhttp.open("POST", upload_path, true); - xhttp.send(file); - } - enableStatusTimer = true; - }); - $("#flash").on("click", function() { - var data = { 'timestamp': Date.now() }; - if (blockFlashButton) return; - blockFlashButton = true; - var url = $("#fwurl").val(); - data['config'] = { - fwurl : { - value : url, - type : 33 - } - }; + var data = { + 'timestamp': Date.now() + }; + var config = getConfigJson(true); + const a = document.createElement("a"); + a.href = URL.createObjectURL( + new Blob([JSON.stringify(config, null, 2)], { + type: "text/plain" + })); + a.setAttribute("download", "nvs_config" + Date.now() + "json"); + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + console.log('sent config JSON with headers:', JSON.stringify(headers)); + console.log('sent config JSON with data:', JSON.stringify(data)); + }); - $.ajax({ - url: '/config.json', - dataType: 'text', - method: 'POST', - cache: false, - contentType: 'application/json; charset=utf-8', - data: JSON.stringify(data), - error: function (xhr, ajaxOptions, thrownError) { - console.log(xhr.status); - console.log(thrownError); - if (thrownError != '') showMessage(thrownError, 'MESSAGING_ERROR'); - } - }); - enableStatusTimer = true; - }); + $("#save-nvs").on("click", function() { + var headers = {}; + var data = { + 'timestamp': Date.now() + }; + var config = getConfigJson(false); + data['config'] = config; + $.ajax({ + url: '/config.json', + dataType: 'text', + method: 'POST', + cache: false, + headers: headers, + contentType: 'application/json; charset=utf-8', + data: JSON.stringify(data), + error: function(xhr, ajaxOptions, thrownError) { + console.log(xhr.status); + console.log(thrownError); + if (thrownError != '') showMessage(thrownError, 'MESSAGING_ERROR'); + } + }); + console.log('sent config JSON with headers:', JSON.stringify(headers)); + console.log('sent config JSON with data:', JSON.stringify(data)); + }); + $("#fwUpload").on("click", function() { + var upload_path = "/flash.json"; + var fileInput = document.getElementById("flashfilename").files; + if (fileInput.length == 0) { + alert("No file selected!"); + } else { + var file = fileInput[0]; + var xhttp = new XMLHttpRequest(); + xhttp.onreadystatechange = function() { + if (xhttp.readyState == 4) { + if (xhttp.status == 200) { + showMessage(xhttp.responseText, 'MESSAGING_INFO') + } else if (xhttp.status == 0) { + showMessage("Upload connection was closed abruptly!", 'MESSAGING_ERROR'); + } else { + showMessage(xhttp.status + " Error!\n" + xhttp.responseText, 'MESSAGING_ERROR'); + } + } + }; + xhttp.open("POST", upload_path, true); + xhttp.send(file); + } + enableStatusTimer = true; + }); + $("#flash").on("click", function() { + var data = { + 'timestamp': Date.now() + }; + if (blockFlashButton) return; + blockFlashButton = true; + var url = $("#fwurl").val(); + data['config'] = { + fwurl: { + value: url, + type: 33 + } + }; - $("#generate-command").on("click", function() { - var commandLine = commandHeader + ' -n "' + $("#player").val() + '"'; + $.ajax({ + url: '/config.json', + dataType: 'text', + method: 'POST', + cache: false, + contentType: 'application/json; charset=utf-8', + data: JSON.stringify(data), + error: function(xhr, ajaxOptions, thrownError) { + console.log(xhr.status); + console.log(thrownError); + if (thrownError != '') showMessage(thrownError, 'MESSAGING_ERROR'); + } + }); + enableStatusTimer = true; + }); - if (output == 'bt') { - commandLine += ' -o "BT -n \'' + $("#btsink").val() + '\'" -R -Z 192000'; - } else if (output == 'spdif') { - commandLine += ' -o SPDIF -R -Z 192000'; - } else { - commandLine += ' -o I2S'; - } - if ($("#optional").val() != '') { - commandLine += ' ' + $("#optional").val(); - } - $("#autoexec1").val(commandLine); - }); + $("#generate-command").on("click", function() { + var commandLine = commandHeader + ' -n "' + $("#player").val() + '"'; - $('[name=audio]').on("click", function(){ - if (this.id == 'bt') { - $("#btsinkdiv").show(200); - output = 'bt'; - } else if (this.id == 'spdif') { - $("#btsinkdiv").hide(200); - output = 'spdif'; - } else { - $("#btsinkdiv").hide(200); - output = 'i2s'; - } - }); + if (output == 'bt') { + commandLine += ' -o "BT -n \'' + $("#btsink").val() + '\'" -R -Z 192000'; + } else if (output == 'spdif') { + commandLine += ' -o SPDIF -R -Z 192000'; + } else { + commandLine += ' -o I2S'; + } + if ($("#optional").val() != '') { + commandLine += ' ' + $("#optional").val(); + } + $("#autoexec1").val(commandLine); + }); - $('#fwcheck').on("click", function(){ - $("#releaseTable").html(""); - $.getJSON(releaseURL, function(data) { - var i=0; - var branches = []; - data.forEach(function(release) { - var [ver, idf, cfg, branch] = release.name.split('#'); - if (!branches.includes(branch)) { - branches.push(branch); - } - }); - var fwb; - branches.forEach(function(branch) { - fwb += ''; - }); - $("#fwbranch").append(fwb); + $('[name=audio]').on("click", function() { + if (this.id == 'bt') { + $("#btsinkdiv").show(200); + output = 'bt'; + } else if (this.id == 'spdif') { + $("#btsinkdiv").hide(200); + output = 'spdif'; + } else { + $("#btsinkdiv").hide(200); + output = 'i2s'; + } + }); - data.forEach(function(release) { - var url = ''; - release.assets.forEach(function(asset) { - if (asset.name.match(/\.bin$/)) { - url = asset.browser_download_url; - } - }); - var [ver, idf, cfg, branch] = release.name.split('#'); - var body = release.body; - body = body.replace(/\'/ig, "\""); - body = body.replace(/[\s\S]+(### Revision Log[\s\S]+)### ESP-IDF Version Used[\s\S]+/, "$1"); - body = body.replace(/- \(.+?\) /g, "- "); - var [date, time] = release.created_at.split('T'); - var trclass = (i++ > 6)?' hide':''; - $("#releaseTable").append( - ""+ - ""+ver+""+ - ""+date+""+ - ""+cfg+""+ - ""+idf+""+ - ""+branch+""+ - ""+ - "" - ); - }); - if (i > 7) { - $("#releaseTable").append( - ""+ - ""+ - ""+ - ""+ - "" - ); - $('#showallbutton').on("click", function(){ - $("tr.hide").removeClass("hide"); - $("tr#showall").addClass("hide"); - }); - } - $("#searchfw").css("display", "inline"); - }) - .fail(function() { - alert("failed to fetch release history!"); - }); - }); + $('#fwcheck').on("click", function() { + $("#releaseTable").html(""); + $.getJSON(releaseURL, function(data) { + var i = 0; + var branches = []; + data.forEach(function(release) { + namecomponents=release.name.split('#'); + ver=namecomponents[0]; + idf=namecomponents[1]; + cfg=namecomponents[2]; + branch=namecomponents[3]; + if (!branches.includes(branch)) { + branches.push(branch); + } + }); + var fwb; + branches.forEach(function(branch) { + fwb += ''; + }); + $("#fwbranch").append(fwb); - $('input#searchinput').on("input", function(){ - var s = $('input#searchinput').val(); - var re = new RegExp(s, "gi"); - if (s.length == 0) { - $("tr.release").removeClass("hide"); - } else if (s.length < 3) { - $("tr.release").addClass("hide"); - } else { - $("tr.release").addClass("hide"); - $("tr.release").each(function(tr){ - $(this).find('td').each (function() { - if ($(this).html().match(re)) { - $(this).parent().removeClass('hide'); - } - }); - }); - } - }); + data.forEach(function(release) { + var url = ''; + release.assets.forEach(function(asset) { + if (asset.name.match(/\.bin$/)) { + url = asset.browser_download_url; + } + }); + namecomponents = release.name.split('#'); + ver=namecomponents[0]; + idf=namecomponents[1]; + cfg=namecomponents[2]; + branch=namecomponents[3]; + + var body = release.body; + body = body.replace(/\'/ig, "\""); + body = body.replace(/[\s\S]+(### Revision Log[\s\S]+)### ESP-IDF Version Used[\s\S]+/, "$1"); + body = body.replace(/- \(.+?\) /g, "- "); + var [date, time] = release.created_at.split('T'); + var trclass = (i++ > 6) ? ' hide' : ''; + $("#releaseTable").append( + "" + + "" + ver + "" + + "" + date + "" + + "" + cfg + "" + + "" + idf + "" + + "" + branch + "" + + "" + + "" + ); + }); + if (i > 7) { + $("#releaseTable").append( + "" + + "" + + "" + + "" + + "" + ); + $('#showallbutton').on("click", function() { + $("tr.hide").removeClass("hide"); + $("tr#showall").addClass("hide"); + }); + } + $("#searchfw").css("display", "inline"); + }) + .fail(function() { + alert("failed to fetch release history!"); + }); + }); - $("#fwbranch").change(function(e) { - var branch = this.value; - var re = new RegExp('^'+branch+'$', "gi"); - $("tr.release").addClass("hide"); - $("tr.release").each(function(tr){ - $(this).find('td').each (function() { - console.log($(this).html()); - if ($(this).html().match(re)) { - $(this).parent().removeClass('hide'); - } - }); - }); - }); + $('input#searchinput').on("input", function() { + var s = $('input#searchinput').val(); + var re = new RegExp(s, "gi"); + if (s.length == 0) { + $("tr.release").removeClass("hide"); + } else if (s.length < 3) { + $("tr.release").addClass("hide"); + } else { + $("tr.release").addClass("hide"); + $("tr.release").each(function(tr) { + $(this).find('td').each(function() { + if ($(this).html().match(re)) { + $(this).parent().removeClass('hide'); + } + }); + }); + } + }); - $('#boot-button').on("click", function(){ - enableStatusTimer = true; - }); - $('#reboot-button').on("click", function(){ - enableStatusTimer = true; - }); - - $('#updateAP').on("click", function(){ - refreshAP(true); - console.log("refresh AP"); - }); + $("#fwbranch").change(function(e) { + var branch = this.value; + var re = new RegExp('^' + branch + '$', "gi"); + $("tr.release").addClass("hide"); + $("tr.release").each(function(tr) { + $(this).find('td').each(function() { + console.log($(this).html()); + if ($(this).html().match(re)) { + $(this).parent().removeClass('hide'); + } + }); + }); + }); - //first time the page loads: attempt to get the connection status and start the wifi scan - refreshAP(false); - getConfig(); - getCommands(); + $('#boot-button').on("click", function() { + enableStatusTimer = true; + }); + $('#reboot-button').on("click", function() { + enableStatusTimer = true; + }); - //start timers - startCheckStatusInterval(); - //startRefreshAPInterval(); + $('#updateAP').on("click", function() { + refreshAP(true); + console.log("refresh AP"); + }); - $('[data-toggle="tooltip"]').tooltip({ - html: true, - placement : 'right', - }); - $('a[href^="#tab-firmware"]').dblclick(function () { - dblclickCounter++; - if(dblclickCounter>=2) - { - dblclickCounter=0; - blockFlashButton=false; - alert("Unocking flash button!"); - } - }); - $('a[href^="#tab-firmware"]').click(function () { - // when navigating back to this table, reset the counter - if(!this.classList.contains("active")) dblclickCounter=0; - }); + //first time the page loads: attempt to get the connection status and start the wifi scan + refreshAP(false); + getConfig(); + getCommands(); + + //start timers + startCheckStatusInterval(); + //startRefreshAPInterval(); + + $('[data-toggle="tooltip"]').tooltip({ + html: true, + placement: 'right', + }); + $('a[href^="#tab-firmware"]').dblclick(function() { + dblclickCounter++; + if (dblclickCounter >= 2) { + dblclickCounter = 0; + blockFlashButton = false; + alert("Unocking flash button!"); + } + }); + $('a[href^="#tab-firmware"]').click(function() { + // when navigating back to this table, reset the counter + if (!this.classList.contains("active")) dblclickCounter = 0; + }); }); function setURL(button) { - var url = button.dataset.url; - $("#fwurl").val(url); + var url = button.dataset.url; + $("#fwurl").val(url); - $('[data-url^="http"]').addClass("btn-success").removeClass("btn-danger"); - $('[data-url="'+url+'"]').addClass("btn-danger").removeClass("btn-success"); + $('[data-url^="http"]').addClass("btn-success").removeClass("btn-danger"); + $('[data-url="' + url + '"]').addClass("btn-danger").removeClass("btn-success"); } -function performConnect(conntype){ - //stop the status refresh. This prevents a race condition where a status - //request would be refreshed with wrong ip info from a previous connection - //and the request would automatically shows as succesful. - stopCheckStatusInterval(); +function performConnect(conntype) { + //stop the status refresh. This prevents a race condition where a status + //request would be refreshed with wrong ip info from a previous connection + //and the request would automatically shows as succesful. + stopCheckStatusInterval(); - //stop refreshing wifi list - stopRefreshAPInterval(); + //stop refreshing wifi list + stopRefreshAPInterval(); - var pwd; - var dhcpname; - if (conntype == 'manual') { - //Grab the manual SSID and PWD - selectedSSID=$('#manual_ssid').val(); - pwd = $("#manual_pwd").val(); - dhcpname= $("#dhcp-name2").val();; - }else{ - pwd = $("#pwd").val(); - dhcpname= $("#dhcp-name1").val();; - } - //reset connection - $( "#loading" ).show(); - $( "#connect-success" ).hide(); - $( "#connect-fail" ).hide(); + var pwd; + var dhcpname; + if (conntype == 'manual') { + //Grab the manual SSID and PWD + selectedSSID = $('#manual_ssid').val(); + pwd = $("#manual_pwd").val(); + dhcpname = $("#dhcp-name2").val();; + } else { + pwd = $("#pwd").val(); + dhcpname = $("#dhcp-name1").val();; + } + //reset connection + $("#loading").show(); + $("#connect-success").hide(); + $("#connect-fail").hide(); - $( "#ok-connect" ).prop("disabled",true); - $( "#ssid-wait" ).text(selectedSSID); - $( "#connect" ).slideUp( "fast", function() {}); - $( "#connect_manual" ).slideUp( "fast", function() {}); - $( "#connect-wait" ).slideDown( "fast", function() {}); + $("#ok-connect").prop("disabled", true); + $("#ssid-wait").text(selectedSSID); + $("#connect").slideUp("fast", function() {}); + $("#connect_manual").slideUp("fast", function() {}); + $("#connect-wait").slideDown("fast", function() {}); - $.ajax({ - url: '/connect.json', - dataType: 'text', - method: 'POST', - cache: false, -// headers: { 'X-Custom-ssid': selectedSSID, 'X-Custom-pwd': pwd, 'X-Custom-host_name': dhcpname }, - contentType: 'application/json; charset=utf-8', - data: JSON.stringify({ 'timestamp': Date.now(), - 'ssid' : selectedSSID, - 'pwd' : pwd, - 'host_name' : dhcpname - }), - error: function (xhr, ajaxOptions, thrownError) { - console.log(xhr.status); - console.log(thrownError); - if (thrownError != '') showMessage(thrownError, 'MESSAGING_ERROR'); - } - }); + $.ajax({ + url: '/connect.json', + dataType: 'text', + method: 'POST', + cache: false, + // headers: { 'X-Custom-ssid': selectedSSID, 'X-Custom-pwd': pwd, 'X-Custom-host_name': dhcpname }, + contentType: 'application/json; charset=utf-8', + data: JSON.stringify({ + 'timestamp': Date.now(), + 'ssid': selectedSSID, + 'pwd': pwd, + 'host_name': dhcpname + }), + error: function(xhr, ajaxOptions, thrownError) { + console.log(xhr.status); + console.log(thrownError); + if (thrownError != '') showMessage(thrownError, 'MESSAGING_ERROR'); + } + }); - //now we can re-set the intervals regardless of result - startCheckStatusInterval(); - startRefreshAPInterval(); + //now we can re-set the intervals regardless of result + startCheckStatusInterval(); + startRefreshAPInterval(); } -function rssiToIcon(rssi){ - if(rssi >= -60){ - return 'w0'; - } - else if(rssi >= -67){ - return 'w1'; - } - else if(rssi >= -75){ - return 'w2'; - } - else{ - return 'w3'; - } +function rssiToIcon(rssi) { + if (rssi >= -60) { + return 'w0'; + } else if (rssi >= -67) { + return 'w1'; + } else if (rssi >= -75) { + return 'w2'; + } else { + return 'w3'; + } } -function refreshAP(force){ - if (!enableAPTimer && !force) return; - $.getJSON( "/scan.json", async function( data ) { - await sleep(2000); - $.getJSON( "/ap.json", function( data ) { - if(data.length > 0){ - //sort by signal strength - data.sort(function (a, b) { - var x = a["rssi"]; var y = b["rssi"]; - return ((x < y) ? 1 : ((x > y) ? -1 : 0)); - }); - apList = data; - refreshAPHTML(apList); - } - }); - }); +function refreshAP(force) { + if (!enableAPTimer && !force) return; + $.getJSON("/scan.json", async function(data) { + await sleep(2000); + $.getJSON("/ap.json", function(data) { + if (data.length > 0) { + //sort by signal strength + data.sort(function(a, b) { + var x = a["rssi"]; + var y = b["rssi"]; + return ((x < y) ? 1 : ((x > y) ? -1 : 0)); + }); + apList = data; + refreshAPHTML(apList); + } + }); + }); } -function refreshAPHTML(data){ - var h = ""; - data.forEach(function(e, idx, array) { - h += '
{3}
'.format(idx === array.length - 1?'':' brdb', rssiToIcon(e.rssi), e.auth==0?'':'pw',e.ssid); - h += "\n"; - }); +function refreshAPHTML(data) { + var h = ""; + data.forEach(function(e, idx, array) { + h += '
{3}
'.format(idx === array.length - 1 ? '' : ' brdb', rssiToIcon(e.rssi), e.auth == 0 ? '' : 'pw', e.ssid); + h += "\n"; + }); - $( "#wifi-list" ).html(h) + $("#wifi-list").html(h) } function getMessages() { - $.getJSON("/messages.json?1", async function(data) { - for (const msg of data) { - var msg_age = msg["current_time"] - msg["sent_time"]; - var msg_time = new Date(); - msg_time.setTime( msg_time.getTime() - msg_age ); - switch (msg["class"]) { - case "MESSAGING_CLASS_OTA": - //message: "{"ota_dsc":"Erasing flash complete","ota_pct":0}" - var ota_data = JSON.parse(msg["message"]); - if (ota_data.hasOwnProperty('ota_pct') && ota_data['ota_pct'] != 0){ - otapct = ota_data['ota_pct']; - $('.progress-bar').css('width', otapct+'%').attr('aria-valuenow', otapct); - $('.progress-bar').html(otapct+'%'); - } - if (ota_data.hasOwnProperty('ota_dsc') && ota_data['ota_dsc'] != ''){ - otadsc = ota_data['ota_dsc']; - $("span#flash-status").html(otadsc); - if (msg.type =="MESSAGING_ERROR" || otapct > 95) { - blockFlashButton = false; - enableStatusTimer = true; - } - } - break; - case "MESSAGING_CLASS_STATS": - // for task states, check structure : task_state_t - var stats_data = JSON.parse(msg["message"]); - console.log(msg_time.toLocaleString() + " - Number of tasks on the ESP32: " + stats_data["ntasks"]); - var stats_tasks = stats_data["tasks"]; - console.log(msg_time.toLocaleString() + '\tname' + '\tcpu' + '\tstate'+ '\tminstk'+ '\tbprio'+ '\tcprio'+ '\tnum' ); - stats_tasks.forEach(function(task) { - console.log(msg_time.toLocaleString() + '\t' + task["nme"] + '\t'+ task["cpu"] + '\t'+ task_state_t[task["st"]]+ '\t'+ task["minstk"]+ '\t'+ task["bprio"]+ '\t'+ task["cprio"]+ '\t'+ task["num"]); - }); - break; - case "MESSAGING_CLASS_SYSTEM": - var r = await showMessage(msg["message"], msg["type"],msg_age); + $.getJSON("/messages.json?1", async function(data) { + for (const msg of data) { + var msg_age = msg["current_time"] - msg["sent_time"]; + var msg_time = new Date(); + msg_time.setTime(msg_time.getTime() - msg_age); + switch (msg["class"]) { + case "MESSAGING_CLASS_OTA": + //message: "{"ota_dsc":"Erasing flash complete","ota_pct":0}" + var ota_data = JSON.parse(msg["message"]); + if (ota_data.hasOwnProperty('ota_pct') && ota_data['ota_pct'] != 0) { + otapct = ota_data['ota_pct']; + $('.progress-bar').css('width', otapct + '%').attr('aria-valuenow', otapct); + $('.progress-bar').html(otapct + '%'); + } + if (ota_data.hasOwnProperty('ota_dsc') && ota_data['ota_dsc'] != '') { + otadsc = ota_data['ota_dsc']; + $("span#flash-status").html(otadsc); + if (msg.type == "MESSAGING_ERROR" || otapct > 95) { + blockFlashButton = false; + enableStatusTimer = true; + } + } + break; + case "MESSAGING_CLASS_STATS": + // for task states, check structure : task_state_t + var stats_data = JSON.parse(msg["message"]); + console.log(msg_time.toLocaleString() + " - Number of tasks on the ESP32: " + stats_data["ntasks"]); + var stats_tasks = stats_data["tasks"]; + console.log(msg_time.toLocaleString() + '\tname' + '\tcpu' + '\tstate' + '\tminstk' + '\tbprio' + '\tcprio' + '\tnum'); + stats_tasks.forEach(function(task) { + console.log(msg_time.toLocaleString() + '\t' + task["nme"] + '\t' + task["cpu"] + '\t' + task_state_t[task["st"]] + '\t' + task["minstk"] + '\t' + task["bprio"] + '\t' + task["cprio"] + '\t' + task["num"]); + }); + break; + case "MESSAGING_CLASS_SYSTEM": + var r = await showMessage(msg["message"], msg["type"], msg_age); - $("#syslogTable").append( - ""+ - ""+msg_time.toLocaleString()+""+ - ""+escapeHTML(msg["message"]).replace(/\n/g, '
')+""+ - "" - ); - break; - default: - break; - } - } - }) - .fail(function(xhr, ajaxOptions, thrownError) { - console.log(xhr.status); - console.log(thrownError); - if (thrownError != '') showMessage(thrownError, 'MESSAGING_ERROR'); - }); - /* + $("#syslogTable").append( + "" + + "" + msg_time.toLocaleString() + "" + + "" + escapeHTML(msg["message"]).replace(/\n/g, '
') + "" + + "" + ); + break; + default: + break; + } + } + }) + .fail(function(xhr, ajaxOptions, thrownError) { + console.log(xhr.status); + console.log(thrownError); + if (thrownError != '') showMessage(thrownError, 'MESSAGING_ERROR'); + }); + /* Minstk is minimum stack space left Bprio is base priority cprio is current priority @@ -870,434 +900,421 @@ st is task state. I provided a "typedef" that you can use to convert to text cpu is cpu percent used */ } -function checkStatus(){ - RepeatCheckStatusInterval(); - if (!enableStatusTimer) return; - if (blockAjax) return; - blockAjax = true; - getMessages(); - $.getJSON( "/status.json", function( data ) { - if (data.hasOwnProperty('ssid') && data['ssid'] != ""){ - if (data["ssid"] === selectedSSID){ - //that's a connection attempt - if (data["urc"] === 0){ - //got connection - $("#connected-to span").text(data["ssid"]); - $("#connect-details h1").text(data["ssid"]); - $("#ip").text(data["ip"]); - $("#netmask").text(data["netmask"]); - $("#gw").text(data["gw"]); - $("#wifi-status").slideDown( "fast", function() {}); - $("span#foot-wifi").html(", SSID: "+data["ssid"]+", IP: "+data["ip"]+""); - //unlock the wait screen if needed - $( "#ok-connect" ).prop("disabled",false); +function checkStatus() { + RepeatCheckStatusInterval(); + if (!enableStatusTimer) return; + if (blockAjax) return; + blockAjax = true; + getMessages(); + $.getJSON("/status.json", function(data) { + if (data.hasOwnProperty('ssid') && data['ssid'] != "") { + if (data["ssid"] === selectedSSID) { + //that's a connection attempt + if (data["urc"] === 0) { + //got connection + $("#connected-to span").text(data["ssid"]); + $("#connect-details h1").text(data["ssid"]); + $("#ip").text(data["ip"]); + $("#netmask").text(data["netmask"]); + $("#gw").text(data["gw"]); + $("#wifi-status").slideDown("fast", function() {}); + $("span#foot-wifi").html(", SSID: " + data["ssid"] + ", IP: " + data["ip"] + ""); - //update wait screen - $( "#loading" ).hide(); - $( "#connect-success" ).text("Your IP address now is: " + data["ip"] ); - $( "#connect-success" ).show(); - $( "#connect-fail" ).hide(); + //unlock the wait screen if needed + $("#ok-connect").prop("disabled", false); - enableAPTimer = false; - if (!recovery) enableStatusTimer = false; - } - else if (data["urc"] === 1){ - //failed attempt - $("#connected-to span").text(''); - $("#connect-details h1").text(''); - $("#ip").text('0.0.0.0'); - $("#netmask").text('0.0.0.0'); - $("#gw").text('0.0.0.0'); - $("span#foot-wifi").html(""); + //update wait screen + $("#loading").hide(); + $("#connect-success").text("Your IP address now is: " + data["ip"]); + $("#connect-success").show(); + $("#connect-fail").hide(); - //don't show any connection - $("#wifi-status").slideUp( "fast", function() {}); + enableAPTimer = false; + if (!recovery) enableStatusTimer = false; + } else if (data["urc"] === 1) { + //failed attempt + $("#connected-to span").text(''); + $("#connect-details h1").text(''); + $("#ip").text('0.0.0.0'); + $("#netmask").text('0.0.0.0'); + $("#gw").text('0.0.0.0'); + $("span#foot-wifi").html(""); - //unlock the wait screen - $( "#ok-connect" ).prop("disabled",false); + //don't show any connection + $("#wifi-status").slideUp("fast", function() {}); - //update wait screen - $( "#loading" ).hide(); - $( "#connect-fail" ).show(); - $( "#connect-success" ).hide(); + //unlock the wait screen + $("#ok-connect").prop("disabled", false); - enableAPTimer = true; - enableStatusTimer = true; - } - } - else if (data.hasOwnProperty('urc') && data['urc'] === 0){ - //ESP32 is already connected to a wifi without having the user do anything - if( !($("#wifi-status").is(":visible")) ){ - $("#connected-to span").text(data["ssid"]); - $("#connect-details h1").text(data["ssid"]); - $("#ip").text(data["ip"]); - $("#netmask").text(data["netmask"]); - $("#gw").text(data["gw"]); - $("#wifi-status").slideDown( "fast", function() {}); - $("span#foot-wifi").html(", SSID: "+data["ssid"]+", IP: "+data["ip"]+""); - } - enableAPTimer = false; - if (!recovery) enableStatusTimer = false; - } - } - else if (data.hasOwnProperty('urc') && data['urc'] === 2){ - //that's a manual disconnect - if($("#wifi-status").is(":visible")){ - $("#wifi-status").slideUp( "fast", function() {}); - $("span#foot-wifi").html(""); - } - enableAPTimer = true; - enableStatusTimer = true; - } - if (data.hasOwnProperty('recovery')) { - if(LastRecoveryState != data["recovery"]){ - LastRecoveryState = data["recovery"]; - $("input#show-nvs")[0].checked=LastRecoveryState==1?true:false; - } - if($("input#show-nvs")[0].checked){ - $('a[href^="#tab-nvs"]').show(); - } else{ - $('a[href^="#tab-nvs"]').hide(); - } + //update wait screen + $("#loading").hide(); + $("#connect-fail").show(); + $("#connect-success").hide(); - if (data["recovery"] === 1) { - recovery = true; - $("#otadiv").show(); - $('a[href^="#tab-audio"]').hide(); - $('a[href^="#tab-gpio"]').show(); - $('#uploaddiv').show(); - $("footer.footer").removeClass('sl'); - $("footer.footer").addClass('recovery'); - $("#boot-button").html('Reboot'); - $("#boot-form").attr('action', '/reboot_ota.json'); + enableAPTimer = true; + enableStatusTimer = true; + } + } else if (data.hasOwnProperty('urc') && data['urc'] === 0) { + //ESP32 is already connected to a wifi without having the user do anything + if (!($("#wifi-status").is(":visible"))) { + $("#connected-to span").text(data["ssid"]); + $("#connect-details h1").text(data["ssid"]); + $("#ip").text(data["ip"]); + $("#netmask").text(data["netmask"]); + $("#gw").text(data["gw"]); + $("#wifi-status").slideDown("fast", function() {}); + $("span#foot-wifi").html(", SSID: " + data["ssid"] + ", IP: " + data["ip"] + ""); + } + enableAPTimer = false; + if (!recovery) enableStatusTimer = false; + } + } else if (data.hasOwnProperty('urc') && data['urc'] === 2) { + //that's a manual disconnect + if ($("#wifi-status").is(":visible")) { + $("#wifi-status").slideUp("fast", function() {}); + $("span#foot-wifi").html(""); + } + enableAPTimer = true; + enableStatusTimer = true; + } + if (data.hasOwnProperty('recovery')) { + if (LastRecoveryState != data["recovery"]) { + LastRecoveryState = data["recovery"]; + $("input#show-nvs")[0].checked = LastRecoveryState == 1 ? true : false; + } + if ($("input#show-nvs")[0].checked) { + $('a[href^="#tab-nvs"]').show(); + } else { + $('a[href^="#tab-nvs"]').hide(); + } - enableStatusTimer = true; - } else { - recovery = false; - $("#otadiv").hide(); - $('a[href^="#tab-audio"]').show(); - $('a[href^="#tab-gpio"]').hide(); - $('#uploaddiv').hide(); - $("footer.footer").removeClass('recovery'); - $("footer.footer").addClass('sl'); - $("#boot-button").html('Recovery'); - $("#boot-form").attr('action', '/recovery.json'); - - enableStatusTimer = false; - } - } - if (data.hasOwnProperty('project_name') && data['project_name'] != ''){ - pname = data['project_name']; - } - if (data.hasOwnProperty('version') && data['version'] != ''){ - ver = data['version']; - $("span#foot-fw").html("fw: "+ver+", mode: "+pname+""); - } - else { - $("span#flash-status").html(''); - } - - if (data.hasOwnProperty('Voltage')) { - var voltage = data['Voltage']; - var layer; - if (voltage > 0) { - if (inRange(voltage, 5.8, 6.2) || inRange(voltage, 8.8, 9.2)) { - layer = bat0; - } else if (inRange(voltage, 6.2, 6.8) || inRange(voltage, 9.2, 10.0)) { - layer = bat1; - } else if (inRange(voltage, 6.8, 7.1) || inRange(voltage, 10.0, 10.5)) { - layer = bat2; - } else if (inRange(voltage, 7.1, 7.5) || inRange(voltage, 10.5, 11.0)) { - layer = bat3; - } else { - layer = bat4; - } - layer.setAttribute("display","inline"); - } - } - if (data.hasOwnProperty('Jack')) { - var jack = data['Jack']; - if (jack == '1') { - o_jack.setAttribute("display","inline"); - } - } - blockAjax = false; - }) - .fail(function(xhr, ajaxOptions, thrownError) { - console.log(xhr.status); - console.log(thrownError); - if (thrownError != '') showMessage(thrownError, 'MESSAGING_ERROR'); - blockAjax = false; - }); + if (data["recovery"] === 1) { + recovery = true; + $("#otadiv").show(); + $('a[href^="#tab-audio"]').hide(); + $('a[href^="#tab-gpio"]').show(); + $('#uploaddiv').show(); + $("footer.footer").removeClass('sl'); + $("footer.footer").addClass('recovery'); + $("#boot-button").html('Reboot'); + $("#boot-form").attr('action', '/reboot_ota.json'); + + enableStatusTimer = true; + } else { + recovery = false; + $("#otadiv").hide(); + $('a[href^="#tab-audio"]').show(); + $('a[href^="#tab-gpio"]').hide(); + $('#uploaddiv').hide(); + $("footer.footer").removeClass('recovery'); + $("footer.footer").addClass('sl'); + $("#boot-button").html('Recovery'); + $("#boot-form").attr('action', '/recovery.json'); + + enableStatusTimer = false; + } + } + if (data.hasOwnProperty('project_name') && data['project_name'] != '') { + pname = data['project_name']; + } + if (data.hasOwnProperty('version') && data['version'] != '') { + ver = data['version']; + $("span#foot-fw").html("fw: " + ver + ", mode: " + pname + ""); + } else { + $("span#flash-status").html(''); + } + + if (data.hasOwnProperty('Voltage')) { + var voltage = data['Voltage']; + var layer; + if (voltage > 0) { + if (inRange(voltage, 5.8, 6.2) || inRange(voltage, 8.8, 9.2)) { + layer = bat0; + } else if (inRange(voltage, 6.2, 6.8) || inRange(voltage, 9.2, 10.0)) { + layer = bat1; + } else if (inRange(voltage, 6.8, 7.1) || inRange(voltage, 10.0, 10.5)) { + layer = bat2; + } else if (inRange(voltage, 7.1, 7.5) || inRange(voltage, 10.5, 11.0)) { + layer = bat3; + } else { + layer = bat4; + } + layer.setAttribute("display", "inline"); + } + } + if (data.hasOwnProperty('Jack')) { + var jack = data['Jack']; + if (jack == '1') { + o_jack.setAttribute("display", "inline"); + } + } + blockAjax = false; + }) + .fail(function(xhr, ajaxOptions, thrownError) { + console.log(xhr.status); + console.log(thrownError); + if (thrownError != '') showMessage(thrownError, 'MESSAGING_ERROR'); + blockAjax = false; + }); } -function runCommand(button,reboot) { +function runCommand(button, reboot) { cmdstring = button.attributes.cmdname.value; - fields=document.getElementById("flds-"+cmdstring); - cmdstring+=' '; - if(fields){ - allfields=fields.querySelectorAll("select,input"); + fields = document.getElementById("flds-" + cmdstring); + cmdstring += ' '; + if (fields) { + allfields = fields.querySelectorAll("select,input"); for (i = 0; i < allfields.length; i++) { - attr=allfields[i].attributes; - qts=''; - opt=''; - optspacer=' '; - isSelect=allfields[i].attributes?.class?.value=="custom-select"; - if(( isSelect && allfields[i].selectedIndex != 0 )|| !isSelect ){ - if (attr.longopts.value!== "undefined"){ - opt+= '--' + attr.longopts.value; - optspacer='='; + attr = allfields[i].attributes; + qts = ''; + opt = ''; + optspacer = ' '; + isSelect = allfields[i].attributes?.class?.value == "custom-select"; + if ((isSelect && allfields[i].selectedIndex != 0) || !isSelect) { + if (attr.longopts.value !== "undefined") { + opt += '--' + attr.longopts.value; + optspacer = '='; + } else if (attr.shortopts.value !== "undefined") { + opt = '-' + attr.shortopts.value; } - else if(attr.shortopts.value!== "undefined"){ - opt= '-' + attr.shortopts.value; - } - - if(attr.hasvalue.value== "true" ){ - if(allfields[i].value!=''){ - qts = (/\s/.test(allfields[i].value))?'"':''; - cmdstring+=opt+optspacer+qts +allfields[i].value +qts+ ' '; + + if (attr.hasvalue.value == "true") { + if (allfields[i].value != '') { + qts = (/\s/.test(allfields[i].value)) ? '"' : ''; + cmdstring += opt + optspacer + qts + allfields[i].value + qts + ' '; } - } - else { + } else { // this is a checkbox - if(allfields[i].checked) cmdstring+=opt+ ' '; + if (allfields[i].checked) cmdstring += opt + ' '; } } } } console.log(cmdstring); - var data = { 'timestamp': Date.now() }; + var data = { + 'timestamp': Date.now() + }; data['command'] = cmdstring; - + $.ajax({ url: '/commands.json', dataType: 'text', method: 'POST', cache: false, contentType: 'application/json; charset=utf-8', - data: JSON.stringify(data), - error: function (xhr, ajaxOptions, thrownError) { + data: JSON.stringify(data), + error: function(xhr, ajaxOptions, thrownError) { console.log(xhr.status); console.log(thrownError); if (thrownError != '') showMessage(thrownError, 'MESSAGING_ERROR'); - + }, - complete: function(response) { - //var returnedResponse = JSON.parse(response.responseText); - console.log(response.responseText); - if(reboot){ - showMessage('Applying. Please wait for the ESP32 to reboot', 'MESSAGING_WARNING'); - console.log('now triggering reboot'); - $.ajax({ - url: '/reboot.json', - dataType: 'text', - method: 'POST', - cache: false, - contentType: 'application/json; charset=utf-8', - data: JSON.stringify({ 'timestamp': Date.now()}), - error: function (xhr, ajaxOptions, thrownError) { - console.log(xhr.status); - console.log(thrownError); - if (thrownError != '') showMessage(thrownError, 'MESSAGING_ERROR'); - }, - complete: function(response) { - console.log('reboot call completed'); - Promise.resolve().delay(5000).then(function(v) { - console.log('Getting updated commands'); - getCommands(); - }); - } - }); - } - } + complete: function(response) { + //var returnedResponse = JSON.parse(response.responseText); + console.log(response.responseText); + if (reboot) { + showMessage('Applying. Please wait for the ESP32 to reboot', 'MESSAGING_WARNING'); + console.log('now triggering reboot'); + $.ajax({ + url: '/reboot.json', + dataType: 'text', + method: 'POST', + cache: false, + contentType: 'application/json; charset=utf-8', + data: JSON.stringify({ + 'timestamp': Date.now() + }), + error: function(xhr, ajaxOptions, thrownError) { + console.log(xhr.status); + console.log(thrownError); + if (thrownError != '') showMessage(thrownError, 'MESSAGING_ERROR'); + }, + complete: function(response) { + console.log('reboot call completed'); + Promise.resolve().delay(5000).then(function(v) { + console.log('Getting updated commands'); + getCommands(); + }); + } + }); + } + } }); enableStatusTimer = true; } - function getCommands() { - $.getJSON("/commands.json", function(data) { - console.log(data); - data.commands.forEach(function(command) { - if($("#flds-"+command.name).length == 0){ - isConfig=($('#'+command.name+'-list').length>0); - innerhtml=''; - //innerhtml+=''+(isConfig?'

':''); - innerhtml+='
' + escapeHTML(command.help).replace(/\n/g, '
')+'
'; - if(command.hasOwnProperty("argtable")){ - command.argtable.forEach(function (arg){ - placeholder=arg?.datatype || ''; - ctrlname=command.name+'-'+arg.longopts; - curvalue=data.values?.[command.name]?.[arg.longopts] || ''; - - - var attributes='hasvalue='+arg.hasvalue+' '; - //attributes +='datatype="'+arg.datatype+'" '; - attributes+='longopts="'+arg.longopts+'" '; - attributes+='shortopts="'+arg.shortopts+'" '; - attributes+='checkbox='+arg.checkbox+' '; - attributes+='cmdname="'+command.name+'" '; - attributes+= 'id="'+ctrlname+'" name="'+ctrlname+'" hasvalue="'+arg.hasvalue+'" '; - if(arg.checkbox){ - innerhtml+='
'; - } - else { - innerhtml+='
'; - if(placeholder.includes('|')){ - placeholder = placeholder.replace('<','').replace('>',''); - innerhtml+=''; + $.getJSON("/commands.json", function(data) { + console.log(data); + data.commands.forEach(function(command) { + if ($("#flds-" + command.name).length == 0) { + isConfig = ($('#' + command.name + '-list').length > 0); + innerhtml = ''; + //innerhtml+=''+(isConfig?'

':''); + innerhtml += '
' + escapeHTML(command.help).replace(/\n/g, '
') + '
'; + innerhtml += '
'; + if (command.hasOwnProperty("argtable")) { + command.argtable.forEach(function(arg) { + placeholder = arg?.datatype || ''; + ctrlname = command.name + '-' + arg.longopts; + curvalue = data.values?. [command.name]?. [arg.longopts]; + + var attributes = 'hasvalue=' + arg.hasvalue + ' '; + //attributes +='datatype="'+arg.datatype+'" '; + attributes += 'longopts="' + arg.longopts + '" '; + attributes += 'shortopts="' + arg.shortopts + '" '; + attributes += 'checkbox=' + arg.checkbox + ' '; + attributes += 'cmdname="' + command.name + '" '; + attributes += 'id="' + ctrlname + '" name="' + ctrlname + '" hasvalue="' + arg.hasvalue + '" '; + if (arg.checkbox) { + innerhtml += '
'; + } else { + innerhtml += '
'; + if (placeholder.includes('|')) { + placeholder = placeholder.replace('<', '').replace('>', ''); + innerhtml += ''; + } else { + innerhtml += ''; + } + innerhtml += 'Previous value: ' + (curvalue || '') + ''; } - else { - innerhtml+=''; + innerhtml += '
'; + }); + } + innerhtml +='
'; + if (isConfig) { + innerhtml += ''; + innerhtml += ''; + } else { + innerhtml += ''; + } + innerhtml += '
'; + + if (isConfig) { + $('#' + command.name + '-list').append(innerhtml); + } else { + $("#commands-list").append(innerhtml); + } + } + }); + + data.commands.forEach(function(command) { + if (command.hasOwnProperty("argtable")) { + command.argtable.forEach(function(arg) { + ctrlselector = '#' + command.name + '-' + arg.longopts; + if (arg.checkbox) { + $(ctrlselector)[0].checked = data.values?. [command.name]?. [arg.longopts]; + } else { + $(ctrlselector)[0].value = data.values?. [command.name]?. [arg.longopts] || ''; + if ($(ctrlselector)[0].value.length == 0 && (arg?.datatype || '').includes('|')) { + $(ctrlselector)[0].value = '--'; } - innerhtml+='Previous value: '+curvalue+''; + } - innerhtml+='

'; - + }); } - - if(isConfig){ - innerhtml+=''; - innerhtml+=''; - } - else { - innerhtml+=''; - } - innerhtml+='
'; - - if(isConfig){ - $('#'+command.name+'-list').append(innerhtml); - } - else { - $("#commands-list").append(innerhtml); - } - } - }); - - - data.commands.forEach(function(command) { - if(command.hasOwnProperty("argtable")){ - command.argtable.forEach(function (arg){ - ctrlselector='#'+command.name+'-'+arg.longopts; - if(arg.checkbox){ - $(ctrlselector)[0].checked=data.values?.[command.name]?.[arg.longopts]; - } - else { - $(ctrlselector)[0].value=data.values?.[command.name]?.[arg.longopts] || ''; - if($(ctrlselector)[0].value.length==0 && (arg?.datatype || '').includes('|')){ - $(ctrlselector)[0].value='--'; - } - - } + }); - }); - } - }); - - - }) - .fail(function(xhr, ajaxOptions, thrownError) { - console.log(xhr.status); - console.log(thrownError); - $("#commands-list").empty(); - if (thrownError != '') showMessage(thrownError, 'MESSAGING_ERROR'); - blockAjax = false; - }); + }) + .fail(function(xhr, ajaxOptions, thrownError) { + console.log(xhr.status); + console.log(thrownError); + $("#commands-list").empty(); + if (thrownError != '') showMessage(thrownError, 'MESSAGING_ERROR'); + blockAjax = false; + }); } function getConfig() { - $.getJSON("/config.json", function(data) { - Object.keys(data).sort().forEach(function(key, i) { - if (data.hasOwnProperty(key)) { - if (key == 'autoexec') { - if (data["autoexec"].value === "1") { - $("#autoexec-cb")[0].checked=true; - } else { - $("#autoexec-cb")[0].checked=false; - } - } else if (key == 'autoexec1') { - $("textarea#autoexec1").val(data[key].value); - var re = / -o "?(\S+)\b/g; - var m = re.exec(data[key].value); - if (m[1] =='I2S') { - o_i2s.setAttribute("display","inline"); - } else if (m[1] =='SPDIF') { - o_spdif.setAttribute("display","inline"); - } else if (m[1] =='BT') { - o_bt.setAttribute("display","inline"); - } - } else if (key == 'host_name') { - $("input#dhcp-name1").val(data[key].value); - $("input#dhcp-name2").val(data[key].value); - } + $.getJSON("/config.json", function(data) { + Object.keys(data.hasOwnProperty('config') ? data.config : data).sort().forEach(function(key, i) { + if (data.hasOwnProperty(key)) { + if (key == 'autoexec') { + if (data["autoexec"].value === "1") { + $("#autoexec-cb")[0].checked = true; + } else { + $("#autoexec-cb")[0].checked = false; + } + } else if (key == 'autoexec1') { + $("textarea#autoexec1").val(data[key].value); + var re = / -o "?(\S+)\b/g; + var m = re.exec(data[key].value); + if (m[1] == 'I2S') { + o_i2s.setAttribute("display", "inline"); + } else if (m[1] == 'SPDIF') { + o_spdif.setAttribute("display", "inline"); + } else if (m[1] == 'BT') { + o_bt.setAttribute("display", "inline"); + } + } else if (key == 'host_name') { + $("input#dhcp-name1").val(data[key].value); + $("input#dhcp-name2").val(data[key].value); + } - $("tbody#nvsTable").append( - ""+ - ""+key+""+ - ""+ - ""+ - ""+ - "" - ); - $("input#"+key).val(data[key].value); - } - }); - $("tbody#nvsTable").append( - ""+ - ""+ - ""+ - ""+ - ""+ - ""+ // todo: provide a way to choose field type - ""+ - "" - ); - }) - .fail(function(xhr, ajaxOptions, thrownError) { - console.log(xhr.status); - console.log(thrownError); - if (thrownError != '') showMessage(thrownError, 'MESSAGING_ERROR'); - blockAjax = false; - }); + $("tbody#nvsTable").append( + "" + + "" + key + "" + + "" + + "" + + "" + + "" + ); + $("input#" + key).val(data[key].value); + } + }); + $("tbody#nvsTable").append(""); + if (data.hasOwnProperty('gpio')) { + data.gpio.forEach(function(gpio_entry) { + cl = gpio_entry.fixed ? "table-light" : "table-dark"; + $("tbody#gpiotable").append('' + gpio_entry.group + '' + gpio_entry.name + '' + gpio_entry.gpio + '' + (gpio_entry.fixed ? 'Fixed':'Configuration') + ''); + }); + } + }) + .fail(function(xhr, ajaxOptions, thrownError) { + console.log(xhr.status); + console.log(thrownError); + if (thrownError != '') showMessage(thrownError, 'MESSAGING_ERROR'); + blockAjax = false; + }); } -function showMessage(message, severity, age=0) { +function showMessage(message, severity, age = 0) { if (severity == 'MESSAGING_INFO') { - $('#message').css('background', '#6af'); - } else if (severity == 'MESSAGING_WARNING') { - $('#message').css('background', '#ff0'); - } else if (severity == 'MESSAGING_ERROR' ) { - $('#message').css('background', '#f00'); - } else { - $('#message').css('background', '#f00'); - } + $('#message').css('background', '#6af'); + } else if (severity == 'MESSAGING_WARNING') { + $('#message').css('background', '#ff0'); + } else if (severity == 'MESSAGING_ERROR') { + $('#message').css('background', '#f00'); + } else { + $('#message').css('background', '#f00'); + } - $('#message').html(message); - return new Promise(function(resolve, reject) { - $("#content").fadeTo("slow", 0.3, function() { - $("#message").show(500).delay(5000).hide(500, function() { - $("#content").fadeTo("slow", 1.0, function() { - resolve(true); - }); - }); - }); - }); + $('#message').html(message); + return new Promise(function(resolve, reject) { + $("#content").fadeTo("slow", 0.3, function() { + $("#message").show(500).delay(5000).hide(500, function() { + $("#content").fadeTo("slow", 1.0, function() { + resolve(true); + }); + }); + }); + }); } function inRange(x, min, max) { - return ((x-min)*(x-max) <= 0); + return ((x - min) * (x - max) <= 0); } function sleep(ms) { - return new Promise(resolve => setTimeout(resolve, ms)); - } + return new Promise(resolve => setTimeout(resolve, ms)); +} \ No newline at end of file diff --git a/components/wifi-manager/http_server_handlers.c b/components/wifi-manager/http_server_handlers.c index ecb78abf..de198c24 100644 --- a/components/wifi-manager/http_server_handlers.c +++ b/components/wifi-manager/http_server_handlers.c @@ -53,6 +53,7 @@ function to process requests, decode URLs, serve files, etc. etc. #include "esp_console.h" #include "argtable3/argtable3.h" #include "platform_console.h" +#include "accessors.h" #define HTTP_STACK_SIZE (5*1024) const char str_na[]="N/A"; @@ -576,7 +577,15 @@ esp_err_t config_get_handler(httpd_req_t *req){ } else { ESP_LOGD_LOC(TAG, "config json : %s",json ); - httpd_resp_send(req, (const char *)json, HTTPD_RESP_USE_STRLEN); + cJSON * gplist=get_gpio_list(); + char * gpliststr=cJSON_PrintUnformatted(gplist); + httpd_resp_sendstr_chunk(req,"{ \"gpio\":"); + httpd_resp_sendstr_chunk(req,gpliststr); + httpd_resp_sendstr_chunk(req,", \"config\":"); + httpd_resp_sendstr_chunk(req, (const char *)json); + httpd_resp_sendstr_chunk(req,"}"); + httpd_resp_sendstr_chunk(req,NULL); + free(gpliststr); free(json); } } diff --git a/components/wifi-manager/index.development.html b/components/wifi-manager/index.development.html new file mode 100644 index 00000000..1f8018b2 --- /dev/null +++ b/components/wifi-manager/index.development.html @@ -0,0 +1,399 @@ + + + + + + + + + + + + + + esp32-wifi-manager + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+
+
+
+
+

Connected to:

+
+
+
+
+
+
+
+
+

Manual connect

+
+
ADD (HIDDEN) SSID
+
+

or choose a network... + +

+
+
+
+
+
+

Enter Details

+
+

DHCP host name

+
+ +
+

Manual Connection

+
+ + +
+
+ + +
+
+
+
+

Connect to network

+
+

DHCP host name

+
+ +
+

Password for

+
+ +
+
+ + +
+
+
+
+

Please wait...

+
+

Connecting to

+
+
+
+
+
+
+

You may lose wifi access while the esp32 recalibrates its radio. Please wait until your device automatically reconnects. This can take up to 30s.

+
+
+

Success!

+
+
+

Connection failed

+

Please double-check wifi password if any and make sure the access point has good signal.

+
+
+
+ +
+
+
+
+
+

+
+

+
+
+ +
+
+

IP Address

+
+
+ IP Address: +
+
+
+ Subnet Mask: +
+
+
+ Default Gateway: +
+
+
+
+ +
+
+
+
+

Are you sure you would like to disconnect from this wifi?

+
+ + +
+
+
+
+
+ +
+
+
+
+
+
+ +
+
+

Audio output

+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ +
+
+

Player name

+ +
+
+

Optional setting (e.g. for LMS IP address)

+ +
+
+ +
+

Squeezelite command to run

+
+ +
+
+ +
+

Start Squeezelite (toggle to activate changes)

+
+ + +
+
+
+ +
+
+
+ +
+
+

Check for firmware upgrade

+
+ +
+
+ + +
+ + + + + + + + + + + + + +
Firmware versionRelease dateHW platformIDF versionBranchFlash this FW
+

Firmware URL:

+ +
+ +
+

OR

+
+ +
+ +
+
+
+
+
+ 0% +
+
+
+
+ +
+
+
+ +
+
+
Logs
+
+ + + + + + + + + +
TimestampMessage
+
+ +
+
+
Pin Assignments
+
+ + +
DevicePin NameGPIO NumberType
+ +
+ + + + + + + + + +
KeyValue
+
+
+
+ +
+
+ + + + +
+
+ +
+
+

squeezelite-esp32, © 2020, philippe44, sle118, daduke
Licensed under the GPL

+

+ This app would not be possible without the following libraries: +

+
    +
  • squeezelite, © 2012-2019, Adrian Smith and Ralph Irving. Licensed under the GPL License.
  • +
  • esp32-wifi-manager, © 2017-2019, Tony Pottier. Licensed under the MIT License.
  • +
  • SpinKit, © 2015, Tobias Ahlin. Licensed under the MIT License.
  • +
  • jQuery, The jQuery Foundation. Licensed under the MIT License.
  • +
  • cJSON, © 2009-2017, Dave Gamble and cJSON contributors. Licensed under the MIT License.
  • +
  • esp32-rotary-encoder, © 2011-2019, David Antliff and Ben Buxton. Licensed under the GPL License.
  • +
  • tarablessd1306, © 2017-2018, Tara Keeling. Licensed under the MIT license.
  • +
+
+

Show NVS Editor

+
+ + +
+

Show Advanced Commands

+
+ + +
+
+ +
+
+ +
+ + \ No newline at end of file diff --git a/components/wifi-manager/index.html b/components/wifi-manager/index.html index a87ad94c..3d0e27b4 100644 --- a/components/wifi-manager/index.html +++ b/components/wifi-manager/index.html @@ -1,385 +1 @@ - - - - - - - - - - - - - - - esp32-wifi-manager - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
-
-
-
-
-
-

Connected to:

-
-
-
-
-

Manual connect

-
-
ADD (HIDDEN) SSID
-
-

or choose a network... - -

-
-
-
- -
-
-

Enter Details

-
-

DHCP host name

-
- -
-

Manual Connection

-
- - -
-
- - -
-
- -
-
-

Connect to network

-
-

DHCP host name

-
- -
-

Password for

-
- -
-
- - -
-
- -
-
-

Please wait...

-
-

Connecting to

-
-
-
-

You may lose wifi access while the esp32 recalibrates its radio. Please wait until your device automatically reconnects. This can take up to 30s.

-
-
-

Success!

-
-
-

Connection failed

-

Please double-check wifi password if any and make sure the access point has good signal.

-
-
-
- -
-
- -
-
-
-

-
-

-
-
- -
-
-

IP Address

-
-
IP Address:
-
Subnet Mask:
-
Default Gateway:
-
-
- -
-
-
-
-

Are you sure you would like to disconnect from this wifi?

-
- - -
-
-
-
-
-
-
-
-
-
- -
- -
-
-

Audio output

-
-
- - -
-
- - -
-
- - -
-
-
-
- -
-
-

Player name

- -
-
-

Optional setting (e.g. for LMS IP address)

- -
- -
- -
- -

Squeezelite command to run

-
- -
-
- -
- -

Start Squeezelite (toggle to activate changes)

-
- - -
-
-
- -
-
-
- -
-
-

Check for firmware upgrade

-
- -
-
- - - -
- - - - - - - - - - - - - -
Firmware versionRelease dateHW platformIDF versionBranchFlash this FW
-

Firmware URL:

- -
- -
-

OR

-
- -
- -
-
- -
-
-
- 0% -
-
-
-
-
-
-
-
- - - - - - - - - -
TimestampMessage
-
- -
-
- -
- - - - - - - - - -
KeyValue
-
-
-
- -
-
- - - - -
-
- -
-
-

squeezelite-esp32, © 2020, philippe44, sle118, daduke
Licensed under the GPL

-

- This app would not be possible without the following libraries: -

-
    -
  • squeezelite, © 2012-2019, Adrian Smith and Ralph Irving. Licensed under the GPL License.
  • -
  • esp32-wifi-manager, © 2017-2019, Tony Pottier. Licensed under the MIT License.
  • -
  • SpinKit, © 2015, Tobias Ahlin. Licensed under the MIT License.
  • -
  • jQuery, The jQuery Foundation. Licensed under the MIT License.
  • -
  • cJSON, © 2009-2017, Dave Gamble and cJSON contributors. Licensed under the MIT License.
  • -
  • esp32-rotary-encoder, © 2011-2019, David Antliff and Ben Buxton. Licensed under the GPL License.
  • -
  • tarablessd1306, © 2017-2018, Tara Keeling. Licensed under the MIT license.
  • -
-
-

Show NVS Editor

-
- - -
-

Show Advanced Commands

-
- - -
-
-
-
- -
- - +esp32-wifi-manager

Connected to:

Manual connect

ADD (HIDDEN) SSID

or choose a network...

Enter Details

DHCP host name

Manual Connection

Connect to network

DHCP host name

Password for

Please wait...

Connecting to

You may lose wifi access while the esp32 recalibrates its radio. Please wait until your device automatically reconnects. This can take up to 30s.

Success!

Connection failed

Please double-check wifi password if any and make sure the access point has good signal.

IP Address

IP Address:
Subnet Mask:
Default Gateway:

Are you sure you would like to disconnect from this wifi?

Audio output

Player name

Optional setting (e.g. for LMS IP address)

Squeezelite command to run

Start Squeezelite (toggle to activate changes)


Check for firmware upgrade

Firmware versionRelease dateHW platformIDF versionBranchFlash this FW

Firmware URL:

OR

0%
Logs
TimestampMessage
Pin Assignments
DevicePin NameGPIO NumberType
KeyValue

squeezelite-esp32, © 2020, philippe44, sle118, daduke
Licensed under the GPL

This app would not be possible without the following libraries:

  • squeezelite, © 2012-2019, Adrian Smith and Ralph Irving. Licensed under the GPL License.
  • esp32-wifi-manager, © 2017-2019, Tony Pottier. Licensed under the MIT License.
  • SpinKit, © 2015, Tobias Ahlin. Licensed under the MIT License.
  • jQuery, The jQuery Foundation. Licensed under the MIT License.
  • cJSON, © 2009-2017, Dave Gamble and cJSON contributors. Licensed under the MIT License.
  • esp32-rotary-encoder, © 2011-2019, David Antliff and Ben Buxton. Licensed under the GPL License.
  • tarablessd1306, © 2017-2018, Tara Keeling. Licensed under the MIT license.

Show NVS Editor

Show Advanced Commands

\ No newline at end of file diff --git a/main/esp_app_main.c b/main/esp_app_main.c index 90de07c8..bdb1568b 100644 --- a/main/esp_app_main.c +++ b/main/esp_app_main.c @@ -44,6 +44,7 @@ #include "gds_text.h" #include "gds_font.h" #include "display.h" +#include "accessors.h" static const char certs_namespace[] = "certificates"; static const char certs_key[] = "blob"; static const char certs_version[] = "version"; @@ -464,7 +465,6 @@ void app_main() wifi_manager_set_callback(ORDER_START_AP, &start_telnet); wifi_manager_set_callback(ORDER_CONNECT_STA, &start_telnet); } - console_start(); if(fwurl && strlen(fwurl)>0){ if(is_recovery_running){