Core Base Classes for the Light Endpoints

Dependencies:   BufferedSerial

Dependents:   mbed_mqtt_endpoint_ublox_ethernet mbed_mqtt_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_ethernet ... more

Revision:
153:8b32ee1ed6d6
Parent:
152:659a8ebcbe93
Child:
154:6e60f310ab78
--- a/Preferences.cpp	Wed Apr 02 16:08:54 2014 +0000
+++ b/Preferences.cpp	Wed Apr 02 18:15:49 2014 +0000
@@ -36,9 +36,14 @@
  bool Preferences::initialize() {
      char name[PREFERENCE_NAME_LEN+1];
      char value[PREFERENCE_VALUE_LEN+1];
-     char buffer[PREFERENCE_NAME_LEN + PREFERENCE_NAME_LEN + 10];
+     char buffer[PREFERENCE_NAME_LEN + PREFERENCE_VALUE_LEN + 100];
      bool success = true;
      
+     // initialize
+     memset(name,0,PREFERENCE_NAME_LEN+1);
+     memset(value,0,PREFERENCE_VALUE_LEN+1);
+     memset(buffer,0,PREFERENCE_NAME_LEN + PREFERENCE_VALUE_LEN + 100);
+     
      // initialize the memory buffers and count
      for(int i=0;i<MAX_NUM_PREFERENCES;++i) {
          memset(this->m_names[i],0,PREFERENCE_NAME_LEN+1);
@@ -51,7 +56,7 @@
      FILE *fp = fopen(PREFERENCES_FILE,"r");
      if (fp != NULL) {
          // read in the first line
-         memset(buffer,0,PREFERENCE_NAME_LEN + PREFERENCE_NAME_LEN + 10);
+         memset(buffer,0,PREFERENCE_NAME_LEN + PREFERENCE_VALUE_LEN + 100);
          int n = fscanf(fp,"%s",buffer);
          
          // loop and read each line
@@ -73,7 +78,7 @@
              ++this->m_num_preferences;
              
              // reset the buffer and read in another line
-             memset(buffer,0,PREFERENCE_NAME_LEN + PREFERENCE_NAME_LEN + 10);
+             memset(buffer,0,PREFERENCE_NAME_LEN + PREFERENCE_VALUE_LEN + 100);
              n = fscanf(fp,"%s",buffer);
          }