Supla Pushover x4 cd

Masz pomysł na funkcjonalność lub koncepcję na rozwój projektu. Opisz wszystko tutaj.
zzrr
Posts: 1864
Joined: Wed Oct 26, 2022 7:35 pm
Has thanked: 76 times
Been thanked: 119 times

Post

klew wrote: Wed Apr 19, 2023 9:24 am Nie widzę WEBConfigu :P
Chyba, że to był skrót myślowy do Suplower "web configu".
No bo był :)
Dobrze wiesz że to chodziło o EspWebServer ;)
User avatar
klew
Posts: 13908
Joined: Thu Jun 27, 2019 12:16 pm
Location: Wrocław
Has thanked: 134 times
Been thanked: 137 times

Post

zzrr wrote: Wed Apr 19, 2023 9:48 am
klew wrote: Wed Apr 19, 2023 9:24 am Nie widzę WEBConfigu :P
Chyba, że to był skrót myślowy do Suplower "web configu".
No bo był :)
Dobrze wiesz że to chodziło o EspWebServer ;)
Myślałem, że chodziło o WebConfig https://github.com/GerLech/WebConfig ;)
Najlepsze suple dla Twojego domu :mrgreen:
zzrr
Posts: 1864
Joined: Wed Oct 26, 2022 7:35 pm
Has thanked: 76 times
Been thanked: 119 times

Post

klew wrote: Wed Apr 19, 2023 10:14 am Myślałem, że chodziło o WebConfig https://github.com/GerLech/WebConfig ;)
O kurna... niefortunny zbieg nazw. Sorki za wprowadzenie w błąd. Tak to wychodzi ze skrótami myślowymi. 8-)
zzrr
Posts: 1864
Joined: Wed Oct 26, 2022 7:35 pm
Has thanked: 76 times
Been thanked: 119 times

Post

@klew więc tak.... Wstawiam kod jeszcze raz. Powiedzmy taki jak ma być.
Kod dotyczy tego co jest istotne. To co nie dotyczy problemu wyrzuciłem.
I teraz tak... jak podaję na D1 minus to jest właściwa akcja "MOJA_AKCJA_1_START!" i jest reakcja na serwerze w postaci zmiany stanu kanału.
ALE... pushover brak.
I teraz ważne..... robię zakomentowanie tej linii - Supla::EspWebServer suplaServer i wysyłam ponownie na urządzenie.
W efekcie program pobiera SSID WiFi_Pass , API_Token i User_KEY z pamięci i działa wszystko włącznie z pushover !!! Po prostu wszystko tak jak być powinno.
Odkomentuję Supla::EspWebServer suplaServer wysyłam na urządzenie i.... działa wszystko a pushover znowu "głuchy"

Code: Select all

#include <Arduino.h>
#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/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/storage/eeprom.h>
#include <supla/sensor/binary.h>
#include <EEPROM.h>
#include <LittleFS.h>
// #include <ESP8266WebServer.h>
#include <Pushover.h>
#include <ESP8266WiFi.h>
Supla::Eeprom eeprom;
Supla::ESPWifi wifi;
Supla::LittleFsConfig configSupla;
Supla::EspWebServer suplaServer;         //po zakomentowaniu działa PUSHOVER
Supla::Html::DeviceInfo htmlDeviceInfo(&SuplaDevice);
Supla::Html::WifiParameters htmlWifi;
Supla::Html::ProtocolParameters htmlProto;
Supla::Html::StatusLedParameters htmlStatusLed;

#define RELAY_GPIO 12           // D6
#define BUTTON_CFG_RELAY_GPIO 0 // D3
#define LED 13                  // D7
#define BUTT 5                  // D1

bool stan_alarmu = false;
char buf[512] = {};
char buf1[512] = {};
String ssid = "";
String pass = "";

char PUSH_USER[200] = {};
char PUSH_API_KEY[200] = {};
const char PARAM1[] = "param1"; // PUSH_API_KEY
const char PARAM2[] = "param2"; // PUSH_USER

// Supla::Control::Relay *r1 = nullptr;
// Supla::Sensor::VirtualBinary *r2 = nullptr;
// Supla::Control::ActionTrigger *at1 = nullptr;
// RH_ASK driver(2000, 4, NOT_A_PIN); // ESP8266: do not use pin 11  D2

Supla::Sensor::Binary *r2 = nullptr;

enum NoweAkcje
{
    MOJA_AKCJA_1,
    MOJA_AKCJA_2
};
class MojaAkcja : public Supla::ActionHandler
{
public:
    MojaAkcja(){};
    void handleAction(int event, int action) override
    {
        // SUPLA_LOG_DEBUG("Handle action: %d %d", event, action);
        if (action == MOJA_AKCJA_1)
        {
            // SUPLA_LOG_DEBUG("MOJA_AKCJA_1_START!");
            digitalWrite(LED, HIGH);
            if (Supla::Storage::IsConfigStorageAvailable())
            {
                auto cfg = Supla::Storage::ConfigInstance();
                if (cfg->getWiFiSSID(buf) && strlen(buf) > 0)
                {
                    for (size_t i = 0; i < sizeof(buf); i++)
                    {
                        ssid += char(buf[i]);
                    }
                    Serial.println(ssid);
                }
                if (cfg->getWiFiPassword(buf1) && strlen(buf1) > 0)
                {
                    ;
                    for (size_t i = 0; i < sizeof(buf1); i++)
                    {
                        pass += char(buf1[i]);
                    }
                    Serial.println(pass);
                }
            }
            Pushover po = Pushover(PUSH_API_KEY, PUSH_USER, UNSAFE);
            po.setMessage("Testnotification");
            po.setDevice("galaxynote8");
            po.setTitle("kuku");
            po.setSound("bike");
            po.send(); // should return 1 on success
            Serial.println(PUSH_API_KEY);
            Serial.println(PUSH_USER);
            // WiFiClientSecure Client1;
            // if (!Client1.connect("api.Pushover.net", 443))
            // {
            //     SUPLA_LOG_DEBUG("api.Pushover.net POŁĄCZONY");
            // }
        }
        if (action == MOJA_AKCJA_2)
        {
            digitalWrite(LED, LOW);
            SUPLA_LOG_DEBUG("MOJA_AKCJA_1_STOP!");
        }
        ssid = "";
        pass = "";
    }
};
MojaAkcja *custMojaAkcja = new MojaAkcja;

void setup()
{
    Serial.begin(9600);
    wifi.enableSSL(false);

    new Supla::Html::CustomTextParameter(PARAM1, "Pushover API Key", 100);
    new Supla::Html::CustomTextParameter(PARAM2, "Pushover USER Key", 100);
    //new Supla::Html::CustomTextParameter(PARAM2, "Pushover Sound", 100);

    pinMode(LED, OUTPUT);
    r2 = new Supla::Sensor::Binary(BUTT, true, true);
    auto buttonCfgRelay =
        new Supla::Control::Button(BUTTON_CFG_RELAY_GPIO, false, true);
    r2->addAction(MOJA_AKCJA_1, custMojaAkcja, Supla::ON_TURN_ON);
    r2->addAction(MOJA_AKCJA_2, custMojaAkcja, Supla::ON_TURN_OFF);
    buttonCfgRelay->setHoldTime(5000);
    buttonCfgRelay->setMulticlickTime(500);
    buttonCfgRelay->addAction(Supla::TOGGLE_CONFIG_MODE, SuplaDevice, Supla::ON_HOLD);

    ////SuplaDevice.setSuplaCACert(suplaCACert);
    ////SuplaDevice.setSupla3rdPartyCACert(supla3rdCACert);
    SuplaDevice.setName("Pushover Garaż_woda");
    SuplaDevice.begin();

    if (Supla::Storage::ConfigInstance()->getString(PARAM1, PUSH_API_KEY, 200))
    {
        SUPLA_LOG_DEBUG(" **** Param[%s]: %s", PARAM1, PUSH_API_KEY);
    }
    else
    {
        SUPLA_LOG_DEBUG(" **** Param[%s] is not set", PARAM1);
    }

    if (Supla::Storage::ConfigInstance()->getString(PARAM2, PUSH_USER, 200))
    {
        SUPLA_LOG_DEBUG(" **** Param[%s]: %s", PARAM2, PUSH_USER);
    }
    else
    {
        SUPLA_LOG_DEBUG(" **** Param[%s] is not set", PARAM2);
    }
}
unsigned long czas = 0;

void loop()
{
    SuplaDevice.iterate();
}

User avatar
klew
Posts: 13908
Joined: Thu Jun 27, 2019 12:16 pm
Location: Wrocław
Has thanked: 134 times
Been thanked: 137 times

Post

zzrr wrote: Wed Apr 19, 2023 11:53 am @klew więc tak.... Wstawiam kod jeszcze raz. Powiedzmy taki jak ma być.
Jedno z wyjaśnień tego typu dziwnych zachowań, to niedobór pamięci RAM :)

Wstawi sobie logowanie ilości wolnej pamięci w setup (gdzieś na początku i na końcu po SuplaDevice.begin() ), oraz cyklicznie w iterate (np. co 1s). Polecenie ESP.getFreeHeap() zwraca ilość wolnej pamięci.
Następnie odpal to z i bez Supla::EspWebServer.
Najlepsze suple dla Twojego domu :mrgreen:
zzrr
Posts: 1864
Joined: Wed Oct 26, 2022 7:35 pm
Has thanked: 76 times
Been thanked: 119 times

Post

Ok. Dzięki. Będę badał ten kierunek
zzrr
Posts: 1864
Joined: Wed Oct 26, 2022 7:35 pm
Has thanked: 76 times
Been thanked: 119 times

Post

Tak pokazuje z Supla::EspWebServer.
I rozumiem że cyklicznie w iterate (np. co 1s) to chodzi pętlę loop co 1s np z użyciem millis()?

Code: Select all

[RAM_pocztek : 32904
Supla - starting initialization
Storage initialization
readStorage: 8; Read: [53 55 50 4C 41 1 0 0 ]
Storage: Number of sections 0
LittleFsConfig: initializing storage from file...
Validating storage state section with current device configuration
Storage state section validation completed. Loading elements state...
Initializing network layer
Network AP/hostname: PUSHOVER-GARA-WO-BCDDC222A439
Using Supla protocol version 16
Current status: [5] SuplaDevice initialized
Enter normal mode
RAM_koniec: 26416
 **** Param[param1]: ..........
 **** Param[param2]: ..........
WiFi: establishing connection with SSID: "AndroidAP0ea4"
[b]RAM_iterate: 25872
RAM_iterate: 25872
RAM_iterate: 25872
RAM_iterate: 25872
RAM_iterate: 25200
RAM_iterate: 25200[/b]
Connected BSSID: 26:18:1D:CF:0E:A4
local IP: .............
subnetMask: 255.255.255.0
gatewayIP: .............
Signal strength (RSSI): -66 dBm
Establishing NOT encrypted connection with: svr69.supla.org (port: 2015)
Connected to Supla Server
LAST STATE ADDED: Register in progress
Current status: [10] Register in progress
Send: [53 55 50 4C 41 10 01 00 00 00 45 00 00 00 61 02 00 00 7A 7A 72 72 40 77 70 2E 70 6C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 39 61 4E C4 55 F9 A7 25 FA B0 2C 3F 04 0E A1 BF 4D 32 38 88 96 19 4D B0 8C 67 14 C1 A6 C8 34 09 50 75 73 68 6F 76 65 72 20 47 61 72 61 C5 BC 5F 77 6F 64 61 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ]
Send: [53 55 50 4C 41 ]
RAM_iterate: 23472
Recv: [53 55 50 4C 41 10 01 00 00 00 46 00 00 00 07 00 00 00 03 00 00 00 78 13 01 53 55 50 4C 41 ]
Device registered (activity timeout 120 s, server version: 19, server min version: 1)
LAST STATE ADDED: Registered and ready
Current status: [17] Registered and ready
zzrr
Posts: 1864
Joined: Wed Oct 26, 2022 7:35 pm
Has thanked: 76 times
Been thanked: 119 times

Post

A tak jeśli zakomentuję Supla::EspWebServer

Code: Select all

RAM_pocztek : 41376
Supla - starting initialization
Storage initialization
readStorage: 8; Read: [53 55 50 4C 41 1 0 0 ]
Storage: Number of sections 0
LittleFsConfig: initializing storage from file...
Validating storage state section with current device configuration
Storage state section validation completed. Loading elements state...
Initializing network layer
Network AP/hostname: PUSHOVER-GARA-WO-BCDDC222A439
Using Supla protocol version 16
Current status: [5] SuplaDevice initialized
Enter normal mode
RAM_koniec: 34888
 **** Param[param1]: ..................
 **** Param[param2]: ...................
WiFi: establishing connection with SSID: "AndroidAP0ea4"
RAM_iterate: 34344
RAM_iterate: 34344
RAM_iterate: 34344
RAM_iterate: 34344
WiFi station disconnected
RAM_iterate: 34344
Connected BSSID: 26:18:1D:CF:0E:A4
local IP: ....................
subnetMask: 255.255.255.0
gatewayIP: ...................
Signal strength (RSSI): -58 dBm
Establishing NOT encrypted connection with: svr69.supla.org (port: 2015)
Connected to Supla Server
LAST STATE ADDED: Register in progress
Current status: [10] Register in progress
Send: [53 55 50 4C 41 10 01 00 00 00 45 00 00 00 61 02 00 00 7A 7A 72 72 40 77 70 2E 70 6C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 39 61 4E C4 55 F9 A7 25 FA B0 2C 3F 04 0E A1 BF 4D 32 38 88 96 19 4D B0 8C 67 14 C1 A6 C8 34 09 50 75 73 68 6F 76 65 72 20 47 61 72 61 C5 BC 5F 77 6F 64 61 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ]
Send: [53 55 50 4C 41 ]
RAM_iterate: 31944
Recv: [53 55 50 4C 41 10 01 00 00 00 46 00 00 00 07 00 00 00 03 00 00 00 78 13 01 53 55 50 4C 41 ]
Device registered (activity timeout 120 s, server version: 19, server min version: 1)
LAST STATE ADDED: Registered and ready
Current status: [17] Registered and ready
Changing activity timeout to 30
zzrr
Posts: 1864
Joined: Wed Oct 26, 2022 7:35 pm
Has thanked: 76 times
Been thanked: 119 times

Post

klew wrote: Wed Apr 19, 2023 12:42 pm Jedno z wyjaśnień tego typu dziwnych zachowań, to niedobór pamięci RAM :)
Coś widzisz w tych logach co mogło by pomóc w wyciągnięciu właściwych wniosków?
User avatar
klew
Posts: 13908
Joined: Thu Jun 27, 2019 12:16 pm
Location: Wrocław
Has thanked: 134 times
Been thanked: 137 times

Post

zzrr wrote: Wed Apr 19, 2023 1:34 pm
klew wrote: Wed Apr 19, 2023 12:42 pm Jedno z wyjaśnień tego typu dziwnych zachowań, to niedobór pamięci RAM :)
Coś widzisz w tych logach co mogło by pomóc w wyciągnięciu właściwych wniosków?
Widać 8 kB wolnej pamięci mniej.
Natomiast ogólnie pamięci jest nadal sporo.

Spróbuję wieczorem przyjrzeć się jeszcze raz temu co wysłałeś.
Najlepsze suple dla Twojego domu :mrgreen:

Return to “Pomysły i koncepcje”