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)
 connects to host and grabs the http file and tries to update the binary (OTA) More...
 
void performOTAUpdateSimple ()
 retrieves from constant location More...
 

Variables

WiFiClient _client
 
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/OTA_Board/ESP_IOT.ino.esp32.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 58 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 51 of file OTAImageUpdate.cpp.

Here is the caller graph for this function:

◆ performOTAUpdate()

void performOTAUpdate ( char *  hostname,
char *  httpAddress 
)

connects to host and grabs the http file and tries to update the binary (OTA)

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

Definition at line 245 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 261 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 241 of file OTAImageUpdate.cpp.

◆ _binName

String _binName = "/OTA/OTA_Board/ESP_IOT.ino.esp32.bin"

location of bin file

Definition at line 42 of file OTAImageUpdate.cpp.

◆ _client

WiFiClient _client

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 21 of file OTAImageUpdate.cpp.

◆ _contentLength

long _contentLength = 0

Definition at line 25 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 31 of file OTAImageUpdate.cpp.

◆ _isValidContentType

bool _isValidContentType = false

Definition at line 26 of file OTAImageUpdate.cpp.

◆ _port

int _port = 80

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

Definition at line 33 of file OTAImageUpdate.cpp.