Fork from Alex

Dependencies:   mbed MbedJSONValue mbed-rtos 4DGL-uLCD-SE ESP8266NodeMCUInterface

Revision:
9:299eb69af04e
Parent:
8:d323c6406b47
Child:
10:16356570821e
diff -r d323c6406b47 -r 299eb69af04e main.cpp
--- a/main.cpp	Mon Apr 01 17:00:17 2019 +0000
+++ b/main.cpp	Fri Apr 05 18:34:14 2019 +0000
@@ -351,12 +351,12 @@
     }
     buffer[footer_ind + 1] = '\0';
 
-    MbedJSONValue parser;
-    parse(parser, buffer + header_ind);
+    MbedJSONValue* parser = new MbedJSONValue();
+    parse(*parser, buffer + header_ind);
 
-    latitude =  parser["latitude"].get<double>();
-    longitude = parser["longitude"].get<double>();
-
+    latitude = (*parser)["latitude"].get<double>();
+    longitude = (*parser)["longitude"].get<double>();
+    delete(parser);
     // Get the Time
     TCPSocketConnection time_tcp;
 
@@ -407,13 +407,16 @@
         }
     }
     buffer[footer_ind + 1] = '\0';
-
-    MbedJSONValue time_parser;
-    parse(time_parser, buffer + header_ind);
+    parser = new MbedJSONValue();
+    parse(*parser, buffer + header_ind);
 
     // Add 5 so that we make up for the wait(5)
     // Add 3 so that we make up for TCP request - empirically...
-    set_time(time_parser["timestamp"].get<int>() + 5 + 3);
+    set_time((*parser)["timestamp"].get<int>() + 5 + 3);
+    delete(parser);
+    lcd_lock.lock();
+    uLCD.cls();
+    lcd_lock.unlock();
     // Now that we know what time it is, set up our Time Thread
     time_thread.start(time_updater);
 
@@ -422,13 +425,13 @@
     forecast_sck.connect("api.openweathermap.org", 80);
 
     sprintf(cmd,
-            "GET /data/2.5/weather?lat=%0.4f&lon=%0.4f&APPID=%s&cnt=8\r\nHost: api.openweathermap.org\r\n\r\n",
+            "GET /data/2.5/forecast?lat=%0.4f&lon=%0.4f&APPID=%s&cnt=1\r\nHost: api.openweathermap.org\r\n\r\n",
             latitude, longitude, weather_api_key);
     forecast_sck.send_all(cmd, strlen(cmd));
 
     wait(5);
 
-    read_len wifi.recv(buffer, BUF_SIZE - 1, 0);
+    read_len = wifi.recv(buffer, BUF_SIZE - 1, 0);
     buffer[read_len] = '\0';
 
     // We don't have enough memory for another parser (why?), so just
@@ -453,6 +456,7 @@
         }
     }
     int temp = atoi(num_buf);
+
     // Convert
     temp = kelvin2farenheit(temp);
     char temp_buf[12];