* Attach the AutoConnectOTA to hosted AutoConnect which constitutes * the update process. This function creates an OTA operation page as * AutoConnectAux instance and allows it to receive binary updates. * @param portal A reference of AutoConnect */
| 53 | * @param portal A reference of AutoConnect |
| 54 | */ |
| 55 | void AutoConnectOTA::attach(AutoConnectExt<AutoConnectConfigExt>& portal) { |
| 56 | AutoConnectAux* updatePage; |
| 57 | |
| 58 | updatePage = new AutoConnectAux(String(FPSTR(_pageUpdate.uri)), String(FPSTR(_pageUpdate.title)), _pageUpdate.menu); |
| 59 | _buildAux(updatePage, &_pageUpdate, lengthOf(_elmUpdate)); |
| 60 | AutoConnectStyle& s_cap = updatePage->getElement<AutoConnectStyle>(F("s_cap")); |
| 61 | if (extraCaption) { |
| 62 | s_cap.enable = true; |
| 63 | AutoConnectText& cap = updatePage->getElement<AutoConnectText>(F("cap")); |
| 64 | String extra = String(F("<span class=\"s_cap\">")) + String(extraCaption) + String(F("</span>")); |
| 65 | cap.value += extra; |
| 66 | } |
| 67 | else |
| 68 | s_cap.enable = false; |
| 69 | _auxUpdate.reset(updatePage); |
| 70 | |
| 71 | updatePage = new AutoConnectAux(String(FPSTR(_pageResult.uri)), String(FPSTR(_pageResult.title)), _pageResult.menu); |
| 72 | _buildAux(updatePage, &_pageResult, lengthOf(_elmResult)); |
| 73 | _auxResult.reset(updatePage); |
| 74 | |
| 75 | _auxResult->on(std::bind(&AutoConnectOTA::_updated, this, std::placeholders::_1, std::placeholders::_2)); |
| 76 | _auxResult->onUpload<AutoConnectOTA>(*this); |
| 77 | |
| 78 | portal.join(*_auxUpdate.get()); |
| 79 | portal.join(*_auxResult.get()); |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * Create the update operation pages using a predefined page structure |