Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/json-quoting'
Browse files Browse the repository at this point in the history
  • Loading branch information
eykamp committed Feb 4, 2018
2 parents 166c5b3 + e5f68fb commit 6063a83
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions aREST.h
Original file line number Diff line number Diff line change
Expand Up @@ -1416,28 +1416,29 @@ virtual void root_answer() {
else {
addToBufferF(F("{\"variables\": {"));

for (uint8_t i = 0; i < variables_index; i++){
for (uint8_t i = 0; i < variables_index; i++) {
addToBuffer(variable_names[i], true);

addToBufferF(F(": "));
variables[i]->addToBuffer(this);

// Add a comma unless this is our last variable
if (i < variables_index - 1) {
addToBufferF(F(", "));
}
}

addToBufferF(F("}, "));
// END
}

// End
addHardwareToBuffer();

#ifndef PubSubClient_h
addToBufferF(F("\r\n"));
#endif
}


void function(char * function_name, int (*f)(String)){

functions_names[functions_index] = function_name;
Expand Down Expand Up @@ -1609,8 +1610,8 @@ void addToBuffer(const char * toAdd, bool quotable){

// Add to output buffer
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(ESP8266) || defined(CORE_WILDFIRE) || !defined(ADAFRUIT_CC3000_H) || defined(ESP32)
void addToBuffer(const String& toAdd, bool quotable){

void addToBuffer(const String& toAdd, bool quotable) {
if (DEBUG_MODE) {
#if defined(ESP8266)|| defined (ESP32)
Serial.print("Memory loss:");
Expand Down Expand Up @@ -1831,15 +1832,13 @@ uint8_t esp_12_pin_map(uint8_t pin) {

}


void addVariableToBuffer(uint8_t index) {
addToBuffer(variable_names[index], true);
addToBufferF(F(": "));
variables[index]->addToBuffer(this);
addToBufferF(F(", "));
}


void addHardwareToBuffer() {
addToBufferF(F("\"id\": "));
addToBuffer(id, true);
Expand All @@ -1850,7 +1849,6 @@ void addHardwareToBuffer() {
addToBufferF(F(", \"connected\": true}"));
}


// For non AVR boards
#if defined (__arm__)
char *dtostrf (double val, signed char width, unsigned char prec, char *sout) {
Expand Down

0 comments on commit 6063a83

Please sign in to comment.