Giter Site home page Giter Site logo

Comments (16)

Hieromon avatar Hieromon commented on August 18, 2024

AutoConnectAux can separate some configuration screen into external files. You can define the following elements in its configuration.

  • AutoConnectButton: Labeled button
  • AutoConnectCheckbox: Labeled checkbox
  • AutoConnectElement: General tag
  • AutoConnectInput: Labeled text input box
  • AutoConnectRadio: Labeled radio button
  • AutoConnectSelect: Selection list
  • AutoConnectSubmit: Submit button
  • AutoConnectText: Style attributed text

You can load the external file described the above elements in JSON format from SPIFFS or SD and incorporate it into AutoConnectMenu. Each element can be accessed from the sketch. The values ​​of each element entered in the menu can be output to the stream, so you can save it to SPIFFS and reload it from SPIFFS.
Also, you can sketch the function that is called back when the AutoConnectAux page is requested from the menu. I added an example using this feature, please experience it.
The example publishes the RSSI of ESP8266 to the public cloud MQTT broker. I have released the Thingspeak channel for it. The access keys are as follows. Please enter from the AutoConnect menu.

  • Server: mqtt.thingspeak.com
  • Channel ID: 454951
  • User Key: NRTFYGJ6TJFGX4RC
  • API Key: HBVQ2XV6VYBI4582

It may be possible to isolate the OTA configuration screen and arbitrarily call it from the AutoConnectMenu to execute the OTA.

from autoconnect.

ageurtse avatar ageurtse commented on August 18, 2024

Looking good, keep up the good working.
Know i'm trying to make my own project so i can go further with my wifi dimmer.

I am not using the FS part, don't know how to upload the data folder using Sloeber.

i think it is nicer to have the variables from the json file automatic be stored in the file system and not from within the main file.
but that is my opinion.

from autoconnect.

ageurtse avatar ageurtse commented on August 18, 2024

when running the example file mqttRSSI.ino the checkbutton isn't stored correct.
when checked it is stored as uniqueid, when uncheck it is stored als an empty string.
the hostename isn't loading, the string is empty.
Saving of the hostname is going good, after opening the config after a reboot the dat is presented.

When storing data in the code within AUX_mqtt_setting this data is displayed.

below is my altered code to see what's in the variable's

    Serial.println("----------");
    Serial.println(uniqueidElm.value);
    Serial.println("----------");
    if (uniqueidElm.value = "unique") {
      config.apid = String("ESP") + "_" + String(ESP.getChipId(), HEX);
      Serial.println("apid set");
      Serial.println("----------");
    }
    Serial.println(hostnameElm.value);
    Serial.println("----------");
    if (hostnameElm.value.length()) {
      config.hostName = hostnameElm.value;
    }

from autoconnect.

Hieromon avatar Hieromon commented on August 18, 2024

Yes, I also found it. Thank you feedback. I'm revising now.

from autoconnect.

Hieromon avatar Hieromon commented on August 18, 2024

In about OTA and HTTP update, I examined the necessity and suitability of implementation.
I think the HTTPUpdater function can be implemented inside AutoConnect. It seems to have wide utility for users. Unless you know the internal structure of AutoConnect, it is difficult to use HTTPUpdater with the proper call sequence. If I have time to spare, I will implement it with v 0.97. But with an optimistic observation.
Is OTA necessary? It may be necessary for the ESP8266 module that does not have a serial interface.
I'm not sure.

from autoconnect.

ageurtse avatar ageurtse commented on August 18, 2024

well it is not necessary, just for what i'm trying to build it would be nice to have the abilty to update over air.

If there is a webupdate, that only would be nice.
OTA so one can flash from the development enviroment is nice but not necesary.

Maybe, this is something for version 0.98

from autoconnect.

ageurtse avatar ageurtse commented on August 18, 2024

did you solve the problem with reading the settings ?

from autoconnect.

Hieromon avatar Hieromon commented on August 18, 2024

Hello @ageurtse, Parameter values storing problem was solved, normal loading and saving of parameters will work. also it works fine with in SPIFFS.
But I have new difficult problems to solve. The problem is overwrite loading from Json.
For example, when placing radio buttons, write JSON as follows.

{
  "name": "period",
  "type": "ACRadio",
  "label": "Update period",
  "value": [
    "30 sec.",
    "60 sec.",
    "180 sec."
  ],
  "arrange": "vertical",
  "checked": 1
}

The meanings of JSON object keys are as follows.

  • name : Element name, you can handle it by "name" in sketches.
  • type : Element type, ACRadio generates HTML tag as "<input type="radio" ...>".
  • label: Label text for the Radio button.
  • value: Radio button's label text. This is an array for putting radio buttons in the same group.
  • arrange: An arrangement direction of buttons. (vertical or horizontal)
  • checked: The number of the button checked in the array. (numerical)

And then, the Web page is generated as follows.

img_0343

If you simply load it you will see that screen correctly. Input values ​​are also saved correctly, saving will work. But overwrite load does not work. There seems to be a problem with my implementation using std::vector or std::vectorstd::string.
Overwrite loading is the ability to overwrite values ​​and attributes of previously loaded AutoConnectElemet. It is called as follows.

aux.loadElement(in, name);

It loads and overwrites elements specified by names from the stream or PROGMEM.
The problem is when you increase array elements with overwriting loading. (the number of radio buttons above).
For example, suppose you load the following JSON additionally from another source.

{
  "name": "period",
  "type": "ACRadio",
  "label": "Update period",
  "value": [
    "30 sec.",
    "60 sec.",
    "180 sec.",
    "240 sec."
  ],
  "arrange": "vertical",
  "checked": 1
}

It is necessary to add and display ○240 sec., but the screen will be blank. The generated whole HTML is lost. It seems that the generated HTML instance is destructed. Sometimes, reloading in the browser will display normally.
I found the source code location that is the direct trigger. The problem is in push_back of std::vector<String> or std::vector<std::string>. Once releasing the allocated vectors once again and securing again, it seems that a memory leak occurs if it is larger than the previous number of elements. But I am not sure why the phenomenon happens.
Honest, is pretty tough...
I may need help from someone who is familiar with the combined implementation of std::vector and Arduino String.
For now, I will update the development branch with a problematic version.

from autoconnect.

ageurtse avatar ageurtse commented on August 18, 2024

Sorry to hear, this is way beyond my programming skills, so i can't help you.

Why can't i use the loaded values in my sketch, it seems they aren't loaded.

AutoConnectInput&     hostnameElm = setting->getElement<AutoConnectInput>("hostname");
AutoConnectInput&     mqttElm = setting->getElement<AutoConnectInput>("mqttserver");

Serial.println("----------");
Serial.println(hostnameElm.value);
Serial.println(mqttElm.value);
Serial.println("----------");

gives empty values.

from autoconnect.

Hieromon avatar Hieromon commented on August 18, 2024

Problem diagnosis advanced a little. Maybe the cause is insufficient memory, but I'll manage.

from autoconnect.

Hieromon avatar Hieromon commented on August 18, 2024

A more simple access method is also available. Aux page values are passed to the callback function, you can get the value by accessing it by name.
Like this:

AutoConnect portal;
AutoConnectAux aux;

String callback(AutoConnectAux& aux, PageArgument& args) {
  String value = args.arg("Element_name");
  ...
}

void setup() {
  ...
  aux.load(...some_source...);
  aux.on(callback);
  portal.join(aux);
  portal.begin();
  ...

from autoconnect.

Hieromon avatar Hieromon commented on August 18, 2024

Sorry, my above comment is missing the point.

Why can't i use the loaded values in my sketch, it seems they aren't loaded.

It's bug. I will do it by New Year's Eve...

from autoconnect.

ageurtse avatar ageurtse commented on August 18, 2024

great, thanks a lot.
can't wait to see the next release, if i need to test something, let me know.

from autoconnect.

Hieromon avatar Hieromon commented on August 18, 2024

@ageurtse, I updated develop branch. In my environment memory leaks seem to be fixed but I continue to test for a while.

from autoconnect.

ageurtse avatar ageurtse commented on August 18, 2024

I will look into it, i'm trying to get my hardware for wifi dimmer to work.

from autoconnect.

Hieromon avatar Hieromon commented on August 18, 2024

Incorporating the update function into the AutoConnect menu has been postponed in v 0.9.8. You can import WebUpdate in the way posted to Issue #50.
The ability to update the farm over the internet will be supported in v0.9.9 or later. Reopen this topic for reminding.

from autoconnect.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.