Skip to content

Commit 011b4ed

Browse files
ci(pre-commit): Apply automatic fixes
1 parent a37aebb commit 011b4ed

File tree

3 files changed

+33
-33
lines changed

3 files changed

+33
-33
lines changed

cores/esp32/esp32-hal-hosted.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ static bool hostedInit() {
198198
conf.pin_d3.pin = sdio_pin_config.pin_d3;
199199
conf.pin_reset.pin = sdio_pin_config.pin_reset;
200200
esp_err_t err = esp_hosted_sdio_set_config(&conf);
201-
if (err != ESP_OK) { //&& err != ESP_ERR_NOT_ALLOWED) { // uncomment when second init is fixed
201+
if (err != ESP_OK) { //&& err != ESP_ERR_NOT_ALLOWED) { // uncomment when second init is fixed
202202
log_e("esp_hosted_sdio_set_config failed: %s", esp_err_to_name(err));
203203
return false;
204204
}

libraries/ESP_HostedOTA/examples/ESP_HostedOTA/ESP_HostedOTA.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/*
22
* ESP-Hosted OTA Update Example
3-
*
3+
*
44
* This example demonstrates how to update the ESP-Hosted co-processor firmware
55
* over-the-air (OTA). The ESP-Hosted solution allows an ESP32 to act as a WiFi
66
* co-processor for other microcontrollers.
7-
*
7+
*
88
* Prerequisites:
99
* - ESP32 with ESP-Hosted firmware configured as WiFi co-processor
1010
* - Network connectivity to download firmware updates
@@ -38,8 +38,8 @@ void setup() {
3838
// Step 5: Wait for WiFi connection to be established
3939
// Display progress dots while connecting
4040
while (WiFi.STA.status() != WL_CONNECTED) {
41-
delay(500); // Wait 500ms between connection attempts
42-
Serial.print("."); // Show connection progress
41+
delay(500); // Wait 500ms between connection attempts
42+
Serial.print("."); // Show connection progress
4343
}
4444
Serial.println();
4545

libraries/ESP_HostedOTA/src/ESP_HostedOTA.cpp

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
#include <stdbool.h>
44
#if CONFIG_ESP_WIFI_REMOTE_ENABLED
55
#include "Arduino.h"
6-
#include "esp32-hal-hosted.h" // ESP-Hosted specific functions
7-
#include "Network.h" // Network connectivity management
8-
#include "HTTPClient.h" // HTTP client for downloading updates
9-
#include "NetworkClientSecure.h" // Secure network client for HTTPS
6+
#include "esp32-hal-hosted.h" // ESP-Hosted specific functions
7+
#include "Network.h" // Network connectivity management
8+
#include "HTTPClient.h" // HTTP client for downloading updates
9+
#include "NetworkClientSecure.h" // Secure network client for HTTPS
1010
#endif
1111

1212
/**
@@ -17,47 +17,47 @@
1717
bool updateEspHostedSlave() {
1818
#if CONFIG_ESP_WIFI_REMOTE_ENABLED
1919
bool updateSuccess = false;
20-
20+
2121
// Step 1: Verify ESP-Hosted is properly initialized
2222
if (!hostedIsInitialized()) {
2323
Serial.println("ERROR: esp-hosted is not initialized. Did you call WiFi.STA.begin()?");
2424
return updateSuccess;
2525
}
26-
26+
2727
// Step 2: Check if an update is actually available
2828
if (!hostedHasUpdate()) {
2929
// esp-hosted is already the latest version - no update needed
3030
return updateSuccess;
3131
}
32-
32+
3333
// Step 3: Ensure network connectivity is available
3434
if (!Network.isOnline()) {
3535
Serial.println("ERROR: Network is not online! Did you call WiFi.STA.connect(ssid, password)?");
3636
return updateSuccess;
3737
}
38-
38+
3939
// Step 4: Begin the update process - display update URL
4040
Serial.print("Updating esp-hosted co-processor from ");
4141
Serial.println(hostedGetUpdateURL());
42-
42+
4343
// Step 5: Create a secure network client for HTTPS communication
4444
NetworkClientSecure *client = new NetworkClientSecure();
4545
if (!client) {
4646
Serial.println("ERROR: Could not allocate client!");
4747
return updateSuccess;
4848
}
49-
49+
5050
// Step 6: Configure client to skip certificate verification (insecure mode)
5151
client->setInsecure();
52-
52+
5353
// Step 7: Initialize HTTP client and attempt to connect to update server
5454
HTTPClient https;
5555
int httpCode = 0;
5656
if (!https.begin(*client, hostedGetUpdateURL())) {
5757
Serial.println("ERROR: HTTP begin failed!");
5858
goto finish_ota;
5959
}
60-
60+
6161
// Step 8: Send HTTP GET request to download the firmware
6262
httpCode = https.GET();
6363
if (httpCode == HTTP_CODE_OK) {
@@ -68,68 +68,68 @@ bool updateEspHostedSlave() {
6868
https.end();
6969
goto finish_ota;
7070
}
71-
71+
7272
// Step 10: Get stream pointer for reading firmware data
7373
NetworkClient *stream = https.getStreamPtr();
74-
74+
7575
// Step 11: Initialize the ESP-Hosted update process
7676
if (!hostedBeginUpdate()) {
7777
Serial.println("ERROR: esp-hosted update start failed!");
7878
https.end();
7979
goto finish_ota;
8080
}
81-
82-
// Step 12: Allocate buffer for firmware data transfer (2KB chunks)
83-
#define HOSTED_OTA_BUF_SIZE 2048
84-
uint8_t * buff = (uint8_t*)malloc(HOSTED_OTA_BUF_SIZE);
81+
82+
// Step 12: Allocate buffer for firmware data transfer (2KB chunks)
83+
#define HOSTED_OTA_BUF_SIZE 2048
84+
uint8_t *buff = (uint8_t *)malloc(HOSTED_OTA_BUF_SIZE);
8585
if (!buff) {
8686
Serial.println("ERROR: Could not allocate OTA buffer!");
8787
https.end();
8888
goto finish_ota;
8989
}
90-
90+
9191
// Step 13: Download and write firmware data in chunks
9292
while (https.connected() && len > 0) {
9393
size_t size = stream->available();
9494
if (size > 0) {
9595
// Show progress indicator
9696
Serial.print(".");
97-
97+
9898
// Limit chunk size to buffer capacity
9999
if (size > HOSTED_OTA_BUF_SIZE) {
100100
size = HOSTED_OTA_BUF_SIZE;
101101
}
102-
102+
103103
// Prevent reading more data than expected
104104
if (size > len) {
105105
Serial.printf("\nERROR: Update received extra bytes: %u!", size - len);
106106
break;
107107
}
108-
108+
109109
// Read firmware data chunk into buffer
110110
int readLen = stream->readBytes(buff, size);
111111
len -= readLen;
112-
112+
113113
// Write the chunk to ESP-Hosted co-processor
114114
if (!hostedWriteUpdate(buff, readLen)) {
115115
Serial.println("\nERROR: esp-hosted update write failed!");
116116
break;
117117
}
118-
118+
119119
// Step 14: Check if entire firmware has been downloaded
120120
if (len == 0) {
121121
// Finalize the update process
122122
if (!hostedEndUpdate()) {
123123
Serial.println("\nERROR: esp-hosted update end failed!");
124124
break;
125125
}
126-
126+
127127
// Activate the new firmware
128128
if (!hostedActivateUpdate()) {
129129
Serial.println("\nERROR: esp-hosted update activate failed!");
130130
break;
131131
}
132-
132+
133133
// Update completed successfully
134134
updateSuccess = true;
135135
Serial.println("\nSUCCESS: esp-hosted co-processor updated!");
@@ -139,15 +139,15 @@ bool updateEspHostedSlave() {
139139
// Small delay to prevent overwhelming the system
140140
delay(1);
141141
}
142-
142+
143143
// Step 15: Clean up allocated buffer
144144
free(buff);
145145
Serial.println();
146146
}
147147

148148
// Step 16: Close HTTP connection
149149
https.end();
150-
150+
151151
finish_ota:
152152
// Step 17: Clean up network client
153153
delete client;

0 commit comments

Comments
 (0)