mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-11 22:17:17 +03:00
Wi fi manager (#11)
* autoexec config settings working * small fixes * working autoexec* saving * allow double quotes in command line
This commit is contained in:
@@ -225,6 +225,8 @@ void http_server_netconn_serve(struct netconn *conn) {
|
||||
uint8_t autoexec_flag=0;
|
||||
int buflen=MAX_COMMAND_LINE_SIZE+strlen(template)+1;
|
||||
char * buff = malloc(buflen);
|
||||
char *s = "\"";
|
||||
char *r = "\\\"";
|
||||
if(!buff)
|
||||
{
|
||||
ESP_LOGE(TAG,"Unable to allocate buffer for config.json!");
|
||||
@@ -242,7 +244,7 @@ void http_server_netconn_serve(struct netconn *conn) {
|
||||
do {
|
||||
snprintf(autoexec_name,sizeof(autoexec_name)-1,"autoexec%u",i);
|
||||
ESP_LOGD(TAG,"Getting command name %s", autoexec_name);
|
||||
autoexec_value= wifi_manager_alloc_get_config(autoexec_name, &l);
|
||||
autoexec_value = wifi_manager_alloc_get_config(autoexec_name, &l);
|
||||
if(autoexec_value!=NULL ){
|
||||
if(i>1)
|
||||
{
|
||||
@@ -250,6 +252,7 @@ void http_server_netconn_serve(struct netconn *conn) {
|
||||
ESP_LOGD(TAG,"%s", array_separator);
|
||||
}
|
||||
ESP_LOGI(TAG,"found command %s = %s", autoexec_name, autoexec_value);
|
||||
strreplace(autoexec_value, s, r);
|
||||
snprintf(buff, buflen-1, template, autoexec_name, autoexec_value);
|
||||
netconn_write(conn, buff, strlen(buff), NETCONN_NOCOPY);
|
||||
ESP_LOGD(TAG,"%s", buff);
|
||||
@@ -367,3 +370,23 @@ void http_server_netconn_serve(struct netconn *conn) {
|
||||
/* free the buffer */
|
||||
netbuf_delete(inbuf);
|
||||
}
|
||||
|
||||
void strreplace(char *src, char *str, char *rep)
|
||||
{
|
||||
char *p = strstr(src, str);
|
||||
if (p)
|
||||
{
|
||||
int len = strlen(src)+strlen(rep)-strlen(str);
|
||||
char r[len];
|
||||
memset(r, 0, len);
|
||||
if ( p >= src ){
|
||||
strncpy(r, src, p-src);
|
||||
r[p-src]='\0';
|
||||
strncat(r, rep, strlen(rep));
|
||||
strncat(r, p+strlen(str), p+strlen(str)-src+strlen(src));
|
||||
strcpy(src, r);
|
||||
strreplace(p+strlen(rep), str, rep);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -88,6 +88,9 @@ void http_server_start();
|
||||
*/
|
||||
char* http_server_get_header(char *request, char *header_name, int *len);
|
||||
|
||||
void strreplace(char *src, char *str, char *rep);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -184,7 +184,7 @@ function handleClick(cb) {
|
||||
<div id="autoexec-command">
|
||||
<h2>Command to run</h2>
|
||||
<section id="command-list">
|
||||
<input id="autoexec1" type="text" size="50" maxlength="201" value="squeezelite -o I2S -b 500:2000 -d all=info" />
|
||||
<textarea id="autoexec1" maxlength="120">squeezelite -o I2S -b 500:2000 -d all=info -M esp32</textarea>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -265,6 +265,9 @@ h3 {
|
||||
position: absolute;
|
||||
cursor: pointer;
|
||||
top: 1.5em;
|
||||
|
||||
left: 8px;
|
||||
|
||||
width: 4em;
|
||||
height: 2em;
|
||||
background-color: #c32e04;
|
||||
@@ -343,3 +346,8 @@ input#ota {
|
||||
#otadiv {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
textarea#autoexec1 {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
|
||||
@@ -77,10 +77,9 @@ CONFIG_SPIRAM_SIZE=-1
|
||||
CONFIG_SPIRAM_SPEED_80M=y
|
||||
CONFIG_SPIRAM_MEMTEST=y
|
||||
CONFIG_SPIRAM_CACHE_WORKAROUND=y
|
||||
CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=256
|
||||
CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=65536
|
||||
CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=512
|
||||
CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=32768
|
||||
CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=y
|
||||
CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY=y
|
||||
CONFIG_SPIRAM_OCCUPY_VSPI_HOST=y
|
||||
CONFIG_SPIRAM_BANKSWITCH_ENABLE=n
|
||||
CONFIG_D0WD_PSRAM_CLK_IO=17
|
||||
@@ -114,7 +113,6 @@ CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER=20
|
||||
CONFIG_ESP32_PHY_MAX_TX_POWER=20
|
||||
CONFIG_FREERTOS_HZ=100
|
||||
CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=32
|
||||
CONFIG_LWIP_UDP_RECVMBOX_SIZE=32
|
||||
CONFIG_LWIP_NETIF_LOOPBACK=y
|
||||
CONFIG_LWIP_TCP_MSL=60000
|
||||
CONFIG_LWIP_TCP_SND_BUF_DEFAULT=8192
|
||||
|
||||
Reference in New Issue
Block a user