Supla-Device z ESP-IDF i ETH LAN8720

proxxon
Posts: 124
Joined: Wed Nov 22, 2017 2:42 pm
Has thanked: 4 times
Been thanked: 2 times

Post

Hej,

Czy ktoś mógłby pokazać przykładowy kod dla ESP-IDF jak odpalić Suplę ale na interfejsie ETH LAN8720? Dobrze by było móc ustawiać adres email w WebInterface ale nie przez AP'ka WiFi tylko właśnie przez LAN. Męczę się z tym już któryś dzień i nie chce mi to zadziałać.
User avatar
klew
Posts: 13907
Joined: Thu Jun 27, 2019 12:16 pm
Location: Wrocław
Has thanked: 134 times
Been thanked: 137 times

Post

A co masz już zrobione?
Daj link do kodu
Najlepsze suple dla Twojego domu :mrgreen:
proxxon
Posts: 124
Joined: Wed Nov 22, 2017 2:42 pm
Has thanked: 4 times
Been thanked: 2 times

Post

Zadziałało, wrzucam main'a którego użyłem. Musiałem w pliku extras\esp-idf\supla-lan8720\esp_idf_lan8720.cpp w linii:

Code: Select all

// Automatically detect PHY address
phyConfig.phy_addr = -1;
zmienić na sztywne zero dla mojej płytki:

Code: Select all

phyConfig.phy_addr = 0;
Rozumiem że wartość "-1" ma sugerować tryb automatycznego rozpoznania adresu ale u mnie to nie działało.
Płytka ma też wyłączany PHY na GPIO5 więc dodałem go jako reset (sterowanie odwrotne):

Code: Select all

phyConfig.reset_gpio_num = 5;
main.cpp:

Code: Select all

/*
 Copyright (C) AC SOFTWARE SP. Z O.O.

 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

/*
 Example of supla-device project for ESP32 with EPS-IDF SDK
 */

#include <SuplaDevice.h>
#include <esp_log.h>
#include <freertos/FreeRTOS.h>
#include <supla/log_wrapper.h>
#include <supla/control/virtual_relay.h>

// Supla extras/porting/esp-idf files - specific to ESP-IDF and ESP8266 RTOS
// targets
#include <esp_idf_web_server.h>
#include <nvs_config.h>
#include <spiffs_storage.h>

// HTML generation
#include <supla/network/html/device_info.h>
#include <supla/network/html/protocol_parameters.h>
#include <supla/network/html/status_led_parameters.h>
#include <supla/network/html/ethernet_parameters.h>
#include <esp_idf_lan8720.h>

extern "C" void cpp_main(void*);

extern const uint8_t suplaOrgCertPemStart[] asm(
  "_binary_supla_org_cert_pem_start");

extern const uint8_t supla3rdCertPemStart[] asm(
  "_binary_supla_3rd_cert_pem_start");

void cpp_main(void* param) {
  // Content of HTML for cfg mode
  new Supla::Html::DeviceInfo(&SuplaDevice);
  new Supla::Html::EthernetParameters;
  new Supla::Html::ProtocolParameters;
  new Supla::Html::StatusLedParameters;

  // Spiffs storage for channel states
  new Supla::SpiffsStorage(512);

  // Nvs based device configuration storage
  new Supla::NvsConfig;

  // Cfg mode web server
  new Supla::EspIdfWebServer;

  // Show all SUPLA related logs
  esp_log_level_set("SUPLA", ESP_LOG_DEBUG);

  Supla::EspIdfLan8720 ethernet(23, 18); // GPIOs for MDC and MDIO

  auto r1 = new Supla::Control::VirtualRelay();

  r1->setDefaultStateRestore();

  SuplaDevice.setInitialMode(Supla::InitialMode::StartInCfgMode);  // config mode for the first time

  SuplaDevice.begin();

  while (true) {
    SuplaDevice.iterate();
  }
}

extern "C" {
  void app_main() {
    xTaskCreate(&cpp_main, "cpp_main", 8192, NULL, 5, NULL);
  }
}
User avatar
klew
Posts: 13907
Joined: Thu Jun 27, 2019 12:16 pm
Location: Wrocław
Has thanked: 134 times
Been thanked: 137 times

Post

proxxon wrote: Wed Dec 31, 2025 9:29 am Zadziałało, wrzucam main'a którego użyłem. Musiałem w pliku extras\esp-idf\supla-lan8720\esp_idf_lan8720.cpp w linii:

Code: Select all

// Automatically detect PHY address
phyConfig.phy_addr = -1;
zmienić na sztywne zero dla mojej płytki:

Code: Select all

phyConfig.phy_addr = 0;
Rozumiem że wartość "-1" ma sugerować tryb automatycznego rozpoznania adresu ale u mnie to nie działało.
Płytka ma też wyłączany PHY na GPIO5 więc dodałem go jako reset (sterowanie odwrotne):

Code: Select all

phyConfig.reset_gpio_num = 5;
Dzięki za info.
Dorzucę to do issue, aby rozbudować tą klasę o możliwość ustawienia tych parametrów:
https://github.com/SUPLA/supla-device/issues/131
Najlepsze suple dla Twojego domu :mrgreen:

Return to “supla-dev”