Skip to content

Commit c676ce7

Browse files
committed
fix(p4): Move ESP-HOSTED init to WiFiGeneric
@P-R-O-C-H-Y will add the configured pins to periman, so that they can not be assigned to anything else
1 parent f706c27 commit c676ce7

File tree

2 files changed

+32
-7
lines changed

2 files changed

+32
-7
lines changed

Diff for: libraries/Network/src/NetworkManager.cpp

-7
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010
#include "esp_mac.h"
1111
#include "netdb.h"
1212

13-
#if CONFIG_ESP_WIFI_REMOTE_ENABLED
14-
extern "C" esp_err_t esp_hosted_init(void *);
15-
#endif
16-
1713
NetworkManager::NetworkManager() {}
1814

1915
NetworkInterface *getNetifByID(Network_Interface_ID id);
@@ -22,9 +18,6 @@ bool NetworkManager::begin() {
2218
static bool initialized = false;
2319
if (!initialized) {
2420
initialized = true;
25-
#if CONFIG_ESP_WIFI_REMOTE_ENABLED
26-
esp_hosted_init(NULL);
27-
#endif
2821
#if CONFIG_IDF_TARGET_ESP32
2922
uint8_t mac[8];
3023
if (esp_efuse_mac_get_default(mac) == ESP_OK) {

Diff for: libraries/WiFi/src/WiFiGeneric.cpp

+32
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,41 @@ void WiFiGenericClass::useStaticBuffers(bool bufferMode) {
233233
extern "C" void phy_bbpll_en_usb(bool en);
234234
#endif
235235

236+
#if CONFIG_ESP_WIFI_REMOTE_ENABLED
237+
extern "C" esp_err_t esp_hosted_init(void *);
238+
239+
static bool wifiHostedInit() {
240+
static bool initialized = false;
241+
if (!initialized) {
242+
initialized = true;
243+
if (esp_hosted_init(NULL) != ESP_OK) {
244+
log_e("esp_hosted_init failed!");
245+
return false;
246+
}
247+
}
248+
// Attach pins to periman here
249+
// Slave chip model is CONFIG_IDF_SLAVE_TARGET
250+
// CONFIG_ESP_SDIO_PIN_CMD
251+
// CONFIG_ESP_SDIO_PIN_CLK
252+
// CONFIG_ESP_SDIO_PIN_D0
253+
// CONFIG_ESP_SDIO_PIN_D1
254+
// CONFIG_ESP_SDIO_PIN_D2
255+
// CONFIG_ESP_SDIO_PIN_D3
256+
// CONFIG_ESP_SDIO_GPIO_RESET_SLAVE
257+
258+
return true;
259+
}
260+
#endif
261+
236262
bool wifiLowLevelInit(bool persistent) {
237263
if (!lowLevelInitDone) {
238264
lowLevelInitDone = true;
265+
#if CONFIG_ESP_WIFI_REMOTE_ENABLED
266+
if (!wifiHostedInit()) {
267+
lowLevelInitDone = false;
268+
return lowLevelInitDone;
269+
}
270+
#endif
239271
if (!Network.begin()) {
240272
lowLevelInitDone = false;
241273
return lowLevelInitDone;

0 commit comments

Comments
 (0)