Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is it possible to have update feather in the menu #26

Closed
ageurtse opened this issue Dec 22, 2018 · 16 comments
Closed

is it possible to have update feather in the menu #26

ageurtse opened this issue Dec 22, 2018 · 16 comments
Labels
enhancement New feature or request

Comments

@ageurtse
Copy link

i would like to see a webupdate feather in the menu, now in the main file i add ArduinoOta.h and ESP8266HTTPUpdateServer.h.
But it would realy be nice that this is implemented within autoconnect.

@Hieromon
Copy link
Owner

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.

@Hieromon Hieromon added the enhancement New feature or request label Dec 22, 2018
@ageurtse
Copy link
Author

ageurtse commented Dec 23, 2018

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.

@ageurtse
Copy link
Author

ageurtse commented Dec 23, 2018

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;
    }

@Hieromon
Copy link
Owner

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

@Hieromon
Copy link
Owner

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.

@ageurtse
Copy link
Author

ageurtse commented Dec 23, 2018

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

@ageurtse
Copy link
Author

did you solve the problem with reading the settings ?

@Hieromon
Copy link
Owner

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.

@ageurtse
Copy link
Author

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.

@Hieromon
Copy link
Owner

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

@Hieromon
Copy link
Owner

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();
  ...

@Hieromon
Copy link
Owner

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...

@ageurtse
Copy link
Author

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

@Hieromon
Copy link
Owner

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

@ageurtse
Copy link
Author

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

Hieromon added a commit that referenced this issue Mar 1, 2019
@Hieromon Hieromon closed this as completed Mar 1, 2019
@Hieromon Hieromon added this to Requirements in Enhancement v0.9.8 Mar 6, 2019
@Hieromon
Copy link
Owner

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.

@Hieromon Hieromon reopened this Apr 14, 2019
@Hieromon Hieromon moved this from Requirements to Release specification in Enhancement v0.9.8 Apr 14, 2019
@Hieromon Hieromon added this to Requirements in Enhancement v0.9.9 Apr 16, 2019
@Hieromon Hieromon mentioned this issue Sep 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
No open projects
Enhancement v0.9.8
Release specification
Development

Successfully merging a pull request may close this issue.

2 participants