Skip to content

Commit

Permalink
command-set fix new install issues
Browse files Browse the repository at this point in the history
  • Loading branch information
wizmo2 committed Oct 15, 2023
1 parent 168b2fa commit 643bf54
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 10 deletions.
29 changes: 25 additions & 4 deletions components/platform_console/cmd_system.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "messaging.h"
#include "platform_console.h"
#include "tools.h"
#include "nvs_utilities.h"
#if defined(CONFIG_WITH_METRICS)
#include "Metrics.h"
#endif
Expand All @@ -42,6 +43,7 @@
#pragma message("Runtime stats disabled")
#endif
EXT_RAM_ATTR static struct {
struct arg_rem *rem;
struct arg_str *name;
struct arg_end *end;
} name_args;
Expand Down Expand Up @@ -215,8 +217,22 @@ esp_err_t guided_factory(){
guided_boot(ESP_PARTITION_SUBTYPE_APP_FACTORY);
return ESP_FAIL; // return fail. This should never return... we're rebooting!
}
static struct {
struct arg_lit *clear;
struct arg_end *end;
} restart_args;

static int restart_factory(int argc, char **argv)
{
int nerrors = arg_parse_msg(argc, argv,(struct arg_hdr **)&restart_args);
if (nerrors != 0) {
return 1;
}
if (restart_args.clear->count) {
cmd_send_messaging(argv[0],MESSAGING_WARNING, "CLEARING ALL SETTINGS");
erase_settings_partition();
}

cmd_send_messaging(argv[0],MESSAGING_WARNING, "Booting to Recovery");
guided_boot(ESP_PARTITION_SUBTYPE_APP_FACTORY);
return 0; // return fail. This should never return... we're rebooting!
Expand Down Expand Up @@ -256,11 +272,15 @@ static void register_restart_ota()

static void register_factory_boot()
{
restart_args.clear = arg_lit0(NULL,"clear","Clear all configurations (WARNING: THIS WILL RESET THE DEVICE TO FACTORY SETTINGS!)");
restart_args.end = arg_end(1);

const esp_console_cmd_t cmd = {
.command = "recovery",
.help = "Reboot system to Recovery",
.hint = NULL,
.func = &restart_factory,
.argtable = &restart_args,
};
#if CONFIG_WITH_CONFIG_UI
cmd_to_json(&cmd);
Expand Down Expand Up @@ -514,8 +534,9 @@ static void register_dump_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);
name_args.rem = arg_rem("rem", "Changing the device name updates the host, ap, and player names (plus the airplay, bluetooth and cspot names if enabled)");
name_args.name = arg_str0("n", "name", default_host_name, "New Name");
name_args.end = arg_end(2);
const esp_console_cmd_t set_name= {
.command = CFG_TYPE_SYST("name"),
.help="Device Name",
Expand Down Expand Up @@ -742,9 +763,9 @@ static void register_set_services(){
#if CONFIG_BT_ENABLED
set_services_args.btspeaker = arg_lit0(NULL, "BT_Speaker", "Bluetooth Speaker");
#endif
set_services_args.telnet= arg_str0("t", "telnet","Disabled|Telnet Only|Telnet and Serial","Telnet server. Use only for troubleshooting");
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");
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 = {
Expand Down
2 changes: 1 addition & 1 deletion components/wifi-manager/network_status.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void init_network_status() {
ESP_LOGD(TAG, "init_network_status. Creating status json structure");
ip_info_cjson = network_status_clear_ip_info_json(&ip_info_cjson);
ESP_LOGD(TAG, "Getting release url ");
char* release_url = (char*)config_alloc_get_default(NVS_TYPE_STR, "release_url", QUOTE(CONFIG_SQUEEZELITE_ESP32_RELEASE_URL), 0);
char* release_url = (char*)config_alloc_get_default(NVS_TYPE_STR, "release_url", CONFIG_SQUEEZELITE_ESP32_RELEASE_URL, 0);
if (release_url == NULL) {
ESP_LOGE(TAG, "Unable to retrieve the release url from nvs");
} else {
Expand Down
10 changes: 5 additions & 5 deletions main/esp_app_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,14 @@ const DefaultStringVal defaultStringVals[] = {
{"a2dp_ctrld", STR(CONFIG_A2DP_CONTROL_DELAY_MS)},
{"a2dp_sink_name", CONFIG_A2DP_SINK_NAME},
{"autoexec", "1"},
#endif
#ifdef CONFIG_AIRPLAY_SINK
{"airplay_port", CONFIG_AIRPLAY_PORT},
{"enable_airplay", STR(CONFIG_AIRPLAY_SINK)}
{"enable_airplay", STR(CONFIG_AIRPLAY_SINK)},
#endif
#endif
{"autoexec1",CONFIG_DEFAULT_COMMAND_LINE},
{"autoexec1_2",CONFIG_DEFAULT_COMMAND_2_LINE},
{"autoexec1_3",CONFIG_DEFAULT_COMMAND_3_LINE}
};
static bool bNetworkConnected=false;

Expand Down Expand Up @@ -306,9 +309,6 @@ void register_default_nvs(){
#endif
register_default_with_mac("host_name", DEFAULT_HOST_NAME);
register_default_with_mac("ap_ssid", CONFIG_DEFAULT_AP_SSID);
register_default_with_mac("autoexec1",CONFIG_DEFAULT_COMMAND_LINE);
register_default_with_mac("autoexec1_2",CONFIG_DEFAULT_COMMAND_2_LINE);
register_default_with_mac("autoexec1_3",CONFIG_DEFAULT_COMMAND_3_LINE);
for (int i = 0; i < sizeof(defaultStringVals) / sizeof(DefaultStringVal); ++i) {
register_default_string_val(defaultStringVals[i].key, defaultStringVals[i].value);
}
Expand Down

0 comments on commit 643bf54

Please sign in to comment.