Atam atam... wiadomo że wiedza @klewa w tych tematach to przygniata. Ale Twoja też...

Code: Select all
int32_t ip1, ip2, ip3, ip4;
// ... tutaj wczytanie wartości przez Supla::Storage::ConfigInstance()->getString() i jej przerobienie na ip1..ip4
new Supla::PV::Fronius(IPAddress(ip1, ip2, ip3, ip4));
Code: Select all
const char FRONIUSIP[] = "FroniusIPAddr";
...
new Supla::Html::CustomTextParameter(FRONIUSIP, "Adres IP inwertera Fronius", 15);
char ip[50] = {};
if (Supla::Storage::ConfigInstance()->getString(FRONIUSIP, ip, 50)) {
SUPLA_LOG_DEBUG(" **** Param[%s]: %s", FRONIUSIP, ip);
} else {
SUPLA_LOG_DEBUG(" **** Param[%s] is not set", FRONIUSIP);
}
IPAddress ipAddr;
size_t index = 0;
int i = 0;
ipAddr[index] = 0;
while (ip[i]) {
if (isdigit(ip[i])) {
ipAddr[index] *= 10;
ipAddr[index] += ip[i] - '0';
} else {
index++;
ipAddr[index] = 0;
}
i++;
}
new Supla::PV::Fronius(ipAddr);
https://github.com/espressif/arduino-es ... s.cpp#L111malarz wrote: Sun Dec 15, 2024 1:09 pm W związku z tym, że jakieś rozwiązanie doprowadziłem do końca to je pokazuję:
Nie wiem czy ładnie, ale skutecznie:
Uwagi mile widziane.Code: Select all
const char FRONIUSIP[] = "FroniusIPAddr"; ... new Supla::Html::CustomTextParameter(FRONIUSIP, "Adres IP inwertera Fronius", 15); char ip[50] = {}; if (Supla::Storage::ConfigInstance()->getString(FRONIUSIP, ip, 50)) { SUPLA_LOG_DEBUG(" **** Param[%s]: %s", FRONIUSIP, ip); } else { SUPLA_LOG_DEBUG(" **** Param[%s] is not set", FRONIUSIP); } IPAddress ipAddr; size_t index = 0; int i = 0; ipAddr[index] = 0; while (ip[i]) { if (isdigit(ip[i])) { ipAddr[index] *= 10; ipAddr[index] += ip[i] - '0'; } else { index++; ipAddr[index] = 0; } i++; } new Supla::PV::Fronius(ipAddr);
Code: Select all
ipAddr.fromString(ip);
Dzięki.lukfud wrote: Sun Dec 15, 2024 4:52 pm https://github.com/espressif/arduino-es ... s.cpp#L111Code: Select all
ipAddr.fromString(ip);
Nie. Ta klasa jest brana gdy nie używasz Arduinomalarz wrote: Sun Dec 15, 2024 7:30 pmDzięki.lukfud wrote: Sun Dec 15, 2024 4:52 pm https://github.com/espressif/arduino-es ... s.cpp#L111Code: Select all
ipAddr.fromString(ip);
A to się nie pogryzie z https://github.com/SUPLA/supla-device/b ... ddress.cpp ?
Fajnie zadziałało. Teraz zachciałem jeszcze dodać do projektu OTA na bazie
Code: Select all
#define STATUS_LED_GPIO 13
#define RELAY_GPIO 12
#define BUTTON_CFG_RELAY_GPIO 0
#include <SuplaDevice.h>
#include <supla/network/esp_wifi.h>
#include <supla/control/relay.h>
#include <supla/control/button.h>
#include <supla/control/action_trigger.h>
#include <supla/device/status_led.h>
#include <supla/storage/littlefs_config.h>
#include <supla/network/esp_web_server.h>
#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/wifi_parameters.h>
#include <supla/network/html/custom_text_parameter.h>
#include <supla/device/supla_ca_cert.h>
#include <supla/events.h>
#include <supla/pv/fronius.h>
Supla::ESPWifi wifi;
Supla::LittleFsConfig configSupla;
Supla::Device::StatusLed statusLed(STATUS_LED_GPIO, true); // inverted state
Supla::EspWebServer suplaServer;
#ifdef ARDUINO_ARCH_ESP32
#include <HTTPUpdateServer.h>
HTTPUpdateServer httpUpdater;
#else
#include <ESP8266HTTPUpdateServer.h>
ESP8266HTTPUpdateServer httpUpdater;
#endif
// Those tags are used for HTML element names and for keys to access parameter
// values in Config storage class. Max length of those values is 15 chars.
const char FRONIUSIP[] = "FroniusIPAddr";
void setup() {
Serial.begin(115200);
// HTML www component (they appear in sections according to creation
// sequence).
new Supla::Html::DeviceInfo(&SuplaDevice);
new Supla::Html::WifiParameters;
new Supla::Html::ProtocolParameters;
new Supla::Html::StatusLedParameters;
// Here user defined inputs are defined.
// Simple text input:
// 15 - maximum text length accepted by your input
new Supla::Html::CustomTextParameter(FRONIUSIP, "Adres IP inwertera Fronius", 15);
Supla::Storage::Init();
char ip[50] = {};
if (Supla::Storage::ConfigInstance()->getString(FRONIUSIP, ip, 50)) {
SUPLA_LOG_DEBUG(" +++++ Param[%s]: %s", FRONIUSIP, ip);
} else {
SUPLA_LOG_DEBUG(" +++++ Param[%s] is not set", FRONIUSIP);
}
// Channels configuration
// CH 0 - Fronius inverter
IPAddress ipAddr;
ipAddr.fromString(ip);
new Supla::PV::Fronius(ipAddr);
// Buttons configuration
auto buttonCfgRelay = new Supla::Control::Button(BUTTON_CFG_RELAY_GPIO, true, true);
buttonCfgRelay->configureAsConfigButton(&SuplaDevice);
// dodaj updater
httpUpdater.setup(suplaServer.getServerPtr(), "/update");
// configure defualt Supla CA certificate
SuplaDevice.setSuplaCACert(suplaCACert);
SuplaDevice.setSupla3rdPartyCACert(supla3rdCACert);
SuplaDevice.begin();
}
void loop() {
SuplaDevice.iterate();
}
Code: Select all
httpUpdater.setup(suplaServer.getServerPtr(), "/update");