Saved custom task setting disappears after a while

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
buzink
New user
Posts: 2
Joined: 22 Jan 2017, 15:39

Saved custom task setting disappears after a while

#1 Post by buzink » 29 Jan 2017, 14:48

I need a variable for the plugin I am creating that holds the name of a template (like "[Import1#tablelamp]"). I successfully added a new element to the form. It saves the entered text and also loads it next time I open the device page. If I then close and open the page again, the text is gone. I'm new to C, so probably I am doing something obvious wrong. I am most unsure about the char deviceTemplate[8][64] bit. Below is my code. Who sees what I have done wrong?

Code: Select all

    case PLUGIN_WEBFORM_LOAD:
      {
        char deviceTemplate[8][64];
        LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate));
        string += F("<TR><TD>Initial value template");
        string += F(":<TD><input type='text' size='80' maxlength='80' name='Plugin_198_template1' value='");
        string += deviceTemplate[0];
        string += F("'>"); 
      }
      
     case PLUGIN_WEBFORM_SAVE:
      {
        char deviceTemplate[8][64];
        char argc[25];
        String arg = F("Plugin_198_template1");
        arg.toCharArray(argc, 25);
        String tmpString = WebServer.arg(argc);
        strncpy(deviceTemplate[0], tmpString.c_str(), sizeof(deviceTemplate[0]));
        
        //Settings.TaskDeviceID[event->TaskIndex] = 5; // temp fix, needs a dummy value

        SaveCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate));
        success = true;
        break;
      }
 
     case PLUGIN_TEN_PER_SECOND:
      {
          char deviceTemplate[8][64];
          LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate));
          String tmpString = deviceTemplate[0];
          if (tmpString.length())
          {
            String newString = parseTemplate(tmpString, 20);
            Plugin_198_initlevel = newString.toInt();
          }
               
     ....
       
      

Post Reply

Who is online

Users browsing this forum: No registered users and 18 guests