Compare commits

...

43 Commits

Author SHA1 Message Date
Sebastien
3e74292fc0 Reposition audio config and other small fixes - release 2020-10-09 16:35:30 -04:00
Sebastien
b301376fc6 Fix update page - release
Pressing check for update no longer appends duplicate entries in the branch selection drop down
2020-10-09 06:51:32 -04:00
Sebastien
262f5ff3e7 Merge remote-tracking branch 'origin/master-cmake' into master-cmake 2020-10-09 06:46:15 -04:00
Sebastien
d379858dd2 Display config UI fixes - release
Add 2 entries as a replacement for the ST77xx driver name, remove SSD1306 default.
2020-10-08 21:09:36 -04:00
Sébastien
368832d0d5 Major UI Update - release
- Bug fixes 
- Jack doesn't show as plugged in if no jack detection is configured 
- New layout
- Updated jQuery to latest version
- Updated bootstrap to latest version
- Updated the command processing backend to support UI interactions
- Added a number of accessors to normalize read/update various configuration entries 
- Added more GPIOs to the status tab GPIO list
- Added several configuration sections for hardware and system
- Removed pop-over windows from system messages
- Added a message count pill to the status tab
- Added support for message count pill based on the highest severity 
- Updated the message list table to set colours based on messages severity
- Added command processing message area close to the action buttons to provide feedback from running the commands


** See pervious commit for changed files**
2020-10-08 17:23:57 -04:00
Sebastien
be1d841039 Major UI Update
- Bug fixes 
- Jack doesn't show as plugged in if no jack detection is configured 
- New layout
- Updated jQuery to latest version
- Updated bootstrap to latest version
- Updated the command processing backend to support UI interactions
- Added a number of accessors to normalize read/update various configuration entries 
- Added more GPIOs to the status tab GPIO list
- Added several configuration sections for hardware and system
- Removed pop-over windows from system messages
- Added a message count pill to the status tab
- Added support for message count pill based on the highest severity 
- Updated the message list table to set colours based on messages severity
- Added command processing message area close to the action buttons to provide feedback from running the commands
2020-10-08 17:19:22 -04:00
Philippe G
6ae47a908b add player type 101 - release 2020-10-06 22:28:01 -07:00
Philippe G
797a21ee9f release 2020-09-26 12:21:45 -07:00
Philippe G
7f1db60c45 fix reboot logic upon server loss - release 2020-09-25 21:50:44 -07:00
Philippe G
fb530645b8 CRLF 2020-09-25 19:01:53 -07:00
Sébastien
7f932630fc release 2020-09-13 16:47:00 -04:00
Sebastien
458efb376a Merge branch 'master-cmake' of https://github.com/sle118/squeezelite-esp32.git into master-cmake 2020-09-13 12:17:38 -04:00
Sebastien
3ffbe022e5 Added wifi scanmode NVS option - release
f= default, fast scan
a= All channel scan
2020-09-13 12:17:27 -04:00
Philippe G
762c529563 fix a couple of gpio names (SPI/I2C)
Also a few "style" consistency changes so that within each file, look is the same, although different files can have different styles
2020-09-12 22:58:52 -07:00
Sebastien
0c224b4b84 New config UI for Services (Airplay, bt, etc) - release 2020-09-12 23:09:38 -04:00
Sebastien
bbbc924fcd Add nvs "wifi_ps" to disable wifi power save mode - release
Set disable_ps = n to disable power save mode. This may help with wifi
signal stability, but will likely result in a higher power consumption.
2020-09-12 16:05:49 -04:00
Chuck
cc5fb49ff8 Battery gauge fix (#52)
* Fix battery reporting in status.json, and adjust scaling for bettery level representation

* remove comment verbosity

* change battery_value_svc to return float

Co-authored-by: rochuck <chuck@zethus.ca>
2020-09-12 11:31:28 -04:00
Sebastien
189bc763dd WIP User Interface improvement. Fix SqueezeAmp build - release 2020-09-11 16:27:27 -04:00
Sebastien
78b7639400 WIP - User Interface improvements 2020-09-11 16:15:31 -04:00
Sebastien
56954962a3 WIP - Rework UI, add new commands for SPI and device name 2020-09-09 22:07:55 -04:00
Sebastien
5ff673ae7d Fix build issue - release 2020-09-08 17:11:52 -04:00
Sebastien
2eb995d621 Merge branch 'master-cmake' of https://github.com/sle118/squeezelite-esp32.git into master-cmake 2020-09-08 16:47:08 -04:00
Sebastien
573ddb6fda Bug fix - some values weren't passed back in the command call - release 2020-09-08 16:46:50 -04:00
Philippe G
708a3f9c4a small tweaks 2020-09-06 17:06:52 -07:00
Philippe G
a73c659a1e solving mistery of component made of external static libs only
(and I hate CMake)
2020-09-06 16:54:09 -07:00
Philippe G
b22143a3b6 typos 2020-09-06 00:49:04 -07:00
Sebastien
6195750b41 Minor fix to the UI and command line help text - release 2020-09-04 16:24:12 -04:00
Sebastien
889b1097cc Reorganize configuration UI - release
The System tab is now hidden by default and can be enabled via a toggle
under the Credits tab, similar to how NVS tab works.  A new tab was
created to hold configurations, and display configuration was added.
2020-09-04 16:02:53 -04:00
Sebastien
41cdb8bcdd Allow saving/loading nvs from the nvs editor - release 2020-09-02 13:09:46 -04:00
Philippe G
8c33acfd35 tweak dac_controlset timing - release 2020-09-01 16:24:36 -07:00
Sebastien
0222a34286 Merge branch 'master-cmake' of https://github.com/sle118/squeezelite-esp32.git into master-cmake 2020-09-01 16:45:11 -04:00
Sebastien
a90c9802ab Fix commands not working in telnet #43 - release 2020-09-01 16:43:48 -04:00
Philippe G
94da8ca950 i2c timeout change + remove some wifi test code used for led fix - release 2020-09-01 13:40:25 -07:00
Philippe G
9a9a4fef65 Merge branch 'master-cmake' of https://github.com/sle118/squeezelite-esp32 into master-cmake 2020-09-01 12:24:11 -07:00
Philippe G
3a7b1f48c7 change a bit log 2020-09-01 12:24:09 -07:00
Sebastien
a46bbb409f Fixes #50 - Green led flash state reset on wifi connect - release 2020-09-01 15:11:45 -04:00
Sebastien
08d16c2ca2 Led configuration wasn't correctly reported in logs 2020-09-01 12:03:31 -04:00
Philippe G
b501352ddc Merge branch 'master-cmake' of https://github.com/sle118/squeezelite-esp32 into master-cmake 2020-08-31 15:36:21 -07:00
Philippe G
1c51598366 shift i2c address by 1 for consistency - release 2020-08-31 15:36:17 -07:00
Sebastien
db839a9ccd Add new status field: is_i2c_locked to help with the new config page 2020-08-31 16:56:54 -04:00
Philippe G
5aba426b98 no mutex needed for polling - release 2020-08-30 12:30:30 -07:00
Philippe G
6c184efa92 faster & simpler solution for stream poll() - release 2020-08-30 11:22:03 -07:00
Philippe G
028a090864 update plugin files 2020-08-29 22:20:26 -07:00
86 changed files with 7588 additions and 4091 deletions

26
.gitignore vendored
View File

@@ -69,3 +69,29 @@ squeezelite-esp32-jsonblob.zip
/flash_cmd.txt
/writeSequeezeEsp.bat
/writeSequeezeEsp.sh
all_releases.json
alltags.txt
releases.json
sdkconfig
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/settings.json
.vscode/tasks.json
components/wifi-manager/.project
components/wifi-manager/.settings/.jsdtscope
components/wifi-manager/.settings/org.eclipse.wst.jsdt.ui.superType.container
components/wifi-manager/.settings/org.eclipse.wst.jsdt.ui.superType.name
components/wifi-manager/res/backup/
*.code-workspace
test/.vscode/

View File

@@ -250,15 +250,7 @@ The above command will mount this repo into the docker container and start a bas
for you to then follow the below build steps
### Manual Install of ESP-IDF
<<<<<<< HEAD
Follow the instructions from https://docs.espressif.com/projects/esp-idf/en/v4.0/get-started/index.html to install the esp-idf v4.0. This is the currently supported release of the espressif software development system.
=======
<strong>Currently the master branch of this project requires this [IDF](https://github.com/espressif/esp-idf/tree/28f1cdf5ed7149d146ad5019c265c8bc3bfa2ac9) with gcc 5.2 (toolschain dated 20181001)
If you want to use a more recent version of gcc and IDF (4.0 stable), move to cmake-master branch</strong>
You can install IDF manually on Linux or Windows (using the Subsystem for Linux) following the instructions at: https://www.instructables.com/id/ESP32-Development-on-Windows-Subsystem-for-Linux/
You also need to use esp-dsp recent version or at least make sure you have this patch https://github.com/espressif/esp-dsp/pull/12/commits/8b082c1071497d49346ee6ed55351470c1cb4264
>>>>>>> refs/remotes/origin/master
## Building Squeezelite-esp32
MOST IMPORTANT: create the right default config file
@@ -353,4 +345,3 @@ See squeezlite command line, but keys options are
- git clone --recursive https://github.com/sle118/squeezelite-esp32.git
- If you have already cloned the repository and you are getting compile errors on one of the submodules (e.g. telnet), run the following git command in the root of the repository location
- git submodule update --init --recursive

View File

@@ -1,6 +1,5 @@
idf_component_register(SRC_DIRS .
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
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
)
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(libogg lib/libogg.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(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} PRIVATE libalac)
target_link_libraries(${COMPONENT_LIB} PRIVATE libremple16)
target_link_libraries(${COMPONENT_LIB} PRIVATE libopusfile)
target_link_libraries(${COMPONENT_LIB} PRIVATE libopus)
target_link_libraries(${COMPONENT_LIB} INTERFACE libmad)
target_link_libraries(${COMPONENT_LIB} INTERFACE libFLAC)
target_link_libraries(${COMPONENT_LIB} INTERFACE libhelix-aac)
target_link_libraries(${COMPONENT_LIB} INTERFACE libvorbisidec)
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)

View File

@@ -1,3 +0,0 @@
void dummy_obj() {
return;
}

View File

@@ -1,4 +1,3 @@
idf_component_register(SRC_DIRS . core core/ifaces fonts
INCLUDE_DIRS . fonts core
REQUIRES platform_config tools esp_common

View File

@@ -35,7 +35,7 @@ static bool I2CDefaultWriteData( struct GDS_Device* Device, const uint8_t* Data,
bool GDS_I2CInit( int PortNumber, int SDA, int SCL, int Speed ) {
I2CPortNumber = PortNumber;
I2CWait = pdMS_TO_TICKS( Speed ? Speed / 4000 : 100 );
I2CWait = pdMS_TO_TICKS( Speed ? (250 * 250000) / Speed : 250 );
if (SDA != -1 && SCL != -1) {
i2c_config_t Config = { 0 };

View File

@@ -52,7 +52,8 @@ static const char *known_drivers[] = {"SH1106",
"SSD1327",
"SSD1675",
"SSD1351",
"ST77xx",
"ST7735",
"ST7789",
"ILI9341",
NULL
};
@@ -381,14 +382,14 @@ void displayer_control(enum displayer_cmd_e cmd, ...) {
/****************************************************************************************
*
*/
bool display_is_valid_driver(char * driver){
bool display_is_valid_driver(const char * driver){
return display_conf_get_driver_name(driver)!=NULL;
}
/****************************************************************************************
*
*/
const char *display_conf_get_driver_name(char * driver){
const char *display_conf_get_driver_name(const char * driver){
for(uint8_t i=0;known_drivers[i]!=NULL && strlen(known_drivers[i])>0;i++ ){
if(strcasestr(driver,known_drivers[i])){
return known_drivers[i];
@@ -396,3 +397,27 @@ const char *display_conf_get_driver_name(char * driver){
}
return NULL;
}
/****************************************************************************************
*
*/
char * display_get_supported_drivers(void){
int total_size = 1;
char * supported_drivers=NULL;
const char * separator = "|";
int separator_len = strlen(separator);
for(uint8_t i=0;known_drivers[i]!=NULL && strlen(known_drivers[i])>0;i++ ){
total_size += strlen(known_drivers[i])+separator_len;
}
total_size+=2;
supported_drivers = malloc(total_size);
memset(supported_drivers,0x00,total_size);
strcat(supported_drivers,"<");
for(uint8_t i=0;known_drivers[i]!=NULL && strlen(known_drivers[i])>0;i++ ){
supported_drivers = strcat(supported_drivers,known_drivers[i]);
supported_drivers = strcat(supported_drivers,separator);
}
strcat(supported_drivers,">");
return supported_drivers;
}

View File

@@ -10,6 +10,7 @@
#include "gds.h"
/*
The displayer is not thread-safe and the caller must ensure use its own
mutexes if it wants something better. Especially, text() line() and draw()
@@ -31,10 +32,11 @@ enum displayer_time_e { DISPLAYER_ELAPSED, DISPLAYER_REMAINING };
enum display_bus_cmd_e { DISPLAY_BUS_TAKE, DISPLAY_BUS_GIVE };
bool (*display_bus)(void *from, enum display_bus_cmd_e cmd);
const char *display_conf_get_driver_name(char * driver);
bool display_is_valid_driver(char * driver);
const char *display_conf_get_driver_name(const char * driver);
bool display_is_valid_driver(const char * driver);
void displayer_scroll(char *string, int speed, int pause);
void displayer_control(enum displayer_cmd_e cmd, ...);
void displayer_metadata(char *artist, char *album, char *title);
void displayer_timer(enum displayer_time_e mode, int elapsed, int duration);
char * display_get_supported_drivers(void);

View File

@@ -5,6 +5,7 @@ idf_component_register( SRCS
cmd_system.c
cmd_wifi.c
platform_console.c
cmd_config.c
INCLUDE_DIRS .
REQUIRES nvs_flash
PRIV_REQUIRES console app_update tools services spi_flash platform_config vfs pthread wifi-manager platform_config newlib telnet display )

View File

@@ -0,0 +1,609 @@
/* cmd_i2ctools.c
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
//#define LOG_LOCAL_LEVEL ESP_LOG_DEBUG
#include <stdio.h>
#include "cmd_config.h"
#include "argtable3/argtable3.h"
#include "platform_console.h"
#include "esp_log.h"
#include "string.h"
#include "stdio.h"
#include "platform_config.h"
#include "trace.h"
#include "messaging.h"
#include "accessors.h"
const char * desc_squeezelite ="Squeezelite Options";
const char * desc_dac= "DAC Options";
const char * desc_spdif= "SPDIF Options";
const char * desc_audio= "General Audio Options";
#define CODECS_BASE "flac,pcm,mp3,ogg"
#if NO_FAAD
#define CODECS_AAC ""
#else
#define CODECS_AAC ",aac"
#endif
#if FFMPEG
#define CODECS_FF ",wma,alac"
#else
#define CODECS_FF ""
#endif
#if DSD
#define CODECS_DSD ",dsd"
#else
#define CODECS_DSD ""
#endif
#define CODECS_MP3 " (mad,mpg for specific mp3 codec)"
#define CODECS CODECS_BASE CODECS_AAC CODECS_FF CODECS_DSD CODECS_MP3
#define NOT_OUTPUT "has input capabilities only"
#define NOT_GPIO "is not a GPIO"
static const char *TAG = "cmd_config";
extern struct arg_end *getParmsEnd(struct arg_hdr * * argtable);
//bck=<gpio>,ws=<gpio>,do=<gpio>[,mute=<gpio>[:0|1][,model=TAS57xx|TAS5713|AC101|I2S][,sda=<gpio>,scl=gpio[,i2c=<addr>]]
static struct {
struct arg_str *model_name;
struct arg_int *clock;
struct arg_int *wordselect;
struct arg_int *data;
struct arg_int *mute_gpio;
struct arg_lit *mute_level;
struct arg_int *dac_sda;
struct arg_int *dac_scl;
struct arg_int *dac_i2c;
struct arg_lit *clear;
struct arg_end *end;
} i2s_args;
static struct {
struct arg_int *clock;
struct arg_int *wordselect;
struct arg_int *data;
struct arg_lit *clear;
struct arg_end *end;
} spdif_args;
static struct {
struct arg_str *jack_behavior;
struct arg_end *end;
} audio_args;
static struct {
struct arg_str * server; // -s <server>[:<port>]\tConnect to specified server, otherwise uses autodiscovery to find server\n"
struct arg_str * buffers;// " -b <stream>:<output>\tSpecify internal Stream and Output buffer sizes in Kbytes\n"
struct arg_str * codecs;// " -c <codec1>,<codec2>\tRestrict codecs to those specified, otherwise load all available codecs; known codecs: " CODECS "\n"
struct arg_int * timeout;// " -C <timeout>\t\tClose output device when idle after timeout seconds, default is to keep it open while player is 'on'\n"
struct arg_str * log_level; // " -d <log>=<level>\tSet logging level, logs: all|slimproto|stream|decode|output|ir, level: info|debug|sdebug\n"
// struct arg_str * log_level_all; // " -d <log>=<level>\tSet logging level, logs: all|slimproto|stream|decode|output|ir, level: info|debug|sdebug\n"
// struct arg_str * log_level_slimproto; // " -d <log>=<level>\tSet logging level, logs: all|slimproto|stream|decode|output|ir, level: info|debug|sdebug\n"
// struct arg_str * log_level_stream;
// struct arg_str * log_level_decode;
// struct arg_str * log_level_output;
#if IR
struct arg_str * log_level_ir;
#endif
struct arg_str * output_device; // " -d <log>=<level>\tSet logging level, logs: all|slimproto|stream|decode|output|ir, level: info|debug|sdebug\n"
// " -e <codec1>,<codec2>\tExplicitly exclude native support of one or more codecs; known codecs: " CODECS "\n"
// " -f <logfile>\t\tWrite debug to logfile\n"
// #if IR
// " -i [<filename>]\tEnable lirc remote control support (lirc config file ~/.lircrc used if filename not specified)\n"
// #endif
struct arg_str * mac_addr; // " -m <mac addr>\t\tSet mac address, format: ab:cd:ef:12:34:56\n"
struct arg_str * model_name;// " -M <modelname>\tSet the squeezelite player model name sent to the server (default: " MODEL_NAME_STRING ")\n"
struct arg_str * name;// " -n <name>\t\tSet the player name\n"
struct arg_lit * header_format;// " -W\t\t\tRead wave and aiff format from header, ignore server parameters\n"
struct arg_str * rates; // " -r <rates>[:<delay>]\tSample rates supported, allows output to be off when squeezelite is started; rates = <maxrate>|<minrate>-<maxrate>|<rate1>,<rate2>,<rate3>; delay = optional delay switching rates in ms\n"
#if RESAMPLE
struct arg_lit * resample;
struct arg_str * resample_parms; //" -R -u [params]\tResample, params = <recipe>:<flags>:<attenuation>:<precision>:<passband_end>:<stopband_start>:<phase_response>,\n"
#endif
#if RESAMPLE16
struct arg_lit * resample;
struct arg_str * resample_parms; //" -R -u [params]\tResample, params = (b|l|m)[:i],\n"
// " \t\t\t b = basic linear interpolation, l = 13 taps, m = 21 taps, i = interpolate filter coefficients\n"
#endif
struct arg_int * rate;// " -Z <rate>\t\tReport rate to server in helo as the maximum sample rate we can support\n"
struct arg_end *end;
} squeezelite_args;
int is_output_gpio(struct arg_int * gpio, FILE * f, int * gpio_out, bool mandatory){
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){
if(mandatory){
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;
}
int check_missing_parm(struct arg_int * int_parm, FILE * f){
int res=0;
const char * name = int_parm->hdr.longopts?int_parm->hdr.longopts:int_parm->hdr.glossary;
if(int_parm->count==0){
fprintf(f,"Missing: %s\n", name);
res++;
}
return res;
}
static int do_audio_cmd(int argc, char **argv){
esp_err_t err=ESP_OK;
int nerrors = arg_parse(argc, argv,(void **)&audio_args);
char *buf = NULL;
size_t buf_size = 0;
FILE *f = open_memstream(&buf, &buf_size);
if (f == NULL) {
cmd_send_messaging(argv[0],MESSAGING_ERROR,"Unable to open memory stream.\n");
return 1;
}
if(nerrors >0){
arg_print_errors(f,audio_args.end,desc_audio);
return 1;
}
if(audio_args.jack_behavior->count>0){
err = ESP_OK; // suppress any error code that might have happened in a previous step
if(strcasecmp(audio_args.jack_behavior->sval[0],"Headphones")){
err = config_set_value(NVS_TYPE_STR, "jack_mutes_amp", "y");
}
else if(strcasecmp(audio_args.jack_behavior->sval[0],"Subwoofer")){
err = config_set_value(NVS_TYPE_STR, "jack_mutes_amp", "n");
}
else {
nerrors++;
fprintf(f,"Unknown Audio Jack Behavior %s.\n",audio_args.jack_behavior->sval[0]);
}
if(err!=ESP_OK){
nerrors++;
fprintf(f,"Error setting Audio Jack Behavior %s. %s\n",audio_args.jack_behavior->sval[0], esp_err_to_name(err));
}
else {
fprintf(f,"Audio Jack Behavior changed to %s\n",audio_args.jack_behavior->sval[0]);
}
}
if(!nerrors ){
fprintf(f,"Done.\n");
}
fflush (f);
cmd_send_messaging(argv[0],nerrors>0?MESSAGING_ERROR:MESSAGING_INFO,"%s", buf);
fclose(f);
FREE_AND_NULL(buf);
return (nerrors==0 && err==ESP_OK)?0:1;
}
static int do_spdif_cmd(int argc, char **argv){
i2s_platform_config_t i2s_dac_pin = {
.i2c_addr = -1,
.sda= -1,
.scl = -1,
.mute_gpio = -1,
.mute_level = -1
};
if(is_spdif_config_locked()){
cmd_send_messaging(argv[0],MESSAGING_ERROR,"SPDIF Configuration is locked on this platform\n");
return 1;
}
esp_err_t err=ESP_OK;
int nerrors = arg_parse(argc, argv,(void **)&spdif_args);
if (spdif_args.clear->count) {
cmd_send_messaging(argv[0],MESSAGING_WARNING,"SPDIF config cleared\n");
config_set_value(NVS_TYPE_STR, "spdif_config", "");
return 0;
}
char *buf = NULL;
size_t buf_size = 0;
FILE *f = open_memstream(&buf, &buf_size);
if (f == NULL) {
cmd_send_messaging(argv[0],MESSAGING_ERROR,"Unable to open memory stream.\n");
return 1;
}
if(nerrors >0){
arg_print_errors(f,spdif_args.end,desc_dac);
return 1;
}
nerrors+=is_output_gpio(spdif_args.clock, f, &i2s_dac_pin.pin.bck_io_num, true);
nerrors+=is_output_gpio(spdif_args.wordselect, f, &i2s_dac_pin.pin.ws_io_num, true);
nerrors+=is_output_gpio(spdif_args.data, f, &i2s_dac_pin.pin.data_out_num, true);
if(!nerrors ){
fprintf(f,"Storing SPDIF parameters.\n");
nerrors+=(config_spdif_set(&i2s_dac_pin )!=ESP_OK);
}
if(!nerrors ){
fprintf(f,"Done.\n");
}
fflush (f);
cmd_send_messaging(argv[0],nerrors>0?MESSAGING_ERROR:MESSAGING_INFO,"%s", buf);
fclose(f);
FREE_AND_NULL(buf);
return (nerrors==0 && err==ESP_OK)?0:1;
}
static int do_i2s_cmd(int argc, char **argv)
{
i2s_platform_config_t i2s_dac_pin = {
.i2c_addr = -1,
.sda= -1,
.scl = -1,
.mute_gpio = -1,
.mute_level = -1
};
if(is_dac_config_locked()){
cmd_send_messaging(argv[0],MESSAGING_ERROR,"DAC Configuration is locked on this platform\n");
return 1;
}
strcpy(i2s_dac_pin.model, "I2S");
esp_err_t err=ESP_OK;
int nerrors = arg_parse(argc, argv,(void **)&i2s_args);
if (i2s_args.clear->count) {
cmd_send_messaging(argv[0],MESSAGING_WARNING,"DAC config cleared\n");
config_set_value(NVS_TYPE_STR, "dac_config", "");
return 0;
}
char *buf = NULL;
size_t buf_size = 0;
FILE *f = open_memstream(&buf, &buf_size);
if (f == NULL) {
cmd_send_messaging(argv[0],MESSAGING_ERROR,"Unable to open memory stream.\n");
return 1;
}
if(nerrors >0){
arg_print_errors(f,i2s_args.end,desc_dac);
return 1;
}
nerrors+=is_output_gpio(i2s_args.clock, f, &i2s_dac_pin.pin.bck_io_num, true);
nerrors+=is_output_gpio(i2s_args.wordselect, f, &i2s_dac_pin.pin.ws_io_num, true);
nerrors+=is_output_gpio(i2s_args.data, f, &i2s_dac_pin.pin.data_out_num, true);
nerrors+=is_output_gpio(i2s_args.mute_gpio, f, &i2s_dac_pin.mute_gpio, false);
if(i2s_dac_pin.mute_gpio>0){
i2s_dac_pin.mute_level = i2s_args.mute_level->count>0?1:0;
}
if(i2s_args.dac_sda->count>0 && i2s_args.dac_sda->ival[0]>=0){
// if SDA specified, then SDA and SCL are both mandatory
nerrors+=is_output_gpio(i2s_args.dac_sda, f, &i2s_dac_pin.sda, false);
nerrors+=is_output_gpio(i2s_args.dac_scl, f, &i2s_dac_pin.scl, false);
}
if(i2s_args.dac_sda->count==0&& i2s_args.dac_i2c->count>0){
fprintf(f,"warning: ignoring i2c address, since dac i2c gpios config is incomplete\n");
}
else if(i2s_args.dac_i2c->count>0){
i2s_dac_pin.i2c_addr = i2s_args.dac_i2c->ival[0];
}
if(i2s_args.model_name->count>0 && strlen(i2s_args.model_name->sval[0])>0){
strncpy(i2s_dac_pin.model,i2s_args.model_name->sval[0],sizeof(i2s_dac_pin.model));
}
if(!nerrors ){
fprintf(f,"Storing i2s parameters.\n");
nerrors+=(config_i2s_set(&i2s_dac_pin, "dac_config")!=ESP_OK);
}
if(!nerrors ){
fprintf(f,"Done.\n");
}
fflush (f);
cmd_send_messaging(argv[0],nerrors>0?MESSAGING_ERROR:MESSAGING_INFO,"%s", buf);
fclose(f);
FREE_AND_NULL(buf);
return (nerrors==0 && err==ESP_OK)?0:1;
}
cJSON * example_cb(){
cJSON * values = cJSON_CreateObject();
// int 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);
// }
// if(i2c->sda_io_num>0) {
// cJSON_AddNumberToObject(values,"sda",i2c->sda_io_num);
// }
// if(i2c->master.clk_speed>0) {
// cJSON_AddNumberToObject(values,"freq",i2c->master.clk_speed);
// }
// if(i2c_port>0) {
// cJSON_AddNumberToObject(values,"port",i2c_port);
// }
return values;
}
//const i2s_pin_config_t * config_get_spdif_pin_struct( );
cJSON * i2s_cb(){
cJSON * values = cJSON_CreateObject();
const i2s_platform_config_t * i2s_conf= config_dac_get( );
if(i2s_conf->pin.bck_io_num>0 ) {
cJSON_AddNumberToObject(values,"clock",i2s_conf->pin.bck_io_num);
}
if(i2s_conf->pin.ws_io_num>=0 ) {
cJSON_AddNumberToObject(values,"wordselect",i2s_conf->pin.ws_io_num);
}
if(i2s_conf->pin.data_out_num>=0 ) {
cJSON_AddNumberToObject(values,"data",i2s_conf->pin.data_out_num);
}
if(i2s_conf->sda>=0 ) {
cJSON_AddNumberToObject(values,"dac_sda",i2s_conf->sda);
}
if(i2s_conf->scl>=0 ) {
cJSON_AddNumberToObject(values,"dac_scl",i2s_conf->scl);
}
if(i2s_conf->i2c_addr>=0 ) {
cJSON_AddNumberToObject(values,"dac_i2c",i2s_conf->i2c_addr);
}
if(i2s_conf->mute_gpio>=0 ) {
cJSON_AddNumberToObject(values,"mute_gpio",i2s_conf->mute_gpio);
}
if(i2s_conf->mute_level>=0 ) {
cJSON_AddBoolToObject(values,"mute_level",i2s_conf->mute_level>0);
}
if(strlen(i2s_conf->model)>0){
cJSON_AddStringToObject(values,"model_name",i2s_conf->model);
}
else {
cJSON_AddStringToObject(values,"model_name","I2S");
}
return values;
}
cJSON * spdif_cb(){
cJSON * values = cJSON_CreateObject();
const i2s_platform_config_t * spdif_conf= config_spdif_get( );
if(spdif_conf->pin.bck_io_num>0 ) {
cJSON_AddNumberToObject(values,"clock",spdif_conf->pin.bck_io_num);
}
if(spdif_conf->pin.ws_io_num>=0 ) {
cJSON_AddNumberToObject(values,"wordselect",spdif_conf->pin.ws_io_num);
}
if(spdif_conf->pin.data_out_num>=0 ) {
cJSON_AddNumberToObject(values,"data",spdif_conf->pin.data_out_num);
}
return values;
}
cJSON * audio_cb(){
cJSON * values = cJSON_CreateObject();
char * p = config_alloc_get_default(NVS_TYPE_STR, "jack_mutes_amp", "n", 0);
cJSON_AddBoolToObject(values,"jack_behavior",(strcmp(p,"1") == 0 ||strcasecmp(p,"y") == 0));
FREE_AND_NULL(p);
return values;
}
void get_str_parm_json(struct arg_str * parm, cJSON * entry){
const char * name = parm->hdr.longopts?parm->hdr.longopts:parm->hdr.glossary;
if(parm->count>0){
cJSON_AddStringToObject(entry,name,parm->sval[0]);
}
}
void get_file_parm_json(struct arg_file * parm, cJSON * entry){
const char * name = parm->hdr.longopts?parm->hdr.longopts:parm->hdr.glossary;
if(parm->count>0){
cJSON_AddStringToObject(entry,name,parm->filename[0]);
}
}
void get_lit_parm_json(struct arg_lit * parm, cJSON * entry){
const char * name = parm->hdr.longopts?parm->hdr.longopts:parm->hdr.glossary;
cJSON_AddBoolToObject(entry,name,(parm->count>0));
}
void get_int_parm_json(struct arg_int * parm, cJSON * entry){
const char * name = parm->hdr.longopts?parm->hdr.longopts:parm->hdr.glossary;
if(parm->count>0){
cJSON_AddNumberToObject(entry,name,parm->ival[0]);
}
}
static int do_squeezelite_cmd(int argc, char **argv)
{
esp_err_t err=ESP_OK;
int nerrors = arg_parse_msg(argc, argv,(struct arg_hdr ** )&squeezelite_args);
char *buf = NULL;
size_t buf_size = 0;
FILE *f = open_memstream(&buf, &buf_size);
if (f == NULL) {
cmd_send_messaging(argv[0],MESSAGING_ERROR,"Unable to open memory stream.\n");
return 1;
}
fprintf(f,"Not yet implemented!");
nerrors+=1;
fflush (f);
cmd_send_messaging(argv[0],nerrors>0?MESSAGING_ERROR:MESSAGING_INFO,"%s", buf);
fclose(f);
FREE_AND_NULL(buf);
return (nerrors==0 && err==ESP_OK)?0:1;
}
cJSON * squeezelite_cb(){
cJSON * values = cJSON_CreateObject();
char * nvs_config= config_alloc_get(NVS_TYPE_STR, "autoexec1");
char **argv = NULL;
char *buf = NULL;
size_t buf_size = 0;
int nerrors=1;
FILE *f = open_memstream(&buf, &buf_size);
if (f == NULL) {
log_send_messaging(MESSAGING_ERROR,"Unable to parse squeezelite parameters");
}
else {
if(nvs_config && strlen(nvs_config)>0){
ESP_LOGD(TAG,"Parsing command %s",nvs_config);
argv = (char **) calloc(22, sizeof(char *));
if (argv == NULL) {
FREE_AND_NULL(nvs_config);
return values;
}
size_t argc = esp_console_split_argv(nvs_config, argv,22);
if (argc != 0) {
nerrors = arg_parse(argc, argv,(void **)&squeezelite_args);
ESP_LOGD(TAG,"Parsing completed");
}
}
if (nerrors == 0) {
get_str_parm_json(squeezelite_args.buffers, values);
get_str_parm_json(squeezelite_args.codecs, values);
get_lit_parm_json(squeezelite_args.header_format, values);
get_str_parm_json(squeezelite_args.log_level, values);
// get_str_parm_json(squeezelite_args.log_level_all, values);
// get_str_parm_json(squeezelite_args.log_level_decode, values);
// get_str_parm_json(squeezelite_args.log_level_output, values);
// get_str_parm_json(squeezelite_args.log_level_slimproto, values);
// get_str_parm_json(squeezelite_args.log_level_stream, values);
get_str_parm_json(squeezelite_args.mac_addr, values);
get_str_parm_json(squeezelite_args.output_device, values);
get_str_parm_json(squeezelite_args.model_name, values);
get_str_parm_json(squeezelite_args.name, values);
get_int_parm_json(squeezelite_args.rate, values);
get_str_parm_json(squeezelite_args.rates, values);
get_str_parm_json(squeezelite_args.server, values);
get_int_parm_json(squeezelite_args.timeout, values);
char * p = cJSON_Print(values);
ESP_LOGD(TAG,"%s",p);
free(p);
}
else {
arg_print_errors(f, squeezelite_args.end, desc_squeezelite);
}
fflush (f);
if(strlen(buf)>0){
log_send_messaging(nerrors?MESSAGING_ERROR:MESSAGING_INFO,"%s", buf);
}
fclose(f);
FREE_AND_NULL(buf);
}
FREE_AND_NULL(nvs_config);
FREE_AND_NULL(argv);
return values;
}
static char * get_log_level_options(const char * longname){
const char * template = "<%s=info|%s=debug|%s=sdebug>";
char * options = NULL;
int len = snprintf(NULL,0,template,longname,longname,longname);
if(len>0){
options = malloc(len+1);
snprintf(options,len,template,longname,longname,longname);
}
return options;
}
static void register_i2s_config(void){
i2s_args.model_name = arg_str1(NULL,"model_name","TAS57xx|TAS5713|AC101|I2S","DAC Model Name");
i2s_args.clear = arg_lit0(NULL, "clear", "Clear configuration");
i2s_args.clock = arg_int1(NULL,"clock","<n>","Clock GPIO. e.g. 33");
i2s_args.wordselect = arg_int1(NULL,"wordselect","<n>","Word Select GPIO. e.g. 25");
i2s_args.data = arg_int1(NULL,"data","<n>","Data GPIO. e.g. 32");
i2s_args.mute_gpio = arg_int0(NULL,"mute_gpio", "<n>", "Mute GPIO. e.g. 14");
i2s_args.mute_level = arg_lit0(NULL,"mute_level","Mute GPIO level. Checked=HIGH, Unchecked=LOW");
i2s_args.dac_sda = arg_int0(NULL,"dac_sda", "<n>", "SDA GPIO. e.g. 27");
i2s_args.dac_scl = arg_int0(NULL,"dac_scl", "<n>", "SCL GPIO. e.g. 26");
i2s_args.dac_i2c = arg_int0(NULL,"dac_i2c", "<n>", "I2C device address. e.g. 106");
i2s_args.end = arg_end(6);
const esp_console_cmd_t cmd = {
.command = CFG_TYPE_HW("dac"),
.help = desc_dac,
.hint = NULL,
.func = &do_i2s_cmd,
.argtable = &i2s_args
};
cmd_to_json_with_cb(&cmd,&i2s_cb);
ESP_ERROR_CHECK(esp_console_cmd_register(&cmd));
}
static void register_audio_config(void){
audio_args.jack_behavior = arg_str0("j", "jack_behavior","Headphones|Subwoofer","On supported DAC, determines the audio jack behavior. Selecting headphones will cause the external amp to be muted on insert, while selecting Subwoofer will keep the amp active all the time.");
audio_args.end = arg_end(6);
const esp_console_cmd_t cmd = {
.command = CFG_TYPE_AUDIO("general"),
.help = desc_audio,
.hint = NULL,
.func = &do_audio_cmd,
.argtable = &audio_args
};
cmd_to_json_with_cb(&cmd,&audio_cb);
ESP_ERROR_CHECK(esp_console_cmd_register(&cmd));
}static void register_spdif_config(void){
spdif_args.clear = arg_lit0(NULL, "clear", "Clear configuration");
spdif_args.clock = arg_int1(NULL,"clock","<n>","Clock GPIO. e.g. 33");
spdif_args.wordselect = arg_int1(NULL,"wordselect","<n>","Word Select GPIO. e.g. 25");
spdif_args.data = arg_int1(NULL,"data","<n>","Data GPIO. e.g. 32");
spdif_args.end = arg_end(6);
const esp_console_cmd_t cmd = {
.command = CFG_TYPE_HW("spdif"),
.help = desc_spdif,
.hint = NULL,
.func = &do_spdif_cmd,
.argtable = &spdif_args
};
cmd_to_json_with_cb(&cmd,&spdif_cb);
ESP_ERROR_CHECK(esp_console_cmd_register(&cmd));
}
static void register_squeezelite_config(void){
squeezelite_args.server = arg_str0("s","server","<server>[:<port>]","Connect to specified server, otherwise uses autodiscovery to find server");
squeezelite_args.buffers = arg_str0("b","buffers","<stream>:<output>","Internal Stream and Output buffer sizes in Kbytes");
squeezelite_args.codecs = arg_strn("c","codecs","<codec1>,<codec2>",0,20,"Restrict codecs to those specified, otherwise load all available codecs; known codecs");
squeezelite_args.timeout = arg_int0("C","timeout","<n>","Close output device when idle after timeout seconds, default is to keep it open while player is 'on");
squeezelite_args.log_level = arg_str0("d","loglevel","log=level","Set logging level, logs: all|slimproto|stream|decode|output|ir, level: info|debug|sdebug"); // " -d <log>=<level>\tSet logging level, logs: all|slimproto|stream|decode|output|ir, level: info|debug|sdebug\n"
// squeezelite_args.log_level_all = arg_str0(NULL,"all",get_log_level_options("all"),"Overall Logging Level");
// squeezelite_args.log_level_slimproto = arg_str0(NULL,"loglevel_slimproto",get_log_level_options("slimproto"),"Slimproto Logging Level");
// squeezelite_args.log_level_stream= arg_str0(NULL,"loglevel_stream",get_log_level_options("stream"),"Stream Logging Level");
// squeezelite_args.log_level_decode= arg_str0(NULL,"loglevel_decode",get_log_level_options("decode"),"Decode Logging Level");
// squeezelite_args.log_level_output= arg_str0(NULL,"loglevel_output",get_log_level_options("output"),"Output Logging Level");
#if IR
squeezelite_args.log_level_ir= arg_str0(NULL,"loglevel_ir",get_log_level_options("ir"),"IR Logging Level");
#endif
squeezelite_args.output_device = arg_str0("o","output_device","<string>","Output device");
squeezelite_args.mac_addr = arg_str0("m","mac_addr","<string>","Mac address, format: ab:cd:ef:12:34:56");
squeezelite_args.model_name = arg_str0("M", "modelname", "<string>","Squeezelite player model name sent to the server");
squeezelite_args.name = arg_str0("n","name","<string>","Player name");
squeezelite_args.header_format = arg_lit0("W","header_format","Read wave and aiff format from header, ignore server parameters");
squeezelite_args.rates = arg_str0("r","rates","<rates>[:<delay>]", "Sample rates supported, allows output to be off when squeezelite is started; rates = <maxrate>|<minrate>-<maxrate>|<rate1>,<rate2>,<rate3>; delay = optional delay switching rates in ms\n");
#if RESAMPLE
squeezelite_args.resample = arg_lit0("R","resample","Activate Resample");
squeezelite_args.resample_parms = arg_str0("u","resample_parms","<recipe>:<flags>:<attenuation>:<precision>:<passband_end>:<stopband_start>:<phase_response>","Resample, params");
#endif
#if RESAMPLE16
squeezelite_args.resample = arg_lit0("R","resample","Activate Resample");
squeezelite_args.resample_parms = arg_str0("u","resample_parms","(b|l|m)[:i]","Resample, params. b = basic linear interpolation, l = 13 taps, m = 21 taps, i = interpolate filter coefficients");
#endif
squeezelite_args.rate = arg_int0("Z","max_rate", "<n>", "Report rate to server in helo as the maximum sample rate we can support");
squeezelite_args.end = arg_end(6);
const esp_console_cmd_t cmd = {
.command = CFG_TYPE_AUDIO("squeezelite"),
.help = desc_squeezelite,
.hint = NULL,
.func = &do_squeezelite_cmd,
.argtable = &squeezelite_args
};
cmd_to_json_with_cb(&cmd,&squeezelite_cb);
ESP_ERROR_CHECK(esp_console_cmd_register(&cmd));
}
void register_config_cmd(void){
register_audio_config();
register_squeezelite_config();
register_i2s_config();
register_spdif_config();
}

View File

@@ -0,0 +1,19 @@
/* cmd_i2ctools.h
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
#pragma once
#include "stdbool.h"
#include "stdio.h"
#ifdef __cplusplus
extern "C" {
#endif
void register_config_cmd(void);
#ifdef __cplusplus
}
#endif

View File

@@ -17,6 +17,7 @@ extern "C" {
#include "cmd_nvs.h"
#include "cmd_i2ctools.h"
#include "cmd_ota.h"
#include "cmd_config.h"
#ifdef __cplusplus
}
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -330,11 +330,11 @@ static int set_value(int argc, char **argv)
const char *key = set_args.key->sval[0];
const char *type = set_args.type->sval[0];
const char *values = set_args.value->sval[0];
log_send_messaging(MESSAGING_INFO, "Setting '%s' (type %s)", key,type);
cmd_send_messaging(argv[0],MESSAGING_INFO, "Setting '%s' (type %s)", key,type);
esp_err_t err = set_value_in_nvs(key, type, values);
if (err != ESP_OK) {
log_send_messaging(MESSAGING_ERROR, "%s", esp_err_to_name(err));
cmd_send_messaging(argv[0],MESSAGING_ERROR, "%s", esp_err_to_name(err));
return 1;
}
@@ -355,7 +355,7 @@ static int get_value(int argc, char **argv)
esp_err_t err = get_value_from_nvs(key, type);
if (err != ESP_OK) {
log_send_messaging(MESSAGING_ERROR, "%s", esp_err_to_name(err));
cmd_send_messaging(argv[0],MESSAGING_ERROR, "%s", esp_err_to_name(err));
return 1;
}
@@ -374,7 +374,7 @@ static int erase_value(int argc, char **argv)
esp_err_t err = erase(key);
if (err != ESP_OK) {
log_send_messaging(MESSAGING_ERROR, "%s", esp_err_to_name(err));
cmd_send_messaging(argv[0],MESSAGING_ERROR, "%s", esp_err_to_name(err));
return 1;
}
@@ -392,7 +392,7 @@ static int erase_namespace(int argc, char **argv)
esp_err_t err = erase_all(name);
if (err != ESP_OK) {
log_send_messaging(MESSAGING_ERROR, "%s", esp_err_to_name(err));
cmd_send_messaging(argv[0],MESSAGING_ERROR, "%s", esp_err_to_name(err));
return 1;
}
@@ -411,11 +411,11 @@ static int erase_wifi_manager(int argc, char **argv)
}
nvs_close(nvs);
if (err != ESP_OK) {
log_send_messaging(MESSAGING_ERROR, "wifi manager configuration was not erase. %s", esp_err_to_name(err));
cmd_send_messaging(argv[0],MESSAGING_ERROR, "wifi manager configuration was not erase. %s", esp_err_to_name(err));
return 1;
}
else {
log_send_messaging(MESSAGING_WARNING, "Wifi manager configuration was erased");
cmd_send_messaging(argv[0],MESSAGING_WARNING, "Wifi manager configuration was erased");
}
return 0;
}

View File

@@ -1,7 +1,7 @@
/* Console example — various system commands
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
@@ -31,17 +31,33 @@
#include "driver/uart.h" // for the uart driver access
#include "messaging.h"
#include "platform_console.h"
#ifdef CONFIG_FREERTOS_USE_STATS_FORMATTING_FUNCTIONS
#include "trace.h"
#ifdef CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS
#define WITH_TASKS_INFO 1
#endif
static struct {
struct arg_str *scanmode;
struct arg_lit *disable_power_save;
struct arg_end *end;
} wifi_parms_arg;
static struct {
struct arg_str *name;
struct arg_end *end;
} name_args;
static struct {
struct arg_lit *btspeaker;
struct arg_lit *airplay;
struct arg_str *telnet;
#if WITH_TASKS_INFO
struct arg_lit *stats;
#endif
struct arg_end *end;
} set_services_args;
static const char * TAG = "cmd_system";
static void register_setbtsource();
//static void register_setbtsource();
static void register_free();
static void register_setdevicename();
static void register_heap();
static void register_version();
static void register_restart();
@@ -50,15 +66,20 @@ static void register_light_sleep();
static void register_factory_boot();
static void register_restart_ota();
static void register_update_certs();
static void register_set_services();
static void register_set_wifi_parms();
#if WITH_TASKS_INFO
static void register_tasks();
#endif
extern BaseType_t wifi_manager_task;
void register_system()
{
register_setbtsource();
register_set_wifi_parms();
// register_setbtsource();
register_free();
register_set_services();
register_heap();
register_setdevicename();
register_version();
register_restart();
register_deep_sleep();
@@ -76,7 +97,7 @@ static int get_version(int argc, char **argv)
{
esp_chip_info_t info;
esp_chip_info(&info);
log_send_messaging(MESSAGING_INFO,
cmd_send_messaging(argv[0],MESSAGING_INFO,
"IDF Version:%s\r\n"
"Chip info:\r\n"
"\tmodel:%s\r\n"
@@ -104,35 +125,32 @@ static void register_version()
ESP_ERROR_CHECK( esp_console_cmd_register(&cmd) );
}
/** 'restart' command restarts the program */
esp_err_t guided_boot(esp_partition_subtype_t partition_subtype)
{
if(is_recovery_running){
if(partition_subtype ==ESP_PARTITION_SUBTYPE_APP_FACTORY){
log_send_messaging(MESSAGING_WARNING,"RECOVERY application is already active");
if(!wait_for_commit()){
log_send_messaging(MESSAGING_WARNING,"Unable to commit configuration. ");
}
vTaskDelay(750/ portTICK_PERIOD_MS);
esp_restart();
return ESP_OK;
}
}
else {
if(partition_subtype !=ESP_PARTITION_SUBTYPE_APP_FACTORY){
log_send_messaging(MESSAGING_WARNING,"SQUEEZELITE application is already active");
if(!wait_for_commit()){
log_send_messaging(MESSAGING_WARNING,"Unable to commit configuration. ");
}
vTaskDelay(750/ portTICK_PERIOD_MS);
esp_restart();
return ESP_OK;
}
}
if(is_recovery_running){
if(partition_subtype ==ESP_PARTITION_SUBTYPE_APP_FACTORY){
log_send_messaging(MESSAGING_WARNING,"RECOVERY application is already active");
if(!wait_for_commit()){
log_send_messaging(MESSAGING_WARNING,"Unable to commit configuration. ");
}
vTaskDelay(750/ portTICK_PERIOD_MS);
esp_restart();
return ESP_OK;
}
}
else {
if(partition_subtype !=ESP_PARTITION_SUBTYPE_APP_FACTORY){
log_send_messaging(MESSAGING_WARNING,"SQUEEZELITE application is already active");
if(!wait_for_commit()){
log_send_messaging(MESSAGING_WARNING,"Unable to commit configuration. ");
}
vTaskDelay(750/ portTICK_PERIOD_MS);
esp_restart();
return ESP_OK;
}
}
esp_err_t err = ESP_OK;
bool bFound=false;
log_send_messaging(MESSAGING_INFO, "Looking for partition type %u",partition_subtype);
@@ -156,9 +174,7 @@ else {
log_send_messaging(MESSAGING_ERROR,"Unable to select partition for reboot: %s",esp_err_to_name(err));
}
else{
log_send_messaging(MESSAGING_WARNING, "Application partition %s sub type %u is selected for boot", partition->label,partition_subtype);
bFound=true;
messaging_post_message(MESSAGING_WARNING,MESSAGING_CLASS_SYSTEM,"Reboot failed. Cannot iterate through partitions");
bFound=true;
}
}
else
@@ -169,9 +185,8 @@ else {
ESP_LOGD(TAG, "Yielding to other processes");
taskYIELD();
if(bFound) {
log_send_messaging(MESSAGING_WARNING,"Configuration %s changes. ",config_has_changes()?"has":"does not have");
if(!wait_for_commit()){
log_send_messaging(MESSAGING_WARNING,"Unable to commit configuration. ");
log_send_messaging(MESSAGING_WARNING,"Unable to commit configuration changes. ");
}
vTaskDelay(750/ portTICK_PERIOD_MS);
esp_restart();
@@ -185,7 +200,7 @@ static int restart(int argc, char **argv)
{
log_send_messaging(MESSAGING_WARNING, "\n\nPerforming a simple restart to the currently active partition.");
if(!wait_for_commit()){
log_send_messaging(MESSAGING_WARNING,"Unable to commit configuration. ");
cmd_send_messaging(argv[0],MESSAGING_WARNING,"Unable to commit configuration. ");
}
vTaskDelay(750/ portTICK_PERIOD_MS);
esp_restart();
@@ -194,7 +209,7 @@ static int restart(int argc, char **argv)
void simple_restart()
{
log_send_messaging(MESSAGING_WARNING,"\n\n Called to perform a simple system reboot.");
log_send_messaging(MESSAGING_WARNING,"System reboot requested.");
if(!wait_for_commit()){
log_send_messaging(MESSAGING_WARNING,"Unable to commit configuration. ");
}
@@ -205,24 +220,24 @@ void simple_restart()
}
esp_err_t guided_restart_ota(){
log_send_messaging(MESSAGING_WARNING,"\n\nCalled for a reboot to OTA Application");
log_send_messaging(MESSAGING_WARNING,"System reboot to Application requested");
guided_boot(ESP_PARTITION_SUBTYPE_APP_OTA_0);
return ESP_FAIL; // return fail. This should never return... we're rebooting!
}
esp_err_t guided_factory(){
log_send_messaging(MESSAGING_WARNING,"\n\nCalled for a reboot to recovery application");
log_send_messaging(MESSAGING_WARNING,"System reboot to recovery requested");
guided_boot(ESP_PARTITION_SUBTYPE_APP_FACTORY);
return ESP_FAIL; // return fail. This should never return... we're rebooting!
}
static int restart_factory(int argc, char **argv)
{
log_send_messaging(MESSAGING_WARNING, "Executing guided boot into recovery");
cmd_send_messaging(argv[0],MESSAGING_WARNING, "Executing guided boot into recovery");
guided_boot(ESP_PARTITION_SUBTYPE_APP_FACTORY);
return 0; // return fail. This should never return... we're rebooting!
}
static int restart_ota(int argc, char **argv)
{
log_send_messaging(MESSAGING_WARNING, "Executing guided boot into ota app 0");
cmd_send_messaging(argv[0],MESSAGING_WARNING, "Executing guided boot into ota app 0");
guided_boot(ESP_PARTITION_SUBTYPE_APP_OTA_0);
return 0; // return fail. This should never return... we're rebooting!
}
@@ -230,7 +245,7 @@ static void register_restart()
{
const esp_console_cmd_t cmd = {
.command = "restart",
.help = "Software reset of the chip",
.help = "Reboot system",
.hint = NULL,
.func = &restart,
};
@@ -241,7 +256,7 @@ static void register_restart_ota()
{
const esp_console_cmd_t cmd = {
.command = "restart_ota",
.help = "Selects the ota app partition to boot from and performa a software reset of the chip",
.help = "Reboot system to Squeezelite",
.hint = NULL,
.func = &restart_ota,
};
@@ -253,7 +268,7 @@ static void register_factory_boot()
{
const esp_console_cmd_t cmd = {
.command = "recovery",
.help = "Resets and boot to recovery (if available)",
.help = "Reboot system to Recovery",
.hint = NULL,
.func = &restart_factory,
};
@@ -264,94 +279,10 @@ static void register_factory_boot()
static int free_mem(int argc, char **argv)
{
log_send_messaging(MESSAGING_INFO,"%d", esp_get_free_heap_size());
cmd_send_messaging(argv[0],MESSAGING_INFO,"%d", esp_get_free_heap_size());
return 0;
}
/*
static struct {
struct arg_str *a2dp_dev_name;
struct arg_str *a2dp_sink_name;
struct arg_str *wakeup_gpio_level;
struct arg_str *bt_sink_pin;
struct arg_str *enable_bt_sink;
struct arg_end *end;
} set_btsource_args;
*/
//static int do_set_btsource(int argc, char **argv)
//{
// a2dp_dev_name;
// a2dp_sink_name;
// wakeup_gpio_level;
// bt_sink_pin;
// enable_bt_sink;
// int nerrors = arg_parse_msg(argc, argv,(struct arg_hdr **)&deep_sleep_args);
// if (nerrors != 0) {
// return 1;
// }
// if (deep_sleep_args.wakeup_time->count) {
// uint64_t timeout = 1000ULL * deep_sleep_args.wakeup_time->ival[0];
// log_send_messaging(MESSAGING_INFO, "Enabling timer wakeup, timeout=%lluus", timeout);
// ESP_ERROR_CHECK( esp_sleep_enable_timer_wakeup(timeout) );
// }
// if (deep_sleep_args.wakeup_gpio_num->count) {
// int io_num = deep_sleep_args.wakeup_gpio_num->ival[0];
// if (!rtc_gpio_is_valid_gpio(io_num)) {
// log_send_messaging(MESSAGING_ERROR, "GPIO %d is not an RTC IO", io_num);
// return 1;
// }
// int level = 0;
// if (deep_sleep_args.wakeup_gpio_level->count) {
// level = deep_sleep_args.wakeup_gpio_level->ival[0];
// if (level != 0 && level != 1) {
// log_send_messaging(MESSAGING_ERROR, "Invalid wakeup level: %d", level);
// return 1;
// }
// }
// log_send_messaging(MESSAGING_INFO, "Enabling wakeup on GPIO%d, wakeup on %s level",
// io_num, level ? "HIGH" : "LOW");
//
// ESP_ERROR_CHECK( esp_sleep_enable_ext1_wakeup(1ULL << io_num, level) );
// }
// rtc_gpio_isolate(GPIO_NUM_12);
// esp_deep_sleep_start();
//return 0;
//}
static void register_setbtsource(){
// a2dp_dev_name;
// a2dp_sink_name;
// wakeup_gpio_level;
// bt_sink_pin;
// enable_bt_sink;
//
// set_btsource_args.wakeup_time =
// arg_int0("t", "time", "<t>", "Wake up time, ms");
// set_btsource_args.wakeup_gpio_num =
// arg_int0(NULL, "io", "<n>",
// "If specified, wakeup using GPIO with given number");
// set_btsource_args.wakeup_gpio_level =
// arg_int0(NULL, "io_level", "<0|1>", "GPIO level to trigger wakeup");
// set_btsource_args.end = arg_end(3);
//
// const esp_console_cmd_t cmd = {
// .command = "deep_sleep",
// .help = "Enter deep sleep mode. "
// "Two wakeup modes are supported: timer and GPIO. "
// "If no wakeup option is specified, will sleep indefinitely.",
// .hint = NULL,
// .func = &do_set_btsource,
// .argtable = &set_btsource_args
// };
// ESP_ERROR_CHECK( esp_console_cmd_register(&cmd) );
}
static void register_free()
{
@@ -369,9 +300,137 @@ static void register_free()
static int heap_size(int argc, char **argv)
{
uint32_t heap_size = heap_caps_get_minimum_free_size(MALLOC_CAP_DEFAULT);
log_send_messaging(MESSAGING_INFO, "min heap size: %u", heap_size);
cmd_send_messaging(argv[0],MESSAGING_INFO, "min heap size: %u", heap_size);
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;
}
typedef enum {
SCANNING,
PROCESSING_NAME
} scanstate_t;
int set_squeezelite_player_name(FILE * f,const char * name){
char * nvs_config= config_alloc_get(NVS_TYPE_STR, "autoexec1");
char **argv = NULL;
esp_err_t err=ESP_OK;
int nerrors=0;
bool bFoundParm=false;
scanstate_t state=SCANNING;
char * newCommandLine = NULL;
char * parm = " -n ";
char * cleaned_name = strdup(name);
for(char * p=cleaned_name;*p!='\0';p++){
if(*p == ' '){
*p='_'; // no spaces allowed
}
}
if(nvs_config && strlen(nvs_config)>0){
// allocate enough memory to hold the new command line
size_t cmdLength = strlen(nvs_config) + strlen(cleaned_name) + strlen(parm) +1 ;
newCommandLine = malloc(cmdLength);
memset(newCommandLine,0x00, cmdLength);
ESP_LOGD(TAG,"Parsing command %s",nvs_config);
argv = (char **) calloc(22, sizeof(char *));
if (argv == NULL) {
FREE_AND_NULL(nvs_config);
return 1;
}
size_t argc = esp_console_split_argv(nvs_config, argv,22);
for(int i=0;i<argc;i++) {
if(i>0){
strcat(newCommandLine," ");
}
switch (state)
{
case SCANNING:
strcat(newCommandLine,argv[i]);
if(strcasecmp(argv[i],"--name")==0 || strcasecmp(argv[i],"-n")==0 ){
state = PROCESSING_NAME;
}
break;
case PROCESSING_NAME:
bFoundParm=true;
strcat(newCommandLine,cleaned_name);
state = SCANNING;
break;
default:
break;
}
}
if(!bFoundParm){
strcat(newCommandLine,parm);
strcat(newCommandLine,name);
}
fprintf(f,"Squeezelite player name changed to %s\n",newCommandLine);
if((err=config_set_value(NVS_TYPE_STR, "autoexec1",newCommandLine))!=ESP_OK){
nerrors++;
fprintf(f,"Failed updating squeezelite command. %s", esp_err_to_name(err));
}
}
FREE_AND_NULL(nvs_config);
FREE_AND_NULL(argv);
return nerrors;
}
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 1;
}
/* Check "--name" option */
if (name_args.name->count) {
name=strdup(name_args.name->sval[0]);
}
else {
cmd_send_messaging(argv[0],MESSAGING_ERROR,"Name must be specified.");
return 1;
}
char *buf = NULL;
size_t buf_size = 0;
FILE *f = open_memstream(&buf, &buf_size);
if (f == NULL) {
cmd_send_messaging(argv[0],MESSAGING_ERROR,"Unable to open memory stream.");
return 1;
}
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);
nerrors+=set_squeezelite_player_name(f, name);
if(nerrors==0){
fprintf(f,"Device name changed to %s\n",name);
}
if(!nerrors ){
fprintf(f,"Done.\n");
}
FREE_AND_NULL(name);
fflush (f);
cmd_send_messaging(argv[0],nerrors>0?MESSAGING_ERROR:MESSAGING_INFO,"%s", buf);
fclose(f);
FREE_AND_NULL(buf);
return nerrors;
}
static void register_heap()
{
@@ -386,6 +445,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 = CFG_TYPE_SYST("name"),
.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 */
#if WITH_TASKS_INFO
@@ -394,16 +469,16 @@ static int tasks_info(int argc, char **argv)
const size_t bytes_per_task = 40; /* see vTaskList description */
char *task_list_buffer = malloc(uxTaskGetNumberOfTasks() * bytes_per_task);
if (task_list_buffer == NULL) {
log_send_messaging(MESSAGING_ERROR, "failed to allocate buffer for vTaskList output");
cmd_send_messaging(argv[0],MESSAGING_ERROR, "failed to allocate buffer for vTaskList output");
return 1;
}
log_send_messaging(MESSAGING_INFO,"Task Name\tStatus\tPrio\tHWM\tTask#"
cmd_send_messaging(argv[0],MESSAGING_INFO,"Task Name\tStatus\tPrio\tHWM\tTask#"
#ifdef CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID
"\tAffinity"
#endif
"\n");
vTaskList(task_list_buffer);
log_send_messaging(MESSAGING_INFO,"%s", task_list_buffer);
cmd_send_messaging(argv[0],MESSAGING_INFO,"%s", task_list_buffer);
free(task_list_buffer);
return 0;
}
@@ -423,7 +498,7 @@ static void register_tasks()
extern esp_err_t update_certificates(bool force);
static int force_update_cert(int argc, char **argv){
return update_certificates(true)==ESP_OK;
return update_certificates(true);
}
static void register_update_certs()
@@ -457,30 +532,31 @@ static int deep_sleep(int argc, char **argv)
}
if (deep_sleep_args.wakeup_time->count) {
uint64_t timeout = 1000ULL * deep_sleep_args.wakeup_time->ival[0];
log_send_messaging(MESSAGING_INFO, "Enabling timer wakeup, timeout=%lluus", timeout);
cmd_send_messaging(argv[0],MESSAGING_INFO, "Enabling timer wakeup, timeout=%lluus", timeout);
ESP_ERROR_CHECK( esp_sleep_enable_timer_wakeup(timeout) );
}
if (deep_sleep_args.wakeup_gpio_num->count) {
int io_num = deep_sleep_args.wakeup_gpio_num->ival[0];
if (!rtc_gpio_is_valid_gpio(io_num)) {
log_send_messaging(MESSAGING_ERROR, "GPIO %d is not an RTC IO", io_num);
cmd_send_messaging(argv[0],MESSAGING_ERROR, "GPIO %d is not an RTC IO", io_num);
return 1;
}
int level = 0;
if (deep_sleep_args.wakeup_gpio_level->count) {
level = deep_sleep_args.wakeup_gpio_level->ival[0];
if (level != 0 && level != 1) {
log_send_messaging(MESSAGING_ERROR, "Invalid wakeup level: %d", level);
cmd_send_messaging(argv[0],MESSAGING_ERROR, "Invalid wakeup level: %d", level);
return 1;
}
}
log_send_messaging(MESSAGING_INFO, "Enabling wakeup on GPIO%d, wakeup on %s level",
cmd_send_messaging(argv[0],MESSAGING_INFO, "Enabling wakeup on GPIO%d, wakeup on %s level",
io_num, level ? "HIGH" : "LOW");
ESP_ERROR_CHECK( esp_sleep_enable_ext1_wakeup(1ULL << io_num, level) );
}
rtc_gpio_isolate(GPIO_NUM_12);
esp_deep_sleep_start();
return 0; // this code will never run. deep sleep will cause the system to restart
}
static void register_deep_sleep()
@@ -505,7 +581,189 @@ static void register_deep_sleep()
};
ESP_ERROR_CHECK( esp_console_cmd_register(&cmd) );
}
static int enable_disable(FILE * f,char * nvs_name, struct arg_lit *arg){
esp_err_t err = config_set_value(NVS_TYPE_STR, nvs_name, arg->count>0?"Y":"N");
const char * name = arg->hdr.longopts?arg->hdr.longopts:arg->hdr.glossary;
if(err!=ESP_OK){
fprintf(f,"Error %s %s. %s\n",arg->count>0?"Enabling":"Disabling", name, esp_err_to_name(err));
}
else {
fprintf(f,"%s %s\n",arg->count>0?"Enabled":"Disabled",name);
}
return err;
}
static int do_configure_wifi(int argc, char **argv){
esp_err_t err = ESP_OK;
int nerrors = arg_parse_msg(argc, argv,(struct arg_hdr **)&wifi_parms_arg);
if (nerrors != 0) {
return 1;
}
char *buf = NULL;
size_t buf_size = 0;
FILE *f = open_memstream(&buf, &buf_size);
if (f == NULL) {
cmd_send_messaging(argv[0],MESSAGING_ERROR,"Unable to open memory stream.");
return 1;
}
nerrors += enable_disable(f,"disable_ps",wifi_parms_arg.disable_power_save);
if(wifi_parms_arg.scanmode->count>0){
if(strcasecmp(wifi_parms_arg.scanmode->sval[0],"Comprehensive") == 0){
err = config_set_value(NVS_TYPE_STR, "wifi_smode", "A");
}
else {
err = config_set_value(NVS_TYPE_STR, "wifi_smode", "F");
}
if(err!=ESP_OK){
nerrors++;
fprintf(f,"Error setting wifi scan mode to %s. %s\n",wifi_parms_arg.scanmode->sval[0], esp_err_to_name(err));
}
else {
fprintf(f,"Wifi Scan Mode changed to %s\n",wifi_parms_arg.scanmode->sval[0]);
}
}
if(!nerrors ){
fprintf(f,"Done.\n");
}
fflush (f);
cmd_send_messaging(argv[0],nerrors>0?MESSAGING_ERROR:MESSAGING_INFO,"%s", buf);
fclose(f);
FREE_AND_NULL(buf);
return nerrors;
}
static int do_set_services(int argc, char **argv)
{
esp_err_t err = ESP_OK;
int nerrors = arg_parse_msg(argc, argv,(struct arg_hdr **)&set_services_args);
if (nerrors != 0) {
return 1;
}
char *buf = NULL;
size_t buf_size = 0;
FILE *f = open_memstream(&buf, &buf_size);
if (f == NULL) {
cmd_send_messaging(argv[0],MESSAGING_ERROR,"Unable to open memory stream.");
return 1;
}
nerrors += enable_disable(f,"enable_airplay",set_services_args.airplay);
nerrors += enable_disable(f,"enable_bt_sink",set_services_args.btspeaker);
if(set_services_args.telnet->count>0){
if(strcasecmp(set_services_args.telnet->sval[0],"Disabled") == 0){
err = config_set_value(NVS_TYPE_STR, "telnet_enable", "N");
}
else if(strcasecmp(set_services_args.telnet->sval[0],"Telnet Only") == 0){
err = config_set_value(NVS_TYPE_STR, "telnet_enable", "Y");
}
else if(strcasecmp(set_services_args.telnet->sval[0],"Telnet and Serial") == 0){
err = config_set_value(NVS_TYPE_STR, "telnet_enable", "D");
}
if(err!=ESP_OK){
nerrors++;
fprintf(f,"Error setting telnet service to %s. %s\n",set_services_args.telnet->sval[0], esp_err_to_name(err));
}
else {
fprintf(f,"Telnet service changed to %s\n",set_services_args.telnet->sval[0]);
}
}
#if WITH_TASKS_INFO
nerrors += enable_disable(f,"stats",set_services_args.stats);
#endif
if(!nerrors ){
fprintf(f,"Done.\n");
}
fflush (f);
cmd_send_messaging(argv[0],nerrors>0?MESSAGING_ERROR:MESSAGING_INFO,"%s", buf);
fclose(f);
FREE_AND_NULL(buf);
return nerrors;
}
cJSON * configure_wifi_cb(){
cJSON * values = cJSON_CreateObject();
char * p=NULL;
if ((p = config_alloc_get(NVS_TYPE_STR, "disable_ps")) != NULL) {
cJSON_AddBoolToObject(values,"disable_power_save",strcmp(p,"1") == 0 || strcasecmp(p,"y") == 0);
FREE_AND_NULL(p);
}
if ((p = config_alloc_get(NVS_TYPE_STR, "wifi_smode")) != NULL) {
cJSON_AddStringToObject(values,"scanmode",strcasecmp(p,"a") == 0 ?"Comprehensive":"Fast");
FREE_AND_NULL(p);
}
return values;
}
cJSON * set_services_cb(){
cJSON * values = cJSON_CreateObject();
char * p=NULL;
if ((p = config_alloc_get(NVS_TYPE_STR, "enable_bt_sink")) != NULL) {
cJSON_AddBoolToObject(values,"BT_Speaker",strcmp(p,"1") == 0 || strcasecmp(p,"y") == 0);
FREE_AND_NULL(p);
}
if ((p = config_alloc_get(NVS_TYPE_STR, "enable_airplay")) != NULL) {
cJSON_AddBoolToObject(values,"AirPlay",strcmp(p,"1") == 0 || strcasecmp(p,"y") == 0);
FREE_AND_NULL(p);
}
if ((p = config_alloc_get(NVS_TYPE_STR, "telnet_enable")) != NULL) {
if(strcasestr("YX",p)!=NULL){
cJSON_AddStringToObject(values,"telnet","Telnet Only");
}
else if(strcasestr("D",p)!=NULL){
cJSON_AddStringToObject(values,"telnet","Telnet and Serial");
}
else {
cJSON_AddStringToObject(values,"telnet","Disabled");
}
FREE_AND_NULL(p);
}
#if WITH_TASKS_INFO
if((p = config_alloc_get_default(NVS_TYPE_STR, "stats", "n", 0))!=NULL){
cJSON_AddBoolToObject(values,"stats",(*p == '1' || *p == 'Y' || *p == 'y')) ;
}
#endif
return values;
}
static void register_set_services(){
set_services_args.airplay = arg_lit0(NULL, "AirPlay", "AirPlay");
set_services_args.btspeaker = arg_lit0(NULL, "BT_Speaker", "Bluetooth Speaker");
set_services_args.telnet= arg_str0("t", "telnet","Disabled|Telnet Only|Telnet and Serial","Telnet server. Use only for troubleshooting");
#if WITH_TASKS_INFO
set_services_args.stats= arg_lit0(NULL, "stats", "System Statistics. Use only for troubleshooting");
#endif
set_services_args.end=arg_end(2);
const esp_console_cmd_t cmd = {
.command = CFG_TYPE_SYST("services"),
.help = "Services",
.argtable = &set_services_args,
.hint = NULL,
.func = &do_set_services,
};
cmd_to_json_with_cb(&cmd,&set_services_cb);
ESP_ERROR_CHECK( esp_console_cmd_register(&cmd) );
}
static void register_set_wifi_parms(){
wifi_parms_arg.scanmode = arg_str0(NULL, "scanmode", "Fast|Comprehensive","Sets the WiFi Scan Mode. Use Comprehensive where more than one AP has the same name on different channels. This will ensure that the AP with the strongest signal is chosen.");
wifi_parms_arg.disable_power_save = arg_lit0(NULL, "disable_power_save", "Disable Power Saving. This may help if the wifi connection is unstable.");
wifi_parms_arg.end=arg_end(2);
const esp_console_cmd_t cmd = {
.command = CFG_TYPE_SYST("wifi"),
.help = "WiFi",
.argtable = &wifi_parms_arg,
.hint = NULL,
.func = &do_configure_wifi,
};
cmd_to_json_with_cb(&cmd,&configure_wifi_cb);
ESP_ERROR_CHECK( esp_console_cmd_register(&cmd) );
}
/** 'light_sleep' command puts the chip into light sleep mode */
static struct {
@@ -524,22 +782,22 @@ static int light_sleep(int argc, char **argv)
esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_ALL);
if (light_sleep_args.wakeup_time->count) {
uint64_t timeout = 1000ULL * light_sleep_args.wakeup_time->ival[0];
log_send_messaging(MESSAGING_INFO, "Enabling timer wakeup, timeout=%lluus", timeout);
cmd_send_messaging(argv[0],MESSAGING_INFO, "Enabling timer wakeup, timeout=%lluus", timeout);
ESP_ERROR_CHECK( esp_sleep_enable_timer_wakeup(timeout) );
}
int io_count = light_sleep_args.wakeup_gpio_num->count;
if (io_count != light_sleep_args.wakeup_gpio_level->count) {
log_send_messaging(MESSAGING_INFO, "Should have same number of 'io' and 'io_level' arguments");
cmd_send_messaging(argv[0],MESSAGING_INFO, "Should have same number of 'io' and 'io_level' arguments");
return 1;
}
for (int i = 0; i < io_count; ++i) {
int io_num = light_sleep_args.wakeup_gpio_num->ival[i];
int level = light_sleep_args.wakeup_gpio_level->ival[i];
if (level != 0 && level != 1) {
log_send_messaging(MESSAGING_ERROR, "Invalid wakeup level: %d", level);
cmd_send_messaging(argv[0],MESSAGING_ERROR, "Invalid wakeup level: %d", level);
return 1;
}
log_send_messaging(MESSAGING_INFO, "Enabling wakeup on GPIO%d, wakeup on %s level",
cmd_send_messaging(argv[0],MESSAGING_INFO, "Enabling wakeup on GPIO%d, wakeup on %s level",
io_num, level ? "HIGH" : "LOW");
ESP_ERROR_CHECK( gpio_wakeup_enable(io_num, level ? GPIO_INTR_HIGH_LEVEL : GPIO_INTR_LOW_LEVEL) );
@@ -548,7 +806,7 @@ static int light_sleep(int argc, char **argv)
ESP_ERROR_CHECK( esp_sleep_enable_gpio_wakeup() );
}
if (CONFIG_ESP_CONSOLE_UART_NUM <= UART_NUM_1) {
log_send_messaging(MESSAGING_INFO, "Enabling UART wakeup (press ENTER to exit light sleep)");
cmd_send_messaging(argv[0],MESSAGING_INFO, "Enabling UART wakeup (press ENTER to exit light sleep)");
ESP_ERROR_CHECK( uart_set_wakeup_threshold(CONFIG_ESP_CONSOLE_UART_NUM, 3) );
ESP_ERROR_CHECK( esp_sleep_enable_uart_wakeup(CONFIG_ESP_CONSOLE_UART_NUM) );
}
@@ -571,7 +829,7 @@ static int light_sleep(int argc, char **argv)
cause_str = "unknown";
printf("%d\n", cause);
}
log_send_messaging(MESSAGING_INFO, "Woke up from: %s", cause_str);
cmd_send_messaging(argv[0],MESSAGING_INFO, "Woke up from: %s", cause_str);
return 0;
}

View File

@@ -50,7 +50,7 @@ const char* recovery_prompt = LOG_COLOR_E "recovery-squeezelite-esp32> " LOG_RES
#define MOUNT_PATH "/data"
#define HISTORY_PATH MOUNT_PATH "/history.txt"
void run_command(char * line);
esp_err_t run_command(char * line);
#define ADD_TO_JSON(o,t,n) if (t->n) cJSON_AddStringToObject(o,QUOTE(n),t->n);
#define ADD_PARMS_TO_CMD(o,t,n) { cJSON * parms = ParmsToJSON(&t.n->hdr); if(parms) cJSON_AddItemToObject(o,QUOTE(n),parms); }
cJSON * cmdList;
@@ -99,6 +99,8 @@ cJSON * ParmsToJSON(struct arg_hdr * * argtable){
ADD_TO_JSON(entry,table[tabindex],shortopts);
cJSON_AddBoolToObject(entry, "checkbox", (table[tabindex]->flag & ARG_HASOPTVALUE)==0 && (table[tabindex]->flag & ARG_HASVALUE)==0);
cJSON_AddBoolToObject(entry, "hasvalue", table[tabindex]->flag & ARG_HASVALUE);
cJSON_AddNumberToObject(entry,"mincount",table[tabindex]->mincount);
cJSON_AddNumberToObject(entry,"maxcount",table[tabindex]->maxcount);
cJSON_AddItemToArray(arg_list, entry);
tabindex++;
}
@@ -171,7 +173,7 @@ int arg_parse_msg(int argc, char **argv, struct arg_hdr ** args){
if (f != NULL) {
arg_print_errors(f, getParmsEnd(args), argv[0]);
fflush (f);
log_send_messaging(MESSAGING_ERROR,"%s", buf);
cmd_send_messaging(argv[0],MESSAGING_ERROR,"%s", buf);
}
fclose(f);
FREE_AND_NULL(buf);
@@ -254,7 +256,7 @@ void initialize_console() {
esp_vfs_dev_uart_use_driver(CONFIG_ESP_CONSOLE_UART_NUM);
/* Initialize the console */
esp_console_config_t console_config = { .max_cmdline_args = 22,
esp_console_config_t console_config = { .max_cmdline_args = 28,
.max_cmdline_length = 600,
#if CONFIG_LOG_COLORS
.hint_color = atoi(LOG_COLOR_CYAN)
@@ -285,7 +287,7 @@ void console_start() {
}
else {
/* Initialize the console */
esp_console_config_t console_config = { .max_cmdline_args = 22,
esp_console_config_t console_config = { .max_cmdline_args = 28,
.max_cmdline_length = 600,
#if CONFIG_LOG_COLORS
.hint_color = atoi(LOG_COLOR_CYAN)
@@ -296,8 +298,10 @@ void console_start() {
/* Register commands */
esp_console_register_help_command();
register_system();
register_config_cmd();
register_nvs();
register_wifi();
if(!is_recovery_running){
register_squeezelite();
}
@@ -364,7 +368,7 @@ void console_start() {
}
}
void run_command(char * line){
esp_err_t run_command(char * line){
/* Try to run the command */
int ret;
esp_err_t err = esp_console_run(line, &ret);
@@ -373,13 +377,16 @@ void run_command(char * line){
ESP_LOGE(TAG,"Unrecognized command: %s", line);
} else if (err == ESP_ERR_INVALID_ARG) {
// command was empty
} else if (err == ESP_OK && ret != ESP_OK) {
} else if (err != ESP_OK && ret != ESP_OK) {
ESP_LOGW(TAG,"Command returned non-zero error code: 0x%x (%s)", ret,
esp_err_to_name(err));
esp_err_to_name(err));
} else if (err == ESP_OK && ret != ESP_OK) {
ESP_LOGW(TAG,"Command returned in error");
err = ESP_FAIL;
} else if (err != ESP_OK) {
ESP_LOGE(TAG,"Internal error: %s", esp_err_to_name(err));
}
return err;
}
static void * console_thread() {
if(!is_recovery_running){

View File

@@ -13,6 +13,11 @@
#ifdef __cplusplus
extern "C" {
#endif
#define CFG_TYPE_HW(a) "cfg-hw-" a
#define CFG_TYPE_AUDIO(a) "cfg-audio-" a
#define CFG_TYPE_SYST(a) "cfg-syst-" a
#define CFG_TYPE_FW(a) "cfg-fw-" a
#define CFG_TYPE_GEN(a) "cfg-gen-" a
typedef cJSON * parm_values_fn_t(void);
esp_err_t cmd_to_json(const esp_console_cmd_t *cmd);
esp_err_t cmd_to_json_with_cb(const esp_console_cmd_t *cmd, parm_values_fn_t parm_values_fn);

View File

@@ -0,0 +1,3 @@
idf_component_register(SRCS "test_system.c"
INCLUDE_DIRS "."
REQUIRES unity tools console json platform_console platform_config )

View File

@@ -0,0 +1,189 @@
/* test_mean.c: Implementation of a testable component.
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
#include <limits.h>
#include "unity.h"
#include "platform_console.h"
#include "platform_esp32.h"
#include "platform_config.h"
#include "string.h"
struct arg_lit *arglit;
struct arg_int *argint;
struct arg_str *argstr;
struct arg_end *end;
extern int is_output_gpio(struct arg_int * gpio, FILE * f, int * gpio_out, bool mandatory);
extern void initialize_console();
extern esp_err_t run_command(char * line);
static char *buf = NULL;
static char * s_tmp_line_buf=NULL;
static size_t buf_size = 0;
static FILE * f;
static size_t argc=1;
static char ** argv=NULL;
static bool config_initialized=false;
void init_console(){
if(config_initialized) return;
initialize_console();
config_initialized=true;
}
/****************************************************************************************
*
*/
void open_mem_stream_file(){
f = open_memstream(&buf, &buf_size);
}
/****************************************************************************************
*
*/
void close_flush_all(void * argtable, int count,bool print){
fflush (f);
if(print){
printf("%s", buf);
}
fclose(f);
free(buf);
arg_freetable(argtable,count);
free(argv);
}
/****************************************************************************************
*
*/
int alloc_split_command_line(char * cmdline){
argv = (char **) calloc(22, sizeof(char *));
if(!s_tmp_line_buf){
s_tmp_line_buf= calloc(strlen(cmdline), 1);
}
strlcpy(s_tmp_line_buf, cmdline, 22);
argc = esp_console_split_argv(s_tmp_line_buf, argv,22);
return 0;
}
/****************************************************************************************
*
*/
int alloc_split_parse_command_line(char * cmdline, void ** args){
alloc_split_command_line(cmdline);
return arg_parse(argc, argv,args);
}
/****************************************************************************************
*
*/
TEST_CASE("Invalid GPIO detected", "[config][ui]")
{
char * cmdline = "test -i 55\n";
void *argtable[] = {
argint = arg_int1("i","int","<gpio>","GPIO number"),
end = arg_end(6)
};
open_mem_stream_file();
alloc_split_parse_command_line(cmdline, &argtable);
int out_val = 0;
TEST_ASSERT_EQUAL_INT_MESSAGE(1,is_output_gpio(argtable[0], f, &out_val, true),"Invalid GPIO not detected");
TEST_ASSERT_EQUAL_INT_MESSAGE(-1,out_val,"GPIO Should be set to -1");
fflush (f);
TEST_ASSERT_EQUAL_STRING_MESSAGE("Invalid int gpio: [55] is not a GPIO\n",buf,"Invalid GPIO message wrong");
close_flush_all(argtable,sizeof(argtable)/sizeof(argtable[0]),false);
}
/****************************************************************************************
*
*/
TEST_CASE("Input Only GPIO detected", "[config][ui]")
{
char * cmdline = "test -i 35\n";
void *argtable[] = {
argint = arg_int1("i","int","<gpio>","GPIO number"),
end = arg_end(6)
};
open_mem_stream_file();
alloc_split_parse_command_line(cmdline, &argtable);
int out_val = 0;
TEST_ASSERT_EQUAL_INT_MESSAGE(1,is_output_gpio(argtable[0], f, &out_val, true),"Input only GPIO not detected");
TEST_ASSERT_EQUAL_INT_MESSAGE(-1,out_val,"GPIO Should be set to -1");
fflush (f);
TEST_ASSERT_EQUAL_STRING_MESSAGE("Invalid int gpio: [35] has input capabilities only\n",buf,"Missing GPIO message wrong");
close_flush_all(argtable,sizeof(argtable)/sizeof(argtable[0]),false);
}
/****************************************************************************************
*
*/
TEST_CASE("Valid GPIO Processed", "[config][ui]")
{
char * cmdline = "test -i 33\n";
void *argtable[] = {
argint = arg_int1("i","int","<gpio>","GPIO number"),
end = arg_end(6)
};
open_mem_stream_file();
alloc_split_parse_command_line(cmdline, &argtable);
int out_val = 0;
TEST_ASSERT_EQUAL_INT_MESSAGE(0,is_output_gpio(argtable[0], f, &out_val, true),"Valid GPIO not recognized");
TEST_ASSERT_EQUAL_INT_MESSAGE(33,out_val,"GPIO Should be set to 33");
fflush (f);
TEST_ASSERT_EQUAL_STRING_MESSAGE("",buf,"Valid GPIO shouldn't produce a message");
close_flush_all(argtable,sizeof(argtable)/sizeof(argtable[0]),false);
}
/****************************************************************************************
*
*/
TEST_CASE("Missing mandatory GPIO detected", "[config][ui]")
{
char * cmdline = "test \n";
void *argtable[] = {
argint = arg_int1("i","int","<gpio>","GPIO number"),
end = arg_end(6)
};
open_mem_stream_file();
alloc_split_parse_command_line(cmdline, &argtable);
int out_val = 0;
TEST_ASSERT_EQUAL_INT_MESSAGE(1,is_output_gpio(argtable[0], f, &out_val, true),"Missing GPIO not detected");
fflush (f);
TEST_ASSERT_EQUAL_STRING_MESSAGE("Missing: int\n",buf,"Missing GPIO parameter message wrong");
TEST_ASSERT_EQUAL_INT_MESSAGE(-1,out_val,"GPIO Should be set to -1");
close_flush_all(argtable,sizeof(argtable)/sizeof(argtable[0]),false);
}
/****************************************************************************************
*
*/
TEST_CASE("Missing mandatory parameter detected", "[config][ui]")
{
char * cmdline = "test \n";
void *argtable[] = {
argint = arg_int1("i","int","<gpio>","GPIO number"),
end = arg_end(6)
};
open_mem_stream_file();
alloc_split_parse_command_line(cmdline, &argtable);
int out_val = 0;
TEST_ASSERT_EQUAL_INT_MESSAGE(1,is_output_gpio(argtable[0], f, &out_val, true),"Missing parameter not detected");
fflush (f);
TEST_ASSERT_EQUAL_STRING_MESSAGE("Missing: int\n",buf,"Missing parameter message wrong");
TEST_ASSERT_EQUAL_INT_MESSAGE(-1,out_val,"GPIO Should be set to -1");
close_flush_all(argtable,sizeof(argtable)/sizeof(argtable[0]),false);
}
/****************************************************************************************
*
*/
TEST_CASE("dac config command", "[config_cmd]")
{
config_set_value(NVS_TYPE_STR, "dac_config", "");
esp_err_t err=run_command("cfg-hw-dac\n");
char * nvs_value = config_alloc_get_str("dac_config", NULL,NULL);
TEST_ASSERT_NOT_NULL(nvs_value);
TEST_ASSERT_EQUAL_MESSAGE(ESP_OK,err,"Running command failed");
free(nvs_value);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
idf_component_register(SRC_DIRS .
INCLUDE_DIRS . ${IDF_PATH}/components/driver
REQUIRES json tools platform_config display
INCLUDE_DIRS . ${IDF_PATH}/components/driver
REQUIRES json tools platform_config display
PRIV_REQUIRES soc esp32 squeezelite
)

View File

@@ -15,33 +15,322 @@
#include "accessors.h"
#include "globdefs.h"
#include "display.h"
#include "display.h"
#include "cJSON.h"
#include "driver/gpio.h"
#include "stdbool.h"
#include "driver/adc.h"
#include "esp_attr.h"
#include "soc/spi_periph.h"
#include "esp_err.h"
#include "soc/rtc.h"
#include "sdkconfig.h"
#include "soc/efuse_periph.h"
#include "driver/gpio.h"
#include "driver/spi_common_internal.h"
#include "esp32/rom/efuse.h"
#include "adac.h"
#include "trace.h"
#include "monitor.h"
#include "messaging.h"
static const char *TAG = "services";
static const char *i2c_name="I2C";
static const char *spi_name="SPI";
const char *i2c_name_type="I2C";
const char *spi_name_type="SPI";
static cJSON * gpio_list=NULL;
#define min(a,b) (((a) < (b)) ? (a) : (b))
#ifndef QUOTE
#define QUOTE(name) #name
#endif
#ifndef STR
#define STR(macro) QUOTE(macro)
#endif
bool are_statistics_enabled(){
#if defined(CONFIG_FREERTOS_USE_TRACE_FACILITY) && defined (CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS)
return true;
#endif
return false;
}
/****************************************************************************************
*
*/
static char * config_spdif_get_string(){
return 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));
}
/****************************************************************************************
*
*/
static char * get_dac_config_string(){
return 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));
}
/****************************************************************************************
*
*/
bool is_dac_config_locked(){
#if ( defined CONFIG_DAC_CONFIG )
if(strlen(CONFIG_DAC_CONFIG) > 0){
return true;
}
#endif
#if defined(CONFIG_I2S_BCK_IO) && CONFIG_I2S_BCK_IO>0
return true;
#endif
return false;
}
/****************************************************************************************
*
*/
bool is_spdif_config_locked(){
#if ( defined CONFIG_SPDIF_CONFIG )
if(strlen(CONFIG_SPDIF_CONFIG) > 0){
return true;
}
#endif
#if defined(CONFIG_SPDIF_BCK_IO) && CONFIG_SPDIF_BCK_IO>0
return true;
#endif
return false;
}
/****************************************************************************************
* Set pin from config string
*/
static void set_i2s_pin(char *config, i2s_pin_config_t *pin_config) {
char *p;
pin_config->bck_io_num = pin_config->ws_io_num = pin_config->data_out_num = pin_config->data_in_num = -1;
if ((p = strcasestr(config, "bck")) != NULL) pin_config->bck_io_num = atoi(strchr(p, '=') + 1);
if ((p = strcasestr(config, "ws")) != NULL) pin_config->ws_io_num = atoi(strchr(p, '=') + 1);
if ((p = strcasestr(config, "do")) != NULL) pin_config->data_out_num = atoi(strchr(p, '=') + 1);
}
/****************************************************************************************
* Get i2s config structure from config string
*/
const i2s_platform_config_t * config_get_i2s_from_str(char * dac_config ){
static i2s_platform_config_t i2s_dac_pin = {
.i2c_addr = -1,
.sda= -1,
.scl = -1,
.mute_gpio = -1,
.mute_level = -1
};
set_i2s_pin(dac_config, &i2s_dac_pin.pin);
strcpy(i2s_dac_pin.model, "i2s");
char * p=NULL;
if ((p = strcasestr(dac_config, "i2c")) != NULL) i2s_dac_pin.i2c_addr = atoi(strchr(p, '=') + 1);
if ((p = strcasestr(dac_config, "sda")) != NULL) i2s_dac_pin.sda = atoi(strchr(p, '=') + 1);
if ((p = strcasestr(dac_config, "scl")) != NULL) i2s_dac_pin.scl = atoi(strchr(p, '=') + 1);
if ((p = strcasestr(dac_config, "model")) != NULL) sscanf(p, "%*[^=]=%31[^,]", i2s_dac_pin.model);
if ((p = strcasestr(dac_config, "mute")) != NULL) {
char mute[8] = "";
sscanf(p, "%*[^=]=%7[^,]", mute);
i2s_dac_pin.mute_gpio = atoi(mute);
if ((p = strchr(mute, ':')) != NULL) i2s_dac_pin.mute_level = atoi(p + 1);
}
return &i2s_dac_pin;
}
/****************************************************************************************
* Get spdif config structure
*/
const i2s_platform_config_t * config_spdif_get( ){
char * spdif_config = config_spdif_get_string();
static i2s_platform_config_t i2s_dac_config;
memcpy(&i2s_dac_config, config_get_i2s_from_str(spdif_config), sizeof(i2s_dac_config));
free(spdif_config);
return &i2s_dac_config;
}
/****************************************************************************************
* Get dac config structure
*/
const i2s_platform_config_t * config_dac_get(){
char * spdif_config = get_dac_config_string();
static i2s_platform_config_t i2s_dac_config;
memcpy(&i2s_dac_config, config_get_i2s_from_str(spdif_config), sizeof(i2s_dac_config));
free(spdif_config);
return &i2s_dac_config;
}
/****************************************************************************************
*
*/
esp_err_t config_i2c_set(const i2c_config_t * config, int port){
int buffer_size=255;
esp_err_t err=ESP_OK;
char * config_buffer=calloc(buffer_size,1);
if(config_buffer) {
snprintf(config_buffer,buffer_size,"scl=%u sda=%u speed=%u port=%u",config->scl_io_num,config->sda_io_num,config->master.clk_speed,port);
ESP_LOGI(TAG,"Updating i2c configuration to %s",config_buffer);
config_set_value(NVS_TYPE_STR, "i2c_config", config_buffer);
snprintf(config_buffer,buffer_size,"scl=%u,sda=%u,speed=%u,port=%u",config->scl_io_num,config->sda_io_num,config->master.clk_speed,port);
log_send_messaging(MESSAGING_INFO,"Updating I2C configuration to %s",config_buffer);
err = config_set_value(NVS_TYPE_STR, "i2c_config", config_buffer);
if(err!=ESP_OK){
log_send_messaging(MESSAGING_ERROR,"Error: %s",esp_err_to_name(err));
}
free(config_buffer);
}
return ESP_OK;
return err;
}
/****************************************************************************************
*
*/
esp_err_t config_display_set(const display_config_t * config){
int buffer_size=512;
esp_err_t err=ESP_OK;
char * config_buffer=calloc(buffer_size,1);
char * config_buffer2=calloc(buffer_size,1);
if(config_buffer && config_buffer2) {
snprintf(config_buffer,buffer_size,"%s:width=%i,height=%i",config->type,config->width,config->height);
if(strcasecmp("I2C",config->type)==0){
if(config->address>0 ){
snprintf(config_buffer2,buffer_size,"%s,address=%i",config_buffer,config->address);
strcpy(config_buffer,config_buffer2);
}
}
else {
if(config->CS_pin >=0 ){
snprintf(config_buffer2,buffer_size,"%s,cs=%i",config_buffer,config->CS_pin);
strcpy(config_buffer,config_buffer2);
}
}
if(config->RST_pin >=0 ){
snprintf(config_buffer2,buffer_size,"%s,reset=%i",config_buffer,config->RST_pin);
strcpy(config_buffer,config_buffer2);
}
// I2C,width=<pixels>,height=<pixels>[address=<i2c_address>][,reset=<gpio>][,HFlip][,VFlip][driver=SSD1306|SSD1326[:1|4]|SSD1327|SH1106]
// SPI,width=<pixels>,height=<pixels>,cs=<gpio>[,back=<gpio>][,reset=<gpio>][,speed=<speed>][,HFlip][,VFlip][driver=SSD1306|SSD1322|SSD1326[:1|4]|SSD1327|SH1106|SSD1675|ST7735|ST7789[,rotate]]
if(config->back >=0 ){
snprintf(config_buffer2,buffer_size,"%s,back=%i",config_buffer,config->back);
strcpy(config_buffer,config_buffer2);
}
if(config->speed >0 && strcasecmp("SPI",config->type)==0){
snprintf(config_buffer2,buffer_size,"%s,speed=%i",config_buffer,config->speed);
strcpy(config_buffer,config_buffer2);
}
snprintf(config_buffer2,buffer_size,"%s,driver=%s%s%s%s",config_buffer,config->drivername,config->hflip?",HFlip":"",config->vflip?",VFlip":"",config->rotate?",rotate":"");
strcpy(config_buffer,config_buffer2);
log_send_messaging(MESSAGING_INFO,"Updating display configuration to %s",config_buffer);
err = config_set_value(NVS_TYPE_STR, "display_config", config_buffer);
if(err!=ESP_OK){
log_send_messaging(MESSAGING_ERROR,"Error: %s",esp_err_to_name(err));
}
}
else {
err = ESP_ERR_NO_MEM;
}
FREE_AND_NULL(config_buffer);
FREE_AND_NULL(config_buffer2);
return err;
}
/****************************************************************************************
*
*/
esp_err_t config_i2s_set(const i2s_platform_config_t * config, const char * nvs_name){
int buffer_size=255;
esp_err_t err=ESP_OK;
char * config_buffer=calloc(buffer_size,1);
char * config_buffer2=calloc(buffer_size,1);
if(config_buffer && config_buffer2) {
snprintf(config_buffer,buffer_size,"model=%s,bck=%u,ws=%u,do=%u",config->model,config->pin.bck_io_num,config->pin.ws_io_num,config->pin.data_out_num);
if(config->mute_gpio>=0){
snprintf(config_buffer2,buffer_size,"%s,mute=%u:%u",config_buffer,config->mute_gpio,config->mute_level);
strcpy(config_buffer,config_buffer2);
}
if(config->sda>=0){
snprintf(config_buffer2,buffer_size,"%s,sda=%u,scl=%u",config_buffer,config->sda,config->scl);
strcpy(config_buffer,config_buffer2);
}
if(config->i2c_addr>0){
snprintf(config_buffer2,buffer_size,"%s,i2c=%u",config_buffer,config->i2c_addr);
strcpy(config_buffer,config_buffer2);
}
log_send_messaging(MESSAGING_INFO,"Updating dac configuration to %s",config_buffer);
err = config_set_value(NVS_TYPE_STR, nvs_name, config_buffer);
if(err!=ESP_OK){
log_send_messaging(MESSAGING_ERROR,"Error: %s",esp_err_to_name(err));
}
}
else {
err = ESP_ERR_NO_MEM;
}
FREE_AND_NULL(config_buffer);
FREE_AND_NULL(config_buffer2);
return err;
}
/****************************************************************************************
*
*/
esp_err_t config_spdif_set(const i2s_platform_config_t * config){
int buffer_size=255;
esp_err_t err=ESP_OK;
char * config_buffer=calloc(buffer_size,1);
if(config_buffer ) {
snprintf(config_buffer,buffer_size,"bck=%u,ws=%u,do=%u",config->pin.bck_io_num,config->pin.ws_io_num,config->pin.data_out_num);
log_send_messaging(MESSAGING_INFO,"Updating SPDIF configuration to %s",config_buffer);
err = config_set_value(NVS_TYPE_STR, "spdif_config", config_buffer);
if(err!=ESP_OK){
log_send_messaging(MESSAGING_ERROR,"Error: %s",esp_err_to_name(err));
}
}
else {
err = ESP_ERR_NO_MEM;
}
FREE_AND_NULL(config_buffer);
return err;
}
/****************************************************************************************
*
*/
esp_err_t config_spi_set(const spi_bus_config_t * config, int host, int dc){
int buffer_size=255;
esp_err_t err = ESP_OK;
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);
log_send_messaging(MESSAGING_INFO,"Updating SPI configuration to %s",config_buffer);
err = config_set_value(NVS_TYPE_STR, "spi_config", config_buffer);
if(err!=ESP_OK){
log_send_messaging(MESSAGING_ERROR,"Error: %s",esp_err_to_name(err));
}
free(config_buffer);
}
return err;
}
/****************************************************************************************
*
*/
const display_config_t * config_display_get(){
static display_config_t dstruct;
static display_config_t dstruct = {
.back = -1,
.CS_pin = -1,
.RST_pin = -1,
.depth = -1,
.address = 0,
.drivername = NULL,
.height = 0,
.width = 0,
.vflip = false,
.hflip = false,
.type = NULL,
.speed = 0,
.rotate = false
};
char *config = config_alloc_get(NVS_TYPE_STR, "display_config");
if (!config) {
return NULL;
@@ -50,19 +339,19 @@ const display_config_t * config_display_get(){
char * p=NULL;
if ((p = strcasestr(config, "driver")) != NULL){
sscanf(p, "%*[^:]:%u", &dstruct.depth);
dstruct.drivername = display_conf_get_driver_name(strchr(p, '=') + 1);
}
dstruct.drivername=dstruct.drivername?dstruct.drivername:"SSD1306";
if ((p = strcasestr(config, "width")) != NULL) dstruct.width = atoi(strchr(p, '=') + 1);
if ((p = strcasestr(config, "height")) != NULL) dstruct.height = atoi(strchr(p, '=') + 1);
if ((p = strcasestr(config, "reset")) != NULL) dstruct.RST_pin = atoi(strchr(p, '=') + 1);
dstruct.i2c_system_port=i2c_system_port;
if (strstr(config, "I2C") ) dstruct.type=i2c_name;
if (strstr(config, "I2C") ) dstruct.type=i2c_name_type;
if ((p = strcasestr(config, "address")) != NULL) dstruct.address = atoi(strchr(p, '=') + 1);
if (strstr(config, "SPI") ) dstruct.type=spi_name;
if (strstr(config, "SPI") ) dstruct.type=spi_name_type;
if ((p = strcasestr(config, "cs")) != NULL) dstruct.CS_pin = atoi(strchr(p, '=') + 1);
if ((p = strcasestr(config, "speed")) != NULL) dstruct.speed = atoi(strchr(p, '=') + 1);
if ((p = strcasestr(config, "back")) != NULL) dstruct.back = atoi(strchr(p, '=') + 1);
dstruct.hflip= strcasestr(config, "HFlip") ? true : false;
dstruct.vflip= strcasestr(config, "VFlip") ? true : false;
dstruct.rotate= strcasestr(config, "rotate") ? true : false;
@@ -93,7 +382,13 @@ const i2c_config_t * config_i2c_get(int * i2c_port) {
if ((p = strcasestr(nvs_item, "port")) != NULL) i2c_system_port = atoi(strchr(p, '=') + 1);
free(nvs_item);
}
if(i2c_port) *i2c_port=i2c_system_port;
if(i2c_port) {
#ifdef CONFIG_I2C_LOCKED
*i2c_port= I2C_NUM_1;
#else
*i2c_port=i2c_system_port;
#endif
}
return &i2c;
}
@@ -140,3 +435,414 @@ void parse_set_GPIO(void (*cb)(int gpio, char *value)) {
free(nvs_item);
}
/****************************************************************************************
*
*/
cJSON * get_gpio_entry(const char * name, const char * prefix, int gpio, bool fixed){
cJSON * entry = cJSON_CreateObject();
cJSON_AddNumberToObject(entry,"gpio",gpio);
cJSON_AddStringToObject(entry,"name",name);
cJSON_AddStringToObject(entry,"group",prefix);
cJSON_AddBoolToObject(entry,"fixed",fixed);
return entry;
}
/****************************************************************************************
*
*/
cJSON * get_GPIO_nvs_list(cJSON * list) {
cJSON * ilist = list?list:cJSON_CreateArray();
char *nvs_item, *p, type[16];
int gpio;
bool fixed=false;
#ifdef CONFIG_JACK_LOCKED
bool bFoundJack=false;
#endif
#ifdef CONFIG_SPKFAULT_LOCKED
bool bFoundSpkFault = false;
#endif
if ((nvs_item = config_alloc_get(NVS_TYPE_STR, "set_GPIO")) == NULL) return ilist;
p = nvs_item;
do {
fixed=false;
if (sscanf(p, "%d=%15[^,]", &gpio, type) > 0 && (GPIO_IS_VALID_GPIO(gpio) || gpio==GPIO_NUM_NC)){
#ifdef CONFIG_JACK_LOCKED
if(strcasecmp(type,"jack")==0){
fixed=true;
bFoundJack=true;
}
#endif
#ifdef CONFIG_SPKFAULT_LOCKED
if(strcasecmp(type,"spkfault")==0){
fixed=true;
bFoundSpkFault=true;
}
#endif
cJSON_AddItemToArray(ilist,get_gpio_entry(type,"gpio", gpio, fixed));
}
p = strchr(p, ',');
} while (p++);
#ifdef CONFIG_JACK_LOCKED
if(!bFoundJack){
monitor_gpio_t *jack= get_jack_insertion_gpio();
cJSON_AddItemToArray(list,get_gpio_entry("jack", "other", jack->gpio, true));
}
#endif
#ifdef CONFIG_SPKFAULT_LOCKED
if(!bFoundSpkFault){
monitor_gpio_t *jack= get_spkfault_gpio();
cJSON_AddItemToArray(list,get_gpio_entry("spkfault", "other", jack->gpio, true));
}
#endif
free(nvs_item);
return ilist;
}
/****************************************************************************************
*
*/
cJSON * get_DAC_GPIO(cJSON * list){
cJSON * llist = list;
if(!llist){
llist = cJSON_CreateArray();
}
const i2s_platform_config_t * i2s_config= config_dac_get();
if(i2s_config->pin.bck_io_num>=0){
cJSON_AddItemToArray(llist,get_gpio_entry("bck","dac",i2s_config->pin.bck_io_num,is_dac_config_locked()));
cJSON_AddItemToArray(llist,get_gpio_entry("ws","dac",i2s_config->pin.ws_io_num,is_dac_config_locked()));
cJSON_AddItemToArray(llist,get_gpio_entry("do","dac",i2s_config->pin.data_out_num,is_dac_config_locked()));
if(i2s_config->sda>=0){
cJSON_AddItemToArray(llist,get_gpio_entry("sda","dac",i2s_config->sda,is_dac_config_locked()));
cJSON_AddItemToArray(llist,get_gpio_entry("scl","dac",i2s_config->scl,is_dac_config_locked()));
}
if(i2s_config->mute_gpio>=0){
cJSON_AddItemToArray(llist,get_gpio_entry("mute","dac",i2s_config->mute_gpio,is_dac_config_locked()));
}
}
return llist;
}
/****************************************************************************************
*
*/
cJSON * get_Display_GPIO(cJSON * list){
cJSON * llist = list;
if(!llist){
llist = cJSON_CreateArray();
}
const display_config_t * config= config_display_get();
if(config->back >=0){
cJSON_AddItemToArray(llist,get_gpio_entry("backlight","display",config->back,false));
}
if(config->CS_pin >=0){
cJSON_AddItemToArray(llist,get_gpio_entry("CS","display",config->CS_pin,false));
}
if(config->RST_pin >=0){
cJSON_AddItemToArray(llist,get_gpio_entry("reset","display",config->RST_pin,false));
}
return llist;
}
/****************************************************************************************
*
*/
cJSON * get_I2C_GPIO(cJSON * list){
cJSON * llist = list;
if(!llist){
llist = cJSON_CreateArray();
}
int port=0;
const i2c_config_t * i2c_config = config_i2c_get(&port);
if(i2c_config->scl_io_num>=0){
cJSON_AddItemToArray(llist,get_gpio_entry("scl","i2c",i2c_config->scl_io_num,false));
cJSON_AddItemToArray(llist,get_gpio_entry("sda","i2c",i2c_config->sda_io_num,false));
}
return llist;
}
/****************************************************************************************
*
*/
cJSON * get_SPI_GPIO(cJSON * list){
cJSON * llist = list;
if(!llist){
llist = cJSON_CreateArray();
}
spi_host_device_t spi_host;
const spi_bus_config_t * spi_config = config_spi_get(&spi_host);
if(spi_config->miso_io_num>=0){
cJSON_AddItemToArray(llist,get_gpio_entry("data","spi",spi_config->miso_io_num,false));
cJSON_AddItemToArray(llist,get_gpio_entry("data","clk",spi_config->sclk_io_num,false));
}
if(spi_system_dc_gpio>0){
cJSON_AddItemToArray(llist,get_gpio_entry("data","dc",spi_system_dc_gpio,false));
}
return llist;
}
/****************************************************************************************
*
*/
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)){
if(gpio>0){
cJSON_AddItemToArray(llist,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));
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;
}
#ifndef PICO_PSRAM_CLK_IO
#define PICO_PSRAM_CLK_IO 6
#endif
#ifndef PSRAM_SPIQ_SD0_IO
#define PSRAM_SPIQ_SD0_IO 7
#define PSRAM_SPID_SD1_IO 8
#define PSRAM_SPIWP_SD3_IO 10
#define PSRAM_SPIHD_SD2_IO 9
#define FLASH_HSPI_CLK_IO 14
#define FLASH_HSPI_CS_IO 15
#define PSRAM_HSPI_SPIQ_SD0_IO 12
#define PSRAM_HSPI_SPID_SD1_IO 13
#define PSRAM_HSPI_SPIWP_SD3_IO 2
#define PSRAM_HSPI_SPIHD_SD2_IO 4
#endif
cJSON * get_psram_gpio_list(cJSON * list){
const char * psram_dev = "psram";
const char * flash_dev = "flash";
const char * clk = "clk";
const char * cs = "cs";
const char * spiq_sd0_io="spiq_sd0_io";
const char * spid_sd1_io = "spid_sd1_io";
const char * spiwp_sd3_io = "spiwp_sd3_io";
const char * spihd_sd2_io = "spihd_sd2_io";
cJSON * llist=list;
uint32_t chip_ver = REG_GET_FIELD(EFUSE_BLK0_RDATA3_REG, EFUSE_RD_CHIP_VER_PKG);
uint32_t pkg_ver = chip_ver & 0x7;
if (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32D2WDQ5) {
rtc_vddsdio_config_t cfg = rtc_vddsdio_get_config();
if (cfg.tieh != RTC_VDDSDIO_TIEH_1_8V) {
return llist;
}
cJSON_AddItemToArray(list,get_gpio_entry(clk,psram_dev,CONFIG_D2WD_PSRAM_CLK_IO,true));
cJSON_AddItemToArray(list,get_gpio_entry(cs,psram_dev,CONFIG_D2WD_PSRAM_CS_IO,true));
} else if ((pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD2) || (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD4)) {
rtc_vddsdio_config_t cfg = rtc_vddsdio_get_config();
if (cfg.tieh != RTC_VDDSDIO_TIEH_3_3V) {
return llist;
}
cJSON_AddItemToArray(list,get_gpio_entry(clk,psram_dev,PICO_PSRAM_CLK_IO,true));
cJSON_AddItemToArray(list,get_gpio_entry(cs,psram_dev,CONFIG_PICO_PSRAM_CS_IO,true));
} else if ((pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32D0WDQ6) || (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32D0WDQ5)){
cJSON_AddItemToArray(list,get_gpio_entry(clk,psram_dev,CONFIG_D0WD_PSRAM_CLK_IO,true));
cJSON_AddItemToArray(list,get_gpio_entry(cs,psram_dev,CONFIG_D0WD_PSRAM_CS_IO,true));
} else {
ESP_LOGW(TAG, "Cant' determine GPIOs for PSRAM chip id: %d", pkg_ver);
cJSON_AddItemToArray(list,get_gpio_entry(clk,psram_dev,-1,true));
cJSON_AddItemToArray(list,get_gpio_entry(cs,psram_dev,-1,true));
}
const uint32_t spiconfig = ets_efuse_get_spiconfig();
if (spiconfig == EFUSE_SPICONFIG_SPI_DEFAULTS) {
cJSON_AddItemToArray(list,get_gpio_entry(spiq_sd0_io,psram_dev,PSRAM_SPIQ_SD0_IO,true));
cJSON_AddItemToArray(list,get_gpio_entry(spid_sd1_io,psram_dev,PSRAM_SPID_SD1_IO,true));
cJSON_AddItemToArray(list,get_gpio_entry(spiwp_sd3_io,psram_dev,PSRAM_SPIWP_SD3_IO,true));
cJSON_AddItemToArray(list,get_gpio_entry(spihd_sd2_io,psram_dev,PSRAM_SPIHD_SD2_IO,true));
} else if (spiconfig == EFUSE_SPICONFIG_HSPI_DEFAULTS) {
cJSON_AddItemToArray(list,get_gpio_entry(spiq_sd0_io,psram_dev,PSRAM_HSPI_SPIQ_SD0_IO,true));
cJSON_AddItemToArray(list,get_gpio_entry(spid_sd1_io,psram_dev,PSRAM_HSPI_SPID_SD1_IO,true));
cJSON_AddItemToArray(list,get_gpio_entry(spiwp_sd3_io,psram_dev,PSRAM_HSPI_SPIWP_SD3_IO,true));
cJSON_AddItemToArray(list,get_gpio_entry(spihd_sd2_io,psram_dev,PSRAM_HSPI_SPIHD_SD2_IO,true));
} else {
cJSON_AddItemToArray(list,get_gpio_entry(spiq_sd0_io,psram_dev,EFUSE_SPICONFIG_RET_SPIQ(spiconfig),true));
cJSON_AddItemToArray(list,get_gpio_entry(spid_sd1_io,psram_dev,EFUSE_SPICONFIG_RET_SPID(spiconfig),true));
cJSON_AddItemToArray(list,get_gpio_entry(spihd_sd2_io,psram_dev,EFUSE_SPICONFIG_RET_SPIHD(spiconfig),true));
// If flash mode is set to QIO or QOUT, the WP pin is equal the value configured in bootloader.
// If flash mode is set to DIO or DOUT, the WP pin should config it via menuconfig.
#if CONFIG_ESPTOOLPY_FLASHMODE_QIO || CONFIG_FLASHMODE_QOUT
cJSON_AddItemToArray(list,get_gpio_entry(spiwp_sd3_io,psram_dev,CONFIG_BOOTLOADER_SPI_WP_PIN,true));
#else
cJSON_AddItemToArray(list,get_gpio_entry(spiwp_sd3_io,psram_dev,CONFIG_SPIRAM_SPIWP_SD3_PIN,true));
#endif
}
if (spiconfig == EFUSE_SPICONFIG_SPI_DEFAULTS) {
cJSON_AddItemToArray(list,get_gpio_entry(clk,flash_dev,SPI_IOMUX_PIN_NUM_CLK,true));
cJSON_AddItemToArray(list,get_gpio_entry(cs,flash_dev,SPI_IOMUX_PIN_NUM_CS,true));
} else if (spiconfig == EFUSE_SPICONFIG_HSPI_DEFAULTS) {
cJSON_AddItemToArray(list,get_gpio_entry(clk,flash_dev,FLASH_HSPI_CLK_IO,true));
cJSON_AddItemToArray(list,get_gpio_entry(cs,flash_dev,FLASH_HSPI_CS_IO,true));
} else {
cJSON_AddItemToArray(list,get_gpio_entry(clk,flash_dev,EFUSE_SPICONFIG_RET_SPICLK(spiconfig),true));
cJSON_AddItemToArray(list,get_gpio_entry(cs,flash_dev,EFUSE_SPICONFIG_RET_SPICS0(spiconfig),true));
}
return llist;
}
/****************************************************************************************
*
*/
cJSON * get_gpio_list() {
gpio_num_t gpio_num;
if(gpio_list){
cJSON_Delete(gpio_list);
}
gpio_list = cJSON_CreateArray();
#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","other",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","other",gpio_num,true));
}
#endif
gpio_list = get_GPIO_nvs_list(gpio_list);
char * spdif_config = config_spdif_get_string();
gpio_list=get_GPIO_from_string(spdif_config,"spdif", gpio_list, is_spdif_config_locked());
free(spdif_config);
gpio_list=get_Display_GPIO(gpio_list);
gpio_list=get_SPI_GPIO(gpio_list);
gpio_list=get_I2C_GPIO(gpio_list);
gpio_list=get_DAC_GPIO(gpio_list);
gpio_list=get_psram_gpio_list(gpio_list);
return gpio_list;
}

View File

@@ -10,23 +10,57 @@
#include "esp_system.h"
#include "driver/i2c.h"
#include "driver/i2s.h"
#include "driver/spi_master.h"
extern const char *i2c_name_type;
extern const char *spi_name_type;
typedef struct {
int width;
int height;
int RST_pin;
int i2c_system_port;
int address;
int CS_pin;
int speed;
const char *drivername;
const char *type;
int RST_pin;
bool hflip;
bool vflip;
const char *drivername;
int CS_pin;
int speed;
int back;
int depth;
const char *type;
bool rotate;
} display_config_t;
const display_config_t * config_display_get();
typedef struct {
i2s_pin_config_t pin;
char model[32];
int mute_gpio;
int mute_level;
int i2c_addr;
int sda;
int scl;
} i2s_platform_config_t;
typedef struct {
bool fixed;
char * name;
char * group;
int gpio;
} gpio_entry_t;
const display_config_t * config_display_get();
esp_err_t config_display_set(const display_config_t * config);
esp_err_t config_i2c_set(const i2c_config_t * config, int port);
esp_err_t config_i2s_set(const i2s_platform_config_t * config, const char * nvs_name);
esp_err_t config_spi_set(const spi_bus_config_t * config, int host, int dc);
const i2c_config_t * config_i2c_get(int * i2c_port);
const spi_bus_config_t * config_spi_get(spi_host_device_t * spi_host);
void parse_set_GPIO(void (*cb)(int gpio, char *value));
const i2s_platform_config_t * config_dac_get();
const i2s_platform_config_t * config_spdif_get( );
esp_err_t config_spdif_set(const i2s_platform_config_t * config);
bool is_spdif_config_locked();
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();
bool is_dac_config_locked();
bool are_statistics_enabled();

View File

@@ -43,7 +43,7 @@ static struct {
/****************************************************************************************
*
*/
int battery_value_svc(void) {
float battery_value_svc(void) {
return battery.avg;
}

View File

@@ -85,7 +85,7 @@ static void vCallbackFunction( TimerHandle_t xTimer ) {
bool led_blink_core(int idx, int ontime, int offtime, bool pushed) {
if (!leds[idx].gpio || leds[idx].gpio < 0 ) return false;
ESP_LOGD(TAG,"led_blink_core");
ESP_LOGD(TAG,"led_blink_core %d on:%d off:%d, pushed:%u", idx, ontime, offtime, pushed);
if (leds[idx].timer) {
// normal requests waits if a pop is pending
if (!pushed && leds[idx].pushed) {
@@ -231,8 +231,7 @@ void led_svc_init(void) {
#ifndef CONFIG_LED_LOCKED
parse_set_GPIO(set_led_gpio);
#endif
ESP_LOGI(TAG,"Configuring LEDs green:%d (active:%d %d%%), red:%d (active:%d %d%%)", green.gpio, green.active, green.pwm, green.gpio, green.active, green.pwm );
char *nvs_item = config_alloc_get(NVS_TYPE_STR, "led_brightness"), *p;
if (nvs_item) {
if ((p = strcasestr(nvs_item, "green")) != NULL) green.pwm = atoi(strchr(p, '=') + 1);
@@ -242,4 +241,6 @@ void led_svc_init(void) {
led_config(LED_GREEN, green.gpio, green.active, green.pwm);
led_config(LED_RED, red.gpio, red.active, red.pwm);
ESP_LOGI(TAG,"Configuring LEDs green:%d (active:%d %d%%), red:%d (active:%d %d%%)", green.gpio, green.active, green.pwm, red.gpio, red.active, red.pwm );
}

View File

@@ -119,6 +119,7 @@ const char * messaging_get_class_desc(messaging_classes msg_class){
CASE_TO_STR(MESSAGING_CLASS_OTA);
CASE_TO_STR(MESSAGING_CLASS_SYSTEM);
CASE_TO_STR(MESSAGING_CLASS_STATS);
CASE_TO_STR(MESSAGING_CLASS_CFGCMD);
default:
return "Unknown";
break;
@@ -141,12 +142,12 @@ cJSON * messaging_retrieve_messages(RingbufHandle_t buf_handle){
else {
json_message = cJSON_CreateObject();
cJSON_AddStringToObject(json_message, "message", message->message);
vRingbufferReturnItem(buf_handle, (void *)message);
cJSON_AddStringToObject(json_message, "type", messaging_get_type_desc(message->type));
cJSON_AddStringToObject(json_message, "class", messaging_get_class_desc(message->msg_class));
cJSON_AddNumberToObject(json_message,"sent_time",message->sent_time);
cJSON_AddNumberToObject(json_message,"current_time",esp_timer_get_time() / 1000);
cJSON_AddItemToArray(json_messages,json_message);
vRingbufferReturnItem(buf_handle, (void *)message);
}
}
return json_messages;
@@ -260,5 +261,23 @@ void log_send_messaging(messaging_types msgtype,const char *fmt, ...) {
else{
ESP_LOGE(tag, "Memory allocation failed while sending message");
}
}
void cmd_send_messaging(const char * cmdname,messaging_types msgtype, const char *fmt, ...){
va_list va;
va_start(va, fmt);
size_t cmd_len = strlen(cmdname)+1;
size_t ln = vsnprintf(NULL, 0, fmt, va)+1;
char * message_txt = malloc(ln+cmd_len);
if(message_txt){
strcpy(message_txt,cmdname);
strcat(message_txt,"\n");
vsprintf((message_txt+cmd_len), fmt, va);
va_end(va);
ESP_LOG_LEVEL_LOCAL(messaging_type_to_err_type(msgtype),tag, "%s",message_txt);
messaging_post_message(msgtype, MESSAGING_CLASS_CFGCMD, message_txt );
free(message_txt);
}
else{
ESP_LOGE(tag, "Memory allocation failed while sending message");
}
}

View File

@@ -1,4 +1,5 @@
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/ringbuf.h"
#include "cJSON.h"
#pragma once
@@ -10,7 +11,8 @@ typedef enum {
typedef enum {
MESSAGING_CLASS_OTA,
MESSAGING_CLASS_SYSTEM,
MESSAGING_CLASS_STATS
MESSAGING_CLASS_STATS,
MESSAGING_CLASS_CFGCMD
} messaging_classes;
typedef struct messaging_list_t *messaging_handle_t;
@@ -30,6 +32,7 @@ void messaging_post_message(messaging_types type,messaging_classes msg_class, co
cJSON * messaging_retrieve_messages(RingbufHandle_t buf_handle);
single_message_t * messaging_retrieve_message(RingbufHandle_t buf_handle);
void log_send_messaging(messaging_types msgtype,const char *fmt, ...);
void cmd_send_messaging(const char * cmdname,messaging_types msgtype, const char *fmt, ...);
esp_err_t messaging_type_to_err_type(messaging_types type);
void messaging_service_init();

View File

@@ -32,11 +32,8 @@ static const char *TAG = "monitor";
static TimerHandle_t monitor_timer;
static struct {
int gpio;
int active;
} jack = { CONFIG_JACK_GPIO, 0 },
spkfault = { CONFIG_SPKFAULT_GPIO, 0 };
static monitor_gpio_t jack = { CONFIG_JACK_GPIO, 0 };
static monitor_gpio_t spkfault = { CONFIG_SPKFAULT_GPIO, 0 };
void (*jack_handler_svc)(bool inserted);
bool jack_inserted_svc(void);
@@ -181,6 +178,9 @@ static void set_jack_gpio(int gpio, char *value) {
jack.gpio = gpio;
if ((p = strchr(value, ':')) != NULL) jack.active = atoi(p + 1);
}
else {
jack.gpio = -1;
}
}
#endif
@@ -194,6 +194,9 @@ static void set_spkfault_gpio(int gpio, char *value) {
spkfault.gpio = gpio;
if ((p = strchr(value, ':')) != NULL) spkfault.active = atoi(p + 1);
}
else {
spkfault.gpio = -1;
}
}
#endif
@@ -237,7 +240,7 @@ void monitor_svc_init(void) {
monitor_timer = xTimerCreate("monitor", MONITOR_TIMER / portTICK_RATE_MS, pdTRUE, NULL, monitor_callback);
xTimerStart(monitor_timer, portMAX_DELAY);
}
free(p);
FREE_AND_NULL(p);
ESP_LOGI(TAG, "Heap internal:%zu (min:%zu) external:%zu (min:%zu)",
heap_caps_get_free_size(MALLOC_CAP_INTERNAL),
@@ -245,3 +248,17 @@ void monitor_svc_init(void) {
heap_caps_get_free_size(MALLOC_CAP_SPIRAM),
heap_caps_get_minimum_free_size(MALLOC_CAP_SPIRAM));
}
/****************************************************************************************
*
*/
monitor_gpio_t * get_spkfault_gpio(){
return &spkfault ;
}
/****************************************************************************************
*
*/
monitor_gpio_t * get_jack_insertion_gpio(){
return &jack;
}

View File

@@ -9,6 +9,10 @@
*/
#pragma once
typedef struct {
int gpio;
int active;
} monitor_gpio_t;
extern void (*jack_handler_svc)(bool inserted);
extern bool jack_inserted_svc(void);
@@ -16,6 +20,9 @@ extern bool jack_inserted_svc(void);
extern void (*spkfault_handler_svc)(bool inserted);
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 monitor_gpio_t * get_spkfault_gpio();
extern monitor_gpio_t * get_jack_insertion_gpio();

View File

@@ -327,12 +327,12 @@ void register_external(void) {
void deregister_external(void) {
if (!strcasestr(output.device, "BT ") && enable_bt_sink) {
bt_sink_deinit();
LOG_INFO("Stopping BT sink");
bt_sink_deinit();
}
if (enable_airplay){
LOG_INFO("Stopping AirPlay sink");
raop_sink_deinit();
LOG_INFO("Stopping AirPlay sink");
}
}

View File

@@ -51,7 +51,7 @@ u8_t custom_player_id = 12;
void embedded_init(void) {
mutex_create(slimp_mutex);
sb_controls_init();
if (sb_display_init()) custom_player_id = 100;
custom_player_id = sb_display_init() ? 100 : 101;
}
u16_t get_RSSI(void) {

View File

@@ -35,7 +35,7 @@ typedef unsigned long long u64_t;
#define OUTPUT_THREAD_STACK_SIZE 6 * 1024
#define IR_THREAD_STACK_SIZE 6 * 1024
// number of 5s times search for a server will happen beforee slimproto exits (0 = no limit)
// number of times the 5s search for a server will happen before slimproto exits (0 = no limit)
#define MAX_SERVER_RETRIES 5
// or can be as simple as #define PLAYER_ID 100

View File

@@ -128,12 +128,12 @@ static esp_err_t i2c_write_reg(uint8_t reg, uint8_t val) {
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, i2c_addr | I2C_MASTER_WRITE, I2C_MASTER_NACK);
i2c_master_write_byte(cmd, (i2c_addr << 1) | I2C_MASTER_WRITE, I2C_MASTER_NACK);
i2c_master_write_byte(cmd, reg, I2C_MASTER_NACK);
i2c_master_write_byte(cmd, val, I2C_MASTER_NACK);
i2c_master_stop(cmd);
ret = i2c_master_cmd_begin(i2c_port, cmd, 1000 / portTICK_RATE_MS);
ret = i2c_master_cmd_begin(i2c_port, cmd, 100 / portTICK_RATE_MS);
i2c_cmd_link_delete(cmd);
if (ret != ESP_OK) {
@@ -153,15 +153,15 @@ static uint8_t i2c_read_reg(uint8_t reg) {
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, i2c_addr | I2C_MASTER_WRITE, I2C_MASTER_NACK);
i2c_master_write_byte(cmd, (i2c_addr << 1) | I2C_MASTER_WRITE, I2C_MASTER_NACK);
i2c_master_write_byte(cmd, reg, I2C_MASTER_NACK);
i2c_master_start(cmd);
i2c_master_write_byte(cmd, i2c_addr | I2C_MASTER_READ, I2C_MASTER_NACK);
i2c_master_write_byte(cmd, (i2c_addr << 1) | I2C_MASTER_READ, I2C_MASTER_NACK);
i2c_master_read_byte(cmd, &data, I2C_MASTER_NACK);
i2c_master_stop(cmd);
ret = i2c_master_cmd_begin(i2c_port, cmd, 1000 / portTICK_RATE_MS);
ret = i2c_master_cmd_begin(i2c_port, cmd, 100 / portTICK_RATE_MS);
i2c_cmd_link_delete(cmd);
if (ret != ESP_OK) {

View File

@@ -962,7 +962,7 @@ void slimproto(log_level level, char *server, u8_t mac[6], const char *name, con
if (++failed_connect > 5 && !server) {
slimproto_ip = serv_addr.sin_addr.s_addr = discover_server(NULL, MAX_SERVER_RETRIES);
if (!slimproto_ip) return;
} else if (MAX_SERVER_RETRIES && failed_connect > 5 * MAX_SERVER_RETRIES) return;
} else if (reconnect && MAX_SERVER_RETRIES && failed_connect > 5 * MAX_SERVER_RETRIES) return;
#else
// rediscover server if it was not set at startup or exit
if (!server && ++failed_connect > 5) {

View File

@@ -46,27 +46,17 @@ struct buffer *streambuf = &buf;
#define UNLOCK mutex_unlock(streambuf->mutex)
/*
After a lot of hesitation, I've added that "poll mutex" to prevent
socket from being allocated while we are still in poll(). The issue
happens is we have a close quickly followed by an open, we might still
be in the poll() and simple OS fail as they re-allocate the same socket
on which a thread is still waiting.
Ideally, you want to set the lock in the disconnect() but that would mean
very often we'd have to always wait for the end of the poll(), i.e. up to
100ms for nothing most of the time where if it is in the open(), it is
less elegant as closing a socket on which there is a poll() is not good
but it's more efficient as it is very rare that you'd have an open() less
then 100ms after a close()
When LMS sends a close/open sequence very quickly, the stream thread might
still be waiting in the poll() on the closed socket. It is never recommended
to have a thread closing a socket used by another thread but it works, as
opposed to an infinite select().
In stream_sock() a new socket is created and full OS will allocate a different
one but on RTOS and simple IP stack, the same might be re-used and that causes
an exception as a thread is already waiting on a newly allocated socket
A simple variable that forces stream_sock() to wait until we are out of poll()
is enough and much faster than a mutex
*/
#if EMBEDDED
static mutex_type poll_mutex;
#define LOCK_L mutex_lock(poll_mutex)
#define UNLOCK_L mutex_unlock(poll_mutex)
#else
#define LOCK_L
#define UNLOCK_L
#endif
static bool polling;
static sockfd fd;
struct streamstate stream;
@@ -209,7 +199,6 @@ static void *stream_thread() {
} else {
LOCK_L;
pollinfo.fd = fd;
pollinfo.events = POLLIN;
if (stream.state == SEND_HEADERS) {
@@ -218,10 +207,12 @@ static void *stream_thread() {
}
UNLOCK;
// no mutex needed - we just want to know if we are inside poll()
polling = true;
if (_poll(ssl, &pollinfo, 100)) {
UNLOCK_L;
polling = false;
LOCK;
// check socket has not been closed while in poll
@@ -374,7 +365,7 @@ static void *stream_thread() {
UNLOCK;
} else {
UNLOCK_L;
polling = false;
LOG_SDEBUG("poll timeout");
}
}
@@ -427,9 +418,6 @@ void stream_init(log_level level, unsigned stream_buf_size) {
*stream.header = '\0';
fd = -1;
#if EMBEDDED
mutex_create_p(poll_mutex);
#endif
#if LINUX || FREEBSD
touch_memory(streambuf->buf, streambuf->size);
@@ -459,9 +447,6 @@ void stream_close(void) {
#endif
free(stream.header);
buf_destroy(streambuf);
#if EMBEDDED
mutex_destroy(poll_mutex);
#endif
}
void stream_file(const char *header, size_t header_len, unsigned threshold) {
@@ -503,9 +488,12 @@ void stream_file(const char *header, size_t header_len, unsigned threshold) {
void stream_sock(u32_t ip, u16_t port, const char *header, size_t header_len, unsigned threshold, bool cont_wait) {
struct sockaddr_in addr;
LOCK_L;
#if EMBEDDED
// wait till we are not polling anymore
while (polling && running) { usleep(10000); }
#endif
int sock = socket(AF_INET, SOCK_STREAM, 0);
UNLOCK_L;
if (sock < 0) {
LOG_ERROR("failed to create socket");

View File

@@ -253,6 +253,10 @@ void process_received_data(const char * buffer, size_t size){
if(bMirrorToUART){
write(uart_fd, command, size);
}
for(int i=strlen(command);i>=0;i--){
// strip any cr/lf
if(command[i]== '\n' || command[i]== '\r') command[i]= '\0';
}
run_command((char *)command);
}
free(command);

View File

@@ -22,11 +22,12 @@
#pragma once
#include "esp_pthread.h"
#include "esp_log.h"
#ifndef SQUEEZELITE_ESP32_RELEASE_URL
#define SQUEEZELITE_ESP32_RELEASE_URL "https://github.com/sle118/squeezelite-esp32/releases"
#endif
extern bool is_recovery_running;
extern void run_command(char * line);
extern esp_err_t run_command(char * line);
extern bool wait_for_wifi();
extern void console_start();
extern pthread_cond_t wifi_connect_suspend_cond;

View File

@@ -33,6 +33,3 @@ extern const char * str_or_null(const char * str);
#ifndef CASE_TO_STR
#define CASE_TO_STR(x) case x: return STR(x); break;
#endif
#define START_FREE_MEM_CHECK(a) size_t a=heap_caps_get_free_size(MALLOC_CAP_INTERNAL);
#define CHECK_RESET_FREE_MEM_CHECK(a,b) ESP_LOGV(__FUNCTION__ ,b "Mem used: %i",a-heap_caps_get_free_size(MALLOC_CAP_INTERNAL)); a=heap_caps_get_free_size(MALLOC_CAP_INTERNAL)

View File

@@ -2,7 +2,7 @@ idf_component_register( SRC_DIRS .
INCLUDE_DIRS . ${IDF_PATH}/components/esp_http_server/src ${IDF_PATH}/components/esp_http_server/src/port/esp32 ${IDF_PATH}/components/esp_http_server/src/util ${IDF_PATH}/components/esp_http_server/src/
REQUIRES squeezelite-ota json mdns
PRIV_REQUIRES tools services platform_config esp_common json newlib freertos spi_flash nvs_flash mdns pthread wpa_supplicant platform_console esp_http_server console
EMBED_FILES style.css code.js index.html bootstrap.min.css.gz jquery.min.js.gz popper.min.js.gz bootstrap.min.js.gz favicon.ico
EMBED_FILES res/style.css.gz res/code.js.gz index.html res/bootstrap.css.gz res/yeti/bootstrap.css.gz res/jquery.js.gz res/bootstrap.js.gz res/favicon.ico
)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,650 @@
{
"commands": [{
"help": "Squeezelite Options",
"hascb": true,
"argtable": [{
"datatype": "<server>[:<port>]",
"glossary": "Connect to specified server, otherwise uses autodiscovery to find server",
"longopts": "server",
"shortopts": "s",
"checkbox": false,
"hasvalue": true,
"mincount": 0,
"maxcount": 1
}, {
"datatype": "<stream>:<output>",
"glossary": "Internal Stream and Output buffer sizes in Kbytes",
"longopts": "buffers",
"shortopts": "b",
"checkbox": false,
"hasvalue": true,
"mincount": 0,
"maxcount": 1
}, {
"datatype": "<codec1>,<codec2>",
"glossary": "Restrict codecs to those specified, otherwise load all available codecs; known codecs",
"longopts": "codecs",
"shortopts": "c",
"checkbox": false,
"hasvalue": true,
"mincount": 0,
"maxcount": 20
}, {
"datatype": "<n>",
"glossary": "Close output device when idle after timeout seconds, default is to keep it open while player is 'on",
"longopts": "timeout",
"shortopts": "C",
"checkbox": false,
"hasvalue": true,
"mincount": 0,
"maxcount": 1
}, {
"datatype": "log=level",
"glossary": "Set logging level, logs: all|slimproto|stream|decode|output|ir, level: info|debug|sdebug",
"longopts": "loglevel",
"shortopts": "d",
"checkbox": false,
"hasvalue": true,
"mincount": 0,
"maxcount": 1
}, {
"datatype": "<string>",
"glossary": "Output device",
"longopts": "output_device",
"shortopts": "o",
"checkbox": false,
"hasvalue": true,
"mincount": 0,
"maxcount": 1
}, {
"datatype": "<string>",
"glossary": "Mac address, format: ab:cd:ef:12:34:56",
"longopts": "mac_addr",
"shortopts": "m",
"checkbox": false,
"hasvalue": true,
"mincount": 0,
"maxcount": 1
}, {
"datatype": "<string>",
"glossary": "Squeezelite player model name sent to the server",
"longopts": "modelname",
"shortopts": "M",
"checkbox": false,
"hasvalue": true,
"mincount": 0,
"maxcount": 1
}, {
"datatype": "<string>",
"glossary": "Player name",
"longopts": "name",
"shortopts": "n",
"checkbox": false,
"hasvalue": true,
"mincount": 0,
"maxcount": 1
}, {
"glossary": "Read wave and aiff format from header, ignore server parameters",
"longopts": "header_format",
"shortopts": "W",
"checkbox": true,
"hasvalue": false,
"mincount": 0,
"maxcount": 1
}, {
"datatype": "<rates>[:<delay>]",
"glossary": "Sample rates supported, allows output to be off when squeezelite is started; rates = <maxrate>|<minrate>-<maxrate>|<rate1>,<rate2>,<rate3>; delay = optional delay switching rates in ms\n",
"longopts": "rates",
"shortopts": "r",
"checkbox": false,
"hasvalue": true,
"mincount": 0,
"maxcount": 1
}, {
"datatype": "<n>",
"glossary": "Report rate to server in helo as the maximum sample rate we can support",
"longopts": "max_rate",
"shortopts": "Z",
"checkbox": false,
"hasvalue": true,
"mincount": 0,
"maxcount": 1
}],
"hint": " [-W] [-s <server>[:<port>]] [-b <stream>:<output>] [-c <codec1>,<codec2>]... [-C <n>] [-d log=level] [-o <string>] [-m <string>] [-M <string>] [-n <string>] [-r <rates>[:<delay>]] [-Z <n>]",
"name": "cfg-syst-squeezelite"
}, {
"help": "DAC Options",
"hascb": true,
"argtable": [{
"datatype": "TAS57xx|TAS5713|AC101|I2S",
"glossary": "DAC Model Name",
"longopts": "model_name",
"checkbox": false,
"hasvalue": true,
"mincount": 1,
"maxcount": 1
}, {
"datatype": "<n>",
"glossary": "Clock GPIO. e.g. 33",
"longopts": "clock",
"checkbox": false,
"hasvalue": true,
"mincount": 1,
"maxcount": 1
}, {
"datatype": "<n>",
"glossary": "Word Select GPIO. e.g. 25",
"longopts": "wordselect",
"checkbox": false,
"hasvalue": true,
"mincount": 1,
"maxcount": 1
}, {
"datatype": "<n>",
"glossary": "Data GPIO. e.g. 32",
"longopts": "data",
"checkbox": false,
"hasvalue": true,
"mincount": 1,
"maxcount": 1
}, {
"datatype": "<n>",
"glossary": "Mute GPIO. e.g. 14",
"longopts": "mute_gpio",
"checkbox": false,
"hasvalue": true,
"mincount": 0,
"maxcount": 1
}, {
"glossary": "Mute active GPIO level",
"longopts": "mute_level",
"checkbox": true,
"hasvalue": false,
"mincount": 0,
"maxcount": 1
}, {
"datatype": "<n>",
"glossary": "SDA GPIO. e.g. 27",
"longopts": "dac_sda",
"checkbox": false,
"hasvalue": true,
"mincount": 0,
"maxcount": 1
}, {
"datatype": "<n>",
"glossary": "SCL GPIO. e.g. 26",
"longopts": "dac_scl",
"checkbox": false,
"hasvalue": true,
"mincount": 0,
"maxcount": 1
}, {
"datatype": "<n>",
"glossary": "I2C device address. e.g. 106",
"longopts": "dac_i2c",
"checkbox": false,
"hasvalue": true,
"mincount": 0,
"maxcount": 1
}, {
"glossary": "Clear configuration",
"longopts": "clear",
"checkbox": true,
"hasvalue": false,
"mincount": 0,
"maxcount": 1
}],
"hint": " --model_name=TAS57xx|TAS5713|AC101|I2S --clock=<n> --wordselect=<n> --data=<n> [--mute_gpio=<n>] [--mute_level] [--dac_sda=<n>] [--dac_scl=<n>] [--dac_i2c=<n>] [--clear]",
"name": "cfg-hw-dac"
}, {
"help": "Get the current size of free heap memory",
"hascb": false,
"name": "free"
}, {
"help": "Services",
"hascb": true,
"argtable": [{
"glossary": "Bluetooth Speaker",
"longopts": "BT_Speaker",
"checkbox": true,
"hasvalue": false,
"mincount": 0,
"maxcount": 1
}, {
"glossary": "AirPlay",
"longopts": "AirPlay",
"checkbox": true,
"hasvalue": false,
"mincount": 0,
"maxcount": 1
}, {
"datatype": "Disabled|Telnet Only|Telnet and Serial",
"glossary": "Telnet server. Use only for troubleshooting",
"longopts": "telnet",
"shortopts": "t",
"checkbox": false,
"hasvalue": true,
"mincount": 0,
"maxcount": 1
}, {
"glossary": "System Statistics. Use only for troubleshooting",
"longopts": "stats",
"checkbox": true,
"hasvalue": false,
"mincount": 0,
"maxcount": 1
}],
"hint": " [--BT_Speaker] [--AirPlay] [-t Disabled|Telnet Only|Telnet and Serial] [--stats]",
"name": "cfg-syst-services"
}, {
"help": "Get minimum size of free heap memory found during execution",
"hascb": false,
"name": "heap"
}, {
"help": "Device Name",
"hascb": true,
"argtable": [{
"datatype": "\"squeezelite-test3\"",
"glossary": "New Name",
"longopts": "name",
"shortopts": "n",
"checkbox": false,
"hasvalue": true,
"mincount": 0,
"maxcount": 1
}],
"hint": " [-n \"squeezelite-test3\"]",
"name": "cfg-syst-name"
}, {
"help": "Get version of chip and SDK",
"hascb": false,
"name": "version"
}, {
"help": "Software reset of the chip",
"hascb": false,
"name": "restart"
}, {
"help": "Resets and boot to recovery (if available)",
"hascb": false,
"name": "recovery"
}, {
"help": "Selects the ota app partition to boot from and performa a software reset of the chip",
"hascb": false,
"name": "restart_ota"
}, {
"help": "I2C Bus Parameters",
"hascb": true,
"argtable": [{
"datatype": "0|1",
"glossary": "Port",
"longopts": "port",
"shortopts": "p",
"checkbox": false,
"hasvalue": true,
"mincount": 0,
"maxcount": 1
}, {
"datatype": "int",
"glossary": "Frequency (Hz) e.g. 100000",
"longopts": "speed",
"shortopts": "f",
"checkbox": false,
"hasvalue": true,
"mincount": 0,
"maxcount": 1
}, {
"datatype": "<n>",
"glossary": "SDA GPIO. e.g. 19",
"longopts": "sda",
"shortopts": "d",
"checkbox": false,
"hasvalue": true,
"mincount": 0,
"maxcount": 1
}, {
"datatype": "<n>",
"glossary": "SCL GPIO. e.g. 18",
"longopts": "scl",
"shortopts": "c",
"checkbox": false,
"hasvalue": true,
"mincount": 0,
"maxcount": 1
}, {
"glossary": "Load Existing Configuration",
"longopts": "load",
"shortopts": "l",
"checkbox": true,
"hasvalue": false,
"mincount": 0,
"maxcount": 1
}, {
"glossary": "Clear configuration",
"longopts": "clear",
"checkbox": true,
"hasvalue": false,
"mincount": 0,
"maxcount": 1
}],
"hint": " [-l] [-p 0|1] [-f int] [-d <n>] [-c <n>] [--clear]",
"name": "cfg-hw-i2c"
}, {
"help": "SPI Bus Parameters",
"hascb": true,
"argtable": [{
"datatype": "<n>",
"glossary": "Data GPIO",
"longopts": "data",
"shortopts": "d",
"checkbox": false,
"hasvalue": true,
"mincount": 0,
"maxcount": 1
}, {
"datatype": "<n>",
"glossary": "Clock GPIO",
"longopts": "clk",
"shortopts": "k",
"checkbox": false,
"hasvalue": true,
"mincount": 0,
"maxcount": 1
}, {
"datatype": "<n>",
"glossary": "DC GPIO",
"longopts": "dc",
"shortopts": "c",
"checkbox": false,
"hasvalue": true,
"mincount": 0,
"maxcount": 1
}, {
"datatype": "int",
"glossary": "SPI Host Number",
"longopts": "host",
"shortopts": "h",
"checkbox": false,
"hasvalue": true,
"mincount": 0,
"maxcount": 1
}, {
"glossary": "Clear configuration",
"longopts": "clear",
"checkbox": true,
"hasvalue": false,
"mincount": 0,
"maxcount": 1
}],
"hint": " [-d <n>] [-k <n>] [-c <n>] [-h int] [--clear]",
"name": "cfg-hw-spi"
}, {
"help": "Scan I2C bus for devices",
"hascb": false,
"name": "i2cdetect"
}, {
"help": "Read registers visible through the I2C bus",
"hascb": false,
"argtable": [{
"datatype": "<chip_addr>",
"glossary": "Specify the address of the chip on that bus",
"longopts": "chip",
"shortopts": "c",
"checkbox": false,
"hasvalue": true,
"mincount": 1,
"maxcount": 1
}, {
"datatype": "<register_addr>",
"glossary": "Specify the address on that chip to read from",
"longopts": "register",
"shortopts": "r",
"checkbox": false,
"hasvalue": true,
"mincount": 0,
"maxcount": 1
}, {
"datatype": "<length>",
"glossary": "Specify the length to read from that data address",
"longopts": "length",
"shortopts": "l",
"checkbox": false,
"hasvalue": true,
"mincount": 0,
"maxcount": 1
}],
"hint": " -c <chip_addr> [-r <register_addr>] [-l <length>]",
"name": "i2cget"
}, {
"help": "Set registers visible through the I2C bus",
"hascb": false,
"argtable": [{
"datatype": "<chip_addr>",
"glossary": "Specify the address of the chip on that bus",
"longopts": "chip",
"shortopts": "c",
"checkbox": false,
"hasvalue": true,
"mincount": 1,
"maxcount": 1
}, {
"datatype": "<n>",
"glossary": "Specify the i2c port (0|2)",
"longopts": "port",
"shortopts": "p",
"checkbox": false,
"hasvalue": true,
"mincount": 0,
"maxcount": 1
}, {
"datatype": "<register_addr>",
"glossary": "Specify the address on that chip to read from",
"longopts": "register",
"shortopts": "r",
"checkbox": false,
"hasvalue": true,
"mincount": 0,
"maxcount": 1
}, {
"datatype": "<data>",
"glossary": "Specify the data to write to that data address",
"checkbox": false,
"hasvalue": true,
"mincount": 0,
"maxcount": 256
}],
"hint": " -c <chip_addr> [-p <n>] [-r <register_addr>] [<data>]...",
"name": "i2cset"
}, {
"help": "Examine registers visible through the I2C bus",
"hascb": false,
"argtable": [{
"datatype": "<chip_addr>",
"glossary": "Specify the address of the chip on that bus",
"longopts": "chip",
"shortopts": "c",
"checkbox": false,
"hasvalue": true,
"mincount": 1,
"maxcount": 1
}, {
"datatype": "<size>",
"glossary": "Specify the size of each read",
"longopts": "size",
"shortopts": "s",
"checkbox": false,
"hasvalue": true,
"mincount": 0,
"maxcount": 1
}],
"hint": " -c <chip_addr> [-s <size>]",
"name": "i2cdump"
}, {
"help": "Display",
"hascb": true,
"argtable": [{
"datatype": "<I2C|SPI>",
"glossary": "Interface (default I2C)",
"longopts": "type",
"shortopts": "t",
"checkbox": false,
"hasvalue": true,
"mincount": 0,
"maxcount": 1
}, {
"datatype": "<SH1106|SSD1306|SSD1322|SSD1326|SSD1327|SSD1675|SSD1351|ST77xx|ILI9341|>",
"glossary": "Driver (default SSD1306)",
"longopts": "driver",
"shortopts": "d",
"checkbox": false,
"hasvalue": true,
"mincount": 0,
"maxcount": 1
}, {
"datatype": "<n>",
"glossary": "I2C address (default 60)",
"longopts": "address",
"shortopts": "a",
"checkbox": false,
"hasvalue": true,
"mincount": 0,
"maxcount": 1
}, {
"datatype": "<n>",
"glossary": "Width",
"longopts": "width",
"shortopts": "w",
"checkbox": false,
"hasvalue": true,
"mincount": 0,
"maxcount": 1
}, {
"datatype": "<n>",
"glossary": "Height",
"longopts": "height",
"shortopts": "h",
"checkbox": false,
"hasvalue": true,
"mincount": 0,
"maxcount": 1
}, {
"glossary": "Rotate 180 degrees",
"longopts": "rotate",
"shortopts": "r",
"checkbox": true,
"hasvalue": false,
"mincount": 0,
"maxcount": 1
}, {
"glossary": "Flip horizontally",
"longopts": "hf",
"checkbox": true,
"hasvalue": false,
"mincount": 0,
"maxcount": 1
}, {
"glossary": "Flip vertically",
"longopts": "vf",
"checkbox": true,
"hasvalue": false,
"mincount": 0,
"maxcount": 1
}, {
"datatype": "<n>",
"glossary": "Bus Speed (Default 8000000 for SPI, 250000 for I2C). SPI interface can work up to 26MHz~40MHz",
"longopts": "speed",
"shortopts": "s",
"checkbox": false,
"hasvalue": true,
"mincount": 0,
"maxcount": 1
}, {
"datatype": "<n>",
"glossary": "Backlight GPIO (if applicable)",
"longopts": "back",
"shortopts": "b",
"checkbox": false,
"hasvalue": true,
"mincount": 0,
"maxcount": 1
}, {
"glossary": "clear configuration and return",
"longopts": "clear",
"checkbox": true,
"hasvalue": false,
"mincount": 0,
"maxcount": 1
}],
"hint": " [-r] [-t <I2C|SPI>] [-d <SH1106|SSD1306|SSD1322|SSD1326|SSD1327|SSD1675|SSD1351|ST77xx|ILI9341|>] [-a <n>] [-w <n>] [-h <n>] [--hf] [--vf] [-s <n>] [-b <n>] [--clear]",
"name": "cfg-hw-display"
}, {
"help": "Shows display options and global i2c configuration",
"hascb": false,
"name": "getdisplay"
}, {
"help": "Stop the I2C bus",
"hascb": false,
"argtable": [{
"datatype": "<0|1>",
"glossary": "I2C bus port number",
"longopts": "port",
"shortopts": "p",
"checkbox": false,
"hasvalue": true,
"mincount": 0,
"maxcount": 1
}],
"hint": " [-p <0|1>]",
"name": "i2cstop"
}, {
"help": "Check if the I2C bus is installed",
"hascb": false,
"argtable": [{
"datatype": "<0|1>",
"glossary": "Set the I2C bus port number",
"longopts": "port",
"shortopts": "p",
"checkbox": false,
"hasvalue": true,
"mincount": 0,
"maxcount": 1
}],
"hint": " [-p <0|1>]",
"name": "i2ccheck"
}],
"values": {
"cfg-syst-squeezelite": {
"buffers": "500:2000",
"header_format": true,
"loglevel": "all=info",
"output_device": "I2S",
"name": "squeezelite",
"timeout": 30
},
"cfg-hw-dac": {
"model_name": "i2s"
},
"cfg-syst-services": {
"BT_Speaker": false,
"AirPlay": false,
"telnet": "Telnet and Serial",
"stats": true
},
"cfg-syst-name": {
"name": "\"squeezelite-test3\""
},
"cfg-hw-i2c": {
"freq": 400000
},
"cfg-hw-spi": {
},
"cfg-hw-display": {
"address": 0,
"width": 0,
"height": 0,
"driver": "SSD1306",
"hf": false,
"vf": false,
"rotate": false
}
}
}

View File

@@ -0,0 +1,343 @@
{
"gpio": [
{
"gpio": 33,
"name": "bck",
"group": "spdif",
"fixed": false
},
{
"gpio": 25,
"name": "ws",
"group": "spdif",
"fixed": false
},
{
"gpio": 15,
"name": "do",
"group": "spdif",
"fixed": false
},
{
"gpio": -1,
"name": "bck",
"group": "dac",
"fixed": false
},
{
"gpio": -1,
"name": "ws",
"group": "dac",
"fixed": false
},
{
"gpio": -1,
"name": "do",
"group": "dac",
"fixed": false
},
{
"gpio": -1,
"name": "sda",
"group": "dac",
"fixed": false
},
{
"gpio": -1,
"name": "scl",
"group": "dac",
"fixed": false
},
{
"gpio": -1,
"name": "mute",
"group": "dac",
"fixed": false
},
{
"gpio": 17,
"name": "clk",
"group": "psram",
"fixed": true
},
{
"gpio": 16,
"name": "cs",
"group": "psram",
"fixed": true
},
{
"gpio": 7,
"name": "spiq_sd0_io",
"group": "psram",
"fixed": true
},
{
"gpio": 8,
"name": "spid_sd1_io",
"group": "psram",
"fixed": true
},
{
"gpio": 10,
"name": "spiwp_sd3_io",
"group": "psram",
"fixed": true
},
{
"gpio": 9,
"name": "spihd_sd2_io",
"group": "psram",
"fixed": true
},
{
"gpio": 6,
"name": "clk",
"group": "flash",
"fixed": true
},
{
"gpio": 11,
"name": "cs",
"group": "flash",
"fixed": true
}
],
"config": {
"a2dp_sink_name": {
"type": 33,
"value": "SMSL BT4.2",
"chg": false
},
"a2dp_ctmt": {
"type": 33,
"value": "1000",
"chg": false
},
"a2dp_ctrld": {
"type": 33,
"value": "500",
"chg": false
},
"bt_sink_pin": {
"type": 33,
"value": "1234",
"chg": false
},
"release_url": {
"type": 33,
"value": "https://github.com/sle118/squeezelite-esp32/releases",
"chg": false
},
"ap_ip_address": {
"type": 33,
"value": "192.168.4.1",
"chg": false
},
"ap_ip_gateway": {
"type": 33,
"value": "192.168.4.1",
"chg": false
},
"ap_ip_netmask": {
"type": 33,
"value": "255.255.255.0",
"chg": false
},
"ap_channel": {
"type": 33,
"value": "1",
"chg": false
},
"ap_pwd": {
"type": 33,
"value": "squeezelite",
"chg": false
},
"airplay_port": {
"type": 33,
"value": "5000",
"chg": false
},
"bypass_wm": {
"type": 33,
"value": "0",
"chg": false
},
"actrls_config": {
"type": 33,
"value": "",
"chg": false
},
"lms_ctrls_raw": {
"type": 33,
"value": "n",
"chg": false
},
"rotary_config": {
"type": 33,
"value": "",
"chg": false
},
"ota_erase_blk": {
"type": 33,
"value": "249856",
"chg": false
},
"ota_stack": {
"type": 33,
"value": "10240",
"chg": false
},
"ota_prio": {
"type": 33,
"value": "6",
"chg": false
},
"display_config": {
"type": 33,
"value": "",
"chg": false
},
"i2c_config": {
"type": 33,
"value": "",
"chg": false
},
"spi_config": {
"type": 33,
"value": "",
"chg": false
},
"set_GPIO": {
"type": 33,
"value": "",
"chg": false
},
"led_brightness": {
"type": 33,
"value": "",
"chg": false
},
"dac_config": {
"type": 33,
"value": "",
"chg": false
},
"dac_controlset": {
"type": 33,
"value": "",
"chg": false
},
"jack_mutes_amp": {
"type": 33,
"value": "n",
"chg": false
},
"bat_config": {
"type": 33,
"value": "",
"chg": false
},
"metadata_config": {
"type": 33,
"value": "",
"chg": false
},
"telnet_buffer": {
"type": 33,
"value": "40000",
"chg": false
},
"telnet_block": {
"type": 33,
"value": "500",
"chg": false
},
"spdif_config": {
"type": 33,
"value": "bck=33,ws=25,do=15",
"chg": false
},
"enable_bt_sink": {
"type": 33,
"value": "N",
"chg": false
},
"enable_airplay": {
"type": 33,
"value": "N",
"chg": false
},
"wifi_smode": {
"type": 33,
"value": "a",
"chg": false
},
"disable_ps": {
"type": 33,
"value": "n",
"chg": false
},
"stats": {
"type": 33,
"value": "Y",
"chg": false
},
"autoexec": {
"type": 33,
"value": "1",
"chg": false
},
"autoexec1_spdif": {
"type": 33,
"value": "squeezelite -b 500:2000 -d all=info -C 30 -W -n \"squeezelite-test3\" -o SPDIF -Z 192000",
"chg": false
},
"autoexec1_i2s": {
"type": 33,
"value": "squeezelite -b 500:2000 -d all=info -C 30 -W -n \"squeezelite-test3\" -o I2S",
"chg": false
},
"autoexec1_bt": {
"type": 33,
"value": "squeezelite -b 500:2000 -d all=info -C 30 -W -n \"squeezelite-test3\" -o \"BT -n 'test'\" -Z 192000",
"chg": false
},
"autoexec1": {
"type": 33,
"value": "squeezelite -b 500:2000 -d all=info -C 30 -W -n \"squeezelite-test3\" -o \"BT -n 'test'\" -Z 192000",
"chg": false
},
"bt_name": {
"type": 33,
"value": "squeezelite-test3",
"chg": false
},
"host_name": {
"type": 33,
"value": "squeezelite-test3",
"chg": false
},
"airplay_name": {
"type": 33,
"value": "squeezelite-test3",
"chg": false
},
"ap_ssid": {
"type": 33,
"value": "squeezelite-test3",
"chg": false
},
"a2dp_dev_name": {
"type": 33,
"value": "squeezelite-test3",
"chg": false
},
"telnet_enable": {
"type": 33,
"value": "D",
"chg": false
}
}
}

View File

@@ -53,6 +53,7 @@ function to process requests, decode URLs, serve files, etc. etc.
#include "esp_console.h"
#include "argtable3/argtable3.h"
#include "platform_console.h"
#include "accessors.h"
#define HTTP_STACK_SIZE (5*1024)
const char str_na[]="N/A";
@@ -88,18 +89,18 @@ static const char redirect_payload3[]="'>here</a> to login.</p></body></html>";
* @see file "component.mk"
* @see https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html#embedding-binary-data
*/
extern const uint8_t style_css_start[] asm("_binary_style_css_start");
extern const uint8_t style_css_end[] asm("_binary_style_css_end");
extern const uint8_t jquery_gz_start[] asm("_binary_jquery_min_js_gz_start");
extern const uint8_t jquery_gz_end[] asm("_binary_jquery_min_js_gz_end");
extern const uint8_t popper_gz_start[] asm("_binary_popper_min_js_gz_start");
extern const uint8_t popper_gz_end[] asm("_binary_popper_min_js_gz_end");
extern const uint8_t bootstrap_js_gz_start[] asm("_binary_bootstrap_min_js_gz_start");
extern const uint8_t bootstrap_js_gz_end[] asm("_binary_bootstrap_min_js_gz_end");
extern const uint8_t bootstrap_css_gz_start[] asm("_binary_bootstrap_min_css_gz_start");
extern const uint8_t bootstrap_css_gz_end[] asm("_binary_bootstrap_min_css_gz_end");
extern const uint8_t code_js_start[] asm("_binary_code_js_start");
extern const uint8_t code_js_end[] asm("_binary_code_js_end");
extern const uint8_t style_css_start[] asm("_binary_style_css_gz_start");
extern const uint8_t style_css_end[] asm("_binary_style_css_gz_end");
extern const uint8_t jquery_gz_start[] asm("_binary_jquery_js_gz_start");
extern const uint8_t jquery_gz_end[] asm("_binary_jquery_js_gz_end");
// extern const uint8_t popper_gz_start[] asm("_binary_popper_min_js_gz_start");
// extern const uint8_t popper_gz_end[] asm("_binary_popper_min_js_gz_end");
extern const uint8_t bootstrap_js_gz_start[] asm("_binary_bootstrap_js_gz_start");
extern const uint8_t bootstrap_js_gz_end[] asm("_binary_bootstrap_js_gz_end");
extern const uint8_t bootstrap_css_gz_start[] asm("_binary_bootstrap_css_gz_start");
extern const uint8_t bootstrap_css_gz_end[] asm("_binary_bootstrap_css_gz_end");
extern const uint8_t code_js_start[] asm("_binary_code_js_gz_start");
extern const uint8_t code_js_end[] asm("_binary_code_js_gz_end");
extern const uint8_t index_html_start[] asm("_binary_index_html_start");
extern const uint8_t index_html_end[] asm("_binary_index_html_end");
extern const uint8_t favicon_ico_start[] asm("_binary_favicon_ico_start");
@@ -231,31 +232,31 @@ bool is_captive_portal_host_name(httpd_req_t *req){
/* Custom function to free context */
void free_ctx_func(void *ctx)
{
START_FREE_MEM_CHECK(ff);
session_context_t * context = (session_context_t *)ctx;
if(context){
ESP_LOGD(TAG, "Freeing up socket context");
FREE_AND_NULL(context->auth_token);
FREE_AND_NULL(context->sess_ip_address);
free(context);
CHECK_RESET_FREE_MEM_CHECK(ff,"free_ctx");
}
}
session_context_t* get_session_context(httpd_req_t *req){
START_FREE_MEM_CHECK(ff);
bool newConnection=false;
if (! req->sess_ctx) {
ESP_LOGD(TAG,"New connection context. Allocating session buffer");
req->sess_ctx = malloc(sizeof(session_context_t));
memset(req->sess_ctx,0x00,sizeof(session_context_t));
req->free_ctx = free_ctx_func;
newConnection = true;
// get the remote IP address only once per session
}
session_context_t *ctx_data = (session_context_t*)req->sess_ctx;
FREE_AND_NULL(ctx_data->sess_ip_address);
ctx_data->sess_ip_address = http_alloc_get_socket_address(req, 0, &ctx_data->port);
ESP_LOGD_LOC(TAG, "serving %s to peer %s port %u", req->uri, ctx_data->sess_ip_address , ctx_data->port);
CHECK_RESET_FREE_MEM_CHECK(ff,"get sess context");
if(newConnection){
ESP_LOGI(TAG, "serving %s to peer %s port %u", req->uri, ctx_data->sess_ip_address , ctx_data->port);
}
return (session_context_t *)req->sess_ctx;
}
@@ -407,11 +408,13 @@ esp_err_t resource_filehandler(httpd_req_t *req){
}
if(strstr(filename, "code.js")) {
const size_t file_size = (code_js_end - code_js_start);
set_content_type_from_file(req, filename);
httpd_resp_set_hdr(req, "Content-Encoding", "gzip");
const size_t file_size = (code_js_end - code_js_start);
httpd_resp_send(req, (const char *)code_js_start, file_size);
} else if(strstr(filename, "style.css")) {
set_content_type_from_file(req, filename);
httpd_resp_set_hdr(req, "Content-Encoding", "gzip");
const size_t file_size = (style_css_end - style_css_start);
httpd_resp_send(req, (const char *)style_css_start, file_size);
} else if(strstr(filename, "favicon.ico")) {
@@ -423,11 +426,11 @@ esp_err_t resource_filehandler(httpd_req_t *req){
httpd_resp_set_hdr(req, "Content-Encoding", "gzip");
const size_t file_size = (jquery_gz_end - jquery_gz_start);
httpd_resp_send(req, (const char *)jquery_gz_start, file_size);
} else if(strstr(filename, "popper.js")) {
set_content_type_from_file(req, filename);
httpd_resp_set_hdr(req, "Content-Encoding", "gzip");
const size_t file_size = (popper_gz_end - popper_gz_start);
httpd_resp_send(req, (const char *)popper_gz_start, file_size);
// } else if(strstr(filename, "popper.js")) {
// set_content_type_from_file(req, filename);
// httpd_resp_set_hdr(req, "Content-Encoding", "gzip");
// const size_t file_size = (popper_gz_end - popper_gz_start);
// httpd_resp_send(req, (const char *)popper_gz_start, file_size);
} else if(strstr(filename, "bootstrap.js")) {
set_content_type_from_file(req, filename);
httpd_resp_set_hdr(req, "Content-Encoding", "gzip");
@@ -486,7 +489,8 @@ esp_err_t console_cmd_get_handler(httpd_req_t *req){
return err;
}
esp_err_t console_cmd_post_handler(httpd_req_t *req){
char success[]="{}";
char success[]="{\"Result\" : \"Success\" }";
char failed[]="{\"Result\" : \"Failed\" }";
ESP_LOGD_LOC(TAG, "serving [%s]", req->uri);
//bool bOTA=false;
//char * otaURL=NULL;
@@ -521,14 +525,18 @@ esp_err_t console_cmd_post_handler(httpd_req_t *req){
ESP_LOGE_LOC(TAG, "Command not found. Received content was: %s",command);
httpd_resp_send_err(req, HTTPD_400_BAD_REQUEST, "Malformed command json. Unable to parse content.");
err = ESP_FAIL;
}
else{
// navigate to the first child of the config structure
run_command(cJSON_GetStringValue(item));
if(run_command(cJSON_GetStringValue(item))!=ESP_OK){
httpd_resp_send(req, (const char *)failed, strlen(failed));
}
else {
httpd_resp_send(req, (const char *)success, strlen(success));
}
}
httpd_resp_send(req, (const char *)success, strlen(success));
ESP_LOGD_LOC(TAG, "done serving [%s]", req->uri);
return err;
}
@@ -576,7 +584,15 @@ esp_err_t config_get_handler(httpd_req_t *req){
}
else {
ESP_LOGD_LOC(TAG, "config json : %s",json );
httpd_resp_send(req, (const char *)json, HTTPD_RESP_USE_STRLEN);
cJSON * gplist=get_gpio_list();
char * gpliststr=cJSON_PrintUnformatted(gplist);
httpd_resp_sendstr_chunk(req,"{ \"gpio\":");
httpd_resp_sendstr_chunk(req,gpliststr);
httpd_resp_sendstr_chunk(req,", \"config\":");
httpd_resp_sendstr_chunk(req, (const char *)json);
httpd_resp_sendstr_chunk(req,"}");
httpd_resp_sendstr_chunk(req,NULL);
free(gpliststr);
free(json);
}
}
@@ -721,6 +737,7 @@ esp_err_t config_post_handler(httpd_req_t *req){
if(err==ESP_OK){
httpd_resp_sendstr(req, "{ \"result\" : \"OK\" }");
messaging_post_message(MESSAGING_INFO,MESSAGING_CLASS_SYSTEM,"Save Success");
}
cJSON_Delete(root);
if(bOTA) {
@@ -1031,7 +1048,11 @@ esp_err_t redirect_processor(httpd_req_t *req, httpd_err_code_t error){
bool connected_to_sta_ip_interface = false;
bool useragentiscaptivenetwork = false;
ESP_LOGW_LOC(TAG, "Invalid URL requested: [%s]", req->uri);
in_port_t port=0;
ESP_LOGV_LOC(TAG, "Getting remote socket address");
remote_ip = http_alloc_get_socket_address(req,0, &port);
ESP_LOGW_LOC(TAG, "%s requested invalid URL: [%s]",remote_ip, req->uri);
if(wifi_manager_lock_sta_ip_string(portMAX_DELAY)){
sta_ip_address = strdup(wifi_manager_get_sta_ip_string());
wifi_manager_unlock_sta_ip_string();
@@ -1041,9 +1062,6 @@ esp_err_t redirect_processor(httpd_req_t *req, httpd_err_code_t error){
httpd_resp_send_err(req, HTTPD_500_INTERNAL_SERVER_ERROR , NULL);
}
in_port_t port=0;
ESP_LOGV_LOC(TAG, "Getting remote socket address");
remote_ip = http_alloc_get_socket_address(req,0, &port);
ESP_LOGV_LOC(TAG, "Getting host name from request");
char *req_host = alloc_get_http_header(req, "Host");
@@ -1118,34 +1136,24 @@ esp_err_t redirect_ev_handler(httpd_req_t *req){
esp_err_t messages_get_handler(httpd_req_t *req){
ESP_LOGD_LOC(TAG, "serving [%s]", req->uri);
START_FREE_MEM_CHECK(before);
START_FREE_MEM_CHECK(all);
if(!is_user_authenticated(req)){
// todo: redirect to login page
// return ESP_OK;
}
CHECK_RESET_FREE_MEM_CHECK(before, "after user auth");
esp_err_t err = set_content_type_from_req(req);
if(err != ESP_OK){
return err;
}
CHECK_RESET_FREE_MEM_CHECK(before, "after set_content_type");
cJSON * json_messages= messaging_retrieve_messages(messaging);
CHECK_RESET_FREE_MEM_CHECK(before, "after receiving messages");
if(json_messages!=NULL){
char * json_text= cJSON_Print(json_messages);
CHECK_RESET_FREE_MEM_CHECK(before, "after json print");
httpd_resp_send(req, (const char *)json_text, strlen(json_text));
CHECK_RESET_FREE_MEM_CHECK(before, "after http send");
free(json_text);
CHECK_RESET_FREE_MEM_CHECK(before, "after free json message");
cJSON_Delete(json_messages);
CHECK_RESET_FREE_MEM_CHECK(before, "after free json");
}
else {
httpd_resp_send_err(req, HTTPD_500_INTERNAL_SERVER_ERROR , "Unable to retrieve messages");
}
CHECK_RESET_FREE_MEM_CHECK(all, "before returning");
return ESP_OK;
}

View File

@@ -0,0 +1,414 @@
<!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="stylesheet" href="/res/bootstrap.css">
<script src="/res/jquery.js"></script>
<link rel="shortcut icon" type="image/x-icon" href="/res/favicon.ico">
<link rel="stylesheet" href="/res/style.css">
<!-- <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 class="nav nav-tabs bg-primary" id="mainnav">
<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-configuration">Configuration</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#tab-syslog">Status<span class="badge badge-success badge-pill" id="msgcnt"></span></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-credits">Credits</a>
</li>
</ul>
<div id="message"></div>
<div id="content" >
<div id="myTabContent" class="tab-content mt-3">
<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>
<!-- Config -->
<div class="tab-pane fade mt-2" id="tab-configuration">
<ul class="nav nav-tabs bg-info" name="secnav">
<li class="nav-link" style="padding: inherit; border: none;">
<a class="nav-link active" data-toggle="tab" href="#tab-cfg-audio">Audio</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#tab-cfg-syst">System</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#tab-cfg-hw" >Hardware</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#tab-cfg-fw" >Updates</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#tab-nvs">NVS editor</a>
</li>
</ul>
<div id="myTabContent2" class="tab-content mt-3">
<div class="tab-pane fade" id="tab-cfg-hw"></div>
<div class="tab-pane fade" id="tab-cfg-syst"></div>
<div class="tab-pane fade" id="tab-cfg-gen"></div>
<div class="tab-pane fade" id="tab-cfg-fw">
<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>
<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>
<div class="tab-pane fade active show" id="tab-cfg-audio">
<div class="card text-white bg-primary mb-3">
<div class="card-header">Usage Templates</div>
<div class="card-body">
<fieldset >
<fieldset class="form-group" id="output-tmpl">
<legend>Output</legend>
<div class="form-check">
<label class="form-check-label">
<input type="radio" class="form-check-input" name="output-tmpl" id="i2s" >
I2S Dac
</label>
</div>
<div class="form-check">
<label class="form-check-label">
<input type="radio" class="form-check-input" name="output-tmpl" id="spdif" >
SPDIF
</label>
</div>
<div class="form-check">
<label class="form-check-label">
<input type="radio" class="form-check-input" name="output-tmpl" id="bt" >
Bluetooth
</label>
</div>
</fieldset>
<div class="form-group"><label for="player">Player Name</label><input type="text" class="form-control " placeholder="Squeezelite" id="player" ></div>
<div class="form-group" style="display: none;"><label for="btsinkdiv">Bluetooth Speaker Name To Connect To</label><input type="text" class="form-control" id="btsinkdiv" ></div>
<div class="form-group"><label for="optional">Optional setting (e.g. for LMS IP address)</label><input type="text" class="form-control" id="optional" ></div>
<div class="form-group"><div class="form-check">
<label class="form-check-label">
<input class="form-check-input" type="checkbox" id="disable-squeezelite" value="" checked="" >
Disable Squeezelite
</label>
</div></div>
<div class="toast show" role="alert" aria-live="assertive" aria-atomic="true" style="display: none;" id="toast_cfg-audio-tmpl"><div class="toast-header"><strong class="mr-auto">Result</strong><button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close" onclick="$(this).parent().parent().hide()"><span aria-hidden="true">×</span></button></div><div class="toast-body" id="msg_cfg-audio-tmpl"></div></div>
<button id="save-autoexec1" type="submit" class="btn btn-info" cmdname="cfg-audio-tmpl" onclick="save_autoexec1(false)">Save</button>
<button id="commit-autoexec1" type="submit" class="btn btn-warning" cmdname="cfg-audio-tmpl" onclick="save_autoexec1(true)">Apply</button>
</fieldset>
</div>
</div>
</div>
</div>
</div>
<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" >
<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">
<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 class="card border-primary mb-3" style="visibility: collapse;" id="tasks_sect">
<div class="card-header">Tasks</div>
<div class="card-body">
<table class="table table-hover">
<!-- console.log(msg_time.toLocaleString() + '\tname' + '\tcpu' + '\tstate' + '\tminstk' + '\tbprio' + '\tcprio' + '\tnum'); -->
<thead><tr><th scope="col">#</th><th scope="col">Task Name</th><th scope="col">CPU</th><th scope="col">State</th><th scope="col">Min Stack</th><th scope="col">Base Priority</th><th scope="col">Cur Priority</th></tr></thead>
<tbody id="tasks"></tbody></table></div></div>
</div>
<!-- syslog -->
<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>, &copy; 2020, philippe44, sle118, daduke<br /><a href="https://opensource.org/licenses/MIT">This software is released under the MIT License.</a></p>
<p>
This app would not be possible without the following libraries:
</p>
<ul>
<li>squeezelite, &copy; 2012-2019, Adrian Smith and Ralph Irving. Licensed under the GPL License.</li>
<li>esp32-wifi-manager, &copy; 2017-2019, Tony Pottier. Licensed under the MIT License.</li>
<li>SpinKit, &copy; 2015, Tobias Ahlin. Licensed under the MIT License.</li>
<li>jQuery, The jQuery Foundation. Licensed under the MIT License.</li>
<li>cJSON, &copy; 2009-2017, Dave Gamble and cJSON contributors. Licensed under the MIT License.</li>
<li>esp32-rotary-encoder, &copy; 2011-2019, David Antliff and Ben Buxton. Licensed under the GPL License.</li>
<li>tarablessd1306, &copy; 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">
<button class="btn-warning" id="reboot_nav" type="submit" onclick="$('#reboot_nav').removeClass('active'); delay_reboot(500,'', false);" style="display: none;">Reboot</button>
<button class="btn-danger" id="reboot_ota_nav" type="submit" onclick="$('#reboot_ota_nav').removeClass('active'); delay_reboot(500,'', true);" style="display: none;">Exit Recovery</button><br>
<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

View File

@@ -1,29 +0,0 @@
/*
Copyright (c) 2017-2019 Tony Pottier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
@file main.c
@author Tony Pottier
@brief Entry point for the ESP32 application.
@see https://idyl.io
@see https://github.com/tonyp7/esp32-wifi-manager
*/

View File

@@ -0,0 +1,56 @@
[{
"message": "{\"free_iram\":190232,\"min_free_iram\":184520,\"free_spiram\":4048492,\"min_free_spiram\":4026220,\"ntasks\":13,\"tasks\":[{\"cpu\":0,\"minstk\":400,\"bprio\":1,\"cprio\":1,\"nme\":\"Tmr Svc\",\"st\":1,\"num\":8},{\"cpu\":99,\"minstk\":1000,\"bprio\":0,\"cprio\":0,\"nme\":\"IDLE1\",\"st\":1,\"num\":7},{\"cpu\":97,\"minstk\":992,\"bprio\":0,\"cprio\":0,\"nme\":\"IDLE0\",\"st\":1,\"num\":6},{\"cpu\":0,\"minstk\":2184,\"bprio\":18,\"cprio\":18,\"nme\":\"tiT\",\"st\":2,\"num\":12},{\"cpu\":0,\"minstk\":536,\"bprio\":24,\"cprio\":24,\"nme\":\"ipc1\",\"st\":2,\"num\":3},{\"cpu\":0,\"minstk\":7244,\"bprio\":1,\"cprio\":1,\"nme\":\"telnet\",\"st\":2,\"num\":17},{\"cpu\":0,\"minstk\":1948,\"bprio\":5,\"cprio\":5,\"nme\":\"console\",\"st\":2,\"num\":18},{\"cpu\":0,\"minstk\":528,\"bprio\":24,\"cprio\":24,\"nme\":\"ipc0\",\"st\":2,\"num\":2},{\"cpu\":0,\"minstk\":1580,\"bprio\":5,\"cprio\":5,\"nme\":\"httpd\",\"st\":2,\"num\":16},{\"cpu\":0,\"minstk\":3468,\"bprio\":22,\"cprio\":22,\"nme\":\"esp_timer\",\"st\":2,\"num\":1},{\"cpu\":2,\"minstk\":868,\"bprio\":23,\"cprio\":23,\"nme\":\"wifi\",\"st\":2,\"num\":14},{\"cpu\":0,\"minstk\":708,\"bprio\":20,\"cprio\":20,\"nme\":\"sys_evt\",\"st\":2,\"num\":13},{\"cpu\":0,\"minstk\":2096,\"bprio\":5,\"cprio\":5,\"nme\":\"wifi_manager\",\"st\":2,\"num\":15}]}",
"type": "MESSAGING_INFO",
"class": "MESSAGING_CLASS_STATS",
"sent_time": 61257,
"current_time": 147316
}, {
"message": "{\"free_iram\":190232,\"min_free_iram\":183992,\"free_spiram\":4048488,\"min_free_spiram\":4026220,\"ntasks\":13,\"tasks\":[{\"cpu\":0,\"minstk\":400,\"bprio\":1,\"cprio\":1,\"nme\":\"Tmr Svc\",\"st\":1,\"num\":8},{\"cpu\":99,\"minstk\":1000,\"bprio\":0,\"cprio\":0,\"nme\":\"IDLE1\",\"st\":1,\"num\":7},{\"cpu\":97,\"minstk\":992,\"bprio\":0,\"cprio\":0,\"nme\":\"IDLE0\",\"st\":1,\"num\":6},{\"cpu\":0,\"minstk\":2184,\"bprio\":18,\"cprio\":18,\"nme\":\"tiT\",\"st\":2,\"num\":12},{\"cpu\":0,\"minstk\":7244,\"bprio\":1,\"cprio\":1,\"nme\":\"telnet\",\"st\":2,\"num\":17},{\"cpu\":0,\"minstk\":1948,\"bprio\":5,\"cprio\":5,\"nme\":\"console\",\"st\":2,\"num\":18},{\"cpu\":0,\"minstk\":528,\"bprio\":24,\"cprio\":24,\"nme\":\"ipc0\",\"st\":2,\"num\":2},{\"cpu\":0,\"minstk\":1580,\"bprio\":5,\"cprio\":5,\"nme\":\"httpd\",\"st\":2,\"num\":16},{\"cpu\":0,\"minstk\":708,\"bprio\":20,\"cprio\":20,\"nme\":\"sys_evt\",\"st\":2,\"num\":13},{\"cpu\":0,\"minstk\":3468,\"bprio\":22,\"cprio\":22,\"nme\":\"esp_timer\",\"st\":2,\"num\":1},{\"cpu\":1,\"minstk\":868,\"bprio\":23,\"cprio\":23,\"nme\":\"wifi\",\"st\":2,\"num\":14},{\"cpu\":0,\"minstk\":2096,\"bprio\":5,\"cprio\":5,\"nme\":\"wifi_manager\",\"st\":2,\"num\":15},{\"cpu\":0,\"minstk\":536,\"bprio\":24,\"cprio\":24,\"nme\":\"ipc1\",\"st\":2,\"num\":3}]}",
"type": "MESSAGING_INFO",
"class": "MESSAGING_CLASS_STATS",
"sent_time": 71255,
"current_time": 147317
}, {
"message": "{\"free_iram\":190232,\"min_free_iram\":183992,\"free_spiram\":4048492,\"min_free_spiram\":4026220,\"ntasks\":13,\"tasks\":[{\"cpu\":0,\"minstk\":400,\"bprio\":1,\"cprio\":1,\"nme\":\"Tmr Svc\",\"st\":1,\"num\":8},{\"cpu\":99,\"minstk\":1000,\"bprio\":0,\"cprio\":0,\"nme\":\"IDLE1\",\"st\":1,\"num\":7},{\"cpu\":97,\"minstk\":992,\"bprio\":0,\"cprio\":0,\"nme\":\"IDLE0\",\"st\":1,\"num\":6},{\"cpu\":0,\"minstk\":2184,\"bprio\":18,\"cprio\":18,\"nme\":\"tiT\",\"st\":2,\"num\":12},{\"cpu\":0,\"minstk\":1948,\"bprio\":5,\"cprio\":5,\"nme\":\"console\",\"st\":2,\"num\":18},{\"cpu\":0,\"minstk\":528,\"bprio\":24,\"cprio\":24,\"nme\":\"ipc0\",\"st\":2,\"num\":2},{\"cpu\":0,\"minstk\":1580,\"bprio\":5,\"cprio\":5,\"nme\":\"httpd\",\"st\":2,\"num\":16},{\"cpu\":0,\"minstk\":708,\"bprio\":20,\"cprio\":20,\"nme\":\"sys_evt\",\"st\":2,\"num\":13},{\"cpu\":0,\"minstk\":2096,\"bprio\":5,\"cprio\":5,\"nme\":\"wifi_manager\",\"st\":2,\"num\":15},{\"cpu\":0,\"minstk\":3436,\"bprio\":22,\"cprio\":22,\"nme\":\"esp_timer\",\"st\":2,\"num\":1},{\"cpu\":1,\"minstk\":868,\"bprio\":23,\"cprio\":23,\"nme\":\"wifi\",\"st\":2,\"num\":14},{\"cpu\":0,\"minstk\":536,\"bprio\":24,\"cprio\":24,\"nme\":\"ipc1\",\"st\":2,\"num\":3},{\"cpu\":0,\"minstk\":7244,\"bprio\":1,\"cprio\":1,\"nme\":\"telnet\",\"st\":2,\"num\":17}]}",
"type": "MESSAGING_INFO",
"class": "MESSAGING_CLASS_STATS",
"sent_time": 81256,
"current_time": 147317
}, {
"message": "{\"free_iram\":190232,\"min_free_iram\":183992,\"free_spiram\":4048488,\"min_free_spiram\":4026220,\"ntasks\":13,\"tasks\":[{\"cpu\":0,\"minstk\":400,\"bprio\":1,\"cprio\":1,\"nme\":\"Tmr Svc\",\"st\":1,\"num\":8},{\"cpu\":99,\"minstk\":1000,\"bprio\":0,\"cprio\":0,\"nme\":\"IDLE1\",\"st\":1,\"num\":7},{\"cpu\":97,\"minstk\":992,\"bprio\":0,\"cprio\":0,\"nme\":\"IDLE0\",\"st\":1,\"num\":6},{\"cpu\":0,\"minstk\":2184,\"bprio\":18,\"cprio\":18,\"nme\":\"tiT\",\"st\":2,\"num\":12},{\"cpu\":0,\"minstk\":528,\"bprio\":24,\"cprio\":24,\"nme\":\"ipc0\",\"st\":2,\"num\":2},{\"cpu\":0,\"minstk\":1580,\"bprio\":5,\"cprio\":5,\"nme\":\"httpd\",\"st\":2,\"num\":16},{\"cpu\":0,\"minstk\":708,\"bprio\":20,\"cprio\":20,\"nme\":\"sys_evt\",\"st\":2,\"num\":13},{\"cpu\":0,\"minstk\":2096,\"bprio\":5,\"cprio\":5,\"nme\":\"wifi_manager\",\"st\":2,\"num\":15},{\"cpu\":0,\"minstk\":536,\"bprio\":24,\"cprio\":24,\"nme\":\"ipc1\",\"st\":2,\"num\":3},{\"cpu\":0,\"minstk\":3436,\"bprio\":22,\"cprio\":22,\"nme\":\"esp_timer\",\"st\":2,\"num\":1},{\"cpu\":1,\"minstk\":868,\"bprio\":23,\"cprio\":23,\"nme\":\"wifi\",\"st\":2,\"num\":14},{\"cpu\":0,\"minstk\":7244,\"bprio\":1,\"cprio\":1,\"nme\":\"telnet\",\"st\":2,\"num\":17},{\"cpu\":0,\"minstk\":1948,\"bprio\":5,\"cprio\":5,\"nme\":\"console\",\"st\":2,\"num\":18}]}",
"type": "MESSAGING_INFO",
"class": "MESSAGING_CLASS_STATS",
"sent_time": 91255,
"current_time": 147317
}, {
"message": "{\"free_iram\":190232,\"min_free_iram\":183992,\"free_spiram\":4048492,\"min_free_spiram\":4026220,\"ntasks\":13,\"tasks\":[{\"cpu\":0,\"minstk\":400,\"bprio\":1,\"cprio\":1,\"nme\":\"Tmr Svc\",\"st\":1,\"num\":8},{\"cpu\":99,\"minstk\":1000,\"bprio\":0,\"cprio\":0,\"nme\":\"IDLE1\",\"st\":1,\"num\":7},{\"cpu\":97,\"minstk\":992,\"bprio\":0,\"cprio\":0,\"nme\":\"IDLE0\",\"st\":1,\"num\":6},{\"cpu\":0,\"minstk\":2184,\"bprio\":18,\"cprio\":18,\"nme\":\"tiT\",\"st\":2,\"num\":12},{\"cpu\":0,\"minstk\":1580,\"bprio\":5,\"cprio\":5,\"nme\":\"httpd\",\"st\":2,\"num\":16},{\"cpu\":0,\"minstk\":708,\"bprio\":20,\"cprio\":20,\"nme\":\"sys_evt\",\"st\":2,\"num\":13},{\"cpu\":0,\"minstk\":2096,\"bprio\":5,\"cprio\":5,\"nme\":\"wifi_manager\",\"st\":2,\"num\":15},{\"cpu\":0,\"minstk\":536,\"bprio\":24,\"cprio\":24,\"nme\":\"ipc1\",\"st\":2,\"num\":3},{\"cpu\":0,\"minstk\":7244,\"bprio\":1,\"cprio\":1,\"nme\":\"telnet\",\"st\":2,\"num\":17},{\"cpu\":0,\"minstk\":3436,\"bprio\":22,\"cprio\":22,\"nme\":\"esp_timer\",\"st\":2,\"num\":1},{\"cpu\":1,\"minstk\":868,\"bprio\":23,\"cprio\":23,\"nme\":\"wifi\",\"st\":2,\"num\":14},{\"cpu\":0,\"minstk\":1948,\"bprio\":5,\"cprio\":5,\"nme\":\"console\",\"st\":2,\"num\":18},{\"cpu\":0,\"minstk\":528,\"bprio\":24,\"cprio\":24,\"nme\":\"ipc0\",\"st\":2,\"num\":2}]}",
"type": "MESSAGING_INFO",
"class": "MESSAGING_CLASS_STATS",
"sent_time": 101255,
"current_time": 147317
}, {
"message": "{\"free_iram\":190232,\"min_free_iram\":183992,\"free_spiram\":4048488,\"min_free_spiram\":4026220,\"ntasks\":13,\"tasks\":[{\"cpu\":0,\"minstk\":400,\"bprio\":1,\"cprio\":1,\"nme\":\"Tmr Svc\",\"st\":1,\"num\":8},{\"cpu\":99,\"minstk\":1000,\"bprio\":0,\"cprio\":0,\"nme\":\"IDLE1\",\"st\":1,\"num\":7},{\"cpu\":98,\"minstk\":992,\"bprio\":0,\"cprio\":0,\"nme\":\"IDLE0\",\"st\":1,\"num\":6},{\"cpu\":0,\"minstk\":2184,\"bprio\":18,\"cprio\":18,\"nme\":\"tiT\",\"st\":2,\"num\":12},{\"cpu\":0,\"minstk\":708,\"bprio\":20,\"cprio\":20,\"nme\":\"sys_evt\",\"st\":2,\"num\":13},{\"cpu\":0,\"minstk\":2096,\"bprio\":5,\"cprio\":5,\"nme\":\"wifi_manager\",\"st\":2,\"num\":15},{\"cpu\":0,\"minstk\":536,\"bprio\":24,\"cprio\":24,\"nme\":\"ipc1\",\"st\":2,\"num\":3},{\"cpu\":0,\"minstk\":7244,\"bprio\":1,\"cprio\":1,\"nme\":\"telnet\",\"st\":2,\"num\":17},{\"cpu\":0,\"minstk\":1948,\"bprio\":5,\"cprio\":5,\"nme\":\"console\",\"st\":2,\"num\":18},{\"cpu\":0,\"minstk\":3436,\"bprio\":22,\"cprio\":22,\"nme\":\"esp_timer\",\"st\":2,\"num\":1},{\"cpu\":1,\"minstk\":868,\"bprio\":23,\"cprio\":23,\"nme\":\"wifi\",\"st\":2,\"num\":14},{\"cpu\":0,\"minstk\":528,\"bprio\":24,\"cprio\":24,\"nme\":\"ipc0\",\"st\":2,\"num\":2},{\"cpu\":0,\"minstk\":1580,\"bprio\":5,\"cprio\":5,\"nme\":\"httpd\",\"st\":2,\"num\":16}]}",
"type": "MESSAGING_INFO",
"class": "MESSAGING_CLASS_STATS",
"sent_time": 111255,
"current_time": 147318
}, {
"message": "{\"free_iram\":190232,\"min_free_iram\":183992,\"free_spiram\":4048492,\"min_free_spiram\":4026220,\"ntasks\":13,\"tasks\":[{\"cpu\":0,\"minstk\":400,\"bprio\":1,\"cprio\":1,\"nme\":\"Tmr Svc\",\"st\":1,\"num\":8},{\"cpu\":99,\"minstk\":1000,\"bprio\":0,\"cprio\":0,\"nme\":\"IDLE1\",\"st\":1,\"num\":7},{\"cpu\":97,\"minstk\":992,\"bprio\":0,\"cprio\":0,\"nme\":\"IDLE0\",\"st\":1,\"num\":6},{\"cpu\":0,\"minstk\":2184,\"bprio\":18,\"cprio\":18,\"nme\":\"tiT\",\"st\":2,\"num\":12},{\"cpu\":0,\"minstk\":2096,\"bprio\":5,\"cprio\":5,\"nme\":\"wifi_manager\",\"st\":2,\"num\":15},{\"cpu\":0,\"minstk\":536,\"bprio\":24,\"cprio\":24,\"nme\":\"ipc1\",\"st\":2,\"num\":3},{\"cpu\":0,\"minstk\":7244,\"bprio\":1,\"cprio\":1,\"nme\":\"telnet\",\"st\":2,\"num\":17},{\"cpu\":0,\"minstk\":1948,\"bprio\":5,\"cprio\":5,\"nme\":\"console\",\"st\":2,\"num\":18},{\"cpu\":0,\"minstk\":528,\"bprio\":24,\"cprio\":24,\"nme\":\"ipc0\",\"st\":2,\"num\":2},{\"cpu\":0,\"minstk\":3436,\"bprio\":22,\"cprio\":22,\"nme\":\"esp_timer\",\"st\":2,\"num\":1},{\"cpu\":1,\"minstk\":868,\"bprio\":23,\"cprio\":23,\"nme\":\"wifi\",\"st\":2,\"num\":14},{\"cpu\":0,\"minstk\":1580,\"bprio\":5,\"cprio\":5,\"nme\":\"httpd\",\"st\":2,\"num\":16},{\"cpu\":0,\"minstk\":708,\"bprio\":20,\"cprio\":20,\"nme\":\"sys_evt\",\"st\":2,\"num\":13}]}",
"type": "MESSAGING_INFO",
"class": "MESSAGING_CLASS_STATS",
"sent_time": 121256,
"current_time": 147318
}, {
"message": "{\"free_iram\":190232,\"min_free_iram\":183872,\"free_spiram\":4048488,\"min_free_spiram\":4026220,\"ntasks\":13,\"tasks\":[{\"cpu\":0,\"minstk\":400,\"bprio\":1,\"cprio\":1,\"nme\":\"Tmr Svc\",\"st\":1,\"num\":8},{\"cpu\":99,\"minstk\":1000,\"bprio\":0,\"cprio\":0,\"nme\":\"IDLE1\",\"st\":1,\"num\":7},{\"cpu\":97,\"minstk\":992,\"bprio\":0,\"cprio\":0,\"nme\":\"IDLE0\",\"st\":1,\"num\":6},{\"cpu\":0,\"minstk\":2184,\"bprio\":18,\"cprio\":18,\"nme\":\"tiT\",\"st\":2,\"num\":12},{\"cpu\":0,\"minstk\":536,\"bprio\":24,\"cprio\":24,\"nme\":\"ipc1\",\"st\":2,\"num\":3},{\"cpu\":0,\"minstk\":7244,\"bprio\":1,\"cprio\":1,\"nme\":\"telnet\",\"st\":2,\"num\":17},{\"cpu\":0,\"minstk\":1948,\"bprio\":5,\"cprio\":5,\"nme\":\"console\",\"st\":2,\"num\":18},{\"cpu\":0,\"minstk\":528,\"bprio\":24,\"cprio\":24,\"nme\":\"ipc0\",\"st\":2,\"num\":2},{\"cpu\":0,\"minstk\":1580,\"bprio\":5,\"cprio\":5,\"nme\":\"httpd\",\"st\":2,\"num\":16},{\"cpu\":0,\"minstk\":3436,\"bprio\":22,\"cprio\":22,\"nme\":\"esp_timer\",\"st\":2,\"num\":1},{\"cpu\":1,\"minstk\":868,\"bprio\":23,\"cprio\":23,\"nme\":\"wifi\",\"st\":2,\"num\":14},{\"cpu\":0,\"minstk\":708,\"bprio\":20,\"cprio\":20,\"nme\":\"sys_evt\",\"st\":2,\"num\":13},{\"cpu\":0,\"minstk\":2096,\"bprio\":5,\"cprio\":5,\"nme\":\"wifi_manager\",\"st\":2,\"num\":15}]}",
"type": "MESSAGING_INFO",
"class": "MESSAGING_CLASS_STATS",
"sent_time": 131255,
"current_time": 147318
}, {
"message": "{\"free_iram\":190232,\"min_free_iram\":183872,\"free_spiram\":4048492,\"min_free_spiram\":4026220,\"ntasks\":13,\"tasks\":[{\"cpu\":0,\"minstk\":400,\"bprio\":1,\"cprio\":1,\"nme\":\"Tmr Svc\",\"st\":1,\"num\":8},{\"cpu\":99,\"minstk\":1000,\"bprio\":0,\"cprio\":0,\"nme\":\"IDLE1\",\"st\":1,\"num\":7},{\"cpu\":97,\"minstk\":992,\"bprio\":0,\"cprio\":0,\"nme\":\"IDLE0\",\"st\":1,\"num\":6},{\"cpu\":0,\"minstk\":2184,\"bprio\":18,\"cprio\":18,\"nme\":\"tiT\",\"st\":2,\"num\":12},{\"cpu\":0,\"minstk\":7244,\"bprio\":1,\"cprio\":1,\"nme\":\"telnet\",\"st\":2,\"num\":17},{\"cpu\":0,\"minstk\":1948,\"bprio\":5,\"cprio\":5,\"nme\":\"console\",\"st\":2,\"num\":18},{\"cpu\":0,\"minstk\":528,\"bprio\":24,\"cprio\":24,\"nme\":\"ipc0\",\"st\":2,\"num\":2},{\"cpu\":0,\"minstk\":1580,\"bprio\":5,\"cprio\":5,\"nme\":\"httpd\",\"st\":2,\"num\":16},{\"cpu\":0,\"minstk\":708,\"bprio\":20,\"cprio\":20,\"nme\":\"sys_evt\",\"st\":2,\"num\":13},{\"cpu\":0,\"minstk\":3436,\"bprio\":22,\"cprio\":22,\"nme\":\"esp_timer\",\"st\":2,\"num\":1},{\"cpu\":1,\"minstk\":868,\"bprio\":23,\"cprio\":23,\"nme\":\"wifi\",\"st\":2,\"num\":14},{\"cpu\":0,\"minstk\":2096,\"bprio\":5,\"cprio\":5,\"nme\":\"wifi_manager\",\"st\":2,\"num\":15},{\"cpu\":0,\"minstk\":536,\"bprio\":24,\"cprio\":24,\"nme\":\"ipc1\",\"st\":2,\"num\":3}]}",
"type": "MESSAGING_INFO",
"class": "MESSAGING_CLASS_STATS",
"sent_time": 141256,
"current_time": 147319
}
]

View File

@@ -0,0 +1,90 @@
[{
"message": "{\"free_iram\":190232,\"min_free_iram\":184520,\"free_spiram\":4048492,\"min_free_spiram\":4026220,\"ntasks\":13,\"tasks\":[{\"cpu\":0,\"minstk\":400,\"bprio\":1,\"cprio\":1,\"nme\":\"Tmr Svc\",\"st\":1,\"num\":8},{\"cpu\":99,\"minstk\":1000,\"bprio\":0,\"cprio\":0,\"nme\":\"IDLE1\",\"st\":1,\"num\":7},{\"cpu\":97,\"minstk\":992,\"bprio\":0,\"cprio\":0,\"nme\":\"IDLE0\",\"st\":1,\"num\":6},{\"cpu\":0,\"minstk\":2184,\"bprio\":18,\"cprio\":18,\"nme\":\"tiT\",\"st\":2,\"num\":12},{\"cpu\":0,\"minstk\":536,\"bprio\":24,\"cprio\":24,\"nme\":\"ipc1\",\"st\":2,\"num\":3},{\"cpu\":0,\"minstk\":7244,\"bprio\":1,\"cprio\":1,\"nme\":\"telnet\",\"st\":2,\"num\":17},{\"cpu\":0,\"minstk\":1948,\"bprio\":5,\"cprio\":5,\"nme\":\"console\",\"st\":2,\"num\":18},{\"cpu\":0,\"minstk\":528,\"bprio\":24,\"cprio\":24,\"nme\":\"ipc0\",\"st\":2,\"num\":2},{\"cpu\":0,\"minstk\":1580,\"bprio\":5,\"cprio\":5,\"nme\":\"httpd\",\"st\":2,\"num\":16},{\"cpu\":0,\"minstk\":3468,\"bprio\":22,\"cprio\":22,\"nme\":\"esp_timer\",\"st\":2,\"num\":1},{\"cpu\":2,\"minstk\":868,\"bprio\":23,\"cprio\":23,\"nme\":\"wifi\",\"st\":2,\"num\":14},{\"cpu\":0,\"minstk\":708,\"bprio\":20,\"cprio\":20,\"nme\":\"sys_evt\",\"st\":2,\"num\":13},{\"cpu\":0,\"minstk\":2096,\"bprio\":5,\"cprio\":5,\"nme\":\"wifi_manager\",\"st\":2,\"num\":15}]}",
"type": "MESSAGING_INFO",
"class": "MESSAGING_CLASS_STATS",
"sent_time": 61257,
"current_time": 147316
}, {
"message": "{\"free_iram\":190232,\"min_free_iram\":183992,\"free_spiram\":4048488,\"min_free_spiram\":4026220,\"ntasks\":13,\"tasks\":[{\"cpu\":0,\"minstk\":400,\"bprio\":1,\"cprio\":1,\"nme\":\"Tmr Svc\",\"st\":1,\"num\":8},{\"cpu\":99,\"minstk\":1000,\"bprio\":0,\"cprio\":0,\"nme\":\"IDLE1\",\"st\":1,\"num\":7},{\"cpu\":97,\"minstk\":992,\"bprio\":0,\"cprio\":0,\"nme\":\"IDLE0\",\"st\":1,\"num\":6},{\"cpu\":0,\"minstk\":2184,\"bprio\":18,\"cprio\":18,\"nme\":\"tiT\",\"st\":2,\"num\":12},{\"cpu\":0,\"minstk\":7244,\"bprio\":1,\"cprio\":1,\"nme\":\"telnet\",\"st\":2,\"num\":17},{\"cpu\":0,\"minstk\":1948,\"bprio\":5,\"cprio\":5,\"nme\":\"console\",\"st\":2,\"num\":18},{\"cpu\":0,\"minstk\":528,\"bprio\":24,\"cprio\":24,\"nme\":\"ipc0\",\"st\":2,\"num\":2},{\"cpu\":0,\"minstk\":1580,\"bprio\":5,\"cprio\":5,\"nme\":\"httpd\",\"st\":2,\"num\":16},{\"cpu\":0,\"minstk\":708,\"bprio\":20,\"cprio\":20,\"nme\":\"sys_evt\",\"st\":2,\"num\":13},{\"cpu\":0,\"minstk\":3468,\"bprio\":22,\"cprio\":22,\"nme\":\"esp_timer\",\"st\":2,\"num\":1},{\"cpu\":1,\"minstk\":868,\"bprio\":23,\"cprio\":23,\"nme\":\"wifi\",\"st\":2,\"num\":14},{\"cpu\":0,\"minstk\":2096,\"bprio\":5,\"cprio\":5,\"nme\":\"wifi_manager\",\"st\":2,\"num\":15},{\"cpu\":0,\"minstk\":536,\"bprio\":24,\"cprio\":24,\"nme\":\"ipc1\",\"st\":2,\"num\":3}]}",
"type": "MESSAGING_INFO",
"class": "MESSAGING_CLASS_STATS",
"sent_time": 71255,
"current_time": 147317
}, {
"message": "{\"free_iram\":190232,\"min_free_iram\":183992,\"free_spiram\":4048492,\"min_free_spiram\":4026220,\"ntasks\":13,\"tasks\":[{\"cpu\":0,\"minstk\":400,\"bprio\":1,\"cprio\":1,\"nme\":\"Tmr Svc\",\"st\":1,\"num\":8},{\"cpu\":99,\"minstk\":1000,\"bprio\":0,\"cprio\":0,\"nme\":\"IDLE1\",\"st\":1,\"num\":7},{\"cpu\":97,\"minstk\":992,\"bprio\":0,\"cprio\":0,\"nme\":\"IDLE0\",\"st\":1,\"num\":6},{\"cpu\":0,\"minstk\":2184,\"bprio\":18,\"cprio\":18,\"nme\":\"tiT\",\"st\":2,\"num\":12},{\"cpu\":0,\"minstk\":1948,\"bprio\":5,\"cprio\":5,\"nme\":\"console\",\"st\":2,\"num\":18},{\"cpu\":0,\"minstk\":528,\"bprio\":24,\"cprio\":24,\"nme\":\"ipc0\",\"st\":2,\"num\":2},{\"cpu\":0,\"minstk\":1580,\"bprio\":5,\"cprio\":5,\"nme\":\"httpd\",\"st\":2,\"num\":16},{\"cpu\":0,\"minstk\":708,\"bprio\":20,\"cprio\":20,\"nme\":\"sys_evt\",\"st\":2,\"num\":13},{\"cpu\":0,\"minstk\":2096,\"bprio\":5,\"cprio\":5,\"nme\":\"wifi_manager\",\"st\":2,\"num\":15},{\"cpu\":0,\"minstk\":3436,\"bprio\":22,\"cprio\":22,\"nme\":\"esp_timer\",\"st\":2,\"num\":1},{\"cpu\":1,\"minstk\":868,\"bprio\":23,\"cprio\":23,\"nme\":\"wifi\",\"st\":2,\"num\":14},{\"cpu\":0,\"minstk\":536,\"bprio\":24,\"cprio\":24,\"nme\":\"ipc1\",\"st\":2,\"num\":3},{\"cpu\":0,\"minstk\":7244,\"bprio\":1,\"cprio\":1,\"nme\":\"telnet\",\"st\":2,\"num\":17}]}",
"type": "MESSAGING_INFO",
"class": "MESSAGING_CLASS_STATS",
"sent_time": 81256,
"current_time": 147317
}, {
"message": "{\"free_iram\":190232,\"min_free_iram\":183992,\"free_spiram\":4048488,\"min_free_spiram\":4026220,\"ntasks\":13,\"tasks\":[{\"cpu\":0,\"minstk\":400,\"bprio\":1,\"cprio\":1,\"nme\":\"Tmr Svc\",\"st\":1,\"num\":8},{\"cpu\":99,\"minstk\":1000,\"bprio\":0,\"cprio\":0,\"nme\":\"IDLE1\",\"st\":1,\"num\":7},{\"cpu\":97,\"minstk\":992,\"bprio\":0,\"cprio\":0,\"nme\":\"IDLE0\",\"st\":1,\"num\":6},{\"cpu\":0,\"minstk\":2184,\"bprio\":18,\"cprio\":18,\"nme\":\"tiT\",\"st\":2,\"num\":12},{\"cpu\":0,\"minstk\":528,\"bprio\":24,\"cprio\":24,\"nme\":\"ipc0\",\"st\":2,\"num\":2},{\"cpu\":0,\"minstk\":1580,\"bprio\":5,\"cprio\":5,\"nme\":\"httpd\",\"st\":2,\"num\":16},{\"cpu\":0,\"minstk\":708,\"bprio\":20,\"cprio\":20,\"nme\":\"sys_evt\",\"st\":2,\"num\":13},{\"cpu\":0,\"minstk\":2096,\"bprio\":5,\"cprio\":5,\"nme\":\"wifi_manager\",\"st\":2,\"num\":15},{\"cpu\":0,\"minstk\":536,\"bprio\":24,\"cprio\":24,\"nme\":\"ipc1\",\"st\":2,\"num\":3},{\"cpu\":0,\"minstk\":3436,\"bprio\":22,\"cprio\":22,\"nme\":\"esp_timer\",\"st\":2,\"num\":1},{\"cpu\":1,\"minstk\":868,\"bprio\":23,\"cprio\":23,\"nme\":\"wifi\",\"st\":2,\"num\":14},{\"cpu\":0,\"minstk\":7244,\"bprio\":1,\"cprio\":1,\"nme\":\"telnet\",\"st\":2,\"num\":17},{\"cpu\":0,\"minstk\":1948,\"bprio\":5,\"cprio\":5,\"nme\":\"console\",\"st\":2,\"num\":18}]}",
"type": "MESSAGING_INFO",
"class": "MESSAGING_CLASS_STATS",
"sent_time": 91255,
"current_time": 147317
}, {
"message": "{\"free_iram\":190232,\"min_free_iram\":183992,\"free_spiram\":4048492,\"min_free_spiram\":4026220,\"ntasks\":13,\"tasks\":[{\"cpu\":0,\"minstk\":400,\"bprio\":1,\"cprio\":1,\"nme\":\"Tmr Svc\",\"st\":1,\"num\":8},{\"cpu\":99,\"minstk\":1000,\"bprio\":0,\"cprio\":0,\"nme\":\"IDLE1\",\"st\":1,\"num\":7},{\"cpu\":97,\"minstk\":992,\"bprio\":0,\"cprio\":0,\"nme\":\"IDLE0\",\"st\":1,\"num\":6},{\"cpu\":0,\"minstk\":2184,\"bprio\":18,\"cprio\":18,\"nme\":\"tiT\",\"st\":2,\"num\":12},{\"cpu\":0,\"minstk\":1580,\"bprio\":5,\"cprio\":5,\"nme\":\"httpd\",\"st\":2,\"num\":16},{\"cpu\":0,\"minstk\":708,\"bprio\":20,\"cprio\":20,\"nme\":\"sys_evt\",\"st\":2,\"num\":13},{\"cpu\":0,\"minstk\":2096,\"bprio\":5,\"cprio\":5,\"nme\":\"wifi_manager\",\"st\":2,\"num\":15},{\"cpu\":0,\"minstk\":536,\"bprio\":24,\"cprio\":24,\"nme\":\"ipc1\",\"st\":2,\"num\":3},{\"cpu\":0,\"minstk\":7244,\"bprio\":1,\"cprio\":1,\"nme\":\"telnet\",\"st\":2,\"num\":17},{\"cpu\":0,\"minstk\":3436,\"bprio\":22,\"cprio\":22,\"nme\":\"esp_timer\",\"st\":2,\"num\":1},{\"cpu\":1,\"minstk\":868,\"bprio\":23,\"cprio\":23,\"nme\":\"wifi\",\"st\":2,\"num\":14},{\"cpu\":0,\"minstk\":1948,\"bprio\":5,\"cprio\":5,\"nme\":\"console\",\"st\":2,\"num\":18},{\"cpu\":0,\"minstk\":528,\"bprio\":24,\"cprio\":24,\"nme\":\"ipc0\",\"st\":2,\"num\":2}]}",
"type": "MESSAGING_INFO",
"class": "MESSAGING_CLASS_STATS",
"sent_time": 101255,
"current_time": 147317
}, {
"message": "{\"free_iram\":190232,\"min_free_iram\":183992,\"free_spiram\":4048488,\"min_free_spiram\":4026220,\"ntasks\":13,\"tasks\":[{\"cpu\":0,\"minstk\":400,\"bprio\":1,\"cprio\":1,\"nme\":\"Tmr Svc\",\"st\":1,\"num\":8},{\"cpu\":99,\"minstk\":1000,\"bprio\":0,\"cprio\":0,\"nme\":\"IDLE1\",\"st\":1,\"num\":7},{\"cpu\":98,\"minstk\":992,\"bprio\":0,\"cprio\":0,\"nme\":\"IDLE0\",\"st\":1,\"num\":6},{\"cpu\":0,\"minstk\":2184,\"bprio\":18,\"cprio\":18,\"nme\":\"tiT\",\"st\":2,\"num\":12},{\"cpu\":0,\"minstk\":708,\"bprio\":20,\"cprio\":20,\"nme\":\"sys_evt\",\"st\":2,\"num\":13},{\"cpu\":0,\"minstk\":2096,\"bprio\":5,\"cprio\":5,\"nme\":\"wifi_manager\",\"st\":2,\"num\":15},{\"cpu\":0,\"minstk\":536,\"bprio\":24,\"cprio\":24,\"nme\":\"ipc1\",\"st\":2,\"num\":3},{\"cpu\":0,\"minstk\":7244,\"bprio\":1,\"cprio\":1,\"nme\":\"telnet\",\"st\":2,\"num\":17},{\"cpu\":0,\"minstk\":1948,\"bprio\":5,\"cprio\":5,\"nme\":\"console\",\"st\":2,\"num\":18},{\"cpu\":0,\"minstk\":3436,\"bprio\":22,\"cprio\":22,\"nme\":\"esp_timer\",\"st\":2,\"num\":1},{\"cpu\":1,\"minstk\":868,\"bprio\":23,\"cprio\":23,\"nme\":\"wifi\",\"st\":2,\"num\":14},{\"cpu\":0,\"minstk\":528,\"bprio\":24,\"cprio\":24,\"nme\":\"ipc0\",\"st\":2,\"num\":2},{\"cpu\":0,\"minstk\":1580,\"bprio\":5,\"cprio\":5,\"nme\":\"httpd\",\"st\":2,\"num\":16}]}",
"type": "MESSAGING_INFO",
"class": "MESSAGING_CLASS_STATS",
"sent_time": 111255,
"current_time": 147318
}, {
"message": "{\"free_iram\":190232,\"min_free_iram\":183992,\"free_spiram\":4048492,\"min_free_spiram\":4026220,\"ntasks\":13,\"tasks\":[{\"cpu\":0,\"minstk\":400,\"bprio\":1,\"cprio\":1,\"nme\":\"Tmr Svc\",\"st\":1,\"num\":8},{\"cpu\":99,\"minstk\":1000,\"bprio\":0,\"cprio\":0,\"nme\":\"IDLE1\",\"st\":1,\"num\":7},{\"cpu\":97,\"minstk\":992,\"bprio\":0,\"cprio\":0,\"nme\":\"IDLE0\",\"st\":1,\"num\":6},{\"cpu\":0,\"minstk\":2184,\"bprio\":18,\"cprio\":18,\"nme\":\"tiT\",\"st\":2,\"num\":12},{\"cpu\":0,\"minstk\":2096,\"bprio\":5,\"cprio\":5,\"nme\":\"wifi_manager\",\"st\":2,\"num\":15},{\"cpu\":0,\"minstk\":536,\"bprio\":24,\"cprio\":24,\"nme\":\"ipc1\",\"st\":2,\"num\":3},{\"cpu\":0,\"minstk\":7244,\"bprio\":1,\"cprio\":1,\"nme\":\"telnet\",\"st\":2,\"num\":17},{\"cpu\":0,\"minstk\":1948,\"bprio\":5,\"cprio\":5,\"nme\":\"console\",\"st\":2,\"num\":18},{\"cpu\":0,\"minstk\":528,\"bprio\":24,\"cprio\":24,\"nme\":\"ipc0\",\"st\":2,\"num\":2},{\"cpu\":0,\"minstk\":3436,\"bprio\":22,\"cprio\":22,\"nme\":\"esp_timer\",\"st\":2,\"num\":1},{\"cpu\":1,\"minstk\":868,\"bprio\":23,\"cprio\":23,\"nme\":\"wifi\",\"st\":2,\"num\":14},{\"cpu\":0,\"minstk\":1580,\"bprio\":5,\"cprio\":5,\"nme\":\"httpd\",\"st\":2,\"num\":16},{\"cpu\":0,\"minstk\":708,\"bprio\":20,\"cprio\":20,\"nme\":\"sys_evt\",\"st\":2,\"num\":13}]}",
"type": "MESSAGING_INFO",
"class": "MESSAGING_CLASS_STATS",
"sent_time": 121256,
"current_time": 147318
}, {
"message": "{\"free_iram\":190232,\"min_free_iram\":183872,\"free_spiram\":4048488,\"min_free_spiram\":4026220,\"ntasks\":13,\"tasks\":[{\"cpu\":0,\"minstk\":400,\"bprio\":1,\"cprio\":1,\"nme\":\"Tmr Svc\",\"st\":1,\"num\":8},{\"cpu\":99,\"minstk\":1000,\"bprio\":0,\"cprio\":0,\"nme\":\"IDLE1\",\"st\":1,\"num\":7},{\"cpu\":97,\"minstk\":992,\"bprio\":0,\"cprio\":0,\"nme\":\"IDLE0\",\"st\":1,\"num\":6},{\"cpu\":0,\"minstk\":2184,\"bprio\":18,\"cprio\":18,\"nme\":\"tiT\",\"st\":2,\"num\":12},{\"cpu\":0,\"minstk\":536,\"bprio\":24,\"cprio\":24,\"nme\":\"ipc1\",\"st\":2,\"num\":3},{\"cpu\":0,\"minstk\":7244,\"bprio\":1,\"cprio\":1,\"nme\":\"telnet\",\"st\":2,\"num\":17},{\"cpu\":0,\"minstk\":1948,\"bprio\":5,\"cprio\":5,\"nme\":\"console\",\"st\":2,\"num\":18},{\"cpu\":0,\"minstk\":528,\"bprio\":24,\"cprio\":24,\"nme\":\"ipc0\",\"st\":2,\"num\":2},{\"cpu\":0,\"minstk\":1580,\"bprio\":5,\"cprio\":5,\"nme\":\"httpd\",\"st\":2,\"num\":16},{\"cpu\":0,\"minstk\":3436,\"bprio\":22,\"cprio\":22,\"nme\":\"esp_timer\",\"st\":2,\"num\":1},{\"cpu\":1,\"minstk\":868,\"bprio\":23,\"cprio\":23,\"nme\":\"wifi\",\"st\":2,\"num\":14},{\"cpu\":0,\"minstk\":708,\"bprio\":20,\"cprio\":20,\"nme\":\"sys_evt\",\"st\":2,\"num\":13},{\"cpu\":0,\"minstk\":2096,\"bprio\":5,\"cprio\":5,\"nme\":\"wifi_manager\",\"st\":2,\"num\":15}]}",
"type": "MESSAGING_INFO",
"class": "MESSAGING_CLASS_STATS",
"sent_time": 131255,
"current_time": 147318
}, {
"message": "{\"free_iram\":190232,\"min_free_iram\":183872,\"free_spiram\":4048492,\"min_free_spiram\":4026220,\"ntasks\":13,\"tasks\":[{\"cpu\":0,\"minstk\":400,\"bprio\":1,\"cprio\":1,\"nme\":\"Tmr Svc\",\"st\":1,\"num\":8},{\"cpu\":99,\"minstk\":1000,\"bprio\":0,\"cprio\":0,\"nme\":\"IDLE1\",\"st\":1,\"num\":7},{\"cpu\":97,\"minstk\":992,\"bprio\":0,\"cprio\":0,\"nme\":\"IDLE0\",\"st\":1,\"num\":6},{\"cpu\":0,\"minstk\":2184,\"bprio\":18,\"cprio\":18,\"nme\":\"tiT\",\"st\":2,\"num\":12},{\"cpu\":0,\"minstk\":7244,\"bprio\":1,\"cprio\":1,\"nme\":\"telnet\",\"st\":2,\"num\":17},{\"cpu\":0,\"minstk\":1948,\"bprio\":5,\"cprio\":5,\"nme\":\"console\",\"st\":2,\"num\":18},{\"cpu\":0,\"minstk\":528,\"bprio\":24,\"cprio\":24,\"nme\":\"ipc0\",\"st\":2,\"num\":2},{\"cpu\":0,\"minstk\":1580,\"bprio\":5,\"cprio\":5,\"nme\":\"httpd\",\"st\":2,\"num\":16},{\"cpu\":0,\"minstk\":708,\"bprio\":20,\"cprio\":20,\"nme\":\"sys_evt\",\"st\":2,\"num\":13},{\"cpu\":0,\"minstk\":3436,\"bprio\":22,\"cprio\":22,\"nme\":\"esp_timer\",\"st\":2,\"num\":1},{\"cpu\":1,\"minstk\":868,\"bprio\":23,\"cprio\":23,\"nme\":\"wifi\",\"st\":2,\"num\":14},{\"cpu\":0,\"minstk\":2096,\"bprio\":5,\"cprio\":5,\"nme\":\"wifi_manager\",\"st\":2,\"num\":15},{\"cpu\":0,\"minstk\":536,\"bprio\":24,\"cprio\":24,\"nme\":\"ipc1\",\"st\":2,\"num\":3}]}",
"type": "MESSAGING_INFO",
"class": "MESSAGING_CLASS_STATS",
"sent_time": 141256,
"current_time": 147319
},
{
"message": "Info Message",
"type": "MESSAGING_INFO",
"class": "MESSAGING_CLASS_SYSTEM",
"sent_time": 3519,
"current_time": 24674
},
{
"message": "Warning Message",
"type": "MESSAGING_WARNING",
"class": "MESSAGING_CLASS_SYSTEM",
"sent_time": 3519,
"current_time": 24674
},
{
"message": "Warning Message",
"type": "MESSAGING_ERROR",
"class": "MESSAGING_CLASS_SYSTEM",
"sent_time": 3519,
"current_time": 24674
},
{
"message": "{\"free_iram\":194144,\"min_free_iram\":185048,\"free_spiram\":4061372,\"min_free_spiram\":4050012,\"ntasks\":13,\"tasks\":[]}",
"type": "MESSAGING_INFO",
"class": "MESSAGING_CLASS_STATS",
"sent_time": 11201,
"current_time": 24674
}, {
"message": "{\"free_iram\":193848,\"min_free_iram\":185048,\"free_spiram\":4049576,\"min_free_spiram\":4049576,\"ntasks\":13,\"tasks\":[{\"cpu\":0,\"minstk\":480,\"bprio\":1,\"cprio\":1,\"nme\":\"Tmr Svc\",\"st\":1,\"num\":8},{\"cpu\":99,\"minstk\":1000,\"bprio\":0,\"cprio\":0,\"nme\":\"IDLE1\",\"st\":1,\"num\":7},{\"cpu\":98,\"minstk\":992,\"bprio\":0,\"cprio\":0,\"nme\":\"IDLE0\",\"st\":1,\"num\":6},{\"cpu\":0,\"minstk\":2184,\"bprio\":18,\"cprio\":18,\"nme\":\"tiT\",\"st\":2,\"num\":12},{\"cpu\":0,\"minstk\":1948,\"bprio\":5,\"cprio\":5,\"nme\":\"console\",\"st\":2,\"num\":18},{\"cpu\":0,\"minstk\":528,\"bprio\":24,\"cprio\":24,\"nme\":\"ipc0\",\"st\":2,\"num\":2},{\"cpu\":0,\"minstk\":676,\"bprio\":20,\"cprio\":20,\"nme\":\"sys_evt\",\"st\":2,\"num\":13},{\"cpu\":0,\"minstk\":2096,\"bprio\":5,\"cprio\":5,\"nme\":\"wifi_manager\",\"st\":2,\"num\":15},{\"cpu\":0,\"minstk\":3468,\"bprio\":22,\"cprio\":22,\"nme\":\"esp_timer\",\"st\":2,\"num\":1},{\"cpu\":0,\"minstk\":2524,\"bprio\":5,\"cprio\":5,\"nme\":\"httpd\",\"st\":2,\"num\":16},{\"cpu\":1,\"minstk\":868,\"bprio\":23,\"cprio\":23,\"nme\":\"wifi\",\"st\":2,\"num\":14},{\"cpu\":0,\"minstk\":536,\"bprio\":24,\"cprio\":24,\"nme\":\"ipc1\",\"st\":2,\"num\":3},{\"cpu\":0,\"minstk\":7244,\"bprio\":1,\"cprio\":1,\"nme\":\"telnet\",\"st\":2,\"num\":17}]}",
"type": "MESSAGING_INFO",
"class": "MESSAGING_CLASS_STATS",
"sent_time": 21267,
"current_time": 24674
}
]

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

2
components/wifi-manager/res/jquery.js vendored Normal file

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1 @@
{}

View File

@@ -1 +0,0 @@
{"ssid":"zodmgbbq","ip":"192.168.1.119","netmask":"255.255.255.0","gw":"192.168.1.1","urc":0}

View File

@@ -0,0 +1 @@
{"project_name":"recovery","version":"custom.build","recovery":1,"Jack":"1","Voltage":0,"disconnect_count":0,"avg_conn_time":0,"is_i2c_locked":false,"urc":0,"ssid":"MyTestSSID","ip":"192.168.10.225","netmask":"255.255.255.0","gw":"192.168.10.1"}

View File

@@ -0,0 +1,15 @@
{
"project_name": "recovery",
"version": "custom.build",
"recovery": 1,
"Jack": "1",
"Voltage": 0,
"disconnect_count": 0,
"avg_conn_time": 0,
"is_i2c_locked": false,
"urc": 0,
"ssid": "MyTestSSID",
"ip": "192.168.10.225",
"netmask": "255.255.255.0",
"gw": "192.168.10.1"
}

View File

@@ -272,10 +272,18 @@ void wifi_manager_init_wifi(){
ESP_LOGD(TAG, "Initializing wifi. Setting WiFi mode to WIFI_MODE_NULL");
ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_NULL) );
ESP_LOGD(TAG, "Initializing wifi. Starting wifi");
if (gpio36_39_used) {
ESP_LOGW(TAG, "GPIO 36 or 39 are in use, need to disable WiFi PowerSave!");
esp_wifi_set_ps(WIFI_PS_NONE);
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){
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);
}
FREE_AND_NULL(disable_ps);
ESP_ERROR_CHECK( esp_wifi_start() );
taskYIELD();
@@ -451,6 +459,7 @@ cJSON * wifi_manager_get_new_array_json(cJSON **old){
return cJSON_CreateArray();
}
cJSON * wifi_manager_get_basic_info(cJSON **old){
monitor_gpio_t *mgpio= get_jack_insertion_gpio();
const esp_app_desc_t* desc = esp_ota_get_app_description();
ESP_LOGV(TAG, "wifi_manager_get_basic_info called");
cJSON *root = wifi_manager_get_new_json(old);
@@ -458,11 +467,15 @@ cJSON * wifi_manager_get_basic_info(cJSON **old){
cJSON_AddItemToObject(root, "version", cJSON_CreateString(desc->version));
if(release_url !=NULL) cJSON_AddItemToObject(root, "release_url", cJSON_CreateString(release_url));
cJSON_AddNumberToObject(root,"recovery", is_recovery_running?1:0);
cJSON_AddItemToObject(root, "Jack", cJSON_CreateString(jack_inserted_svc() ? "1" : "0"));
cJSON_AddItemToObject(root, "Jack", cJSON_CreateString(mgpio->gpio>=0 && jack_inserted_svc() ? "1" : "0"));
cJSON_AddNumberToObject(root,"Voltage", battery_value_svc());
cJSON_AddNumberToObject(root,"disconnect_count", num_disconnect );
cJSON_AddNumberToObject(root,"avg_conn_time", num_disconnect>0?(total_connected_time/num_disconnect):0 );
#if CONFIG_I2C_LOCKED
cJSON_AddTrueToObject(root, "is_i2c_locked");
#else
cJSON_AddFalseToObject(root, "is_i2c_locked");
#endif
ESP_LOGV(TAG, "wifi_manager_get_basic_info done");
return root;
}
@@ -1272,7 +1285,16 @@ void wifi_manager( void * pvParameters ){
}
}
ESP_LOGD(TAG, "MESSAGE: ORDER_CONNECT_STA - setting config for WIFI_IF_STA");
if((err=esp_wifi_set_config(WIFI_IF_STA, wifi_manager_get_wifi_sta_config()))!=ESP_OK) {
wifi_config_t* cfg = wifi_manager_get_wifi_sta_config();
char * scan_mode = config_alloc_get_default(NVS_TYPE_STR, "wifi_smode", "f", 0);
if (scan_mode && strcasecmp(scan_mode,"a")==0) {
cfg->sta.scan_method=WIFI_ALL_CHANNEL_SCAN;
}
else {
cfg->sta.scan_method=WIFI_FAST_SCAN;
}
FREE_AND_NULL(scan_mode);
if((err=esp_wifi_set_config(WIFI_IF_STA, cfg))!=ESP_OK) {
ESP_LOGE(TAG, "Failed to set STA configuration. Error %s",esp_err_to_name(err));
break;
}

View File

@@ -44,7 +44,7 @@ menu "Squeezelite-ESP32"
string
default "model=TAS57xx,bck=33,ws=25,do=32,sda=27,scl=26,mute=14:0" if SQUEEZEAMP
default "model=AC101,bck=27,ws=26,do=25,di=35,sda=33,scl=32" if A1S
default "model=I2S,bck=26,ws=25,do=33,i2c=106,sda=21,scl=22" if TWATCH2020
default "model=I2S,bck=26,ws=25,do=33,i2c=53,sda=21,scl=22" if TWATCH2020
default ""
config SPDIF_CONFIG
string

View File

@@ -44,6 +44,7 @@
#include "gds_text.h"
#include "gds_font.h"
#include "display.h"
#include "accessors.h"
static const char certs_namespace[] = "certificates";
static const char certs_key[] = "blob";
static const char certs_version[] = "version";
@@ -447,7 +448,7 @@ void app_main()
/* start the wifi manager */
ESP_LOGD(TAG,"Blinking led");
led_blink(LED_GREEN, 250, 250);
led_blink_pushed(LED_GREEN, 250, 250);
if(bypass_wifi_manager){
ESP_LOGW(TAG,"*******************************************************************************************");
@@ -464,7 +465,6 @@ void app_main()
wifi_manager_set_callback(ORDER_START_AP, &start_telnet);
wifi_manager_set_callback(ORDER_CONNECT_STA, &start_telnet);
}
console_start();
if(fwurl && strlen(fwurl)>0){
if(is_recovery_running){

Binary file not shown.

View File

@@ -78,7 +78,7 @@ sub displayWidth {
if ($display->widthOverride) {
my $artwork = $prefs->client($client)->get('artwork');
if ($artwork->{'enable'} && $artwork->{'y'} < 32 && ($client->isPlaying || $client->isPaused)) {
return $artwork->{x} + ($display->modes->[$mode || 0]{_width} || 0);
return ($artwork->{x} || $display->widthOverride) + ($display->modes->[$mode || 0]{_width} || 0);
} else {
return $display->widthOverride + ($display->modes->[$mode || 0]{_width} || 0);
}
@@ -113,9 +113,9 @@ sub build_modes {
my $artwork = $cprefs->get('artwork');
my $disp_width = $cprefs->get('width') || 128;
# if artwork is in main display, reduce width
my $width = ($artwork->{'enable'} && $artwork->{'y'} < 32) ? $artwork->{'x'} : $disp_width;
my $width_low = ($artwork->{'enable'} && ($artwork->{'y'} >= 32 || $disp_width - $artwork->{'x'} > 32)) ? $artwork->{'x'} : $disp_width;
# if artwork is in main display, reduce width but when artwork is (0,0) fake it
my $width = ($artwork->{'enable'} && $artwork->{'y'} < 32 && $artwork->{'x'}) ? $artwork->{'x'} : $disp_width;
my $width_low = ($artwork->{'enable'} && $artwork->{'x'} && ($artwork->{'y'} >= 32 || $disp_width - $artwork->{'x'} > 32)) ? $artwork->{'x'} : $disp_width;
my $small_VU = $cprefs->get('small_VU');
my $spectrum = $cprefs->get('spectrum');

View File

@@ -13,6 +13,19 @@ my $sprefs = preferences('server');
my $prefs = preferences('plugin.squeezeesp32');
my $log = logger('plugin.squeezeesp32');
{
__PACKAGE__->mk_accessor('rw', 'tone_update');
}
sub new {
my $class = shift;
my $client = $class->SUPER::new(@_);
$client->init_accessor(
tone_update => 0,
);
return $client;
}
our $defaultPrefs = {
'analogOutMode' => 0,
'bass' => 0,
@@ -44,7 +57,6 @@ sub hasIR { 1 }
# TODO: add in settings when ready
sub hasLineIn { 0 }
sub hasHeadSubOut { 1 }
# TODO: LMS sliders are hard-coded in html file from -23 to +23
sub maxTreble { 20 }
sub minTreble { -13 }
sub maxBass { 20 }
@@ -54,7 +66,7 @@ sub init {
my $client = shift;
if (!$handlersAdded) {
# Add a handler for line-in/out status changes
Slim::Networking::Slimproto::addHandler( LIOS => \&lineInOutStatus );
@@ -80,11 +92,15 @@ sub init {
$client->SUPER::init(@_);
$client->config_artwork;
}
$client->send_equalizer;
main::INFOLOG && $log->is_info && $log->info("SqueezeESP player connected: " . $client->id);
}
sub initPrefs {
my $client = shift;
$sprefs->client($client)->init($defaultPrefs);
$prefs->client($client)->init( { equalizer => [(0) x 10] } );
$client->SUPER::initPrefs;
}
@@ -117,25 +133,50 @@ sub playerSettingsFrame {
}
sub bass {
return tone(2, @_);
}
sub treble {
return tone(8, @_);
my ($client, $new) = @_;
my $value = $client->SUPER::bass($new);
$client->update_equalizer($value, [2, 1, 3]) if defined $new;
return $value;
}
sub tone {
my ($center, $client, $value) = @_;
my $equalizer = $prefs->client($client)->get('equalizer');
sub treble {
my ($client, $new) = @_;
my $value = $client->SUPER::treble($new);
if (defined($value)) {
$equalizer->[$center-1] = int($value * 0.2 + 0.5);
$equalizer->[$center] = int($value * 0.7 + 0.5);
$equalizer->[$center+1] = int($value * 0.1 + 0.5);
$prefs->client($client)->set('equalizer', $equalizer);
}
$client->update_equalizer($value, [8, 9, 7]) if defined $new;
return int($equalizer->[$center-1] * 0.2 + $equalizer->[$center] * 0.7 + $equalizer->[$center+1] * 0.1);
return $value;
}
sub send_equalizer {
my ($client, $equalizer) = @_;
$equalizer ||= $prefs->client($client)->get('equalizer') || [(0) x 10];
my $size = @$equalizer;
my $data = pack("c[$size]", @{$equalizer});
$client->sendFrame( eqlz => \$data );
}
sub update_equalizer {
my ($client, $value, $index) = @_;
return if $client->tone_update;
my $equalizer = $prefs->client($client)->get('equalizer');
$equalizer->[$index->[0]] = $value;
$equalizer->[$index->[1]] = int($value / 2 + 0.5);
$equalizer->[$index->[2]] = int($value / 4 + 0.5);
$prefs->client($client)->set('equalizer', $equalizer);
}
sub update_tones {
my ($client, $equalizer) = @_;
$client->tone_update(1);
$sprefs->client($client)->set('bass', int(($equalizer->[1] * 2 + $equalizer->[2] + $equalizer->[3] * 4) / 7 + 0.5));
$sprefs->client($client)->set('treble', int(($equalizer->[7] * 4 + $equalizer->[8] + $equalizer->[9] * 2) / 7 + 0.5));
$client->tone_update(0);
}
sub update_artwork {
@@ -193,6 +234,11 @@ sub clear_artwork {
if ($artwork && $artwork->{'enable'}) {
main::INFOLOG && $log->is_info && $log->info("artwork stop/clear " . $request->getRequestString());
$client->pluginData('artwork_md5', '');
# refresh screen and disable artwork when artwork was full screen (hack)
if (!$artwork->{'x'} && !$artwork->{'y'}) {
$client->sendFrame(grfa => \("\x00"x4)) unless $artwork->{'x'} || $artwork->{'y'};
$client->display->update;
}
}
}

View File

@@ -73,6 +73,7 @@ sub handler {
$equalizer->[$i] = $paramRef->{"pref_equalizer.$i"} || 0;
}
$cprefs->set('equalizer', $equalizer);
$client->update_tones($equalizer);
}
if ($client->displayWidth) {

View File

@@ -25,7 +25,7 @@ $prefs->migrateClient(1, sub {
});
$prefs->setChange(sub {
send_equalizer($_[2]);
$_[2]->send_equalizer;
}, 'equalizer');
sub initPlugin {
@@ -40,8 +40,10 @@ sub initPlugin {
}
$class->SUPER::initPlugin(@_);
Slim::Networking::Slimproto::addPlayerClass($class, 100, 'squeezeesp32', { client => 'Plugins::SqueezeESP32::Player', display => 'Plugins::SqueezeESP32::Graphics' });
main::INFOLOG && $log->is_info && $log->info("Added class 100 for SqueezeESP32");
# no name can be a subset of others due to a bug in addPlayerClass
Slim::Networking::Slimproto::addPlayerClass($class, 100, 'squeezeesp32-basic', { client => 'Plugins::SqueezeESP32::Player', display => 'Plugins::SqueezeESP32::Graphics' });
Slim::Networking::Slimproto::addPlayerClass($class, 101, 'squeezeesp32-graphic', { client => 'Plugins::SqueezeESP32::Player', display => 'Slim::Display::NoDisplay' });
main::INFOLOG && $log->is_info && $log->info("Added class 100 and 101 for SqueezeESP32");
# register a command to set the EQ - without saving the values! Send params as single comma separated list of values
Slim::Control::Request::addDispatch(['squeezeesp32', 'seteq', '_eq'], [1, 0, 0, \&setEQ]);
@@ -50,9 +52,6 @@ sub initPlugin {
Slim::Control::Request::subscribe( sub { onNotification(@_) }, [ ['newmetadata'] ] );
Slim::Control::Request::subscribe( sub { onNotification(@_) }, [ ['playlist'], ['open', 'newsong'] ]);
Slim::Control::Request::subscribe( \&onStopClear, [ ['playlist'], ['stop', 'clear'] ]);
# the custom player class is only initialized if it has a display - thus we need to listen to connect events in order to initializes other player prefs
Slim::Control::Request::subscribe( \&onPlayer,[ ['client'], [ 'new', 'reconnect' ] ] );
}
sub onStopClear {
@@ -64,20 +63,6 @@ sub onStopClear {
}
}
sub onPlayer {
my $request = shift;
my $client = $request->client || return;
if ($client->model eq 'squeezeesp32') {
main::INFOLOG && $log->is_info && $log->info("SqueezeESP player connected: " . $client->id);
$prefs->client($client)->init( {
equalizer => [(0) x 10],
} );
send_equalizer($client);
}
}
sub onNotification {
my $request = shift;
my $client = $request->client || return;
@@ -104,18 +89,7 @@ sub setEQ {
$eqParams[$x] ||= 0;
}
send_equalizer($client, \@eqParams);
}
sub send_equalizer {
my ($client, $equalizer) = @_;
if ($client->model eq 'squeezeesp32') {
$equalizer ||= $prefs->client($client)->get('equalizer') || [(0) x 10];
my $size = @$equalizer;
my $data = pack("c[$size]", @{$equalizer});
$client->sendFrame( eqlz => \$data );
}
$client->send_equalizer(\@eqParams);
}
1;

View File

@@ -10,6 +10,6 @@
<name>PLUGIN_SQUEEZEESP32</name>
<description>PLUGIN_SQUEEZEESP32_DESC</description>
<module>Plugins::SqueezeESP32::Plugin</module>
<version>0.100</version>
<version>0.200</version>
<creator>Philippe</creator>
</extensions>

View File

@@ -1,10 +1,10 @@
<?xml version='1.0' standalone='yes'?>
<extensions>
<plugins>
<plugin version="0.100" name="SqueezeESP32" minTarget="7.9" maxTarget="*">
<plugin version="0.200" name="SqueezeESP32" minTarget="7.9" maxTarget="*">
<link>https://github.com/sle118/squeezelite-esp32</link>
<creator>Philippe</creator>
<sha>572fa8afeaa3bc3cfb245b8d42ba05739aec584b</sha>
<sha>ab2d65f5ba8e73f0f78a1a8650af19ebb1e8e724</sha>
<email>philippe_44@outlook.com</email>
<desc lang="EN">SqueezeESP32 additional player id (100)</desc>
<url>http://github.com/sle118/squeezelite-esp32/raw/master/plugin/SqueezeESP32.zip</url>

19
test/CMakelists.txt Normal file
View File

@@ -0,0 +1,19 @@
# This is the project CMakeLists.txt file for the test subproject
cmake_minimum_required(VERSION 3.5)
# Include the components directory of the main application:
#
set(EXTRA_COMPONENT_DIRS "../components")
# Set the components to include the tests for.
# This can be overriden from CMake cache:
# - when invoking CMake directly: cmake -D TEST_COMPONENTS="xxxxx" ..
# - when using idf.py: idf.py -T xxxxx build
#
set(TEST_COMPONENTS "platform_console" CACHE STRING "List of components to test")
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(squeezelite_esp32_test)
add_definitions(-include "${PROJECT_SOURCE_DIR}/../build/config/sdkconfig.h")
set_property(TARGET squeezelite_esp32_test.elf PROPERTY RECOVERY_PREFIX app_update )

2
test/main/CMakeLists.txt Normal file
View File

@@ -0,0 +1,2 @@
idf_component_register(SRCS "unit_tests.c"
INCLUDE_DIRS ".")

121
test/main/unit_tests.c Normal file
View File

@@ -0,0 +1,121 @@
/* Example test application for testable component.
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
#include <stdio.h>
#include <string.h>
#include "unity.h"
/*
* Squeezelite for esp32
*
* (c) Sebastien 2019
* Philippe G. 2019, philippe_44@outlook.com
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*
*/
#include "platform_esp32.h"
#include "led.h"
#include <stdio.h>
#include <string.h>
#include "freertos/FreeRTOS.h"
#include "driver/gpio.h"
#include "driver/spi_master.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "esp_spi_flash.h"
#include "esp_wifi.h"
#include "esp_system.h"
#include <esp_event.h>
#include "nvs_flash.h"
#include "esp_log.h"
#include "freertos/event_groups.h"
#include "mdns.h"
#include "lwip/api.h"
#include "lwip/err.h"
#include "lwip/netdb.h"
#include "nvs_utilities.h"
#include "trace.h"
#include "wifi_manager.h"
#include "squeezelite-ota.h"
#include <math.h>
#include "audio_controls.h"
#include "platform_config.h"
#include "telnet.h"
#include "messaging.h"
#include "gds.h"
#include "gds_default_if.h"
#include "gds_draw.h"
#include "gds_text.h"
#include "gds_font.h"
#include "display.h"
#include "accessors.h"
#include "cmd_system.h"
#include "cmd_config.h"
#include "cmd_i2ctools.h"
#include "cmd_nvs.h"
const char unknown_string_placeholder[] = "unknown";
const char null_string_placeholder[] = "null";
// as an exception _init function don't need include
extern void services_init(void);
const char * str_or_unknown(const char * str) { return (str?str:unknown_string_placeholder); }
const char * str_or_null(const char * str) { return (str?str:null_string_placeholder); }
bool is_recovery_running;
extern void initialize_console();
/* brief this is an exemple of a callback that you can setup in your own app to get notified of wifi manager event */
esp_err_t update_certificates(bool force){return ESP_OK; }
void init_commands(){
initialize_console();
/* Register commands */
register_system();
register_config_cmd();
register_nvs();
register_i2ctools();
}
void test_init()
{
const esp_partition_t *running = esp_ota_get_running_partition();
is_recovery_running = (running->subtype == ESP_PARTITION_SUBTYPE_APP_FACTORY);
initialize_nvs();
config_init();
services_init();
init_commands();
}
static void print_banner(const char* text);
void app_main()
{
test_init();
print_banner("Running tests with [config] tag");
UNITY_BEGIN();
unity_run_tests_by_tag("[config]", false);
UNITY_END();
// print_banner("Running all the registered tests");
// UNITY_BEGIN();
// unity_run_all_tests();
// UNITY_END();
print_banner("Starting interactive test menu");
/* This function will not return, and will be busy waiting for UART input.
* Make sure that task watchdog is disabled if you use this function.
*/
unity_run_menu();
}
static void print_banner(const char* text)
{
printf("\n#### %s #####\n\n", text);
}

8
test/partitions.csv Normal file
View File

@@ -0,0 +1,8 @@
# Name, Type, SubType, Offset, Size, Flags
# Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild
nvs, data, nvs, 0x9000, 0x4000,
otadata, data, ota, 0xD000, 0x2000,
phy_init, data, phy, 0xF000, 0x1000,
recovery, app, factory, 0x10000, 0x140000,
ota_0, app, ota_0, , 0x2A0000,
settings, data, nvs, , 0x10000,
1 # Name, Type, SubType, Offset, Size, Flags
2 # Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild
3 nvs, data, nvs, 0x9000, 0x4000,
4 otadata, data, ota, 0xD000, 0x2000,
5 phy_init, data, phy, 0xF000, 0x1000,
6 recovery, app, factory, 0x10000, 0x140000,
7 ota_0, app, ota_0, , 0x2A0000,
8 settings, data, nvs, , 0x10000,