MCPcopy Create free account
hub / github.com/Hieromon/AutoConnect / attach

Method attach

src/AutoConnectOTA.cpp:55–80  ·  view source on GitHub ↗

* 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 */

Source from the content-addressed store, hash-verified

53 * @param portal A reference of AutoConnect
54 */
55void 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

Callers 2

uploadMethod · 0.45
_attachOTAMethod · 0.45

Calls 4

FFunction · 0.85
resetMethod · 0.80
onMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected