Skip to content

Commit c2368cc

Browse files
committed
feat(hosted): Add method to update the hosted slave firmware
1 parent 87b718a commit c2368cc

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

libraries/WiFi/src/WiFiGeneric.cpp

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ extern "C" {
4949
#include "lwip/netif.h"
5050
#include "dhcpserver/dhcpserver.h"
5151
#include "dhcpserver/dhcpserver_options.h"
52-
5352
} //extern "C"
5453

5554
#include "esp32-hal.h"
@@ -241,10 +240,10 @@ extern "C" void phy_bbpll_en_usb(bool en);
241240

242241
#if CONFIG_ESP_WIFI_REMOTE_ENABLED
243242
extern "C" {
244-
//#include "esp_hosted.h"
245-
#include "esp_hosted_transport_config.h"
246-
extern esp_err_t esp_hosted_init();
247-
extern esp_err_t esp_hosted_deinit();
243+
#include "esp_hosted.h"
244+
// #include "esp_hosted_transport_config.h"
245+
// extern esp_err_t esp_hosted_init();
246+
// extern esp_err_t esp_hosted_deinit();
248247
};
249248
typedef struct {
250249
uint8_t pin_clk;
@@ -296,6 +295,15 @@ bool WiFiGenericClass::setPins(int8_t clk, int8_t cmd, int8_t d0, int8_t d1, int
296295
return true;
297296
}
298297

298+
bool WiFiGenericClass::updateSlave(const char * url) {
299+
esp_err_t err = esp_hosted_slave_ota(url);
300+
if (err != ESP_OK) {
301+
log_e("esp_hosted_slave_ota failed! 0x%x: %s", err, esp_err_to_name(err));
302+
return false;
303+
}
304+
return true;
305+
}
306+
299307
static bool wifiHostedInit() {
300308
if (!hosted_initialized) {
301309
hosted_initialized = true;
@@ -314,6 +322,11 @@ static bool wifiHostedInit() {
314322
return false;
315323
}
316324
log_v("ESP-HOSTED initialized!");
325+
// // This throws heap exception when the slave has older firmware
326+
// esp_hosted_coprocessor_fwver_t fwver = {0,0,0};
327+
// if (esp_hosted_get_coprocessor_fwversion(&fwver) == ESP_OK) {
328+
// log_d("ESP-HOSTED Slave FW Version: %lu.%li.%lu", fwver.major1, fwver.minor1, fwver.patch1);
329+
// }
317330
}
318331
// Attach pins to PeriMan here
319332
// Slave chip model is CONFIG_IDF_SLAVE_TARGET

libraries/WiFi/src/WiFiGeneric.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ class WiFiGenericClass {
8585
#if CONFIG_ESP_WIFI_REMOTE_ENABLED
8686
// Set SDIO pins for connection to external ESP MCU
8787
static bool setPins(int8_t clk, int8_t cmd, int8_t d0, int8_t d1, int8_t d2, int8_t d3, int8_t rst);
88+
static bool updateSlave(const char * url);
8889
#endif
8990

9091
wifi_event_id_t onEvent(WiFiEventCb cbEvent, arduino_event_id_t event = ARDUINO_EVENT_MAX);

0 commit comments

Comments
 (0)