Problem saving Task/Plugin settings

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
raihei
New user
Posts: 3
Joined: 03 Jan 2018, 21:00

Problem saving Task/Plugin settings

#1 Post by raihei » 03 Jan 2018, 21:21

Hi all,

I have some problems saving some configuration/values
Build: ESPEasy_v2.0.0-dev12

In a custom devices plugin when a command (http://ip/control?cmd=rgb,off) is received I try to save a value to retain it when the ESP is powered off.

Code: Select all

Settings.TaskDevicePluginConfigLong[event->TaskIndex][2] = rgbvalue;
When I read back this value directly after saving it via

Code: Select all

Serial.println(Settings.TaskDevicePluginConfigLong[event->TaskIndex][2]);
it shows the right (saved) value.

But when powered back on and I try to restore the value in the "PLUGIN_INIT", it is always zero

Code: Select all

case PLUGIN_INIT:
      {
        LoadTaskSettings(event->TaskIndex);
        Serial.println(Settings.TaskDevicePluginConfigLong[event->TaskIndex][2]);
        rgbvalue = Settings.TaskDevicePluginConfigLong[event->TaskIndex][2];
        ...
        success = true;
        break;
      }
Am I doing something wrong, or is it not supposed to work like that?

I also tried to add SaveTaskSettings, but the value is still not saved...

Code: Select all

Settings.TaskDevicePluginConfigLong[event->TaskIndex][2] = rgbvalue;
SaveTaskSettings(event->TaskIndex);
Is there another way to retain a value while powering off the device?

regards
raihei

User avatar
vader
Normal user
Posts: 241
Joined: 21 Mar 2017, 17:35

Re: Problem saving Task/Plugin settings

#2 Post by vader » 05 Jan 2018, 16:30

I think "Settings.TaskDevicePluginConfigLong" does not save to flash! So you are saving/reading just from memory.

You can try this....

SaveCustomTaskSettings(event->TaskIndex, (byte*)&rgbvalue , sizeof(rgbvalue ));
LoadCustomTaskSettings(event->TaskIndex, (byte*)&rgbvalue , sizeof(rgbvalue ));

PS: I'm no prof programmer!

raihei
New user
Posts: 3
Joined: 03 Jan 2018, 21:00

Re: Problem saving Task/Plugin settings

#3 Post by raihei » 05 Jan 2018, 21:32

vader wrote: 05 Jan 2018, 16:30 I think "Settings.TaskDevicePluginConfigLong" does not save to flash! So you are saving/reading just from memory.

You can try this....

SaveCustomTaskSettings(event->TaskIndex, (byte*)&rgbvalue , sizeof(rgbvalue ));
LoadCustomTaskSettings(event->TaskIndex, (byte*)&rgbvalue , sizeof(rgbvalue ));

PS: I'm no prof programmer!
Thank you very much vader, that worked for me!

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 116 guests