Adds the OTA Update documentation (continues)

pull/123/head
Hieromon Ikasamo 6 years ago
parent be22522ca2
commit b1059bc830
  1. 79
      mkdocs/apiupdate.md
  2. 12
      mkdocs/otaserver.md
  3. 2
      mkdocs/otaupdate.md

@ -14,6 +14,8 @@ AutoConnectUpdate(const String& host, const uint16_t port, const String& uri, co
<dd><span class="apidef">ledOn</span><span class="apidesc">Active signal to light the LED ticker during the update. Specifies **HIGH** or **LOW**</span></dt>
</dl>
The AutoConnectUpdate class inherits from the **ESP8266HTTPUpdate** (**HTTPUpdate** for ESP32) class.
## <i class="fa fa-code"></i> Public member functions
### <i class="fa fa-caret-right"></i> attach
@ -21,7 +23,7 @@ AutoConnectUpdate(const String& host, const uint16_t port, const String& uri, co
```cpp
void AutoConnectUpdate::attach(AutoConnect& portal)
```
Attaches the [AutoConnectUpdate](apiupdate.md) to the AutoConnect which constitutes the bedrock of the update process. This function creates a [dialog page](otaserver.md#behavior-of-the-autoconnectupdate-class) for the update operation as an instance of [AutoConnectAux](apiaux.me) and participates in the [AutoConnect menu](menu.md).
Attaches the [AutoConnectUpdate](apiupdate.md) to the AutoConnect which constitutes the bedrock of the update process. This function creates a [dialog page](otaserver.md#behavior-of-the-autoconnectupdate-class) for the update operation as an instance of [AutoConnectAux](apiaux.md) and participates in the [AutoConnect menu](menu.md).
<dl class="apidl">
<dt>**Parameter**</dt>
<dd><span class="apidef">portal</span><span class="apidesc">Specifies a reference to the AutoConnect instance to attach.</span></dd>
@ -43,18 +45,91 @@ Disable the Update item in [AutoConnect menu](menu.md). The [AutoConnect::disabl
```cpp
void AutoConnectUpdate::enable(void)
```
Makes [AutoConnectUpdate](apiupdate.md) class available by incorporating the OTA update function into the [AutoConnect menu](menu.md). In ordinally, the [AutoConnectUpdate](apiupdate.md) class becomes available by just calling the [AutoConnectUpdate::attach](#attach) function.
Makes [AutoConnectUpdate](apiupdate.md) class available by incorporating the OTA update function into the [AutoConnect menu](menu.md). In ordinarily, the [AutoConnectUpdate](apiupdate.md) class becomes available by just calling the [AutoConnectUpdate::attach](#attach) function.
### <i class="fa fa-caret-right"></i> handleUpdate
```cpp
void AutoConnectUpdate::handleUpdate(void)
```
Performs the update process. This function is called by [AutoConnect::handleClient](api.md#handleClient) when AutoConnectUpdate is enabled. In many cases, sketches do not need to call this function on purpose.
### <i class="fa fa-caret-right"></i> isEnabled
```cpp
bool AutoConnectUpdate::isEnabled(void)
```
Returns whether AutoConnectUpdate is enabled.
### <i class="fa fa-caret-right"></i> rebootOnUpdate
```cpp
void AutoConnectUpdate::rebootOnUpdate(bool reboot)
```
Specifies whether or not to automatically restart the module as a result of the successful completion of the update process.
<dl class="apidl">
<dt>**Parameter**</dt>
<dd><span class="apidef">reboot</span><span class="apidesc">If specified the **true** then the ESP module will reboot after the updating successfully completed. For the **false**, The module does not reboot automatically. The updated firmware remains stored in the flash update firmware area equipped on the ESP module. The boot process during the next start turn of the module by reset will copy the updated firmware to the actual program area and a new sketch program will start. The default value is the true.</span></dd>
</dl>
This function inherits from the ESP8266HTTPUpdate (HTTPUpdate for ESP32) class.
### <i class="fa fa-caret-right"></i> setLedPin
```cpp
void AutoConnectUpdate::setLedPin(int ledPin, uint8_t ledOn)
```
Sets the port and the ON signal level of the externally connected LED that should act as a ticker during the update process.
<dl class="apidl">
<dt>**Parameter**</dt>
<dd><span class="apidef">ledPin</span><span class="apidesc">Specifies the PIN connected external LED for the ticker. The default is defined as the **AUTOCONNECT_TICKER_PORT** macro in the `AutoConnectDefs.h` header file and it is derived from the board-specific **LED_BUILTIN**. By default, the AutoConnectUpdate class does not use the ticker for boards without the LED_BUILTIN definition. If you connect the ticker LED externally, you need to specify the PIN using the [setLedPin](#setledpin) function.</span></dd>
<dd><span class="apidef">ledOn</span><span class="apidesc">Specifies the the ON signal level of the LED PIN port. It is **HIGH** or **LOW**.</span></dd>
</dl>
This function inherits from the ESP8266HTTPUpdate (HTTPUpdate for ESP32) class.
### <i class="fa fa-caret-right"></i> status
```cpp
AC_UPDATESTATUS_t AutoConnectUpdate::status(void)
```
Returns the update process status transition indicator as an enumerated value of the **AC_UPDATESTATUS_t** type that indicates the process status of the AutoConnectUpdate class.
<dl class="apidl">
<dt>**Return value**</dt>
<dd>One of the enumerated values indicating the status of the Update class as follows:</dd>
<dd><span class="apidef"></span><span class="apidesc">
- UPDATE_RESET : Update process ended, need to reset.
- UPDATE_IDLE : Update process has not started.
- UPDATE_START : Update process has been started.
- UPDATE_PROGRESS : Update process has been started.
- UPDATE_SUCCESS : Update successfully completed.
- UPDATE_NOAVAIL : No available update.
- UPDATE_FAIL : Update failed.</span></dd>
</dl>
## <i class="fa fa-code"></i> Public member variables
### <i class="fa fa-caret-right"></i> host
Update server address. Specifies IP address or FQDN.
<dl class="apidl">
<dt>**Type**</dt>
<dd><span class="apidef">String</span></dd><dd><span class="apidesc"></span></dd>
</dl>
### <i class="fa fa-caret-right"></i> port
HTTP port for the updating process.
<dl class="apidl">
<dt>**Type**</dt>
<dd><span class="apidef">String</span><span class="apidesc">The default is defined as the **AUTOCONNECT_UPDATE_PORT** macro in the `AutoConnectDefs.h` header file.</span></dd>
</dl>
### <i class="fa fa-caret-right"></i> uri
URI on the update server that has deployed available binary sketch files.
<dl class="apidl">
<dt>**Type**</dt>
<dd><span class="apidef">String</span></dd><dd><span class="apidesc"></span></dd>
</dl>

@ -16,7 +16,7 @@ To embed the AutoConnectUpdate class into your sketch, basically follow these st
1. Declare an ESP8266WebServer object. (In ESP32, as WebServer)
2. Declare an AutoConnect object with an ESP8266WebServer object.
3. Declare an [AutoConnectUpdate](apiupdate.md) object.
3. Declare an [AutoConnectUpdate](apiupdate.md) object with the update server address and the HTTP port as parameters.
4. Invokes [AutoConnect::begin](api.md#begin) function.
5. Attach the AutoConnectUpdate object to AutoConnect using [AutoConnectUpdate::attach](apiupdate.md#attach) function.
6. Invokes [AutoConnect::handleClient](api.md#handleclient) function in the `loop()`.
@ -45,23 +45,25 @@ void loop() {
### <i class="fas fa-desktop"></i> Behavior of the AutoConnectUpdate class
A sketch incorporating the AutoConnectUpdate class has an extended menu item as **UPDATE** in the AutoConnect menu. **UPDATE** as menu item will be attached by the AutoConnectUpdate automatically. The UPDATE menu first requests the [update server](#update-server-for-the-autoconnectupdate-class) from the ESP module for a [**catalog list**](otaserver.md#2-the-catalog-list-content) of updatable binary sketch files. The update server sends back the catalog list of stored binary sketch files to the ESP module as a client. The AutoConnectUpdate class displays this list as a custom Web page[^1] on the browser.
A sketch incorporating the AutoConnectUpdate class has an extended menu item as **UPDATE** in the AutoConnect menu. **UPDATE** as menu item will be attached by the AutoConnectUpdate automatically.
When an UPDATE item started, its first action is requesting a [catalog list](#2-the-catalog-list-content) of updatable binary sketch files to the [update server](#update-server-for-the-autoconnectupdate-class). Then the update server sends back the catalog list of stored binary sketch files to a client which is the ESP module. The AutoConnectUpdate class will display responded list to a custom Web page[^1] on the browser.
[^1]: You can scroll horizontally on the browser to see the timestamp and file size that the catalog list contains.
<img align="top" src="images/updatemenu.png" width="240" />
<img style="margin-left:30px;" src="images/updatelist.png" width="240" />
The substance of the available firmware list is a custom Web page by AutoConnectAux, and you can select the target binary sketch file with the radio button (AutoConnectRadio). A progress bar is displayed indicating the update status when the update starts, and the ESP module will automatically reset and the new firmware will launch when updating finished.
The substance of Available firmware list is a custom Web page by AutoConnectAux, and you can select the target binary sketch file with the radio button (AutoConnectRadio). A progress bar will appear to notify the updating status once the update has begun. When the update finished, the ESP module will reset automatically to launch a new firmware.
<img src="images/updating.png" width="240" />
<img style="margin-left:30px;" src="images/updated.png" width="240" />
The AutoConnectUpdate class performs the above series of operations in conjunction with the update server. All you need to do is attach the AutoConnectUpdate class to AutoConnect and perform the [AutoConnect::handleClient](api.md#handleclient) function.
The AutoConnectUpdate class performs the above series of operations in conjunction with the update server. All you need to do is attach the AutoConnectUpdate class to AutoConnect and execute the [AutoConnect::handleClient](api.md#handleclient) function in the `loop()`.
### <i class="fas fa-server"></i> Update server for the AutoConnectUpdate class
You need an update server to update the binary sketch in the ESP module using the AutoConnectUpdate class. AutoConnect provides the update server scripts implemented in Python. This server script is implemented to fit with the AutoConnectUpdate class as a client agent for updating and separated for Python2 or Python3 environments.[^2]
The above series of actions by the AutoConnectUpdate class requires a cooperated update server. You need to place the update server in a reachable location on the network. AutoConnect provides the update server scripts implemented in Python. This server script is implemented to fit with the AutoConnectUpdate class as a client agent for updating. Also, it exists for each corresponding version of Python 2 or 3.[^2]
[^2]: The folders containing the script:
For Python2: *AUTOCONNECT\_LIBRARY\_PATH*/src/updateserver/python2

@ -1,6 +1,6 @@
## OTA Updates with AutoConnect
AutoConnect provides **two types of the platform** for updating the binary sketch stored in the ESP8266 or ESP32 module via OTA. They correspond to the [Web Browser Update](https://arduino-esp8266.readthedocs.io/en/latest/ota_updates/readme.html) and [HTTP Server Update](https://arduino-esp8266.readthedocs.io/en/latest/ota_updates/readme.html#http-server) mentioned in the [ESP8266 Arduino Core documentation](https://arduino-esp8266.readthedocs.io/en/latest/ota_updates/readme.html#ota-updates).
AutoConnect provides **two types of the platform** for updating the binary sketch stored in the ESP8266 or ESP32 module via OTA. They correspond to the [Web Browser Update](https://arduino-esp8266.readthedocs.io/en/latest/ota_updates/readme.html#web-browser) and [HTTP Server Update](https://arduino-esp8266.readthedocs.io/en/latest/ota_updates/readme.html#http-server) mentioned in the [ESP8266 Arduino Core documentation](https://arduino-esp8266.readthedocs.io/en/latest/ota_updates/readme.html#ota-updates).
[**The update behavior when using a web browser**](otabrowser.md) as an update client keeps with the scenario assumed by the ESP8266 arduino core. Therefore, the user sketch must meet the requirements described in the ESP8266 Arduino Core documentation, but it is not difficult to incorporate an implementation for that into a sketch using AutoConnect. All you need to do is bind the **ESP8266HTTPUpdateServer library class**[^1] of the ESP8266 Arduino core as an [AutoConnectAux](acintro.md) to the [AutoConnect menu](menu.md).

Loading…
Cancel
Save