* A handler for notifying the client of the progress of update processing. * This handler specifies the URI behavior defined as THandlerFunc of * ESP8266 WebServer (WebServer for ESP32). * Usually, that URI is /_ac/update_progress and will return the * processed amount of update processing to the client. */
| 531 | * processed amount of update processing to the client. |
| 532 | */ |
| 533 | void AutoConnectUpdateAct::_progress(void) { |
| 534 | String reqOperation = "op"; |
| 535 | String reqOperand; |
| 536 | String payload = String(""); |
| 537 | int httpCode; |
| 538 | static const char reply_msg_op[] PROGMEM = "invalid operation"; |
| 539 | static const char reply_msg_seq[] PROGMEM = "invalid sequence"; |
| 540 | static const char reply_msg_inv[] PROGMEM = "invalid request"; |
| 541 | static const char* content_type = "text/plain"; |
| 542 | |
| 543 | switch (_webServer->method()) { |
| 544 | |
| 545 | case HTTP_POST: |
| 546 | reqOperand = _webServer->arg(reqOperation); |
| 547 | switch (_status) { |
| 548 | case UPDATE_IDLE: |
| 549 | if (reqOperand == String(AUTOCONNECT_UPDATE_NOTIFY_START)) { |
| 550 | httpCode = 200; |
| 551 | _status = UPDATE_START; |
| 552 | } |
| 553 | else { |
| 554 | payload = String(FPSTR(reply_msg_seq)); |
| 555 | httpCode = 500; |
| 556 | } |
| 557 | break; |
| 558 | case UPDATE_SUCCESS: |
| 559 | if (reqOperand == String(AUTOCONNECT_UPDATE_NOTIFY_REBOOT)) { |
| 560 | _status = UPDATE_RESET; |
| 561 | httpCode = 200; |
| 562 | } |
| 563 | else { |
| 564 | payload = String(FPSTR(reply_msg_seq)); |
| 565 | httpCode = 500; |
| 566 | } |
| 567 | break; |
| 568 | default: |
| 569 | payload = String(FPSTR(reply_msg_op)); |
| 570 | httpCode = 500; |
| 571 | } |
| 572 | break; |
| 573 | |
| 574 | case HTTP_GET: |
| 575 | switch (_status) { |
| 576 | case UPDATE_PROGRESS: |
| 577 | payload = String(AUTOCONNECT_UPDATE_NOTIFY_PROGRESS) + ',' + String(_amount) + ':' + String(_binSize); |
| 578 | httpCode = 200; |
| 579 | break; |
| 580 | case UPDATE_IDLE: |
| 581 | case UPDATE_SUCCESS: |
| 582 | case UPDATE_NOAVAIL: |
| 583 | case UPDATE_FAIL: |
| 584 | payload = String(AUTOCONNECT_UPDATE_NOTIFY_END); |
| 585 | httpCode = 200; |
| 586 | break; |
| 587 | default: |
| 588 | payload = String(FPSTR(reply_msg_seq)); |
| 589 | httpCode = 500; |
| 590 | } |
nothing calls this directly
no outgoing calls
no test coverage detected