mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-08 12:37:01 +03:00
Compare commits
13 Commits
developmen
...
developmen
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0c224b4b84 | ||
|
|
bbbc924fcd | ||
|
|
cc5fb49ff8 | ||
|
|
189bc763dd | ||
|
|
78b7639400 | ||
|
|
56954962a3 | ||
|
|
5ff673ae7d | ||
|
|
2eb995d621 | ||
|
|
573ddb6fda | ||
|
|
708a3f9c4a | ||
|
|
a73c659a1e | ||
|
|
b22143a3b6 | ||
|
|
6195750b41 |
@@ -1,6 +1,5 @@
|
|||||||
idf_component_register(SRC_DIRS .
|
idf_component_register(
|
||||||
INCLUDE_DIRS . ./inc inc/alac inc/FLAC inc/helix-aac inc/mad inc/ogg inc/opus inc/opusfile inc/resample16 inc/soxr inc/vorbis
|
INCLUDE_DIRS . ./inc inc/alac inc/FLAC inc/helix-aac inc/mad inc/ogg inc/opus inc/opusfile inc/resample16 inc/soxr inc/vorbis
|
||||||
PRIV_REQUIRES newlib
|
|
||||||
)
|
)
|
||||||
|
|
||||||
add_prebuilt_library(libmad lib/libmad.a)
|
add_prebuilt_library(libmad lib/libmad.a)
|
||||||
@@ -9,16 +8,16 @@ add_prebuilt_library(libhelix-aac lib/libhelix-aac.a )
|
|||||||
add_prebuilt_library(libvorbisidec lib/libvorbisidec.a )
|
add_prebuilt_library(libvorbisidec lib/libvorbisidec.a )
|
||||||
add_prebuilt_library(libogg lib/libogg.a )
|
add_prebuilt_library(libogg lib/libogg.a )
|
||||||
add_prebuilt_library(libalac lib/libalac.a )
|
add_prebuilt_library(libalac lib/libalac.a )
|
||||||
add_prebuilt_library(libremple16 lib/libresample16.a )
|
add_prebuilt_library(libresample16 lib/libresample16.a )
|
||||||
add_prebuilt_library(libopusfile lib/libopusfile.a )
|
add_prebuilt_library(libopusfile lib/libopusfile.a )
|
||||||
add_prebuilt_library(libopus lib/libopus.a )
|
add_prebuilt_library(libopus lib/libopus.a )
|
||||||
target_link_libraries(${COMPONENT_LIB} PRIVATE libmad)
|
|
||||||
target_link_libraries(${COMPONENT_LIB} PRIVATE libFLAC)
|
|
||||||
target_link_libraries(${COMPONENT_LIB} PRIVATE libhelix-aac)
|
|
||||||
target_link_libraries(${COMPONENT_LIB} PRIVATE libvorbisidec)
|
|
||||||
|
|
||||||
target_link_libraries(${COMPONENT_LIB} PRIVATE libogg)
|
target_link_libraries(${COMPONENT_LIB} INTERFACE libmad)
|
||||||
target_link_libraries(${COMPONENT_LIB} PRIVATE libalac)
|
target_link_libraries(${COMPONENT_LIB} INTERFACE libFLAC)
|
||||||
target_link_libraries(${COMPONENT_LIB} PRIVATE libremple16)
|
target_link_libraries(${COMPONENT_LIB} INTERFACE libhelix-aac)
|
||||||
target_link_libraries(${COMPONENT_LIB} PRIVATE libopusfile)
|
target_link_libraries(${COMPONENT_LIB} INTERFACE libvorbisidec)
|
||||||
target_link_libraries(${COMPONENT_LIB} PRIVATE libopus)
|
target_link_libraries(${COMPONENT_LIB} INTERFACE libogg)
|
||||||
|
target_link_libraries(${COMPONENT_LIB} INTERFACE libalac)
|
||||||
|
target_link_libraries(${COMPONENT_LIB} INTERFACE libresample16)
|
||||||
|
target_link_libraries(${COMPONENT_LIB} INTERFACE libopusfile)
|
||||||
|
target_link_libraries(${COMPONENT_LIB} INTERFACE libopus)
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
void dummy_obj() {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
@@ -400,7 +400,7 @@ const char *display_conf_get_driver_name(char * driver){
|
|||||||
/****************************************************************************************
|
/****************************************************************************************
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
char * display_get_supported_drivers(){
|
char * display_get_supported_drivers(void){
|
||||||
int total_size = 1;
|
int total_size = 1;
|
||||||
char * supported_drivers=NULL;
|
char * supported_drivers=NULL;
|
||||||
const char * separator = "|";
|
const char * separator = "|";
|
||||||
|
|||||||
@@ -39,4 +39,4 @@ void displayer_scroll(char *string, int speed, int pause);
|
|||||||
void displayer_control(enum displayer_cmd_e cmd, ...);
|
void displayer_control(enum displayer_cmd_e cmd, ...);
|
||||||
void displayer_metadata(char *artist, char *album, char *title);
|
void displayer_metadata(char *artist, char *album, char *title);
|
||||||
void displayer_timer(enum displayer_time_e mode, int elapsed, int duration);
|
void displayer_timer(enum displayer_time_e mode, int elapsed, int duration);
|
||||||
char * display_get_supported_drivers();
|
char * display_get_supported_drivers(void);
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
#include "messaging.h"
|
#include "messaging.h"
|
||||||
#include "display.h"
|
#include "display.h"
|
||||||
|
|
||||||
#define I2C_MASTER_TX_BUF_DISABLE 0 /*!< I2C master doesn't need buffer */
|
#define I2C_MASTER_TX_BUF_DISABLE 0 /*!< I2C master doesn't need buffer */
|
||||||
#define I2C_MASTER_RX_BUF_DISABLE 0 /*!< I2C master doesn't need buffer */
|
#define I2C_MASTER_RX_BUF_DISABLE 0 /*!< I2C master doesn't need buffer */
|
||||||
#define WRITE_BIT I2C_MASTER_WRITE /*!< I2C master write */
|
#define WRITE_BIT I2C_MASTER_WRITE /*!< I2C master write */
|
||||||
@@ -28,9 +29,12 @@
|
|||||||
#define ACK_CHECK_DIS 0x0 /*!< I2C master will not check ack from slave */
|
#define ACK_CHECK_DIS 0x0 /*!< I2C master will not check ack from slave */
|
||||||
#define ACK_VAL 0x0 /*!< I2C ack value */
|
#define ACK_VAL 0x0 /*!< I2C ack value */
|
||||||
#define NACK_VAL 0x1 /*!< I2C nack value */
|
#define NACK_VAL 0x1 /*!< I2C nack value */
|
||||||
|
extern int spi_system_host;
|
||||||
|
extern int spi_system_dc_gpio;
|
||||||
|
|
||||||
static const char *TAG = "cmd_i2ctools";
|
static const char *TAG = "cmd_i2ctools";
|
||||||
|
#define NOT_OUTPUT "has input capabilities only"
|
||||||
|
#define NOT_GPIO "is not a GPIO"
|
||||||
static gpio_num_t i2c_gpio_sda = 19;
|
static gpio_num_t i2c_gpio_sda = 19;
|
||||||
static gpio_num_t i2c_gpio_scl = 18;
|
static gpio_num_t i2c_gpio_scl = 18;
|
||||||
static uint32_t i2c_frequency = 100000;
|
static uint32_t i2c_frequency = 100000;
|
||||||
@@ -62,14 +66,23 @@ static struct {
|
|||||||
} i2cdump_args;
|
} i2cdump_args;
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
struct arg_lit *load;
|
|
||||||
struct arg_int *port;
|
struct arg_int *port;
|
||||||
struct arg_int *freq;
|
struct arg_int *freq;
|
||||||
struct arg_int *sda;
|
struct arg_int *sda;
|
||||||
struct arg_int *scl;
|
struct arg_int *scl;
|
||||||
|
struct arg_lit *load;
|
||||||
|
struct arg_lit *clear;
|
||||||
struct arg_end *end;
|
struct arg_end *end;
|
||||||
} i2cconfig_args;
|
} i2cconfig_args;
|
||||||
|
|
||||||
|
static struct {
|
||||||
|
struct arg_int *data;
|
||||||
|
struct arg_int *clk;
|
||||||
|
struct arg_int *dc;
|
||||||
|
struct arg_int *host;
|
||||||
|
struct arg_lit *clear;
|
||||||
|
struct arg_end *end;
|
||||||
|
} spiconfig_args;
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
struct arg_int *port;
|
struct arg_int *port;
|
||||||
@@ -84,9 +97,9 @@ static struct {
|
|||||||
static struct {
|
static struct {
|
||||||
struct arg_str *name;
|
struct arg_str *name;
|
||||||
struct arg_str *driver;
|
struct arg_str *driver;
|
||||||
|
struct arg_int *address;
|
||||||
struct arg_int *width;
|
struct arg_int *width;
|
||||||
struct arg_int *height;
|
struct arg_int *height;
|
||||||
struct arg_int *address;
|
|
||||||
struct arg_lit *rotate;
|
struct arg_lit *rotate;
|
||||||
struct arg_lit *hflip;
|
struct arg_lit *hflip;
|
||||||
struct arg_lit *vflip;
|
struct arg_lit *vflip;
|
||||||
@@ -96,7 +109,23 @@ static struct {
|
|||||||
struct arg_end *end;
|
struct arg_end *end;
|
||||||
} i2cdisp_args;
|
} i2cdisp_args;
|
||||||
|
|
||||||
|
int is_output_gpio(struct arg_int * gpio, FILE * f, int * gpio_out){
|
||||||
|
int res = 0;
|
||||||
|
const char * name = gpio->hdr.longopts?gpio->hdr.longopts:gpio->hdr.glossary;
|
||||||
|
*gpio_out=-1;
|
||||||
|
int t_gpio=gpio->ival[0];
|
||||||
|
if(gpio->count==0){
|
||||||
|
fprintf(f,"Missing: %s\n", name);
|
||||||
|
res++;
|
||||||
|
} else if(!GPIO_IS_VALID_OUTPUT_GPIO(t_gpio)){
|
||||||
|
fprintf(f,"Invalid %s gpio: [%d] %s\n",name, t_gpio, GPIO_IS_VALID_GPIO(t_gpio)?NOT_OUTPUT:NOT_GPIO );
|
||||||
|
res++;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
*gpio_out = t_gpio;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
bool is_i2c_started(i2c_port_t port){
|
bool is_i2c_started(i2c_port_t port){
|
||||||
esp_err_t ret = ESP_OK;
|
esp_err_t ret = ESP_OK;
|
||||||
ESP_LOGD(TAG,"Determining if i2c is started on port %u", port);
|
ESP_LOGD(TAG,"Determining if i2c is started on port %u", port);
|
||||||
@@ -116,7 +145,6 @@ bool is_i2c_started(i2c_port_t port){
|
|||||||
return (ret!=ESP_ERR_INVALID_STATE);
|
return (ret!=ESP_ERR_INVALID_STATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t address;
|
uint8_t address;
|
||||||
char * description;
|
char * description;
|
||||||
@@ -371,7 +399,6 @@ static int do_i2c_show_display(int argc, char **argv){
|
|||||||
static int do_i2c_set_display(int argc, char **argv)
|
static int do_i2c_set_display(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int width=0, height=0, address=60, back=-1, speed=8000000 ;
|
int width=0, height=0, address=60, back=-1, speed=8000000 ;
|
||||||
int result = 0;
|
|
||||||
char * name = NULL;
|
char * name = NULL;
|
||||||
char * driver= NULL;
|
char * driver= NULL;
|
||||||
char config_string[200]={};
|
char config_string[200]={};
|
||||||
@@ -439,22 +466,26 @@ static int do_i2c_set_display(int argc, char **argv)
|
|||||||
driver=strdup(i2cdisp_args.driver->sval[0]);
|
driver=strdup(i2cdisp_args.driver->sval[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Check "--back" option */
|
||||||
|
nerrors +=is_output_gpio(i2cdisp_args.back,f,&back);
|
||||||
|
|
||||||
|
|
||||||
|
if(!name) name = strdup("I2C");
|
||||||
/* Check "--speed" option */
|
/* Check "--speed" option */
|
||||||
if (i2cdisp_args.speed->count) {
|
if (i2cdisp_args.speed->count) {
|
||||||
speed=i2cdisp_args.speed->ival[0];
|
speed=i2cdisp_args.speed->ival[0];
|
||||||
}
|
}
|
||||||
/* Check "--back" option */
|
else {
|
||||||
if (i2cdisp_args.back->count) {
|
if(strcasestr(name,"I2C")){
|
||||||
back=i2cdisp_args.back->ival[0];
|
speed = 250000;
|
||||||
if(!GPIO_IS_VALID_OUTPUT_GPIO(back)){
|
}
|
||||||
fprintf(f,"Invalid GPIO for back light: %d %s\n", back, GPIO_IS_VALID_GPIO(back)?"has input capabilities only":"is not a GPIO");
|
else {
|
||||||
back=-1;
|
speed = 8000000;
|
||||||
nerrors ++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(!name) name = strdup("I2C");
|
|
||||||
if(!driver) driver = strdup("SSD1306");
|
if(!driver) driver = strdup("SSD1306");
|
||||||
|
|
||||||
|
|
||||||
@@ -478,29 +509,103 @@ static int do_i2c_set_display(int argc, char **argv)
|
|||||||
name,back,speed,width,height,address,driver,rotate || i2cdisp_args.hflip->count?",HFlip":"",rotate || i2cdisp_args.vflip->count?",VFlip":"" );
|
name,back,speed,width,height,address,driver,rotate || i2cdisp_args.hflip->count?",HFlip":"",rotate || i2cdisp_args.vflip->count?",VFlip":"" );
|
||||||
fprintf(f,"Updating display configuration string configuration to :\n"
|
fprintf(f,"Updating display configuration string configuration to :\n"
|
||||||
"display_config = \"%s\"",config_string );
|
"display_config = \"%s\"",config_string );
|
||||||
result = config_set_value(NVS_TYPE_STR, "display_config", config_string)!=ESP_OK;
|
nerrors = config_set_value(NVS_TYPE_STR, "display_config", config_string)!=ESP_OK;
|
||||||
}
|
|
||||||
else {
|
|
||||||
result = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FREE_AND_NULL(name);
|
FREE_AND_NULL(name);
|
||||||
FREE_AND_NULL(driver);
|
FREE_AND_NULL(driver);
|
||||||
fflush (f);
|
fflush (f);
|
||||||
log_send_messaging(nerrors>0?MESSAGING_ERROR:MESSAGING_INFO,"%s", buf);
|
log_send_messaging(nerrors>0?MESSAGING_ERROR:MESSAGING_INFO,"%s", buf);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
FREE_AND_NULL(buf);
|
FREE_AND_NULL(buf);
|
||||||
return result;
|
return nerrors==0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int do_spiconfig_cmd(int argc, char **argv){
|
||||||
|
static spi_bus_config_t spi_config = {
|
||||||
|
.mosi_io_num = -1,
|
||||||
|
.sclk_io_num = -1,
|
||||||
|
.miso_io_num = -1,
|
||||||
|
.quadwp_io_num = -1,
|
||||||
|
.quadhd_io_num = -1
|
||||||
|
};
|
||||||
|
|
||||||
|
int data, clk, dc, host = 0;
|
||||||
|
esp_err_t err=ESP_OK;
|
||||||
|
int nerrors = arg_parse_msg(argc, argv,(struct arg_hdr **)&spiconfig_args);
|
||||||
|
if (nerrors != 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check "--clear" option */
|
||||||
|
if (spiconfig_args.clear->count) {
|
||||||
|
log_send_messaging(MESSAGING_WARNING,"spi config cleared");
|
||||||
|
config_set_value(NVS_TYPE_STR, "spi_config", "");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *buf = NULL;
|
||||||
|
size_t buf_size = 0;
|
||||||
|
FILE *f = open_memstream(&buf, &buf_size);
|
||||||
|
if (f == NULL) {
|
||||||
|
log_send_messaging(MESSAGING_ERROR,"Unable to open memory stream.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* Check "--clk" option */
|
||||||
|
nerrors+=is_output_gpio(spiconfig_args.clk, f, &clk);
|
||||||
|
nerrors+=is_output_gpio(spiconfig_args.data, f, &data);
|
||||||
|
nerrors+=is_output_gpio(spiconfig_args.dc, f, &dc);
|
||||||
|
nerrors+=is_output_gpio(spiconfig_args.host, f, &host);
|
||||||
|
|
||||||
|
if(!nerrors){
|
||||||
|
spi_config.mosi_io_num=data;
|
||||||
|
spi_config.sclk_io_num=clk;
|
||||||
|
|
||||||
|
fprintf(f,"Configuring SPI data:%d clk:%d host:%u dc:%d", spi_config.mosi_io_num, spi_config.sclk_io_num, host, dc);
|
||||||
|
if((err=spi_bus_initialize( host, &spi_config, 1 ))!=ESP_OK){
|
||||||
|
fprintf(f,"SPI bus initialization failed. %s\n", esp_err_to_name(err));
|
||||||
|
nerrors++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!nerrors){
|
||||||
|
fprintf(f,"Storing SPI parameters.\n");
|
||||||
|
config_spi_set(&spi_config, host, dc);
|
||||||
|
}
|
||||||
|
fflush (f);
|
||||||
|
log_send_messaging(nerrors>0?MESSAGING_ERROR:MESSAGING_INFO,"%s", buf);
|
||||||
|
fclose(f);
|
||||||
|
FREE_AND_NULL(buf);
|
||||||
|
|
||||||
|
return nerrors==0;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int do_i2cconfig_cmd(int argc, char **argv)
|
static int do_i2cconfig_cmd(int argc, char **argv)
|
||||||
{
|
{
|
||||||
esp_err_t err=ESP_OK;
|
esp_err_t err=ESP_OK;
|
||||||
int res=0;
|
|
||||||
char * err_message=malloc(1);
|
|
||||||
int nerrors = arg_parse_msg(argc, argv,(struct arg_hdr **)&i2cconfig_args);
|
int nerrors = arg_parse_msg(argc, argv,(struct arg_hdr **)&i2cconfig_args);
|
||||||
if (nerrors != 0) {
|
if (nerrors != 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
/* Check "--clear" option */
|
||||||
|
if (i2cconfig_args.clear->count) {
|
||||||
|
log_send_messaging(MESSAGING_WARNING,"i2c config cleared");
|
||||||
|
config_set_value(NVS_TYPE_STR, "i2c_config", "");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *buf = NULL;
|
||||||
|
size_t buf_size = 0;
|
||||||
|
FILE *f = open_memstream(&buf, &buf_size);
|
||||||
|
if (f == NULL) {
|
||||||
|
log_send_messaging(MESSAGING_ERROR,"Unable to open memory stream.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Check "--load" option */
|
/* Check "--load" option */
|
||||||
if (i2cconfig_args.load->count) {
|
if (i2cconfig_args.load->count) {
|
||||||
log_send_messaging(MESSAGING_WARNING,"Loading i2c config");
|
log_send_messaging(MESSAGING_WARNING,"Loading i2c config");
|
||||||
@@ -511,71 +616,57 @@ static int do_i2cconfig_cmd(int argc, char **argv)
|
|||||||
/* Check "--port" option */
|
/* Check "--port" option */
|
||||||
if (i2cconfig_args.port->count) {
|
if (i2cconfig_args.port->count) {
|
||||||
if (i2c_get_port(i2cconfig_args.port->ival[0], &i2c_port) != ESP_OK) {
|
if (i2c_get_port(i2cconfig_args.port->ival[0], &i2c_port) != ESP_OK) {
|
||||||
log_send_messaging(MESSAGING_ERROR, "Invalid port %u ",i2cconfig_args.port->ival[0]);
|
fprintf(f,"Invalid port %u \n",i2cconfig_args.port->ival[0]);
|
||||||
return 1;
|
nerrors ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Check "--freq" option */
|
/* Check "--freq" option */
|
||||||
if (i2cconfig_args.freq->count) {
|
if (i2cconfig_args.freq->count) {
|
||||||
i2c_frequency = i2cconfig_args.freq->ival[0];
|
i2c_frequency = i2cconfig_args.freq->ival[0];
|
||||||
}
|
}
|
||||||
if (i2cconfig_args.sda->count){
|
|
||||||
/* Check "--sda" option */
|
|
||||||
i2c_gpio_sda = i2cconfig_args.sda->ival[0];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
REALLOC_CAT(err_message,"Missing --sda option.");
|
|
||||||
res=1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i2cconfig_args.scl->count){
|
nerrors +=is_output_gpio(i2cconfig_args.sda,f,&i2c_gpio_sda);
|
||||||
/* Check "--sda" option */
|
nerrors +=is_output_gpio(i2cconfig_args.scl,f,&i2c_gpio_scl);
|
||||||
i2c_gpio_scl = i2cconfig_args.scl->ival[0];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
REALLOC_CAT(err_message,"Missing --scl option.");
|
|
||||||
res=1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_SQUEEZEAMP
|
#ifdef CONFIG_SQUEEZEAMP
|
||||||
if (i2c_port == I2C_NUM_0) {
|
if (i2c_port == I2C_NUM_0) {
|
||||||
i2c_port = I2C_NUM_1;
|
i2c_port = I2C_NUM_1;
|
||||||
log_send_messaging(MESSAGING_ERROR, "can't use i2c port 0 on SqueezeAMP. Changing to port 1.");
|
fprintf(f,"can't use i2c port 0 on SqueezeAMP. Changing to port 1.\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if(!res){
|
if(!nerrors){
|
||||||
log_send_messaging(MESSAGING_INFO,"Uninstall i2c driver from port %u if needed",i2c_port);
|
fprintf(f,"Uninstalling i2c driver from port %u if needed\n",i2c_port);
|
||||||
if(is_i2c_started(i2c_port)){
|
if(is_i2c_started(i2c_port)){
|
||||||
if((err=i2c_driver_delete(i2c_port))!=ESP_OK){
|
if((err=i2c_driver_delete(i2c_port))!=ESP_OK){
|
||||||
log_send_messaging(MESSAGING_ERROR, "i2c driver delete failed. %s", esp_err_to_name(err));
|
fprintf(f,"i2c driver delete failed. %s\n", esp_err_to_name(err));
|
||||||
res = 1;
|
nerrors++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!res){
|
if(!nerrors){
|
||||||
log_send_messaging(MESSAGING_INFO, "Initializing driver with config scl=%u sda=%u speed=%u port=%u",i2c_gpio_scl,i2c_gpio_sda,i2c_frequency,i2c_port);
|
fprintf(f,"Initializing driver with config scl=%u sda=%u speed=%u port=%u\n",i2c_gpio_scl,i2c_gpio_sda,i2c_frequency,i2c_port);
|
||||||
if((err=i2c_master_driver_initialize())==ESP_OK){
|
if((err=i2c_master_driver_initialize())==ESP_OK){
|
||||||
log_send_messaging(MESSAGING_INFO, "Initalize success.");
|
fprintf(f,"Initalize success.\n");
|
||||||
// now start the i2c driver
|
// now start the i2c driver
|
||||||
log_send_messaging(MESSAGING_INFO,"Starting the i2c driver.");
|
fprintf(f,"Starting the i2c driver.");
|
||||||
if((err=i2c_master_driver_install())!=ESP_OK){
|
if((err=i2c_master_driver_install())!=ESP_OK){
|
||||||
log_send_messaging(MESSAGING_ERROR,"I2C master driver install failed. %s", esp_err_to_name(err));
|
fprintf(f,"I2C master driver install failed. %s\n", esp_err_to_name(err));
|
||||||
res=1;
|
nerrors++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
log_send_messaging(MESSAGING_INFO,"i2c driver successfully started.");
|
fprintf(f,"i2c driver successfully started.\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
log_send_messaging(MESSAGING_ERROR,"I2C initialization failed. %s", esp_err_to_name(err));
|
fprintf(f,"I2C initialization failed. %s\n", esp_err_to_name(err));
|
||||||
res=1;
|
nerrors++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!res && !i2cconfig_args.load->count){
|
if(!nerrors && !i2cconfig_args.load->count){
|
||||||
log_send_messaging(MESSAGING_INFO,"Storing i2c parameters.");
|
fprintf(f,"Storing i2c parameters.\n");
|
||||||
i2c_config_t config={
|
i2c_config_t config={
|
||||||
.mode = I2C_MODE_MASTER,
|
.mode = I2C_MODE_MASTER,
|
||||||
.sda_io_num = i2c_gpio_sda,
|
.sda_io_num = i2c_gpio_sda,
|
||||||
@@ -586,11 +677,12 @@ static int do_i2cconfig_cmd(int argc, char **argv)
|
|||||||
};
|
};
|
||||||
config_i2c_set(&config, i2c_port);
|
config_i2c_set(&config, i2c_port);
|
||||||
}
|
}
|
||||||
if(res){
|
fflush (f);
|
||||||
log_send_messaging(MESSAGING_ERROR,"%s", err_message);
|
log_send_messaging(nerrors>0?MESSAGING_ERROR:MESSAGING_INFO,"%s", buf);
|
||||||
}
|
fclose(f);
|
||||||
free(err_message);
|
FREE_AND_NULL(buf);
|
||||||
return res;
|
|
||||||
|
return nerrors==0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define RUN_SHOW_ERROR(c)
|
#define RUN_SHOW_ERROR(c)
|
||||||
@@ -917,21 +1009,21 @@ cJSON * i2c_set_display_cb(){
|
|||||||
static void register_i2c_set_display(){
|
static void register_i2c_set_display(){
|
||||||
char * supported_drivers = display_get_supported_drivers();
|
char * supported_drivers = display_get_supported_drivers();
|
||||||
|
|
||||||
i2cdisp_args.address = arg_int0("a", "address", "<n>", "Set the device address, default 60");
|
i2cdisp_args.address = arg_int0("a", "address", "<n>", "I2C address (default 60)");
|
||||||
i2cdisp_args.width = arg_int0("w", "width", "<n>", "Set the display width");
|
i2cdisp_args.width = arg_int0("w", "width", "<n>", "Width");
|
||||||
i2cdisp_args.height = arg_int0("h", "height", "<n>", "Set the display height");
|
i2cdisp_args.height = arg_int0("h", "height", "<n>", "Height");
|
||||||
i2cdisp_args.name = arg_str0("t", "type", "<I2C|SPI>", "Display type, I2C or SPI. Default I2C");
|
i2cdisp_args.name = arg_str0("t", "type", "<I2C|SPI>", "Interface (default I2C)");
|
||||||
i2cdisp_args.driver = arg_str0("d", "driver", supported_drivers?supported_drivers:"<string>", "Set the display driver name. Default SSD1306");
|
i2cdisp_args.driver = arg_str0("d", "driver", supported_drivers?supported_drivers:"<string>", "Driver (default SSD1306)");
|
||||||
i2cdisp_args.clear = arg_lit0(NULL, "clear", "clear configuration and return");
|
i2cdisp_args.clear = arg_lit0(NULL, "clear", "clear configuration and return");
|
||||||
i2cdisp_args.hflip = arg_lit0(NULL, "hf", "Flip picture horizontally");
|
i2cdisp_args.hflip = arg_lit0(NULL, "hf", "Flip horizontally");
|
||||||
i2cdisp_args.vflip = arg_lit0(NULL, "vf", "Flip picture vertically");
|
i2cdisp_args.vflip = arg_lit0(NULL, "vf", "Flip vertically");
|
||||||
i2cdisp_args.rotate = arg_lit0("r", "rotate", "Rotate the picture 180 deg");
|
i2cdisp_args.rotate = arg_lit0("r", "rotate", "Rotate 180 degrees");
|
||||||
i2cdisp_args.back = arg_int0("b", "back", "<n>","Backlight GPIO (if applicable)");
|
i2cdisp_args.back = arg_int0("b", "back", "<n>","Backlight GPIO (if applicable)");
|
||||||
i2cdisp_args.speed = arg_int0("s", "speed", "<n>","Default speed is 8000000 (8MHz) but SPI can work up to 26MHz or even 40MHz");
|
i2cdisp_args.speed = arg_int0("s", "speed", "<n>","Bus Speed (Default 8000000 for SPI, 250000 for I2C). SPI interface can work up to 26MHz~40MHz");
|
||||||
i2cdisp_args.end = arg_end(8);
|
i2cdisp_args.end = arg_end(8);
|
||||||
const esp_console_cmd_t i2c_set_display= {
|
const esp_console_cmd_t i2c_set_display= {
|
||||||
.command = "setdisplay",
|
.command = "setdisplay",
|
||||||
.help="Sets the display options for the board",
|
.help="Display",
|
||||||
.hint = NULL,
|
.hint = NULL,
|
||||||
.func = &do_i2c_set_display,
|
.func = &do_i2c_set_display,
|
||||||
.argtable = &i2cdisp_args
|
.argtable = &i2cdisp_args
|
||||||
@@ -1052,23 +1144,68 @@ cJSON * i2config_cb(){
|
|||||||
cJSON * values = cJSON_CreateObject();
|
cJSON * values = cJSON_CreateObject();
|
||||||
int i2c_port;
|
int i2c_port;
|
||||||
const i2c_config_t * i2c= config_i2c_get(&i2c_port);
|
const i2c_config_t * i2c= config_i2c_get(&i2c_port);
|
||||||
|
if(i2c->scl_io_num>0) {
|
||||||
cJSON_AddNumberToObject(values,"scl",i2c->scl_io_num);
|
cJSON_AddNumberToObject(values,"scl",i2c->scl_io_num);
|
||||||
|
}
|
||||||
|
if(i2c->sda_io_num>0) {
|
||||||
cJSON_AddNumberToObject(values,"sda",i2c->sda_io_num);
|
cJSON_AddNumberToObject(values,"sda",i2c->sda_io_num);
|
||||||
|
}
|
||||||
|
if(i2c->master.clk_speed>0) {
|
||||||
cJSON_AddNumberToObject(values,"freq",i2c->master.clk_speed);
|
cJSON_AddNumberToObject(values,"freq",i2c->master.clk_speed);
|
||||||
|
}
|
||||||
|
if(i2c_port>0) {
|
||||||
cJSON_AddNumberToObject(values,"port",i2c_port);
|
cJSON_AddNumberToObject(values,"port",i2c_port);
|
||||||
|
}
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
cJSON * spiconfig_cb(){
|
||||||
|
cJSON * values = cJSON_CreateObject();
|
||||||
|
const spi_bus_config_t * spi_config= config_spi_get(NULL);
|
||||||
|
if(spi_config->mosi_io_num>0){
|
||||||
|
cJSON_AddNumberToObject(values,"data",spi_config->mosi_io_num);
|
||||||
|
}
|
||||||
|
if(spi_config->sclk_io_num>0){
|
||||||
|
cJSON_AddNumberToObject(values,"clk",spi_config->sclk_io_num);
|
||||||
|
}
|
||||||
|
if(spi_system_dc_gpio>0){
|
||||||
|
cJSON_AddNumberToObject(values,"dc",spi_system_dc_gpio);
|
||||||
|
}
|
||||||
|
if(spi_system_host>0){
|
||||||
|
cJSON_AddNumberToObject(values,"host",spi_system_host);
|
||||||
|
}
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void register_spiconfig(void)
|
||||||
|
{
|
||||||
|
spiconfig_args.clear = arg_lit0(NULL, "clear", "Clear configuration");
|
||||||
|
spiconfig_args.clk = arg_int0("k", "clock", "<n>", "Clock GPIO");
|
||||||
|
spiconfig_args.data = arg_int0("d","data", "<n>","Data GPIO");
|
||||||
|
spiconfig_args.dc = arg_int0("c","dc", "<n>", "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 = "SPI Bus Parameters",
|
||||||
|
.hint = NULL,
|
||||||
|
.func = &do_spiconfig_cmd,
|
||||||
|
.argtable = &spiconfig_args
|
||||||
|
};
|
||||||
|
cmd_to_json_with_cb(&spiconfig_cmd,&spiconfig_cb);
|
||||||
|
ESP_ERROR_CHECK(esp_console_cmd_register(&spiconfig_cmd));
|
||||||
|
}
|
||||||
static void register_i2cconfig(void)
|
static void register_i2cconfig(void)
|
||||||
{
|
{
|
||||||
i2cconfig_args.port = arg_int0("p", "port", "0|1", "Set the I2C bus port number");
|
i2cconfig_args.clear = arg_lit0(NULL, "clear", "Clear configuration");
|
||||||
i2cconfig_args.freq = arg_int0("f", "freq", "int", "Set the frequency(Hz) of I2C bus. e.g. 100000");
|
i2cconfig_args.port = arg_int0("p", "port", "0|1", "Port");
|
||||||
i2cconfig_args.sda = arg_int0("d", "sda", "int", "Set the gpio for I2C SDA. e.g. 19");
|
i2cconfig_args.freq = arg_int0("f", "freq", "int", "Frequency (Hz) e.g. 100000");
|
||||||
i2cconfig_args.scl = arg_int0("c", "scl", "int", "Set the gpio for I2C SCL. e.g. 18");
|
i2cconfig_args.sda = arg_int0("d", "sda", "<n>", "SDA GPIO. e.g. 19");
|
||||||
i2cconfig_args.load = arg_lit0("l", "load", "load existing configuration and return");
|
i2cconfig_args.scl = arg_int0("c", "scl", "<n>", "SCL GPIO. e.g. 18");
|
||||||
|
i2cconfig_args.load = arg_lit0("l", "load", "Load Existing Configuration");
|
||||||
i2cconfig_args.end = arg_end(4);
|
i2cconfig_args.end = arg_end(4);
|
||||||
const esp_console_cmd_t i2cconfig_cmd = {
|
const esp_console_cmd_t i2cconfig_cmd = {
|
||||||
.command = "i2cconfig",
|
.command = "i2cconfig",
|
||||||
.help = "Config I2C bus",
|
.help = "I2C Bus Parameters",
|
||||||
.hint = NULL,
|
.hint = NULL,
|
||||||
.func = &do_i2cconfig_cmd,
|
.func = &do_i2cconfig_cmd,
|
||||||
.argtable = &i2cconfig_args
|
.argtable = &i2cconfig_args
|
||||||
@@ -1080,6 +1217,7 @@ static void register_i2cconfig(void)
|
|||||||
void register_i2ctools(void)
|
void register_i2ctools(void)
|
||||||
{
|
{
|
||||||
register_i2cconfig();
|
register_i2cconfig();
|
||||||
|
register_spiconfig();
|
||||||
register_i2cdectect();
|
register_i2cdectect();
|
||||||
register_i2cget();
|
register_i2cget();
|
||||||
register_i2cset();
|
register_i2cset();
|
||||||
|
|||||||
@@ -31,17 +31,22 @@
|
|||||||
#include "driver/uart.h" // for the uart driver access
|
#include "driver/uart.h" // for the uart driver access
|
||||||
#include "messaging.h"
|
#include "messaging.h"
|
||||||
#include "platform_console.h"
|
#include "platform_console.h"
|
||||||
|
#include "trace.h"
|
||||||
|
|
||||||
#ifdef CONFIG_FREERTOS_USE_STATS_FORMATTING_FUNCTIONS
|
#ifdef CONFIG_FREERTOS_USE_STATS_FORMATTING_FUNCTIONS
|
||||||
#define WITH_TASKS_INFO 1
|
#define WITH_TASKS_INFO 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static struct {
|
||||||
|
struct arg_str *name;
|
||||||
|
struct arg_end *end;
|
||||||
|
} name_args;
|
||||||
|
|
||||||
static const char * TAG = "cmd_system";
|
static const char * TAG = "cmd_system";
|
||||||
|
|
||||||
static void register_setbtsource();
|
static void register_setbtsource();
|
||||||
static void register_free();
|
static void register_free();
|
||||||
|
static void register_setdevicename();
|
||||||
static void register_heap();
|
static void register_heap();
|
||||||
static void register_version();
|
static void register_version();
|
||||||
static void register_restart();
|
static void register_restart();
|
||||||
@@ -59,6 +64,7 @@ void register_system()
|
|||||||
register_setbtsource();
|
register_setbtsource();
|
||||||
register_free();
|
register_free();
|
||||||
register_heap();
|
register_heap();
|
||||||
|
register_setdevicename();
|
||||||
register_version();
|
register_version();
|
||||||
register_restart();
|
register_restart();
|
||||||
register_deep_sleep();
|
register_deep_sleep();
|
||||||
@@ -372,6 +378,61 @@ static int heap_size(int argc, char **argv)
|
|||||||
log_send_messaging(MESSAGING_INFO, "min heap size: %u", heap_size);
|
log_send_messaging(MESSAGING_INFO, "min heap size: %u", heap_size);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
cJSON * setdevicename_cb(){
|
||||||
|
char * default_host_name = config_alloc_get_str("host_name",NULL,"Squeezelite");
|
||||||
|
cJSON * values = cJSON_CreateObject();
|
||||||
|
cJSON_AddStringToObject(values,"name",default_host_name);
|
||||||
|
free(default_host_name);
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
static int setnamevar(char * nvsname, FILE *f, char * value){
|
||||||
|
esp_err_t err=ESP_OK;
|
||||||
|
if((err=config_set_value(NVS_TYPE_STR, nvsname, value))!=ESP_OK){
|
||||||
|
fprintf(f,"Unable to set %s=%s. %s\n",nvsname,value,esp_err_to_name(err));
|
||||||
|
}
|
||||||
|
return err==ESP_OK?0:1;
|
||||||
|
}
|
||||||
|
static int setdevicename(int argc, char **argv)
|
||||||
|
{
|
||||||
|
char * name = NULL;
|
||||||
|
int nerrors = arg_parse_msg(argc, argv,(struct arg_hdr **)&name_args);
|
||||||
|
if (nerrors != 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check "--name" option */
|
||||||
|
if (name_args.name->count) {
|
||||||
|
name=strdup(name_args.name->sval[0]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
log_send_messaging(MESSAGING_ERROR,"Name must be specified.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *buf = NULL;
|
||||||
|
size_t buf_size = 0;
|
||||||
|
FILE *f = open_memstream(&buf, &buf_size);
|
||||||
|
if (f == NULL) {
|
||||||
|
log_send_messaging(MESSAGING_ERROR,"Unable to open memory stream.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
nerrors+=setnamevar("a2dp_dev_name", f, name);
|
||||||
|
nerrors+=setnamevar("airplay_name", f, name);
|
||||||
|
nerrors+=setnamevar("ap_ssid", f, name);
|
||||||
|
nerrors+=setnamevar("bt_name", f, name);
|
||||||
|
nerrors+=setnamevar("host_name", f, name);
|
||||||
|
if(nerrors==0){
|
||||||
|
fprintf(f,"Device name changed to %s\n",name);
|
||||||
|
}
|
||||||
|
|
||||||
|
FREE_AND_NULL(name);
|
||||||
|
fflush (f);
|
||||||
|
log_send_messaging(nerrors>0?MESSAGING_ERROR:MESSAGING_INFO,"%s", buf);
|
||||||
|
fclose(f);
|
||||||
|
FREE_AND_NULL(buf);
|
||||||
|
return nerrors==0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
static void register_heap()
|
static void register_heap()
|
||||||
{
|
{
|
||||||
@@ -386,6 +447,22 @@ 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, "New Name");
|
||||||
|
name_args.end = arg_end(8);
|
||||||
|
const esp_console_cmd_t set_name= {
|
||||||
|
.command = "setname",
|
||||||
|
.help="Device Name",
|
||||||
|
.hint = NULL,
|
||||||
|
.func = &setdevicename,
|
||||||
|
.argtable = &name_args
|
||||||
|
};
|
||||||
|
cmd_to_json_with_cb(&set_name,&setdevicename_cb);
|
||||||
|
ESP_ERROR_CHECK(esp_console_cmd_register(&set_name));
|
||||||
|
}
|
||||||
/** 'tasks' command prints the list of tasks and related information */
|
/** 'tasks' command prints the list of tasks and related information */
|
||||||
#if WITH_TASKS_INFO
|
#if WITH_TASKS_INFO
|
||||||
|
|
||||||
|
|||||||
@@ -15,12 +15,23 @@
|
|||||||
#include "accessors.h"
|
#include "accessors.h"
|
||||||
#include "globdefs.h"
|
#include "globdefs.h"
|
||||||
#include "display.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 *TAG = "services";
|
||||||
static const char *i2c_name="I2C";
|
static const char *i2c_name="I2C";
|
||||||
static const char *spi_name="SPI";
|
static const char *spi_name="SPI";
|
||||||
|
static cJSON * gpio_list=NULL;
|
||||||
#define min(a,b) (((a) < (b)) ? (a) : (b))
|
#define min(a,b) (((a) < (b)) ? (a) : (b))
|
||||||
|
#ifndef QUOTE
|
||||||
|
#define QUOTE(name) #name
|
||||||
|
#endif
|
||||||
|
#ifndef STR
|
||||||
|
#define STR(macro) QUOTE(macro)
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************************
|
/****************************************************************************************
|
||||||
*
|
*
|
||||||
@@ -36,6 +47,20 @@ esp_err_t config_i2c_set(const i2c_config_t * config, int port){
|
|||||||
}
|
}
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
/****************************************************************************************
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
esp_err_t config_spi_set(const spi_bus_config_t * config, int host, int dc){
|
||||||
|
int buffer_size=255;
|
||||||
|
char * config_buffer=calloc(buffer_size,1);
|
||||||
|
if(config_buffer) {
|
||||||
|
snprintf(config_buffer,buffer_size,"data=%u,clk=%u,dc=%u,host=%u",config->mosi_io_num,config->sclk_io_num,dc,host);
|
||||||
|
ESP_LOGI(TAG,"Updating SPI configuration to %s",config_buffer);
|
||||||
|
config_set_value(NVS_TYPE_STR, "spi_config", config_buffer);
|
||||||
|
free(config_buffer);
|
||||||
|
}
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************************
|
/****************************************************************************************
|
||||||
*
|
*
|
||||||
@@ -140,3 +165,228 @@ void parse_set_GPIO(void (*cb)(int gpio, char *value)) {
|
|||||||
|
|
||||||
free(nvs_item);
|
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(gpio_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;
|
||||||
|
}
|
||||||
|
|||||||
@@ -27,6 +27,18 @@ typedef struct {
|
|||||||
} display_config_t;
|
} display_config_t;
|
||||||
const display_config_t * config_display_get();
|
const display_config_t * config_display_get();
|
||||||
esp_err_t config_i2c_set(const i2c_config_t * config, int port);
|
esp_err_t config_i2c_set(const i2c_config_t * config, int port);
|
||||||
|
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 i2c_config_t * config_i2c_get(int * i2c_port);
|
||||||
const spi_bus_config_t * config_spi_get(spi_host_device_t * spi_host);
|
const spi_bus_config_t * config_spi_get(spi_host_device_t * spi_host);
|
||||||
void parse_set_GPIO(void (*cb)(int gpio, char *value));
|
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();
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ static struct {
|
|||||||
/****************************************************************************************
|
/****************************************************************************************
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int battery_value_svc(void) {
|
float battery_value_svc(void) {
|
||||||
return battery.avg;
|
return battery.avg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -237,7 +237,7 @@ void monitor_svc_init(void) {
|
|||||||
monitor_timer = xTimerCreate("monitor", MONITOR_TIMER / portTICK_RATE_MS, pdTRUE, NULL, monitor_callback);
|
monitor_timer = xTimerCreate("monitor", MONITOR_TIMER / portTICK_RATE_MS, pdTRUE, NULL, monitor_callback);
|
||||||
xTimerStart(monitor_timer, portMAX_DELAY);
|
xTimerStart(monitor_timer, portMAX_DELAY);
|
||||||
}
|
}
|
||||||
free(p);
|
FREE_AND_NULL(p);
|
||||||
|
|
||||||
ESP_LOGI(TAG, "Heap internal:%zu (min:%zu) external:%zu (min:%zu)",
|
ESP_LOGI(TAG, "Heap internal:%zu (min:%zu) external:%zu (min:%zu)",
|
||||||
heap_caps_get_free_size(MALLOC_CAP_INTERNAL),
|
heap_caps_get_free_size(MALLOC_CAP_INTERNAL),
|
||||||
|
|||||||
@@ -16,6 +16,6 @@ extern bool jack_inserted_svc(void);
|
|||||||
extern void (*spkfault_handler_svc)(bool inserted);
|
extern void (*spkfault_handler_svc)(bool inserted);
|
||||||
extern bool spkfault_svc(void);
|
extern bool spkfault_svc(void);
|
||||||
|
|
||||||
extern int battery_value_svc(void);
|
extern float battery_value_svc(void);
|
||||||
extern uint8_t battery_level_svc(void);
|
extern uint8_t battery_level_svc(void);
|
||||||
|
|
||||||
|
|||||||
@@ -3,32 +3,45 @@ if (!String.prototype.format) {
|
|||||||
String.prototype.format = function() {
|
String.prototype.format = function() {
|
||||||
var args = arguments;
|
var args = arguments;
|
||||||
return this.replace(/{(\d+)}/g, function(match, number) {
|
return this.replace(/{(\d+)}/g, function(match, number) {
|
||||||
return typeof args[number] != 'undefined'
|
return typeof args[number] != 'undefined' ?
|
||||||
? args[number]
|
args[number] :
|
||||||
: match
|
match;
|
||||||
;
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
var nvs_type_t = {
|
var nvs_type_t = {
|
||||||
NVS_TYPE_U8 : 0x01, /*!< Type uint8_t */
|
NVS_TYPE_U8: 0x01,
|
||||||
NVS_TYPE_I8 : 0x11, /*!< Type int8_t */
|
/*!< Type uint8_t */
|
||||||
NVS_TYPE_U16 : 0x02, /*!< Type uint16_t */
|
NVS_TYPE_I8: 0x11,
|
||||||
NVS_TYPE_I16 : 0x12, /*!< Type int16_t */
|
/*!< Type int8_t */
|
||||||
NVS_TYPE_U32 : 0x04, /*!< Type uint32_t */
|
NVS_TYPE_U16: 0x02,
|
||||||
NVS_TYPE_I32 : 0x14, /*!< Type int32_t */
|
/*!< Type uint16_t */
|
||||||
NVS_TYPE_U64 : 0x08, /*!< Type uint64_t */
|
NVS_TYPE_I16: 0x12,
|
||||||
NVS_TYPE_I64 : 0x18, /*!< Type int64_t */
|
/*!< Type int16_t */
|
||||||
NVS_TYPE_STR : 0x21, /*!< Type string */
|
NVS_TYPE_U32: 0x04,
|
||||||
NVS_TYPE_BLOB : 0x42, /*!< Type blob */
|
/*!< 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_ANY: 0xff /*!< Must be last */
|
||||||
};
|
};
|
||||||
|
|
||||||
var task_state_t = {
|
var task_state_t = {
|
||||||
0 : "eRunning", /*!< A task is querying the state of itself, so must be running. */
|
0: "eRunning",
|
||||||
1 : "eReady", /*!< The task being queried is in a read or pending ready list. */
|
/*!< A task is querying the state of itself, so must be running. */
|
||||||
2 : "eBlocked", /*!< The task being queried is in the Blocked state. */
|
1: "eReady",
|
||||||
3 : "eSuspended", /*!< The task being queried is in the Suspended state, or is in the Blocked state with an infinite time out. */
|
/*!< 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"
|
4: "eDeleted"
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -66,6 +79,18 @@ var LastRecoveryState=null;
|
|||||||
var LastCommandsState = null;
|
var LastCommandsState = null;
|
||||||
var output = '';
|
var output = '';
|
||||||
|
|
||||||
|
function delay_msg(t, v) {
|
||||||
|
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() {
|
function stopCheckStatusInterval() {
|
||||||
if (checkStatusInterval != null) {
|
if (checkStatusInterval != null) {
|
||||||
clearTimeout(checkStatusInterval);
|
clearTimeout(checkStatusInterval);
|
||||||
@@ -101,6 +126,7 @@ function RepeatRefreshAPInterval(){
|
|||||||
if (RefreshAPIIntervalActive)
|
if (RefreshAPIIntervalActive)
|
||||||
startRefreshAPInterval();
|
startRefreshAPInterval();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getConfigJson(slimMode) {
|
function getConfigJson(slimMode) {
|
||||||
var config = {};
|
var config = {};
|
||||||
$("input.nvs").each(function() {
|
$("input.nvs").each(function() {
|
||||||
@@ -110,23 +136,21 @@ function getConfigJson(slimMode){
|
|||||||
var nvs_type = parseInt($(this)[0].attributes.nvs_type.nodeValue, 10);
|
var nvs_type = parseInt($(this)[0].attributes.nvs_type.nodeValue, 10);
|
||||||
if (key != '') {
|
if (key != '') {
|
||||||
config[key] = {};
|
config[key] = {};
|
||||||
if(nvs_type == nvs_type_t.NVS_TYPE_U8
|
if (nvs_type == nvs_type_t.NVS_TYPE_U8 ||
|
||||||
|| nvs_type == nvs_type_t.NVS_TYPE_I8
|
nvs_type == nvs_type_t.NVS_TYPE_I8 ||
|
||||||
|| nvs_type == nvs_type_t.NVS_TYPE_U16
|
nvs_type == nvs_type_t.NVS_TYPE_U16 ||
|
||||||
|| nvs_type == nvs_type_t.NVS_TYPE_I16
|
nvs_type == nvs_type_t.NVS_TYPE_I16 ||
|
||||||
|| nvs_type == nvs_type_t.NVS_TYPE_U32
|
nvs_type == nvs_type_t.NVS_TYPE_U32 ||
|
||||||
|| nvs_type == nvs_type_t.NVS_TYPE_I32
|
nvs_type == nvs_type_t.NVS_TYPE_I32 ||
|
||||||
|| nvs_type == nvs_type_t.NVS_TYPE_U64
|
nvs_type == nvs_type_t.NVS_TYPE_U64 ||
|
||||||
|| nvs_type == nvs_type_t.NVS_TYPE_I64) {
|
nvs_type == nvs_type_t.NVS_TYPE_I64) {
|
||||||
config[key].value = parseInt(val);
|
config[key].value = parseInt(val);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
config[key].value = val;
|
config[key].value = val;
|
||||||
}
|
}
|
||||||
config[key].type = nvs_type;
|
config[key].type = nvs_type;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
config[key] = val;
|
config[key] = val;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -137,21 +161,18 @@ function getConfigJson(slimMode){
|
|||||||
config[key] = {};
|
config[key] = {};
|
||||||
config[key].value = val;
|
config[key].value = val;
|
||||||
config[key].type = 33;
|
config[key].type = 33;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
config[key] = val;
|
config[key] = val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function onFileLoad(elementId, event) {
|
function onFileLoad(elementId, event) {
|
||||||
var data = {};
|
var data = {};
|
||||||
try {
|
try {
|
||||||
data = JSON.parse(elementId.srcElement.result);
|
data = JSON.parse(elementId.srcElement.result);
|
||||||
}
|
} catch (e) {
|
||||||
catch (e){
|
|
||||||
alert('Parsing failed!\r\n ' + e);
|
alert('Parsing failed!\r\n ' + e);
|
||||||
}
|
}
|
||||||
$("input.nvs").each(function() {
|
$("input.nvs").each(function() {
|
||||||
@@ -162,27 +183,25 @@ function getConfigJson(slimMode){
|
|||||||
console.log("Changed " & key & " " & val & "==>" & data[key]);
|
console.log("Changed " & key & " " & val & "==>" & data[key]);
|
||||||
$(this).val(data[key]);
|
$(this).val(data[key]);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
console.log("Value " & key & " missing from file");
|
console.log("Value " & key & " missing from file");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function onChooseFile(event, onLoadFileHandler) {
|
function onChooseFile(event, onLoadFileHandler) {
|
||||||
if (typeof window.FileReader !== 'function')
|
if (typeof window.FileReader !== 'function')
|
||||||
throw ("The file API isn't supported on this browser.");
|
throw ("The file API isn't supported on this browser.");
|
||||||
let input = event.target;
|
input = event.target;
|
||||||
if (!input)
|
if (!input)
|
||||||
throw ("The browser does not properly implement the event object");
|
throw ("The browser does not properly implement the event object");
|
||||||
if (!input.files)
|
if (!input.files)
|
||||||
throw ("This browser does not support the `files` property of the file input.");
|
throw ("This browser does not support the `files` property of the file input.");
|
||||||
if (!input.files[0])
|
if (!input.files[0])
|
||||||
return undefined;
|
return undefined;
|
||||||
let file = input.files[0];
|
file = input.files[0];
|
||||||
let fr = new FileReader();
|
fr = new FileReader();
|
||||||
fr.onload = onLoadFileHandler;
|
fr.onload = onLoadFileHandler;
|
||||||
fr.readAsText(file);
|
fr.readAsText(file);
|
||||||
input.value = "";
|
input.value = "";
|
||||||
@@ -291,7 +310,9 @@ function getConfigJson(slimMode){
|
|||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
cache: false,
|
cache: false,
|
||||||
contentType: 'application/json; charset=utf-8',
|
contentType: 'application/json; charset=utf-8',
|
||||||
data: JSON.stringify({ 'timestamp': Date.now()})
|
data: JSON.stringify({
|
||||||
|
'timestamp': Date.now()
|
||||||
|
})
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -323,7 +344,9 @@ function getConfigJson(slimMode){
|
|||||||
});
|
});
|
||||||
|
|
||||||
$("input#autoexec-cb").on("click", function() {
|
$("input#autoexec-cb").on("click", function() {
|
||||||
var data = { 'timestamp': Date.now() };
|
var data = {
|
||||||
|
'timestamp': Date.now()
|
||||||
|
};
|
||||||
autoexec = (this.checked) ? "1" : "0";
|
autoexec = (this.checked) ? "1" : "0";
|
||||||
data['config'] = {};
|
data['config'] = {};
|
||||||
data['config'] = {
|
data['config'] = {
|
||||||
@@ -333,7 +356,6 @@ function getConfigJson(slimMode){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
showMessage('please wait for the ESP32 to reboot', 'MESSAGING_WARNING');
|
showMessage('please wait for the ESP32 to reboot', 'MESSAGING_WARNING');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/config.json',
|
url: '/config.json',
|
||||||
@@ -360,7 +382,9 @@ function getConfigJson(slimMode){
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
cache: false,
|
cache: false,
|
||||||
contentType: 'application/json; charset=utf-8',
|
contentType: 'application/json; charset=utf-8',
|
||||||
data: JSON.stringify({ 'timestamp': Date.now()}),
|
data: JSON.stringify({
|
||||||
|
'timestamp': Date.now()
|
||||||
|
}),
|
||||||
error: function(xhr, ajaxOptions, thrownError) {
|
error: function(xhr, ajaxOptions, thrownError) {
|
||||||
console.log(xhr.status);
|
console.log(xhr.status);
|
||||||
console.log(thrownError);
|
console.log(thrownError);
|
||||||
@@ -375,7 +399,9 @@ function getConfigJson(slimMode){
|
|||||||
});
|
});
|
||||||
|
|
||||||
$("input#save-autoexec1").on("click", function() {
|
$("input#save-autoexec1").on("click", function() {
|
||||||
var data = { 'timestamp': Date.now() };
|
var data = {
|
||||||
|
'timestamp': Date.now()
|
||||||
|
};
|
||||||
autoexec1 = $("#autoexec1").val();
|
autoexec1 = $("#autoexec1").val();
|
||||||
data['config'] = {};
|
data['config'] = {};
|
||||||
data['config'] = {
|
data['config'] = {
|
||||||
@@ -404,7 +430,9 @@ function getConfigJson(slimMode){
|
|||||||
});
|
});
|
||||||
|
|
||||||
$("input#save-gpio").on("click", function() {
|
$("input#save-gpio").on("click", function() {
|
||||||
var data = { 'timestamp': Date.now() };
|
var data = {
|
||||||
|
'timestamp': Date.now()
|
||||||
|
};
|
||||||
var config = {};
|
var config = {};
|
||||||
|
|
||||||
var headers = {};
|
var headers = {};
|
||||||
@@ -436,9 +464,10 @@ function getConfigJson(slimMode){
|
|||||||
console.log('sent config JSON with data:', JSON.stringify(data));
|
console.log('sent config JSON with data:', JSON.stringify(data));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
$("#save-as-nvs").on("click", function() {
|
$("#save-as-nvs").on("click", function() {
|
||||||
var data = { 'timestamp': Date.now() };
|
var data = {
|
||||||
|
'timestamp': Date.now()
|
||||||
|
};
|
||||||
var config = getConfigJson(true);
|
var config = getConfigJson(true);
|
||||||
const a = document.createElement("a");
|
const a = document.createElement("a");
|
||||||
a.href = URL.createObjectURL(
|
a.href = URL.createObjectURL(
|
||||||
@@ -455,7 +484,9 @@ function getConfigJson(slimMode){
|
|||||||
|
|
||||||
$("#save-nvs").on("click", function() {
|
$("#save-nvs").on("click", function() {
|
||||||
var headers = {};
|
var headers = {};
|
||||||
var data = { 'timestamp': Date.now() };
|
var data = {
|
||||||
|
'timestamp': Date.now()
|
||||||
|
};
|
||||||
var config = getConfigJson(false);
|
var config = getConfigJson(false);
|
||||||
data['config'] = config;
|
data['config'] = config;
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@@ -500,7 +531,9 @@ function getConfigJson(slimMode){
|
|||||||
enableStatusTimer = true;
|
enableStatusTimer = true;
|
||||||
});
|
});
|
||||||
$("#flash").on("click", function() {
|
$("#flash").on("click", function() {
|
||||||
var data = { 'timestamp': Date.now() };
|
var data = {
|
||||||
|
'timestamp': Date.now()
|
||||||
|
};
|
||||||
if (blockFlashButton) return;
|
if (blockFlashButton) return;
|
||||||
blockFlashButton = true;
|
blockFlashButton = true;
|
||||||
var url = $("#fwurl").val();
|
var url = $("#fwurl").val();
|
||||||
@@ -562,7 +595,11 @@ function getConfigJson(slimMode){
|
|||||||
var i = 0;
|
var i = 0;
|
||||||
var branches = [];
|
var branches = [];
|
||||||
data.forEach(function(release) {
|
data.forEach(function(release) {
|
||||||
var [ver, idf, cfg, branch] = release.name.split('#');
|
namecomponents=release.name.split('#');
|
||||||
|
ver=namecomponents[0];
|
||||||
|
idf=namecomponents[1];
|
||||||
|
cfg=namecomponents[2];
|
||||||
|
branch=namecomponents[3];
|
||||||
if (!branches.includes(branch)) {
|
if (!branches.includes(branch)) {
|
||||||
branches.push(branch);
|
branches.push(branch);
|
||||||
}
|
}
|
||||||
@@ -580,7 +617,12 @@ function getConfigJson(slimMode){
|
|||||||
url = asset.browser_download_url;
|
url = asset.browser_download_url;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var [ver, idf, cfg, branch] = release.name.split('#');
|
namecomponents = release.name.split('#');
|
||||||
|
ver=namecomponents[0];
|
||||||
|
idf=namecomponents[1];
|
||||||
|
cfg=namecomponents[2];
|
||||||
|
branch=namecomponents[3];
|
||||||
|
|
||||||
var body = release.body;
|
var body = release.body;
|
||||||
body = body.replace(/\'/ig, "\"");
|
body = body.replace(/\'/ig, "\"");
|
||||||
body = body.replace(/[\s\S]+(### Revision Log[\s\S]+)### ESP-IDF Version Used[\s\S]+/, "$1");
|
body = body.replace(/[\s\S]+(### Revision Log[\s\S]+)### ESP-IDF Version Used[\s\S]+/, "$1");
|
||||||
@@ -678,8 +720,7 @@ function getConfigJson(slimMode){
|
|||||||
});
|
});
|
||||||
$('a[href^="#tab-firmware"]').dblclick(function() {
|
$('a[href^="#tab-firmware"]').dblclick(function() {
|
||||||
dblclickCounter++;
|
dblclickCounter++;
|
||||||
if(dblclickCounter>=2)
|
if (dblclickCounter >= 2) {
|
||||||
{
|
|
||||||
dblclickCounter = 0;
|
dblclickCounter = 0;
|
||||||
blockFlashButton = false;
|
blockFlashButton = false;
|
||||||
alert("Unocking flash button!");
|
alert("Unocking flash button!");
|
||||||
@@ -737,7 +778,8 @@ function performConnect(conntype){
|
|||||||
cache: false,
|
cache: false,
|
||||||
// headers: { 'X-Custom-ssid': selectedSSID, 'X-Custom-pwd': pwd, 'X-Custom-host_name': dhcpname },
|
// headers: { 'X-Custom-ssid': selectedSSID, 'X-Custom-pwd': pwd, 'X-Custom-host_name': dhcpname },
|
||||||
contentType: 'application/json; charset=utf-8',
|
contentType: 'application/json; charset=utf-8',
|
||||||
data: JSON.stringify({ 'timestamp': Date.now(),
|
data: JSON.stringify({
|
||||||
|
'timestamp': Date.now(),
|
||||||
'ssid': selectedSSID,
|
'ssid': selectedSSID,
|
||||||
'pwd': pwd,
|
'pwd': pwd,
|
||||||
'host_name': dhcpname
|
'host_name': dhcpname
|
||||||
@@ -757,14 +799,11 @@ function performConnect(conntype){
|
|||||||
function rssiToIcon(rssi) {
|
function rssiToIcon(rssi) {
|
||||||
if (rssi >= -60) {
|
if (rssi >= -60) {
|
||||||
return 'w0';
|
return 'w0';
|
||||||
}
|
} else if (rssi >= -67) {
|
||||||
else if(rssi >= -67){
|
|
||||||
return 'w1';
|
return 'w1';
|
||||||
}
|
} else if (rssi >= -75) {
|
||||||
else if(rssi >= -75){
|
|
||||||
return 'w2';
|
return 'w2';
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
return 'w3';
|
return 'w3';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -777,7 +816,8 @@ function refreshAP(force){
|
|||||||
if (data.length > 0) {
|
if (data.length > 0) {
|
||||||
//sort by signal strength
|
//sort by signal strength
|
||||||
data.sort(function(a, b) {
|
data.sort(function(a, b) {
|
||||||
var x = a["rssi"]; var y = b["rssi"];
|
var x = a["rssi"];
|
||||||
|
var y = b["rssi"];
|
||||||
return ((x < y) ? 1 : ((x > y) ? -1 : 0));
|
return ((x < y) ? 1 : ((x > y) ? -1 : 0));
|
||||||
});
|
});
|
||||||
apList = data;
|
apList = data;
|
||||||
@@ -860,6 +900,7 @@ st is task state. I provided a "typedef" that you can use to convert to text
|
|||||||
cpu is cpu percent used
|
cpu is cpu percent used
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkStatus() {
|
function checkStatus() {
|
||||||
RepeatCheckStatusInterval();
|
RepeatCheckStatusInterval();
|
||||||
if (!enableStatusTimer) return;
|
if (!enableStatusTimer) return;
|
||||||
@@ -891,8 +932,7 @@ function checkStatus(){
|
|||||||
|
|
||||||
enableAPTimer = false;
|
enableAPTimer = false;
|
||||||
if (!recovery) enableStatusTimer = false;
|
if (!recovery) enableStatusTimer = false;
|
||||||
}
|
} else if (data["urc"] === 1) {
|
||||||
else if (data["urc"] === 1){
|
|
||||||
//failed attempt
|
//failed attempt
|
||||||
$("#connected-to span").text('');
|
$("#connected-to span").text('');
|
||||||
$("#connect-details h1").text('');
|
$("#connect-details h1").text('');
|
||||||
@@ -915,8 +955,7 @@ function checkStatus(){
|
|||||||
enableAPTimer = true;
|
enableAPTimer = true;
|
||||||
enableStatusTimer = true;
|
enableStatusTimer = true;
|
||||||
}
|
}
|
||||||
}
|
} else if (data.hasOwnProperty('urc') && data['urc'] === 0) {
|
||||||
else if (data.hasOwnProperty('urc') && data['urc'] === 0){
|
|
||||||
//ESP32 is already connected to a wifi without having the user do anything
|
//ESP32 is already connected to a wifi without having the user do anything
|
||||||
if (!($("#wifi-status").is(":visible"))) {
|
if (!($("#wifi-status").is(":visible"))) {
|
||||||
$("#connected-to span").text(data["ssid"]);
|
$("#connected-to span").text(data["ssid"]);
|
||||||
@@ -930,8 +969,7 @@ function checkStatus(){
|
|||||||
enableAPTimer = false;
|
enableAPTimer = false;
|
||||||
if (!recovery) enableStatusTimer = false;
|
if (!recovery) enableStatusTimer = false;
|
||||||
}
|
}
|
||||||
}
|
} else if (data.hasOwnProperty('urc') && data['urc'] === 2) {
|
||||||
else if (data.hasOwnProperty('urc') && data['urc'] === 2){
|
|
||||||
//that's a manual disconnect
|
//that's a manual disconnect
|
||||||
if ($("#wifi-status").is(":visible")) {
|
if ($("#wifi-status").is(":visible")) {
|
||||||
$("#wifi-status").slideUp("fast", function() {});
|
$("#wifi-status").slideUp("fast", function() {});
|
||||||
@@ -983,22 +1021,29 @@ function checkStatus(){
|
|||||||
if (data.hasOwnProperty('version') && data['version'] != '') {
|
if (data.hasOwnProperty('version') && data['version'] != '') {
|
||||||
ver = data['version'];
|
ver = data['version'];
|
||||||
$("span#foot-fw").html("fw: <strong>" + ver + "</strong>, mode: <strong>" + pname + "</strong>");
|
$("span#foot-fw").html("fw: <strong>" + ver + "</strong>, mode: <strong>" + pname + "</strong>");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$("span#flash-status").html('');
|
$("span#flash-status").html('');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.hasOwnProperty('Voltage')) {
|
if (data.hasOwnProperty('Voltage')) {
|
||||||
var voltage = data['Voltage'];
|
var voltage = data['Voltage'];
|
||||||
var layer;
|
var layer;
|
||||||
|
|
||||||
|
/* Assuming Li-ion 18650s as a power source, 3.9V per cell, or above is treated
|
||||||
|
as full charge (>75% of capacity). 3.4V is empty. The gauge is loosely
|
||||||
|
following the graph here:
|
||||||
|
https://learn.adafruit.com/li-ion-and-lipoly-batteries/voltages
|
||||||
|
using the 0.2C discharge profile for the rest of the values.
|
||||||
|
*/
|
||||||
|
|
||||||
if (voltage > 0) {
|
if (voltage > 0) {
|
||||||
if (inRange(voltage, 5.8, 6.2) || inRange(voltage, 8.8, 9.2)) {
|
if (inRange(voltage, 5.8, 6.8) || inRange(voltage, 8.8, 10.2)) {
|
||||||
layer = bat0;
|
layer = bat0;
|
||||||
} else if (inRange(voltage, 6.2, 6.8) || inRange(voltage, 9.2, 10.0)) {
|
} else if (inRange(voltage, 6.8, 7.4) || inRange(voltage, 10.2, 11.1)) {
|
||||||
layer = bat1;
|
layer = bat1;
|
||||||
} else if (inRange(voltage, 6.8, 7.1) || inRange(voltage, 10.0, 10.5)) {
|
} else if (inRange(voltage, 7.4, 7.5) || inRange(voltage, 11.1, 11.25)) {
|
||||||
layer = bat2;
|
layer = bat2;
|
||||||
} else if (inRange(voltage, 7.1, 7.5) || inRange(voltage, 10.5, 11.0)) {
|
} else if (inRange(voltage, 7.5, 7.8) || inRange(voltage, 11.25, 11.7)) {
|
||||||
layer = bat3;
|
layer = bat3;
|
||||||
} else {
|
} else {
|
||||||
layer = bat4;
|
layer = bat4;
|
||||||
@@ -1023,23 +1068,22 @@ function checkStatus(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function runCommand(button, reboot) {
|
function runCommand(button, reboot) {
|
||||||
pardiv = button.parentNode.parentNode;
|
cmdstring = button.attributes.cmdname.value;
|
||||||
fields=document.getElementById("flds-"+button.value);
|
fields = document.getElementById("flds-" + cmdstring);
|
||||||
cmdstring=button.value+' ';
|
cmdstring += ' ';
|
||||||
if (fields) {
|
if (fields) {
|
||||||
hint = pardiv.hint;
|
allfields = fields.querySelectorAll("select,input");
|
||||||
allfields=fields.getElementsByTagName("input");
|
|
||||||
for (i = 0; i < allfields.length; i++) {
|
for (i = 0; i < allfields.length; i++) {
|
||||||
attr = allfields[i].attributes;
|
attr = allfields[i].attributes;
|
||||||
qts = '';
|
qts = '';
|
||||||
opt = '';
|
opt = '';
|
||||||
optspacer = ' ';
|
optspacer = ' ';
|
||||||
|
isSelect = allfields[i].attributes?.class?.value == "custom-select";
|
||||||
|
if ((isSelect && allfields[i].selectedIndex != 0) || !isSelect) {
|
||||||
if (attr.longopts.value !== "undefined") {
|
if (attr.longopts.value !== "undefined") {
|
||||||
opt += '--' + attr.longopts.value;
|
opt += '--' + attr.longopts.value;
|
||||||
optspacer = '=';
|
optspacer = '=';
|
||||||
}
|
} else if (attr.shortopts.value !== "undefined") {
|
||||||
else if(attr.shortopts.value!== "undefined"){
|
|
||||||
opt = '-' + attr.shortopts.value;
|
opt = '-' + attr.shortopts.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1048,16 +1092,18 @@ function runCommand(button,reboot) {
|
|||||||
qts = (/\s/.test(allfields[i].value)) ? '"' : '';
|
qts = (/\s/.test(allfields[i].value)) ? '"' : '';
|
||||||
cmdstring += opt + optspacer + qts + allfields[i].value + qts + ' ';
|
cmdstring += opt + optspacer + qts + allfields[i].value + qts + ' ';
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// this is a checkbox
|
// this is a checkbox
|
||||||
if (allfields[i].checked) cmdstring += opt + ' ';
|
if (allfields[i].checked) cmdstring += opt + ' ';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
console.log(cmdstring);
|
console.log(cmdstring);
|
||||||
|
|
||||||
var data = { 'timestamp': Date.now() };
|
var data = {
|
||||||
|
'timestamp': Date.now()
|
||||||
|
};
|
||||||
data['command'] = cmdstring;
|
data['command'] = cmdstring;
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@@ -1085,7 +1131,9 @@ function runCommand(button,reboot) {
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
cache: false,
|
cache: false,
|
||||||
contentType: 'application/json; charset=utf-8',
|
contentType: 'application/json; charset=utf-8',
|
||||||
data: JSON.stringify({ 'timestamp': Date.now()}),
|
data: JSON.stringify({
|
||||||
|
'timestamp': Date.now()
|
||||||
|
}),
|
||||||
error: function(xhr, ajaxOptions, thrownError) {
|
error: function(xhr, ajaxOptions, thrownError) {
|
||||||
console.log(xhr.status);
|
console.log(xhr.status);
|
||||||
console.log(thrownError);
|
console.log(thrownError);
|
||||||
@@ -1093,6 +1141,10 @@ function runCommand(button,reboot) {
|
|||||||
},
|
},
|
||||||
complete: function(response) {
|
complete: function(response) {
|
||||||
console.log('reboot call completed');
|
console.log('reboot call completed');
|
||||||
|
Promise.resolve().delay(5000).then(function(v) {
|
||||||
|
console.log('Getting updated commands');
|
||||||
|
getCommands();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1101,86 +1153,84 @@ function runCommand(button,reboot) {
|
|||||||
enableStatusTimer = true;
|
enableStatusTimer = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function getCommands() {
|
function getCommands() {
|
||||||
$.getJSON("/commands.json", function(data) {
|
$.getJSON("/commands.json", function(data) {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
var advancedtabhtml='';
|
|
||||||
|
|
||||||
data.commands.forEach(function(command) {
|
data.commands.forEach(function(command) {
|
||||||
|
if ($("#flds-" + command.name).length == 0) {
|
||||||
isConfig = ($('#' + command.name + '-list').length > 0);
|
isConfig = ($('#' + command.name + '-list').length > 0);
|
||||||
innerhtml = '';
|
innerhtml = '';
|
||||||
innerhtml+='<tr><td>'+(isConfig?'<h1>':'');
|
//innerhtml+='<tr class="table-light"><td>'+(isConfig?'<h1>':'');
|
||||||
innerhtml+=escapeHTML(command.help).replace(/\n/g, '<br />')+(isConfig?'</h1>':'<br>');
|
innerhtml += '<div class="card text-white bg-primary mb-3"><div class="card-header">' + escapeHTML(command.help).replace(/\n/g, '<br />') + '</div><div class="card-body">';
|
||||||
innerhtml+='<div >';
|
innerhtml += '<fieldset id="flds-' + command.name + '">';
|
||||||
if (command.hasOwnProperty("argtable")) {
|
if (command.hasOwnProperty("argtable")) {
|
||||||
innerhtml+='<table class="table table-hover" id="flds-'+command.name+'"><tbody>';
|
|
||||||
command.argtable.forEach(function(arg) {
|
command.argtable.forEach(function(arg) {
|
||||||
placeholder = arg?.datatype || '';
|
placeholder = arg?.datatype || '';
|
||||||
ctrlname = command.name + '-' + arg.longopts;
|
ctrlname = command.name + '-' + arg.longopts;
|
||||||
curvalue=data.values?.[command.name]?.[arg.longopts] || '';
|
curvalue = data.values?. [command.name]?. [arg.longopts];
|
||||||
innerhtml+="<tr>";
|
|
||||||
var attributes ='datatype="'+arg.datatype+'" ';
|
var attributes = 'hasvalue=' + arg.hasvalue + ' ';
|
||||||
attributes+='hasvalue='+arg.hasvalue+' ';
|
//attributes +='datatype="'+arg.datatype+'" ';
|
||||||
attributes += 'longopts="' + arg.longopts + '" ';
|
attributes += 'longopts="' + arg.longopts + '" ';
|
||||||
attributes += 'shortopts="' + arg.shortopts + '" ';
|
attributes += 'shortopts="' + arg.shortopts + '" ';
|
||||||
attributes += 'checkbox=' + arg.checkbox + ' ';
|
attributes += 'checkbox=' + arg.checkbox + ' ';
|
||||||
|
attributes += 'cmdname="' + command.name + '" ';
|
||||||
|
attributes += 'id="' + ctrlname + '" name="' + ctrlname + '" hasvalue="' + arg.hasvalue + '" ';
|
||||||
|
if (arg.checkbox) {
|
||||||
|
innerhtml += '<div class="form-check"><label class="form-check-label">';
|
||||||
|
innerhtml += '<input type="checkbox" ' + attributes + ' class="form-check-input" value="" >' + arg.glossary + '<small class="form-text text-muted">Previous value: ' + (curvalue?"Checked":"Unchecked") + '</small></label>';
|
||||||
|
} else {
|
||||||
|
innerhtml += '<div class="form-group" ><label for="' + ctrlname + '">' + arg.glossary + '</label>';
|
||||||
if (placeholder.includes('|')) {
|
if (placeholder.includes('|')) {
|
||||||
placeholder = placeholder.replace('<', '').replace('>', '');
|
placeholder = placeholder.replace('<', '').replace('>', '');
|
||||||
innerhtml+='<td><select name="'+ctrlname+'" ';
|
innerhtml += '<select ' + attributes + ' class="form-control"';
|
||||||
innerhtml+=attributes;
|
placeholder = '--|' + placeholder;
|
||||||
innerhtml+=' class="custom-select">';
|
|
||||||
innerhtml+='<option '+(curvalue.length>0?'value':'selected')+'>'+arg.glossary+'</option>'
|
|
||||||
placeholder.split('|').forEach(function(choice) {
|
placeholder.split('|').forEach(function(choice) {
|
||||||
innerhtml+='<option '+(curvalue.length>0&&curvalue==choice?'selected':'value')+'="'+choice+'">'+choice+'</option>';
|
innerhtml += '<option >' + choice + '</option>';
|
||||||
});
|
});
|
||||||
innerhtml+='</select></td>';
|
innerhtml += '</select>';
|
||||||
|
} else {
|
||||||
|
innerhtml += '<input type="text" class="form-control" placeholder="' + placeholder + '" ' + attributes + '>';
|
||||||
}
|
}
|
||||||
else {
|
innerhtml += '<small class="form-text text-muted">Previous value: ' + (curvalue || '') + '</small>';
|
||||||
ctrltype="text";
|
|
||||||
if(arg.checkbox){
|
|
||||||
ctrltype="checkbox";
|
|
||||||
}
|
}
|
||||||
|
innerhtml += '</div>';
|
||||||
innerhtml+='<td><label for="'+ctrlname+'">'+ arg.glossary+'</label></td>';
|
|
||||||
innerhtml+='<td><input type="'+ctrltype+'" id="'+ctrlname+'" name="'+ctrlname+'" placeholder="'+placeholder+'" hasvalue="'+arg.hasvalue+'" ';
|
|
||||||
innerhtml+=attributes;
|
|
||||||
if(arg.checkbox){
|
|
||||||
if(data.values?.[command.name]?.[arg.longopts] ){
|
|
||||||
innerhtml+='checked=true ';
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
innerhtml+='checked=false ';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
innerhtml+='></input></td>';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
innerhtml+='value="'+curvalue+'" ';
|
|
||||||
innerhtml+='></input></td>'+ curvalue.length>0?'<td>last: '+curvalue+'</td>':'';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
innerhtml+="</tr>";
|
|
||||||
});
|
});
|
||||||
innerhtml+='</tbody></table>';
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
innerhtml +='<div style="margin-top: 16px;">';
|
||||||
if (isConfig) {
|
if (isConfig) {
|
||||||
innerhtml+='<div class="buttons"><input id="btn-'+ command.name + '" type="button" class="btn btn-success" value="Save" onclick="runCommand(this,false);">';
|
innerhtml += '<button type="submit" class="btn btn-info" id="btn-' + command.name + '" cmdname="' + command.name + '" onclick="runCommand(this,false)">Save</button>';
|
||||||
innerhtml+='<input id="btn-'+ command.name + '-apply" type="button" class="btn btn-success" value="Apply" onclick="runCommand(this,true);"></div></div><td></tr>';
|
innerhtml += '<button type="submit" class="btn btn-warning" id="btn-' + command.name + '" cmdname="' + command.name + '" onclick="runCommand(this,true)">Apply</button>';
|
||||||
$('#'+command.name+'-list').append(innerhtml);
|
} else {
|
||||||
|
innerhtml += '<button type="submit" class="btn btn-success" id="btn-' + command.name + '" cmdname="' + command.name + '" onclick="runCommand(this,false)">Execute</button>';
|
||||||
}
|
}
|
||||||
else {
|
innerhtml += '</div></fieldset></div></div>';
|
||||||
advancedtabhtml+='<br>'+innerhtml;
|
|
||||||
advancedtabhtml+='<div class="buttons"><input id="btn-'+ command.name + '" type="button" class="btn btn-danger btn-sm" value="'+command.name+'" onclick="runCommand(this);"></div></div><td></tr>';
|
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 = '--';
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
$("#commands-list").append(advancedtabhtml);
|
}
|
||||||
|
});
|
||||||
|
|
||||||
})
|
})
|
||||||
.fail(function(xhr, ajaxOptions, thrownError) {
|
.fail(function(xhr, ajaxOptions, thrownError) {
|
||||||
@@ -1193,7 +1243,8 @@ function getCommands() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getConfig() {
|
function getConfig() {
|
||||||
$.getJSON("/config.json", function(data) {
|
$.getJSON("/config.json", function(entries) {
|
||||||
|
data = entries.hasOwnProperty('config') ? entries.config : entries;
|
||||||
Object.keys(data).sort().forEach(function(key, i) {
|
Object.keys(data).sort().forEach(function(key, i) {
|
||||||
if (data.hasOwnProperty(key)) {
|
if (data.hasOwnProperty(key)) {
|
||||||
if (key == 'autoexec') {
|
if (key == 'autoexec') {
|
||||||
@@ -1229,16 +1280,13 @@ function getConfig() {
|
|||||||
$("input#" + key).val(data[key].value);
|
$("input#" + key).val(data[key].value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$("tbody#nvsTable").append(
|
$("tbody#nvsTable").append("<tr><td><input type='text' class='form-control' id='nvs-new-key' placeholder='new key'></td><td><input type='text' class='form-control' id='nvs-new-value' placeholder='new value' nvs_type=33 ></td></tr>");
|
||||||
"<tr>"+
|
if (entries.hasOwnProperty('gpio')) {
|
||||||
"<td>"+
|
entries.gpio.forEach(function(gpio_entry) {
|
||||||
"<input type='text' class='form-control' id='nvs-new-key' placeholder='new key'>"+
|
cl = gpio_entry.fixed ? "table-secondary" : "table-primary";
|
||||||
"</td>"+
|
$("tbody#gpiotable").append('<tr class=' + cl + '><th scope="row">' + gpio_entry.group + '</th><td>' + gpio_entry.name + '</td><td>' + gpio_entry.gpio + '</td><td>' + (gpio_entry.fixed ? 'Fixed':'Configuration') + '</td></tr>');
|
||||||
"<td>"+
|
});
|
||||||
"<input type='text' class='form-control' id='nvs-new-value' placeholder='new value' nvs_type=33 >"+ // todo: provide a way to choose field type
|
}
|
||||||
"</td>"+
|
|
||||||
"</tr>"
|
|
||||||
);
|
|
||||||
})
|
})
|
||||||
.fail(function(xhr, ajaxOptions, thrownError) {
|
.fail(function(xhr, ajaxOptions, thrownError) {
|
||||||
console.log(xhr.status);
|
console.log(xhr.status);
|
||||||
@@ -1248,7 +1296,6 @@ function getConfig() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function showMessage(message, severity, age = 0) {
|
function showMessage(message, severity, age = 0) {
|
||||||
if (severity == 'MESSAGING_INFO') {
|
if (severity == 'MESSAGING_INFO') {
|
||||||
$('#message').css('background', '#6af');
|
$('#message').css('background', '#6af');
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ function to process requests, decode URLs, serve files, etc. etc.
|
|||||||
#include "esp_console.h"
|
#include "esp_console.h"
|
||||||
#include "argtable3/argtable3.h"
|
#include "argtable3/argtable3.h"
|
||||||
#include "platform_console.h"
|
#include "platform_console.h"
|
||||||
|
#include "accessors.h"
|
||||||
|
|
||||||
#define HTTP_STACK_SIZE (5*1024)
|
#define HTTP_STACK_SIZE (5*1024)
|
||||||
const char str_na[]="N/A";
|
const char str_na[]="N/A";
|
||||||
@@ -576,7 +577,15 @@ esp_err_t config_get_handler(httpd_req_t *req){
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ESP_LOGD_LOC(TAG, "config json : %s",json );
|
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);
|
free(json);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
400
components/wifi-manager/index.development.html
Normal file
400
components/wifi-manager/index.development.html
Normal file
@@ -0,0 +1,400 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8"/>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
|
||||||
|
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||||
|
<link rel="shortcut icon" type="image/x-icon" href="/res/favicon.ico">
|
||||||
|
<link rel="stylesheet" href="/res/bootstrap.css">
|
||||||
|
<link rel="stylesheet" href="/res/style.css">
|
||||||
|
<script src="/res/jquery.js"></script>
|
||||||
|
<script src="/res/popper.js"></script>
|
||||||
|
<script src="/res/bootstrap.js"></script>
|
||||||
|
<script src="/res/code.js"></script>
|
||||||
|
<title>esp32-wifi-manager</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="info">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" id="jack" width="24" height="24" viewBox="0 0 24 24">
|
||||||
|
<g id="o_jack" display="none">
|
||||||
|
<path d="m 16.074253,15.636738 v -1.05413 h 5.893274 c 1.16249,0 2.108261,-0.855111 2.108261,-1.906183 0,-1.051073 -0.945771,-1.906236 -2.108261,-1.906236 H 16.074253 V 9.7160604 c 0,-0.5812492 -0.472879,-1.0541321 -1.054131,-1.0541321 H 6.7847349 c -1.256731,0 -2.301908,0.9212057 -2.496867,2.1237027 h -0.451896 c -0.540407,0 -1.001317,0.349129 -1.173459,0.835611 H 0.47312787 c -0.23285,0 -0.42164599,0.188794 -0.42164599,0.421651 v 1.251779 c 0,0.232857 0.18879599,0.421652 0.42164599,0.421652 H 2.6550809 c 0.165919,0.497866 0.632365,0.857588 1.180831,0.857588 h 0.45312 c 0.19781,1.199177 1.241345,2.116956 2.495659,2.116956 h 8.2353861 c 0.581297,0 1.054176,-0.472883 1.054176,-1.05413 z m 5.060935,-4.023245 v 2.125811 h -0.844935 v -2.125811 z m 2.097293,1.062932 c 0,0.582933 -0.561524,1.057661 -1.253986,1.062668 v -2.125337 c 0.692462,0.0049 1.253986,0.47963 1.253986,1.062669 z m -3.785535,-1.062932 v 2.125811 h -3.372693 v -2.125811 z m -18.55215712,0.851 H 2.5901939 v 0.408475 H 0.89478888 Z m 2.94118302,1.266114 c -0.221897,0 -0.40247,-0.185737 -0.40247,-0.414062 v -1.273547 c 0,-0.228271 0.180573,-0.41401 0.40247,-0.41401 h 0.418855 v 2.101671 h -0.418855 z m 2.948763,2.116956 c -0.929997,0 -1.6866,-0.756601 -1.6866,-1.686608 v -0.0087 -2.944976 -0.01545 c 0,-0.930006 0.756603,-1.6866072 1.6866,-1.6866072 h 8.2353871 c 0.114313,0 0.210838,0.096554 0.210838,0.2108266 v 5.9206786 c 0,0.114268 -0.09656,0.210824 -0.210838,0.210824 z" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" id="output" width="24" height="24" viewBox="0 0 24 24">
|
||||||
|
<g id="o_i2s" display="none">
|
||||||
|
<path d="M2 7L2 8L2 9L2 10L2 11L2 12L2 13L2 14L2 15L2 16L2 17L3 17L3 16L3 15L3 14L3 13L3 12L3 11L3 10L3 9L3 8L2 7M6 7L6 8L6 9L7 9L7 8L8 8L9 8L10 8L10 9L11 9L11 10L11 11L10 11L10 12L9 12L9 13L8 13L8 14L7 14L7 15L6 15L6 16L6 17L7 17L8 17L9 17L10 17L11 17L12 17L12 16L11 16L10 16L9 16L8 16L8 15L9 15L9 14L10 14L10 13L11 13L11 12L12 12L12 11L12 10L12 9L12 8L11 8L11 7L10 7L9 7L8 7L6 7M16 7L16 8L15 8L15 9L15 10L15 11L16 11L16 12L17 12L18 12L18 13L19 13L20 13L21 13L21 14L21 15L20 15L20 16L19 16L18 16L17 16L16 16L16 15L15 15L15 16L15 17L16 17L17 17L18 17L19 17L20 17L21 17L21 16L22 16L22 15L22 14L22 13L21 13L21 12L20 12L20 11L19 11L18 11L17 11L16 11L16 10L16 9L17 9L17 8L18 8L19 8L20 8L21 8L21 9L22 9L22 8L22 7L21 7L20 7L19 7L18 7L16 7z"/>
|
||||||
|
</g>
|
||||||
|
<g id="o_bt" display="none">
|
||||||
|
<path d="M3 7L3 8L3 9L3 10L3 11L3 12L3 13L3 14L3 15L3 16L3 17L4 17L5 17L6 17L7 17L8 17L9 17L9 16L10 16L10 15L10 14L10 13L10 12L9 12L9 11L10 11L10 10L10 9L10 8L9 8L9 7L8 7L7 7L6 7L5 7L3 7M12 7L12 8L13 8L14 8L15 8L16 8L16 9L16 10L16 11L16 12L16 13L16 14L16 15L16 16L16 17L17 17L17 16L17 15L17 14L17 13L17 12L17 11L17 10L17 9L17 8L18 8L19 8L20 8L21 8L21 7L20 7L19 7L18 7L17 7L16 7L15 7L14 7L12 7z"/>
|
||||||
|
<path style="fill:#272B30;" d="M4 8L4 9L4 10L4 11L5 11L6 11L7 11L8 11L8 10L9 10L9 9L9 8L8 8L7 8L6 8L4 8M4 12L4 13L4 14L4 15L4 16L5 16L6 16L7 16L8 16L8 15L9 15L9 14L9 13L8 13L8 12L7 12L6 12L4 12z"/>
|
||||||
|
</g>
|
||||||
|
<g id="o_spdif" display="none">
|
||||||
|
<path d="M3 1L3 2L2 2L2 3L2 4L2 5L3 5L3 6L4 6L5 6L5 7L6 7L7 7L8 7L8 8L8 9L7 9L7 10L6 10L5 10L4 10L3 10L3 9L2 9L2 10L2 11L3 11L4 11L5 11L6 11L7 11L8 11L8 10L9 10L9 9L9 8L9 7L8 7L8 6L7 6L7 5L6 5L5 5L4 5L3 5L3 4L3 3L4 3L4 2L5 2L6 2L7 2L8 2L8 3L9 3L9 2L9 1L8 1L7 1L6 1L5 1L3 1M13 1L13 2L13 3L13 4L12 4L12 5L12 6L12 7L12 8L11 8L11 9L11 10L11 11L10 11L10 12L10 13L11 13L11 12L11 11L12 11L12 10L12 9L12 8L13 8L13 7L13 6L13 5L14 5L14 4L14 3L14 2L15 2L15 1L13 1M16 1L16 2L16 3L16 4L16 5L16 6L16 7L16 8L16 9L16 10L16 11L17 11L17 10L17 9L17 8L17 7L18 7L19 7L20 7L21 7L21 6L22 6L22 5L22 4L22 3L22 2L21 2L21 1L20 1L19 1L18 1L16 1z"/>
|
||||||
|
<path style="fill:#272B30;" d="M17 2L17 3L17 4L17 5L17 6L18 6L19 6L20 6L20 5L21 5L21 4L21 3L20 3L20 2L19 2L17 2z"/>
|
||||||
|
<path d="M2 13L2 14L2 15L2 16L2 17L2 18L2 19L2 20L2 21L2 22L2 23L3 23L4 23L5 23L6 23L7 23L8 23L8 22L9 22L9 21L10 21L10 20L10 19L10 18L10 17L10 16L10 15L9 15L9 14L8 14L7 14L7 13L6 13L5 13L4 13L2 13M13 13L13 14L13 15L13 16L13 17L13 18L13 19L13 20L13 21L13 22L13 23L14 23L14 22L14 21L14 20L14 19L14 18L14 17L14 16L14 15L14 14L13 13M17 13L17 14L17 15L17 16L17 17L17 18L17 19L17 20L17 21L17 22L17 23L18 23L18 22L18 21L18 20L18 19L18 18L19 18L20 18L21 18L22 18L22 17L21 17L20 17L19 17L18 17L18 16L18 15L18 14L19 14L20 14L21 14L22 14L22 13L21 13L20 13L19 13L17 13z"/>
|
||||||
|
<path style="fill:#272B30;" d="M3 14L3 15L3 16L3 17L3 18L3 19L3 20L3 21L3 22L4 22L5 22L6 22L7 22L7 21L8 21L8 20L9 20L9 19L9 18L9 17L9 16L8 16L8 15L7 15L7 14L6 14L5 14L3 14z"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" id="battery" width="24" height="24" viewBox="0 0 24 24">
|
||||||
|
<g id="bat0" display="none">
|
||||||
|
<path d="M19 8v8h-17v-8h17zm2-2h-21v12h21v-12zm1 9h.75c.69 0 1.25-.56 1.25-1.25v-3.5c0-.69-.56-1.25-1.25-1.25h-.75v6z"/>
|
||||||
|
</g>
|
||||||
|
<g id="bat1" display="none">
|
||||||
|
<path d="M19 8v8h-17v-8h17zm2-2h-21v12h21v-12zm1 9h.75c.69 0 1.25-.56 1.25-1.25v-3.5c0-.69-.56-1.25-1.25-1.25h-.75v6zm-16-6h-3v6h3v-6z"/>
|
||||||
|
</g>
|
||||||
|
<g id="bat2" display="none">
|
||||||
|
<path d="M19 8v8h-17v-8h17zm2-2h-21v12h21v-12zm1 9h.75c.69 0 1.25-.56 1.25-1.25v-3.5c0-.69-.56-1.25-1.25-1.25h-.75v6zm-16-6h-3v6h3v-6zm4 0h-3v6h3v-6z"/>
|
||||||
|
</g>
|
||||||
|
<g id="bat3" display="none">
|
||||||
|
<path d="M19 8v8h-17v-8h17zm2-2h-21v12h21v-12zm1 9h.75c.69 0 1.25-.56 1.25-1.25v-3.5c0-.69-.56-1.25-1.25-1.25h-.75v6zm-16-6h-3v6h3v-6zm4 0h-3v6h3v-6zm4 0h-3v6h3v-6z"/>
|
||||||
|
</g>
|
||||||
|
<g id="bat4" display="none">
|
||||||
|
<path d="M19 8v8h-17v-8h17zm2-2h-21v12h21v-12zm1 9h.75c.69 0 1.25-.56 1.25-1.25v-3.5c0-.69-.56-1.25-1.25-1.25h-.75v6zm-16-6h-3v6h3v-6zm4 0h-3v6h3v-6zm4 0h-3v6h3v-6zm4 0h-3v6h3v-6z"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<ul id="navbar" class="nav nav-tabs">
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link active" data-toggle="tab" href="#tab-wifi">WiFi</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" data-toggle="tab" href="#tab-audio">Audio + LMS</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" data-toggle="tab" href="#tab-firmware">Firmware</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" data-toggle="tab" href="#tab-setdisplay">Configuration</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" data-toggle="tab" href="#tab-syslog">Status</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" data-toggle="tab" href="#tab-commands">Advanced</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" data-toggle="tab" href="#tab-nvs">NVS editor</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" data-toggle="tab" href="#tab-credits">Credits</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<div id="message"></div>
|
||||||
|
<div id="content">
|
||||||
|
<div id="myTabContent" class="tab-content">
|
||||||
|
<div class="tab-pane fade active show" id="tab-wifi">
|
||||||
|
<div id="wifi">
|
||||||
|
<div id="wifi-status">
|
||||||
|
<h2>Connected to:</h2>
|
||||||
|
<section id="connected-to">
|
||||||
|
<div class="ape">
|
||||||
|
<div class="w0">
|
||||||
|
<div class="pw"><span></span></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
<h2>Manual connect</h2>
|
||||||
|
<section id="manual_add">
|
||||||
|
<div class="ape">ADD (HIDDEN) SSID</div>
|
||||||
|
</section>
|
||||||
|
<h2>or choose a network...
|
||||||
|
<button type="button" id="updateAP" class="btn btn-info btn-sm">Update</button>
|
||||||
|
</h2>
|
||||||
|
<section id="wifi-list">
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
<div id="connect_manual">
|
||||||
|
<header>
|
||||||
|
<h1>Enter Details</h1>
|
||||||
|
</header>
|
||||||
|
<h2>DHCP host name</h2>
|
||||||
|
<section id="wifi-list">
|
||||||
|
<input id="dhcp-name2" type="text" placeholder="" value="squeezeamp">
|
||||||
|
</section>
|
||||||
|
<h2>Manual Connection</h2>
|
||||||
|
<section>
|
||||||
|
<input id="manual_ssid" type="text" placeholder="SSID" value="">
|
||||||
|
<input id="manual_pwd" type="password" placeholder="Password" value="">
|
||||||
|
</section>
|
||||||
|
<div class="buttons">
|
||||||
|
<input id="manual_join" type="button" class="btn btn-success" value="Join" data-connect="manual" />
|
||||||
|
<input id="manual_cancel" type="button" class="btn btn-danger" value="Cancel"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="connect">
|
||||||
|
<header>
|
||||||
|
<h1>Connect to network</h1>
|
||||||
|
</header>
|
||||||
|
<h2>DHCP host name</h2>
|
||||||
|
<section id="wifi-list">
|
||||||
|
<input id="dhcp-name1" type="text" placeholder="" value="squeezeamp">
|
||||||
|
</section>
|
||||||
|
<h2>Password for <span id="ssid-pwd"></span></h2>
|
||||||
|
<section>
|
||||||
|
<input id="pwd" type="password" placeholder="Password" value="">
|
||||||
|
</section>
|
||||||
|
<div class="buttons">
|
||||||
|
<input id="join" type="button" class="btn btn-success" value="Join" />
|
||||||
|
<input id="cancel" type="button" class="btn btn-danger" value="Cancel"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="connect-wait">
|
||||||
|
<header>
|
||||||
|
<h1>Please wait...</h1>
|
||||||
|
</header>
|
||||||
|
<h2>Connecting to <span id="ssid-wait"></span></h2>
|
||||||
|
<section>
|
||||||
|
<div id="loading">
|
||||||
|
<div class="spinner">
|
||||||
|
<div class="double-bounce1"></div>
|
||||||
|
<div class="double-bounce2"></div>
|
||||||
|
</div>
|
||||||
|
<p class="tctr">You may lose wifi access while the esp32 recalibrates its radio. Please wait until your device automatically reconnects. This can take up to 30s.</p>
|
||||||
|
</div>
|
||||||
|
<div id="connect-success">
|
||||||
|
<h3 class="gr">Success!</h3>
|
||||||
|
</div>
|
||||||
|
<div id="connect-fail">
|
||||||
|
<h3 class="rd">Connection failed</h3>
|
||||||
|
<p class="tctr">Please double-check wifi password if any and make sure the access point has good signal.</p>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<div class="buttons">
|
||||||
|
<input id="ok-connect" type="button" value="OK" class="btn btn-success" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="connect-details">
|
||||||
|
<div id="connect-details-wrap">
|
||||||
|
<header>
|
||||||
|
<h1></h1>
|
||||||
|
</header>
|
||||||
|
<h2></h2>
|
||||||
|
<section>
|
||||||
|
<div class="buttons">
|
||||||
|
<input id="disconnect" type="button" value="Disconnect" class="btn btn-danger"/>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<h2>IP Address</h2>
|
||||||
|
<section>
|
||||||
|
<div class="ape brdb">
|
||||||
|
IP Address:
|
||||||
|
<div id="ip" class="fr"></div>
|
||||||
|
</div>
|
||||||
|
<div class="ape brdb">
|
||||||
|
Subnet Mask:
|
||||||
|
<div id="netmask" class="fr"></div>
|
||||||
|
</div>
|
||||||
|
<div class="ape">
|
||||||
|
Default Gateway:
|
||||||
|
<div id="gw" class="fr"></div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<div class="buttons">
|
||||||
|
<input id="ok-details" type="button" value="Back" class="btn btn-success" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="diag-disconnect" class="diag-box">
|
||||||
|
<div class="diag-box-win">
|
||||||
|
<p>Are you sure you would like to disconnect from this wifi?</p>
|
||||||
|
<div class="buttons">
|
||||||
|
<input id="no-disconnect" type="button" value="No" class="btn btn-success" />
|
||||||
|
<input id="yes-disconnect" type="button" value="Yes" class="btn btn-danger" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- wifi -->
|
||||||
|
<div class="tab-pane fade" id="tab-setdisplay">
|
||||||
|
<div id="set_services-list"></div>
|
||||||
|
<div id="setname-list"></div>
|
||||||
|
<div id="setdisplay-list"></div>
|
||||||
|
<div id="i2cconfig-list"></div>
|
||||||
|
<div id="spiconfig-list"></div>
|
||||||
|
</div>
|
||||||
|
<!-- display -->
|
||||||
|
<div class="tab-pane fade" id="tab-audio">
|
||||||
|
<div id="audioout">
|
||||||
|
<h1>Audio output</h1>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="custom-control custom-radio">
|
||||||
|
<input type="radio" id="i2s" name="audio" class="custom-control-input" checked='checked' />
|
||||||
|
<label for="i2s" class="custom-control-label">I2S</label>
|
||||||
|
</div>
|
||||||
|
<div class="custom-control custom-radio">
|
||||||
|
<input type="radio" id="spdif" name="audio" class="custom-control-input" />
|
||||||
|
<label for="spdif" class="custom-control-label">SPDIF</label>
|
||||||
|
</div>
|
||||||
|
<div class="custom-control custom-radio">
|
||||||
|
<input type="radio" id="bt" name="audio" class="custom-control-input" />
|
||||||
|
<label for="bt" class="custom-control-label">Bluetooth</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="btsinkdiv">
|
||||||
|
<input id="btsink" type="text" value="BT sink name" />
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h1>Player name</h1>
|
||||||
|
<input id="player" type="text" value="squeezelite" />
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h1>Optional setting (e.g. for LMS IP address)</h1>
|
||||||
|
<input id="optional" type="text" value="" placeholder="-s 192.168.0.1" />
|
||||||
|
</div>
|
||||||
|
<div class="buttons">
|
||||||
|
<input id="generate-command" type="button" class="btn btn-success" value="Generate" />
|
||||||
|
</div>
|
||||||
|
<h1>Squeezelite command to run</h1>
|
||||||
|
<section id="command-list">
|
||||||
|
<textarea id="autoexec1" maxlength="120">squeezelite -o I2S -b 500:2000 -d all=info -C 30 - W</textarea>
|
||||||
|
</section>
|
||||||
|
<div class="buttons">
|
||||||
|
<input id="save-autoexec1" type="button" class="btn btn-success" value="Save" />
|
||||||
|
</div>
|
||||||
|
<h1>Start Squeezelite (toggle to activate changes)</h1>
|
||||||
|
<div class="custom-control custom-switch">
|
||||||
|
<input type="checkbox" class="custom-control-input" id="autoexec-cb" checked="checked">
|
||||||
|
<label class="custom-control-label" for="autoexec-cb"></label>
|
||||||
|
</div>
|
||||||
|
<br />
|
||||||
|
</div>
|
||||||
|
<!-- audio -->
|
||||||
|
<div class="tab-pane fade" id="tab-firmware">
|
||||||
|
<div id="boot-div">
|
||||||
|
<form id="boot-form" action="/recovery.json" method="post" target="dummyframe">
|
||||||
|
<button id="boot-button" type="submit" class="btn btn-primary">Recovery</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<h1>Check for firmware upgrade</h1>
|
||||||
|
<div class="buttons">
|
||||||
|
<input type="button" id="fwcheck" class="btn btn-info" value="Check for updates" />
|
||||||
|
</div>
|
||||||
|
<div id="searchfw" class="form-group">
|
||||||
|
<select class="custom-select" id="fwbranch">
|
||||||
|
<option selected="">Choose FW branch</option>
|
||||||
|
</select>
|
||||||
|
<input class="form-control form-control-sm" id="searchinput" type="text" placeholder="search releases" id="inputSmall">
|
||||||
|
</div>
|
||||||
|
<table class="table table-hover">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">Firmware version</th>
|
||||||
|
<th scope="col">Release date</th>
|
||||||
|
<th scope="col">HW platform</th>
|
||||||
|
<th scope="col">IDF version</th>
|
||||||
|
<th scope="col">Branch</th>
|
||||||
|
<th scope="col">Flash this FW</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="releaseTable">
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<h2>Firmware URL:</h2>
|
||||||
|
<textarea id="fwurl" maxlength="1000"></textarea>
|
||||||
|
<div class="buttons">
|
||||||
|
<input type="button" id="flash" class="btn btn-danger" value="Flash!" /><span id="flash-status"></span>
|
||||||
|
</div>
|
||||||
|
<p>OR</p>
|
||||||
|
<div class="form-group">
|
||||||
|
<input type="file" class="form-control-file" id="flashfilename" aria-describedby="fileHelp">
|
||||||
|
<div class="buttons">
|
||||||
|
<button type="button" class="btn btn-danger" id="fwUpload">Upload!</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="otadiv">
|
||||||
|
<div class="progress" id="progress">
|
||||||
|
<div class="progress-bar" role="progressbar" aria-valuemin="0" aria-valuemax="100" style="width:0%">
|
||||||
|
0%
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- firmware -->
|
||||||
|
<div class="tab-pane fade" id="tab-commands">
|
||||||
|
<fieldset id="commands-list"></fieldset>
|
||||||
|
</div>
|
||||||
|
<!-- Status -->
|
||||||
|
<div class="tab-pane fade" id="tab-syslog">
|
||||||
|
<div class="card border-primary mb-3" style="">
|
||||||
|
<div class="card-header">Logs</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<table class="table table-hover">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">Timestamp</th>
|
||||||
|
<th scope="col">Message</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="syslogTable">
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<div class="buttons">
|
||||||
|
<input id="clear-syslog" type="button" class="btn btn-danger btn-sm" value="Clear" />
|
||||||
|
</div></div></div>
|
||||||
|
<div class="card border-primary mb-3" style="">
|
||||||
|
<div class="card-header">Pin Assignments</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<table class="table table-hover">
|
||||||
|
<thead><tr><th scope="col">Device</th><th scope="col">Pin Name</th><th scope="col">GPIO Number</th><th scope="col">Type</th></tr></thead>
|
||||||
|
<tbody id="gpiotable"></tbody></table></div></div></div>
|
||||||
|
<!-- syslog -->
|
||||||
|
<div class="tab-pane fade" id="tab-nvs">
|
||||||
|
<table class="table table-hover">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">Key</th>
|
||||||
|
<th scope="col">Value</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="nvsTable">
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<div class="buttons">
|
||||||
|
<div id="boot-div">
|
||||||
|
<form id="reboot-form" action="/reboot.json" method="post" target="dummyframe">
|
||||||
|
<button id="reboot-button" type="submit" class="btn btn-primary">Reboot</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<input id="save-nvs" type="button" class="btn btn-success" value="Commit">
|
||||||
|
<input id="save-as-nvs" type="button" class="btn btn-success" value="Download config">
|
||||||
|
<input id="load-nvs" type="button" class="btn btn-success" value="Load File">
|
||||||
|
<input aria-describedby="fileHelp" onchange="onChooseFile(event, onFileLoad.bind(this))" id="nvsfilename" type="file" style="display:none">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- nvs -->
|
||||||
|
<div class="tab-pane fade" id="tab-credits">
|
||||||
|
<div class="jumbotron">
|
||||||
|
<p><strong><a href="https://github.com/sle118/squeezelite-esp32">squeezelite-esp32</a></strong>, © 2020, philippe44, sle118, daduke<br />Licensed under the GPL</p>
|
||||||
|
<p>
|
||||||
|
This app would not be possible without the following libraries:
|
||||||
|
</p>
|
||||||
|
<ul>
|
||||||
|
<li>squeezelite, © 2012-2019, Adrian Smith and Ralph Irving. Licensed under the GPL License.</li>
|
||||||
|
<li>esp32-wifi-manager, © 2017-2019, Tony Pottier. Licensed under the MIT License.</li>
|
||||||
|
<li>SpinKit, © 2015, Tobias Ahlin. Licensed under the MIT License.</li>
|
||||||
|
<li>jQuery, The jQuery Foundation. Licensed under the MIT License.</li>
|
||||||
|
<li>cJSON, © 2009-2017, Dave Gamble and cJSON contributors. Licensed under the MIT License.</li>
|
||||||
|
<li>esp32-rotary-encoder, © 2011-2019, David Antliff and Ben Buxton. Licensed under the GPL License.</li>
|
||||||
|
<li>tarablessd1306, © 2017-2018, Tara Keeling. Licensed under the MIT license.</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<h2>Show NVS Editor</h2>
|
||||||
|
<div class="custom-control custom-switch">
|
||||||
|
<input type="checkbox" class="custom-control-input" id="show-nvs" checked="checked">
|
||||||
|
<label class="custom-control-label" for="show-nvs"></label>
|
||||||
|
</div>
|
||||||
|
<h2>Show Advanced Commands</h2>
|
||||||
|
<div class="custom-control custom-switch">
|
||||||
|
<input type="checkbox" class="custom-control-input" id="show-commands" checked="checked">
|
||||||
|
<label class="custom-control-label" for="show-commands"></label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- credits -->
|
||||||
|
</div>
|
||||||
|
<footer class="footer"><span id="foot-fw"></span><span id="foot-wifi"></span></footer>
|
||||||
|
<iframe width="0" height="0" border="0" name="dummyframe" id="dummyframe"></iframe>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
File diff suppressed because one or more lines are too long
@@ -272,10 +272,18 @@ void wifi_manager_init_wifi(){
|
|||||||
ESP_LOGD(TAG, "Initializing wifi. Setting WiFi mode to WIFI_MODE_NULL");
|
ESP_LOGD(TAG, "Initializing wifi. Setting WiFi mode to WIFI_MODE_NULL");
|
||||||
ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_NULL) );
|
ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_NULL) );
|
||||||
ESP_LOGD(TAG, "Initializing wifi. Starting wifi");
|
ESP_LOGD(TAG, "Initializing wifi. Starting wifi");
|
||||||
|
char * disable_ps = config_alloc_get_default(NVS_TYPE_STR, "disable_ps", "n", 0);
|
||||||
|
|
||||||
|
if (gpio36_39_used || (disable_ps && strcasecmp(disable_ps,"y")==0)) {
|
||||||
if(gpio36_39_used){
|
if(gpio36_39_used){
|
||||||
ESP_LOGW(TAG, "GPIO 36 or 39 are in use, need to disable WiFi PowerSave!");
|
ESP_LOGW(TAG, "GPIO 36 or 39 are in use, need to disable WiFi PowerSave!");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ESP_LOGW(TAG, "wifi powersave config is disabled. Disabling WiFi PowerSave!");
|
||||||
|
}
|
||||||
esp_wifi_set_ps(WIFI_PS_NONE);
|
esp_wifi_set_ps(WIFI_PS_NONE);
|
||||||
}
|
}
|
||||||
|
FREE_AND_NULL(disable_ps);
|
||||||
ESP_ERROR_CHECK( esp_wifi_start() );
|
ESP_ERROR_CHECK( esp_wifi_start() );
|
||||||
|
|
||||||
taskYIELD();
|
taskYIELD();
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
#include "gds_text.h"
|
#include "gds_text.h"
|
||||||
#include "gds_font.h"
|
#include "gds_font.h"
|
||||||
#include "display.h"
|
#include "display.h"
|
||||||
|
#include "accessors.h"
|
||||||
static const char certs_namespace[] = "certificates";
|
static const char certs_namespace[] = "certificates";
|
||||||
static const char certs_key[] = "blob";
|
static const char certs_key[] = "blob";
|
||||||
static const char certs_version[] = "version";
|
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_START_AP, &start_telnet);
|
||||||
wifi_manager_set_callback(ORDER_CONNECT_STA, &start_telnet);
|
wifi_manager_set_callback(ORDER_CONNECT_STA, &start_telnet);
|
||||||
}
|
}
|
||||||
|
|
||||||
console_start();
|
console_start();
|
||||||
if(fwurl && strlen(fwurl)>0){
|
if(fwurl && strlen(fwurl)>0){
|
||||||
if(is_recovery_running){
|
if(is_recovery_running){
|
||||||
|
|||||||
Reference in New Issue
Block a user