From 58fe50d81a49735ac2e8531c8f2eae5aa4112c96 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Thu, 7 Mar 2019 18:18:30 +0100 Subject: [PATCH] Update webserver layout Update webserver layout --- .github/ISSUE_TEMPLATE/Bug_report.md | 54 ++++++++---- .github/ISSUE_TEMPLATE/Custom.md | 43 ++++++--- .github/PULL_REQUEST_TEMPLATE.md | 10 +++ .github/stale.yml | 6 +- CODE_OF_CONDUCT.md | 76 ++++++++++++++++ CONTRIBUTING.md | 63 ++++++++++++++ SUPPORT.md | 22 +++++ sonoff/my_user_config.h | 6 +- sonoff/support.ino | 52 +++++++---- sonoff/xdrv_01_webserver.ino | 125 +++++++++++++++------------ sonoff/xdrv_02_mqtt.ino | 2 +- sonoff/xdrv_07_domoticz.ino | 2 +- sonoff/xdrv_09_timers.ino | 2 +- sonoff/xdrv_11_knx.ino | 2 +- sonoff/xsns_34_hx711.ino | 2 +- 15 files changed, 355 insertions(+), 112 deletions(-) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 CODE_OF_CONDUCT.md create mode 100644 CONTRIBUTING.md create mode 100644 SUPPORT.md diff --git a/.github/ISSUE_TEMPLATE/Bug_report.md b/.github/ISSUE_TEMPLATE/Bug_report.md index ad522ec4e..a0ab5e7e3 100644 --- a/.github/ISSUE_TEMPLATE/Bug_report.md +++ b/.github/ISSUE_TEMPLATE/Bug_report.md @@ -4,39 +4,61 @@ about: Create a report to help us improve --- -**IMPORTANT NOTICE** -If you do not complete the template below it is likely that your issue will not be addressed. When providing information about your issue please be as extensive as possible so that it can be solved by as little as possible responses. + -**FAILURE TO COMPLETE THE REQUESTED INFORMATION WILL RESULT IN YOUR ISSUE BEING CLOSED** + + + + + + + + -**Describe the bug** +### BUG DESCRIPTION _A clear and concise description of what the bug is._ -_Also, make sure these boxes are checked [x] before submitting your issue - Thank you!_ -- [ ] _Searched the problem in issues and in the wiki_ -- [ ] _Hardware used_ : -- [ ] _Development/Compiler/Upload tools used_ : -- [ ] _If a pre-compiled release or development binary was used, which one?_ : -- [ ] _You have tried latest release or development binaries?_ : -- [ ] _Provide the output of command_``status 0`` : +### REQUESTED INFORMATION +_Make sure these boxes are checked before submitting your issue. Thank you_ + +**FAILURE TO COMPLETE THE REQUESTED INFORMATION WILL RESULT IN YOUR ISSUE BEING CLOSED** + +- [ ] Read the [Contributing Guide and Policy](https://github.com/arendst/Sonoff-Tasmota/blob/development/CONTRIBUTING.md) and [the Code of Conduct](https://github.com/arendst/Sonoff-Tasmota/blob/development/CODE_OF_CONDUCT.md) +- [ ] Searched the problem in issues (https://github.com/arendst/Sonoff-Tasmota/issues) +- [ ] Searched the problem in the wiki (https://github.com/arendst/Sonoff-Tasmota/wiki/Troubleshooting) +- [ ] Searched the problem in the forum (https://groups.google.com/d/forum/sonoffusers) +- [ ] Searched the problem in the chat (https://discord.gg/Ks2Kzd4) +- [ ] Device used (i.e. Sonoff Basic) : _____ +- [ ] Tasmota binary firmware version number used : ____ / (pre-compiled or self-compiled ?) +- [ ] Development IDE - Compiler / Upload tools used : ____ / ____ +- [ ] Provide the output of command ``status 0`` : ``` -STATUS 0 OUTPUT HERE - DO NOT DELETE THE MARKERS ABOVE AND BELOW THIS LINE +STATUS 0 OUTPUT HERE: + + +``` +- [ ] Provide the output of console when you experience your issue if apply : +_(Please use_ ``weblog 4`` _for more debug information)_ +``` +CONSOLE OUTPUT HERE: + + ``` -**To Reproduce** +### TO REPRODUCE _Steps to reproduce the behavior:_ -**Expected behavior** +### EXPECTED BEHAVIOUR _A clear and concise description of what you expected to happen._ -**Screenshots** +### SCREENSHOTS _If applicable, add screenshots to help explain your problem._ -**Additional context** +### ADDITIONAL CONTEXT _Add any other context about the problem here._ diff --git a/.github/ISSUE_TEMPLATE/Custom.md b/.github/ISSUE_TEMPLATE/Custom.md index 4d1eba459..44bd847cb 100644 --- a/.github/ISSUE_TEMPLATE/Custom.md +++ b/.github/ISSUE_TEMPLATE/Custom.md @@ -4,24 +4,47 @@ about: Users Troubleshooting Help --- -**IMPORTANT NOTICE** -If you do not complete the template below it is likely that your issue will not be addressed. When providing information about your issue please be as extensive as possible so that it can be solved by as little as possible responses. + + + + + + + + + + + + + +### ISSUE DESCRIPTION - TROUBLESHOOTING +_A clear description of what the issue is and be as extensive as possible_ + + +### REQUESTED INFORMATION +_Make sure these boxes are checked before submitting your issue. Thank you_ **FAILURE TO COMPLETE THE REQUESTED INFORMATION WILL RESULT IN YOUR ISSUE BEING CLOSED** -Make sure these boxes are checked [x] before submitting your issue - Thank you! - +- [ ] Read the [Contributing Guide and Policy](https://github.com/arendst/Sonoff-Tasmota/blob/development/CONTRIBUTING.md) and [the Code of Conduct](https://github.com/arendst/Sonoff-Tasmota/blob/development/CODE_OF_CONDUCT.md) - [ ] Searched the problem in issues (https://github.com/arendst/Sonoff-Tasmota/issues) - [ ] Searched the problem in the wiki (https://github.com/arendst/Sonoff-Tasmota/wiki/Troubleshooting) - [ ] Searched the problem in the forum (https://groups.google.com/d/forum/sonoffusers) - [ ] Searched the problem in the chat (https://discord.gg/Ks2Kzd4) -- [ ] Development/Compiler/Upload tools used : -- [ ] Hardware used : -- [ ] If a pre-compiled release or development binary was used, which one? : -- [ ] You have tried latest release or development binaries? : +- [ ] Device used (i.e. Sonoff Basic) : _____ +- [ ] Tasmota binary firmware version number used : ____ / (pre-compiled or self-compiled ?) +- [ ] Development IDE - Compiler / Upload tools used : ____ / ____ - [ ] Provide the output of command ``status 0`` : ``` -STATUS 0 OUTPUT HERE -``` +STATUS 0 OUTPUT HERE: + +``` +- [ ] Provide the output of console when you experience your issue if apply : +_(Please use_ ``weblog 4`` _for more debug information)_ +``` +CONSOLE OUTPUT HERE: + + +``` **(Please, remember to close the issue when the problem has been addressed)** diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 000000000..aea7cd816 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,10 @@ +## Description: + +**Related issue (if applicable):** fixes # + +## Checklist: + - [ ] The pull request is done against the dev branch + - [ ] Only relevant files were touched (Also beware if your editor has auto-formatting feature enabled) + - [ ] Only one feature/fix was added per PR. + - [ ] The code change is tested and works. + - [ ] The code change pass travis tests. **Your PR cannot be merged unless tests pass** diff --git a/.github/stale.yml b/.github/stale.yml index 88c5f7c21..484010321 100644 --- a/.github/stale.yml +++ b/.github/stale.yml @@ -1,9 +1,9 @@ # Number of days of inactivity before an Issue or Pull Request becomes stale -daysUntilStale: 45 +daysUntilStale: 25 # Number of days of inactivity before a stale Issue or Pull Request is closed. # Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale. -daysUntilClose: 15 +daysUntilClose: 5 # Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable exemptLabels: @@ -37,4 +37,4 @@ closeComment: > limitPerRun: 30 # Limit to only `issues` or `pulls` -only: issues +#only: issues diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 000000000..1408ce048 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,76 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, sex characteristics, gender identity and expression, +level of experience, education, socio-economic status, nationality, personal +appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at https://sidweb.nl/cms3/en/contact. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see +https://www.contributor-covenant.org/faq diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..7cfcdfadb --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,63 @@ +# Contributing to Sonoff-Tasmota + +**Any contribution helps our team and makes Tasmota better for the entire community!** + +Everybody is welcome and invited to contribute to Sonoff-Tasmota Project by: + +* Testing newly released features and reporting issues. +* Providing Pull Requests (Features, Proof of Concepts, Language files or Fixes) +* Contributing missing documentation for features and devices on our [Wiki](https://github.com/arendst/Sonoff-Tasmota/wiki/Contributing) + +This document describes rules that are in effect for this repository, meant for handling issues by contributors in the issue tracker and PRs. + +## Opening New Issues + +**Issue tracker is NOT a general discussion forum!** +1. Opening an issue means that a problem exists in the code and should be addressed by the project contributors. +2. When opening an issue, it is required to fill out the presented template. The requested information is important! If the template is ignored or insufficient info about the issue is provided, the issue may be closed. +3. Questions of type "How do I..." or "Can you please help me with..." or "Can Tasmota do..." WILL NOT be handled here. Such questions should be directed at a discussion forum or to the Tasmota Support Chat. All issues of this type will be closed with a simple reference to this contributing policy. +4. Issues about topics already handled in the documentation will be closed in a similar manner. +5. Issues for unmerged PRs will be closed. If there is an issue with a PR, the explanation should be added to the PR itself. +6. Issues with accompanied investigation that shows the root of the problem should be given priority. +7. Duplicate issues will be closed. + +## Triaging of Issues/PR's + +1. Any contributor to the project can participate in the triaging process, if he/she chooses to do so. +2. An issue that needs to be closed, either due to not complying with this policy, or for other reasons, should be closed by a contributor. +3. Issues that are accepted should be marked with appropriate labels. +4. Issues that could impact functionality for many users should be considered severe. +5. Issues caused by the SDK or chip should not be marked severe, as there usually isn’t much to be done. Common sense should be applied when deciding. Such issues should be documented in the Wiki, for reference by users. +6. Issues with feature requests should be discussed for viability/desirability. +7. Feature requests or changes that are meant to address a very specific/limited use case, especially if at the expense of increased code complexity, may be denied, or may be required to be redesigned, generalized, or simplified. +8. Feature requests that are not accompanied by a PR: + * could be closed immediately (denied). + * could be closed after some predetermined period of time (left as candidate for somebody to pick up). +9. In some cases, feedback may be requested from the issue reporter, either as additional info for clarification, additional testing, or other. If no feedback is provided, the issue may be closed by a contributor or after 30 days by the STALE bot. + +## Pull requests + +A Pull Request (PR) is the process where code modifications are managed in GitHub. + +The process is straight-forward. + + - Read [How to get faster PR reviews](https://github.com/kubernetes/community/blob/master/contributors/guide/pull-requests.md#best-practices-for-faster-reviews) by Kubernetes (but skip step 0) + - Fork the Sonoff-Tasmota Repository [git repository](https://github.com/arendst/Sonoff-Tasmota). + - Write/Change the code in your Fork for a new feature, bug fix, new sensor, optimization, etc. + - Ensure tests work. + - Create a Pull Request against the [**dev**](https://github.com/arendst/Sonoff-Tasmota/tree/dev) branch of Sonoff-Tasmota. + +1. All pull requests must be done against the dev branch. +2. Only relevant files should be touched (Also beware if your editor has auto-formatting feature enabled). +3. Only one feature/fix should be added per PR. +4. If adding a new functionality (new hardware, new library support) not related to an existing component move it to it's own modules (.ino file). +5. PRs that don't compile (break Travis) or cause coding errors will not be merged. Please fix the issue. Same goes for PRs that are raised against older commit in dev - you might need to rebase and resolve conflicts. +6. All pull requests should undergo peer review by at least one contributor other than the creator, excepts for the owner. +7. All pull requests should consider updates to the documentation. +8. Pull requests that address an outstanding issue, particularly an issue deemed to be severe, should be given priority. +9. If a PR is accepted, then it should undergo review and updated based on the feedback provided, then merged. +10. Pull requests that don't meet the above will be denied and closed. + + + + diff --git a/SUPPORT.md b/SUPPORT.md new file mode 100644 index 000000000..46fa03ebc --- /dev/null +++ b/SUPPORT.md @@ -0,0 +1,22 @@ +# Sonoff-Tasmota Support + +If you're looking for support on **Sonoff-Tasmota** there are some options available: + +### Documentation: + +* [Wiki Pages](https://github.com/arendst/Sonoff-Tasmota/wiki): For information on how to Flash Tasmota, configure and use it. +* [Troubleshooting Information](https://github.com/arendst/Sonoff-Tasmota/wiki/Troubleshooting): For information on common problems and solutions. +* [Commands Information](https://github.com/arendst/Sonoff-Tasmota/wiki/Commands): For information on all the commands supported by Tasmota. + +### Support's Community: + +* [Tasmota Forum](https://groups.google.com/d/forum/sonoffusers): For usage and discussions. +* [Tasmota Support Chat](https://discord.gg/Ks2Kzd4): For support, troubleshooting and general questions. You have better chances to get fast answers from members of the Tasmota Community. +* [Search in Issues](https://github.com/arendst/Sonoff-Tasmota/issues): You might find an answer to your question by searching current or closed issues. + +### Developers' Community: + +* [Bug Report](https://github.com/arendst/Sonoff-Tasmota/issues/new?template=Bug_report.md): For reporting Bugs of Tasmota Software. +* [Feature Request](https://github.com/arendst/Sonoff-Tasmota/issues/new?template=Feature_request.md): For requesting features/functions to Tasmota Software. +* [Troubleshooting](https://github.com/arendst/Sonoff-Tasmota/issues/new?template=Custom.md): As a last resort, you can open new *Troubleshooting* issue on GitHub if the solution could not be found using the other channels. Just remember: the more info you provide the more chances you'll have to get an accurate answer. +* [Issue a question](https://github.com/arendst/Sonoff-Tasmota/issues/new/choose): As a last resort, you can open new *Question* issue on GitHub if the answer could not be found using the other channels. Just remember: the more info you provide the more chances you'll have to get an accurate answer. diff --git a/sonoff/my_user_config.h b/sonoff/my_user_config.h index e8d900ebe..b5c52ff81 100644 --- a/sonoff/my_user_config.h +++ b/sonoff/my_user_config.h @@ -280,8 +280,8 @@ // -- Rules --------------------------------------- #define USE_RULES // Add support for rules (+4k4 code) - #define USE_EXPRESSION // Add support for expression evaluation in rules (+3k2 code, +64 bytes mem) - #define SUPPORT_MQTT_EVENT // Support trigger event with MQTT subscriptions (+3k5 code) +// #define USE_EXPRESSION // Add support for expression evaluation in rules (+3k2 code, +64 bytes mem) +// #define SUPPORT_MQTT_EVENT // Support trigger event with MQTT subscriptions (+3k5 code) // -- Internal Analog input ----------------------- #define USE_ADC_VCC // Display Vcc in Power status. Disable for use as Analog input on selected devices @@ -291,7 +291,7 @@ //#define USE_DS18x20_LEGACY // Optional for more than one DS18x20 sensors with dynamic scan using library OneWire (+1k5 code) #define USE_DS18x20 // Optional for more than one DS18x20 sensors with id sort, single scan and read retry (+1k3 code) // #define W1_PARASITE_POWER // If using USE_DS18x20 then optimize for parasite powered sensors -// #define DS18B20_INTERNAL_PULLUP // Use INPUT_PULLUP internal pullup resistors for single DS18B20 +// #define DS18B20_INTERNAL_PULLUP // Use INPUT_PULLUP internal pullup resistors for single DS18B20 // -- I2C sensors --------------------------------- #define USE_I2C // I2C using library wire (+10k code, 0k2 mem, 124 iram) diff --git a/sonoff/support.ino b/sonoff/support.ino index 8bb9d1dea..67f53d451 100644 --- a/sonoff/support.ino +++ b/sonoff/support.ino @@ -160,28 +160,33 @@ double CharToDouble(const char *str) char strbuf[24]; strlcpy(strbuf, str, sizeof(strbuf)); - char *pt; - double left = atoi(strbuf); + char *pt = strbuf; + while ((*pt != '\0') && isblank(*pt)) { pt++; } // Trim leading spaces + + signed char sign = 1; + if (*pt == '-') { sign = -1; } + if (*pt == '-' || *pt=='+') { pt++; } // Skip any sign + + double left = 0; + if (*pt != '.') { + left = atoi(pt); // Get left part + while (isdigit(*pt)) { pt++; } // Skip number + } + double right = 0; - short len = 0; - pt = strtok (strbuf, "."); - if (pt) { - pt = strtok (NULL, "."); - if (pt) { - right = atoi(pt); - len = strlen(pt); - double fac = 1; - while (len) { - fac /= 10.0; - len--; - } - // pow is also very large - //double fac=pow(10,-len); - right *= fac; + if (*pt == '.') { + pt++; + right = atoi(pt); // Decimal part + while (isdigit(*pt)) { + pt++; + right /= 10.0; } } + double result = left + right; - if (left < 0) { result = left - right; } + if (sign < 0) { + return -result; // Add negative sign + } return result; } @@ -1274,6 +1279,17 @@ void AddLog_P(uint8_t loglevel, const char *formatP, const char *formatP2) AddLog(loglevel); } +void AddLog_P2(uint8_t loglevel, PGM_P formatP, ...) +{ + // This uses char strings. Be aware of sending %% if % is needed + va_list arg; + va_start(arg, formatP); + int len = vsnprintf_P(log_data, sizeof(log_data), formatP, arg); + va_end(arg); + + AddLog(loglevel); +} + void AddLogBuffer(uint8_t loglevel, uint8_t *buffer, int count) { snprintf_P(log_data, sizeof(log_data), PSTR("DMP:")); diff --git a/sonoff/xdrv_01_webserver.ino b/sonoff/xdrv_01_webserver.ino index bb2af46e9..8df9529b4 100644 --- a/sonoff/xdrv_01_webserver.ino +++ b/sonoff/xdrv_01_webserver.ino @@ -283,10 +283,11 @@ const char HTTP_MSG_SLIDER2[] PROGMEM = const char HTTP_MSG_RSTRT[] PROGMEM = "
" D_DEVICE_WILL_RESTART "

"; -const char HTTP_BTN_MENU1[] PROGMEM = +const char HTTP_BTN_CONF[] PROGMEM = "
" + "
"; +const char HTTP_BTN_MENU1[] PROGMEM = #ifndef FIRMWARE_MINIMAL - "
" "

" #endif "
" @@ -297,30 +298,30 @@ const char HTTP_BTN_RSTRT[] PROGMEM = const char HTTP_BTN_MENU_MODULE[] PROGMEM = "

" "

"; -const char HTTP_BTN_RESET[] PROGMEM = - "
" - "
"; const char HTTP_BTN_MENU4[] PROGMEM = "

" "

" "

"; + +const char HTTP_BTN_RESET[] PROGMEM = + "
" + "
"; const char HTTP_BTN_MENU5[] PROGMEM = "

" "

"; + const char HTTP_BTN_MAIN[] PROGMEM = "
" "
"; const char HTTP_FORM_LOGIN[] PROGMEM = + "
" "
" - "
" D_USER "

" - "
" D_PASSWORD "

" + "

" D_USER "

" + "

" D_PASSWORD "

" "
" - "
"; - -const char HTTP_BTN_CONF[] PROGMEM = - "
" - "
"; + "" + "
"; const char HTTP_FORM_TEMPLATE[] PROGMEM = "
 " D_TEMPLATE_PARAMETERS " " @@ -481,37 +482,32 @@ void StartWebserver(int type, IPAddress ipweb) if (!Settings.web_refresh) { Settings.web_refresh = HTTP_REFRESH_TIME; } if (!webserver_state) { if (!WebServer) { - WebServer = new ESP8266WebServer((HTTP_MANAGER==type || HTTP_MANAGER_RESET_ONLY == type) ? 80 : WEB_PORT); + WebServer = new ESP8266WebServer((HTTP_MANAGER == type || HTTP_MANAGER_RESET_ONLY == type) ? 80 : WEB_PORT); WebServer->on("/", HandleRoot); WebServer->onNotFound(HandleNotFound); + WebServer->on("/up", HandleUpgradeFirmware); + WebServer->on("/u1", HandleUpgradeFirmwareStart); // OTA + WebServer->on("/u2", HTTP_POST, HandleUploadDone, HandleUploadLoop); + WebServer->on("/u2", HTTP_OPTIONS, HandlePreflightRequest); + WebServer->on("/cs", HandleConsole); + WebServer->on("/cm", HandleHttpCommand); #ifndef FIRMWARE_MINIMAL + WebServer->on("/cn", HandleConfiguration); + WebServer->on("/md", HandleModuleConfiguration); + WebServer->on("/wi", HandleWifiConfiguration); + WebServer->on("/lg", HandleLoggingConfiguration); + WebServer->on("/tp", HandleTemplateConfiguration); + WebServer->on("/co", HandleOtherConfiguration); + WebServer->on("/dl", HandleBackupConfiguration); + WebServer->on("/rs", HandleRestoreConfiguration); WebServer->on("/rt", HandleResetConfiguration); -#endif // FIRMWARE_MINIMAL - if (HTTP_MANAGER_RESET_ONLY != type) { - WebServer->on("/up", HandleUpgradeFirmware); - WebServer->on("/u1", HandleUpgradeFirmwareStart); // OTA - WebServer->on("/u2", HTTP_POST, HandleUploadDone, HandleUploadLoop); - WebServer->on("/u2", HTTP_OPTIONS, HandlePreflightRequest); - WebServer->on("/cs", HandleConsole); - WebServer->on("/cm", HandleHttpCommand); -#ifndef FIRMWARE_MINIMAL - WebServer->on("/cn", HandleConfiguration); - WebServer->on("/md", HandleModuleConfiguration); - WebServer->on("/wi", HandleWifiConfiguration); - WebServer->on("/lg", HandleLoggingConfiguration); - WebServer->on("/tp", HandleTemplateConfiguration); - WebServer->on("/co", HandleOtherConfiguration); - WebServer->on("/dl", HandleBackupConfiguration); - WebServer->on("/rs", HandleRestoreConfiguration); - WebServer->on("/rt", HandleResetConfiguration); - WebServer->on("/in", HandleInformation); + WebServer->on("/in", HandleInformation); #ifdef USE_EMULATION - HueWemoAddHandlers(); + HueWemoAddHandlers(); #endif // USE_EMULATION - XdrvCall(FUNC_WEB_ADD_HANDLER); - XsnsCall(FUNC_WEB_ADD_HANDLER); + XdrvCall(FUNC_WEB_ADD_HANDLER); + XsnsCall(FUNC_WEB_ADD_HANDLER); #endif // Not FIRMWARE_MINIMAL - } } reset_web_log_flag = false; WebServer->begin(); // Web server start @@ -727,7 +723,7 @@ void WSContentSendStyle() WSContentSendStyle(F("")); } -void WSContentStop(void) +void WSContentEnd(void) { if (WifiIsInManagerMode()) { if (WifiConfigCounter()) { @@ -767,7 +763,7 @@ void WebRestart(uint8_t type) } else { WSContentSend(FPSTR(HTTP_BTN_MAIN)); } - WSContentStop(); + WSContentEnd(); ShowWebSource(SRC_WEBGUI); restart_flag = 2; @@ -780,7 +776,16 @@ void HandleWifiLogin(void) WSContentStart(FPSTR(D_CONFIGURE_WIFI), false); // false means show page no matter if the client has or has not credentials WSContentSendStyle(); WSContentSend(FPSTR(HTTP_FORM_LOGIN)); - WSContentStop(); + + if (WifiIsInManagerMode()) { + WSContentSend(F("
")); + WSContentSend(FPSTR(HTTP_BTN_RSTRT)); +#ifndef FIRMWARE_MINIMAL + WSContentSend(FPSTR(HTTP_BTN_RESET)); +#endif // FIRMWARE_MINIMAL + } + + WSContentEnd(); } void HandleRoot(void) @@ -864,10 +869,15 @@ void HandleRoot(void) #endif // Not FIRMWARE_MINIMAL if (HTTP_ADMIN == webserver_state) { +#ifndef FIRMWARE_MINIMAL + WSContentSend(FPSTR(HTTP_BTN_CONF)); +#else + WSContentSend(F("
")); +#endif // Not FIRMWARE_MINIMAL WSContentSend(FPSTR(HTTP_BTN_MENU1)); WSContentSend(FPSTR(HTTP_BTN_RSTRT)); } - WSContentStop(); + WSContentEnd(); } bool HandleRootStatusRefresh(void) @@ -969,7 +979,7 @@ void HandleConfiguration(void) WSContentSend(FPSTR(HTTP_BTN_RESET)); WSContentSend(FPSTR(HTTP_BTN_MENU5)); WSContentSend(FPSTR(HTTP_BTN_MAIN)); - WSContentStop(); + WSContentEnd(); } /*-------------------------------------------------------------------------------------------*/ @@ -1056,7 +1066,7 @@ void HandleTemplateConfiguration(void) WSContentSend(FPSTR(HTTP_FORM_TEMPLATE_FLAG)); WSContentSend(FPSTR(HTTP_FORM_END)); WSContentSend(FPSTR(HTTP_BTN_CONF)); - WSContentStop(); + WSContentEnd(); } void TemplateSaveSettings(void) @@ -1163,7 +1173,7 @@ void HandleModuleConfiguration(void) WSContentSend(F("")); WSContentSend(FPSTR(HTTP_FORM_END)); WSContentSend(FPSTR(HTTP_BTN_CONF)); - WSContentStop(); + WSContentEnd(); } void ModuleSaveSettings(void) @@ -1210,7 +1220,7 @@ String htmlEscape(String s) void HandleWifiConfiguration(void) { - if (!HttpCheckPriviledgedAccess()) { return; } + if (!HttpCheckPriviledgedAccess(!WifiIsInManagerMode())) { return; } AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_CONFIGURE_WIFI); @@ -1220,7 +1230,7 @@ void HandleWifiConfiguration(void) return; } - WSContentStart(FPSTR(S_CONFIGURE_WIFI)); + WSContentStart(FPSTR(S_CONFIGURE_WIFI), !WifiIsInManagerMode()); WSContentSend(FPSTR(HTTP_SCRIPT_WIFI)); WSContentSendStyle(); @@ -1303,6 +1313,7 @@ void HandleWifiConfiguration(void) } if (WifiIsInManagerMode()) { + WSContentSend(F("
")); WSContentSend(FPSTR(HTTP_BTN_RSTRT)); #ifndef FIRMWARE_MINIMAL WSContentSend(FPSTR(HTTP_BTN_RESET)); @@ -1310,7 +1321,7 @@ void HandleWifiConfiguration(void) } else { WSContentSend(FPSTR(HTTP_BTN_CONF)); } - WSContentStop(); + WSContentEnd(); } void WifiSaveSettings(void) @@ -1371,7 +1382,7 @@ void HandleLoggingConfiguration(void) WSContentSend_P(HTTP_FORM_LOG2, Settings.syslog_host, Settings.syslog_port, Settings.tele_period); WSContentSend(FPSTR(HTTP_FORM_END)); WSContentSend(FPSTR(HTTP_BTN_CONF)); - WSContentStop(); + WSContentEnd(); } void LoggingSaveSettings(void) @@ -1448,7 +1459,7 @@ void HandleOtherConfiguration(void) WSContentSend(FPSTR(HTTP_FORM_END)); WSContentSend(FPSTR(HTTP_BTN_CONF)); - WSContentStop(); + WSContentEnd(); } void OtherSaveSettings(void) @@ -1535,16 +1546,16 @@ void HandleBackupConfiguration(void) void HandleResetConfiguration(void) { - if (!HttpCheckPriviledgedAccess()) { return; } + if (!HttpCheckPriviledgedAccess(!WifiIsInManagerMode())) { return; } AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_RESET_CONFIGURATION); - WSContentStart(FPSTR(S_RESET_CONFIGURATION), (HTTP_MANAGER_RESET_ONLY != webserver_state)); + WSContentStart(FPSTR(S_RESET_CONFIGURATION), !WifiIsInManagerMode()); WSContentSendStyle(); WSContentSend(F("
" D_CONFIGURATION_RESET "
")); WSContentSend(FPSTR(HTTP_MSG_RSTRT)); WSContentSend(FPSTR(HTTP_BTN_MAIN)); - WSContentStop(); + WSContentEnd(); char command[CMDSZ]; snprintf_P(command, sizeof(command), PSTR(D_CMND_RESET " 1")); @@ -1562,7 +1573,7 @@ void HandleRestoreConfiguration(void) WSContentSend(FPSTR(HTTP_FORM_RST)); WSContentSend_P(HTTP_FORM_RST_UPG, D_RESTORE); WSContentSend(FPSTR(HTTP_BTN_CONF)); - WSContentStop(); + WSContentEnd(); upload_error = 0; upload_file_type = UPL_SETTINGS; @@ -1664,7 +1675,7 @@ void HandleInformation(void) "
")); // WSContentSend(F("
")); WSContentSend(FPSTR(HTTP_BTN_MAIN)); - WSContentStop(); + WSContentEnd(); } #endif // Not FIRMWARE_MINIMAL @@ -1681,7 +1692,7 @@ void HandleUpgradeFirmware(void) WSContentSend_P(HTTP_FORM_UPG, Settings.ota_url); WSContentSend_P(HTTP_FORM_RST_UPG, D_UPGRADE); WSContentSend(FPSTR(HTTP_BTN_MAIN)); - WSContentStop(); + WSContentEnd(); upload_error = 0; upload_file_type = UPL_TASMOTA; @@ -1709,7 +1720,7 @@ void HandleUpgradeFirmwareStart(void) WSContentSend(F("
" D_UPGRADE_STARTED " ...
")); WSContentSend(FPSTR(HTTP_MSG_RSTRT)); WSContentSend(FPSTR(HTTP_BTN_MAIN)); - WSContentStop(); + WSContentEnd(); snprintf_P(command, sizeof(command), PSTR(D_CMND_UPGRADE " 1")); ExecuteWebCommand(command, SRC_WEBGUI); @@ -1757,7 +1768,7 @@ void HandleUploadDone(void) SettingsBufferFree(); WSContentSend(F("
")); WSContentSend(FPSTR(HTTP_BTN_MAIN)); - WSContentStop(); + WSContentEnd(); } void HandleUploadLoop(void) @@ -2038,7 +2049,7 @@ void HandleConsole(void) WSContentSendStyle(); WSContentSend(FPSTR(HTTP_FORM_CMND)); WSContentSend(FPSTR(HTTP_BTN_MAIN)); - WSContentStop(); + WSContentEnd(); } void HandleConsoleRefresh(void) diff --git a/sonoff/xdrv_02_mqtt.ino b/sonoff/xdrv_02_mqtt.ino index d2874f490..ea0cc01e5 100644 --- a/sonoff/xdrv_02_mqtt.ino +++ b/sonoff/xdrv_02_mqtt.ino @@ -941,7 +941,7 @@ void HandleMqttConfiguration(void) Settings.mqtt_fulltopic); WSContentSend(FPSTR(HTTP_FORM_END)); WSContentSend(FPSTR(HTTP_BTN_CONF)); - WSContentStop(); + WSContentEnd(); } void MqttSaveSettings(void) diff --git a/sonoff/xdrv_07_domoticz.ino b/sonoff/xdrv_07_domoticz.ino index a90245e08..ec4e4f142 100644 --- a/sonoff/xdrv_07_domoticz.ino +++ b/sonoff/xdrv_07_domoticz.ino @@ -485,7 +485,7 @@ void HandleDomoticzConfiguration(void) WSContentSend(F("")); WSContentSend(FPSTR(HTTP_FORM_END)); WSContentSend(FPSTR(HTTP_BTN_CONF)); - WSContentStop(); + WSContentEnd(); } void DomoticzSaveSettings(void) diff --git a/sonoff/xdrv_09_timers.ino b/sonoff/xdrv_09_timers.ino index cfc18904a..094fbcd96 100644 --- a/sonoff/xdrv_09_timers.ino +++ b/sonoff/xdrv_09_timers.ino @@ -721,7 +721,7 @@ void HandleTimerConfiguration(void) WSContentSend(FPSTR(HTTP_FORM_TIMER4)); WSContentSend(FPSTR(HTTP_FORM_END)); WSContentSend(FPSTR(HTTP_BTN_CONF)); - WSContentStop(); + WSContentEnd(); } void TimerSaveSettings(void) diff --git a/sonoff/xdrv_11_knx.ino b/sonoff/xdrv_11_knx.ino index d39001250..379f01157 100644 --- a/sonoff/xdrv_11_knx.ino +++ b/sonoff/xdrv_11_knx.ino @@ -947,7 +947,7 @@ void HandleKNXConfiguration(void) WSContentSend(F("")); WSContentSend(FPSTR(HTTP_FORM_END)); WSContentSend(FPSTR(HTTP_BTN_CONF)); - WSContentStop(); + WSContentEnd(); } } diff --git a/sonoff/xsns_34_hx711.ino b/sonoff/xsns_34_hx711.ino index 5057b8c47..2de8b985a 100644 --- a/sonoff/xsns_34_hx711.ino +++ b/sonoff/xsns_34_hx711.ino @@ -434,7 +434,7 @@ void HandleHxAction(void) WSContentSend_P(HTTP_FORM_HX711, stemp1, stemp2); WSContentSend(FPSTR(HTTP_FORM_END)); WSContentSend(FPSTR(HTTP_BTN_CONF)); - WSContentStop(); + WSContentEnd(); } void HxSaveSettings(void)