diff --git a/.vscode/settings.json b/.vscode/settings.json index 1020abe..67bb37c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -49,6 +49,7 @@ "clocks.h": "c", "pwm.h": "c", "servo_gate.h": "c", - "semphr.h": "c" + "semphr.h": "c", + "version.h": "c" } } diff --git a/src/app.cpp b/src/app.cpp index 33bfca8..bf94867 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -29,13 +29,6 @@ #include "servo_gate.h" -uint8_t software_reboot() { - watchdog_reboot(0, 0, 0); - - return 0; -} - - int main() { // stdio_init_all(); diff --git a/src/app.h b/src/app.h index bb40fc5..99df2c9 100644 --- a/src/app.h +++ b/src/app.h @@ -35,7 +35,6 @@ extern "C" { #endif bool app_init(); -uint8_t software_reboot(); bool http_app_config(); #ifdef __cplusplus diff --git a/src/charge_mode.cpp b/src/charge_mode.cpp index de8232a..5203fd4 100644 --- a/src/charge_mode.cpp +++ b/src/charge_mode.cpp @@ -622,7 +622,7 @@ bool http_rest_charge_mode_config(struct fs_file *file, int num_params, char *pa sizeof(charge_mode_json_buffer), "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n" "{\"c1\":\"#%06lx\",\"c2\":\"#%06lx\",\"c3\":\"#%06lx\",\"c4\":\"#%06lx\"," - "\"c5\":%.3f,\"c6\":%.3f,\"c7\":%.3f,\"c8\":%.3f,\"c9\":%d,\"c10\":\"%s\",\"c11\":%ld,\"c12\":%0.3f}", + "\"c5\":%.3f,\"c6\":%.3f,\"c7\":%.3f,\"c8\":%.3f,\"c9\":%d,\"c10\":%s,\"c11\":%ld,\"c12\":%0.3f}", charge_mode_config.eeprom_charge_mode_data.neopixel_normal_charge_colour, charge_mode_config.eeprom_charge_mode_data.neopixel_under_charge_colour, charge_mode_config.eeprom_charge_mode_data.neopixel_over_charge_colour, diff --git a/src/eeprom.c b/src/eeprom.c index b8867ef..9d9f809 100644 --- a/src/eeprom.c +++ b/src/eeprom.c @@ -6,7 +6,6 @@ #include #include -#include "hardware/watchdog.h" #include "hardware/regs/rosc.h" #include "hardware/regs/addressmap.h" @@ -19,8 +18,8 @@ #include "app.h" #include "neopixel_led.h" #include "rotary_button.h" -#include "version.h" #include "profile.h" +#include "system_control.h" extern bool cat24c256_eeprom_erase(); @@ -78,7 +77,7 @@ uint8_t eeprom_erase(bool reboot) { cat24c256_eeprom_erase(); if (reboot) { - watchdog_reboot(0, 0, 0); + software_reboot(); } return 37; // Configuration Menu ID @@ -186,63 +185,3 @@ bool eeprom_get_board_id(char ** board_id_buffer, size_t bytes_to_copy) { return true; } - -bool http_rest_system_control(struct fs_file *file, int num_params, char *params[], char *values[]) { - // Mappings - // s0 (str): unique_id - // s1 (str): version_string - // s2 (str): vcs_hash - // s3 (str): build_type - // s4 (bool): save_to_eeprom - // s5 (bool): software_reset - // s6 (bool): erase_eeprom - static char eeprom_config_json_buffer[256]; - - bool save_to_eeprom_flag = false; - bool software_reset_flag = false; - bool erase_eeprom_flag = false; - - // Control - for (int idx = 0; idx < num_params; idx += 1) { - if (strcmp(params[idx], "s4") == 0) { - save_to_eeprom_flag = string_to_boolean(values[idx]); - } - else if (strcmp(params[idx], "s5") == 0) { - software_reset_flag = string_to_boolean(values[idx]); - } - else if (strcmp(params[idx], "s6") == 0) { - erase_eeprom_flag = string_to_boolean(values[idx]); - } - } - - if (save_to_eeprom_flag) { - eeprom_save_all(); - } - - if (erase_eeprom_flag) { - eeprom_erase(software_reset_flag); - } - - if (software_reset_flag) { - software_reboot(); - } - - // Response - snprintf(eeprom_config_json_buffer, - sizeof(eeprom_config_json_buffer), - "%s" - "{\"s0\":\"%s\",\"s1\":\"%s\",\"s2\":\"%s\",\"s3\":\"%s\",\"s4\":%s,\"s5\":%s,\"s6\":%s}", - http_json_header, - metadata.unique_id, version_string, vcs_hash, build_type, - boolean_to_string(save_to_eeprom_flag), - boolean_to_string(erase_eeprom_flag), - boolean_to_string(software_reset_flag)); - - size_t data_length = strlen(eeprom_config_json_buffer); - file->data = eeprom_config_json_buffer; - file->len = data_length; - file->index = data_length; - file->flags = FS_FILE_FLAGS_HEADER_INCLUDED; - - return true; -} diff --git a/src/eeprom.h b/src/eeprom.h index 3e819c3..c9bad04 100644 --- a/src/eeprom.h +++ b/src/eeprom.h @@ -47,8 +47,6 @@ uint8_t eeprom_erase(bool); uint8_t eeprom_save_all(void); void eeprom_register_handler(eeprom_save_handler_t handler); -bool http_rest_system_control(struct fs_file *file, int num_params, char *params[], char *values[]); - #ifdef __cplusplus } diff --git a/src/html/web_portal.html b/src/html/web_portal.html index 593b82a..0b50580 100644 --- a/src/html/web_portal.html +++ b/src/html/web_portal.html @@ -608,8 +608,17 @@ - + + +
+ + +
+ + +
+ @@ -747,7 +756,7 @@

Warning

- + + + + +