Skip to content

Commit

Permalink
Fix get/feed/data, allow large phase spec
Browse files Browse the repository at this point in the history
  • Loading branch information
boblemaire committed Sep 24, 2017
1 parent 0abdced commit 1c8f09d
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 16 deletions.
1 change: 1 addition & 0 deletions Firmware/IotaWatt/Changelog.ino
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@
* 09/14/17 2.02.17 Version bump to transition to new update system
* 09/17/17 02_02_18 Encrypted Emoncms, new Script, influxDB, Emoncms outputs
* 09/21/17 02_02_19 Bug fixes, add config context check to app
* 09/24/17 02_02_20 Fix get feed data and initialize WiFi hostname
*
*****************************************************************************************************/
26 changes: 18 additions & 8 deletions Firmware/IotaWatt/GetFeedData.ino
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ uint32_t handleGetFeedData(struct serviceBlock* _serviceBlock){
static char* bufr = nullptr;
static uint32_t bufrSize = 0;
static uint32_t bufrPos = 0;
static double accum1Then = 0;
static double logHoursThen = 0;
static double elapsedHours = 0;
static uint32_t startUnixTime;
static uint32_t endUnixTime;
Expand Down Expand Up @@ -52,6 +50,22 @@ uint32_t handleGetFeedData(struct serviceBlock* _serviceBlock){
case Setup: {
trace(T_GFD,0);

// Validate the request parameters

startUnixTime = server.arg("start").substring(0,10).toInt();
endUnixTime = server.arg("end").substring(0,10).toInt();
intervalSeconds = server.arg("interval").toInt();
if((startUnixTime % 5) ||
(endUnixTime % 5) ||
(intervalSeconds % 5) ||
(intervalSeconds <= 0) ||
(endUnixTime < startUnixTime)){
server.send(400, "text/plain", "Invalid request");
state = Setup;
serverAvailable = true;
return 0;
}

// Parse the ID parm into a list.

String idParm = server.arg("id");
Expand Down Expand Up @@ -82,12 +96,8 @@ uint32_t handleGetFeedData(struct serviceBlock* _serviceBlock){
}
}

startUnixTime = server.arg("start").substring(0,10).toInt();
endUnixTime = server.arg("end").substring(0,10).toInt();
intervalSeconds = server.arg("interval").toInt();
accum1Then = 0;
logHoursThen = 0;



if(startUnixTime >= iotaLog.firstKey()){
lastRecord->UNIXtime = startUnixTime - intervalSeconds;
} else {
Expand Down
4 changes: 2 additions & 2 deletions Firmware/IotaWatt/IotaWatt.ino
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
***********************************************************************************/
#define IOTAWATT_VERSION "02_02_19"
#define IOTAWATT_VERSION "02_02_20"

#define PRINT(txt,val) Serial.print(txt); Serial.print(val); // Quick debug aids
#define PRINTL(txt,val) Serial.print(txt); Serial.println(val);
Expand Down Expand Up @@ -102,7 +102,7 @@ uint8_t ADC_selectPin[3] = {pin_CS_ADC0, // indexable reference for ADC selec

// Identifiers used to construct id numbers for graph API

#define QUERY_VOLTAGE 13
#define QUERY_VOLTAGE 1
#define QUERY_POWER 2
#define QUERY_ENERGY 3

Expand Down
3 changes: 2 additions & 1 deletion Firmware/IotaWatt/Setup.ino
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ void setup()

//*************************************** Start the WiFi connection *****************************

WiFi.begin();
WiFi.setAutoConnect(true);
WiFi.hostname(host);
WiFi.begin();
uint32_t autoConnectTimeout = millis() + 3000UL;
while(WiFi.status() != WL_CONNECTED){
if(millis() > autoConnectTimeout){
Expand Down
1 change: 0 additions & 1 deletion Firmware/IotaWatt/webServer.ino
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ void handleNotFound(){
return;
}
if(serverURI.startsWith("/feed/data")){
Serial.println(serverURI);
serverAvailable = false;
NewService(handleGetFeedData);
return;
Expand Down
4 changes: 0 additions & 4 deletions SD/index.htm
Original file line number Diff line number Diff line change
Expand Up @@ -407,10 +407,6 @@ <h3 class="calcDisplay" id="calcDisplay">0</h3>
}
else {
inputPhase.value = Number(inputPhase.value).toFixed(1);
if(inputPhase.value > 5) {
inputEditMsg(inputPhase, "Must be less than 5 degrees.");
complete = false;
}
}
}

Expand Down

0 comments on commit 1c8f09d

Please sign in to comment.