ESP_IOT v2.5
IOT ESP Coding
OTAImageUpdate.cpp File Reference
#include "OTAImageUpdate.h"
#include <WiFi.h>
#include <Update.h>
Include dependency graph for OTAImageUpdate.cpp:

Go to the source code of this file.

Functions

String getHeaderValue (String header, String headerName)
 Utility to extract header value from headers. More...
 
void execOTA ()
 OTA Logic. More...
 
void performOTAUpdate (char *hostname, char *httpAddress)
 8.16.25 MQTT More...
 
void performOTAUpdateSimple ()
 retrieves from constant location More...
 

Variables

WiFiClient _client
 8.16.25 MQTT More...
 
long _contentLength = 0
 
bool _isValidContentType = false
 
String _hostIP = "KnowledgeShark.org"
 
int _port = 80
 Non https. For HTTPS 443. As of today, HTTPS doesn't work. More...
 
String _binName = "/OTA/ESP_IOT.ino.m5stick_c_plus.bin"
 location of bin file More...
 
char _binAddress [100]
 address of bin string More...
 

Function Documentation

◆ execOTA()

void execOTA ( )

OTA Logic.

Connect to S3

Get the contents of the bin file

Response Structure HTTP/1.1 200 OK x-amz-id-2: NVKxnU1aIQMmpGKhSwpCBh8y2JPbak18QLIfE+OiUDOos+7UftZKjtCFqrwsGOZRN5Zee0jpTd0= x-amz-request-id: 2D56B47560B764EC Date: Wed, 14 Jun 2017 03:33:59 GMT Last-Modified: Fri, 02 Jun 2017 14:50:11 GMT ETag: "d2afebbaaebc38cd669ce36727152af9" Accept-Ranges: bytes Content-Type: application/octet-stream Content-Length: 357280 Server: AmazonS3

{{BIN FILE CONTENTS}}

Check if the HTTP Response is 200 else break and Exit Update

extract headers here Start with content length

Next, the content type

check contentLength and content type

Check if there is enough to OTA Update

restart .. which will ony effect if not rebooting..

Definition at line 64 of file OTAImageUpdate.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getHeaderValue()

String getHeaderValue ( String  header,
String  headerName 
)

Utility to extract header value from headers.

Definition at line 57 of file OTAImageUpdate.cpp.

Here is the caller graph for this function:

◆ performOTAUpdate()

void performOTAUpdate ( char *  hostname,
char *  httpAddress 
)

8.16.25 MQTT

connects to host and grabs the http file and tries to update the binary (OTA) kind = esp32, m5

Definition at line 250 of file OTAImageUpdate.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ performOTAUpdateSimple()

void performOTAUpdateSimple ( )

retrieves from constant location

Definition at line 266 of file OTAImageUpdate.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ _binAddress

char _binAddress[100]

address of bin string

Definition at line 246 of file OTAImageUpdate.cpp.

◆ _binName

String _binName = "/OTA/ESP_IOT.ino.m5stick_c_plus.bin"

location of bin file

for the ESP_M5 there are different builds (some with same m5stick_c_plus.bin names so they are NOTE: these are for the installed "main" executables. The SMART web page provides names for the others

Definition at line 43 of file OTAImageUpdate.cpp.

◆ _client

WiFiClient _client

8.16.25 MQTT

OTAImageUpdate Code from AWS_S3_OTA_Update, it only uses HTTP (not https) https://www.tutorialspoint.com/esp32_for_iot/performing_the_over_the_air_update_of_esp32_firmware.htm

Definition at line 25 of file OTAImageUpdate.cpp.

◆ _contentLength

long _contentLength = 0

Definition at line 29 of file OTAImageUpdate.cpp.

◆ _hostIP

String _hostIP = "KnowledgeShark.org"

String _hostIP = "konacurrents.com"; // Host => bucket-name.s3.region.amazonaws.com host IP address (cannot be https)

Definition at line 35 of file OTAImageUpdate.cpp.

◆ _isValidContentType

bool _isValidContentType = false

Definition at line 30 of file OTAImageUpdate.cpp.

◆ _port

int _port = 80

Non https. For HTTPS 443. As of today, HTTPS doesn't work.

Definition at line 37 of file OTAImageUpdate.cpp.