|
|
@ -174,25 +174,30 @@ void ICACHE_FLASH_ATTR sendValues() { |
|
|
|
char buffer[500]; |
|
|
|
array.printTo(buffer, sizeof(buffer)); |
|
|
|
|
|
|
|
HTTPClient httpclient; |
|
|
|
char url[100]; |
|
|
|
sprintf(url, "http://%s/boxes/%s/data", server, SENSEBOX_ID); |
|
|
|
int httpCode = 0; |
|
|
|
for (int tries=0; tries<3 && httpCode != HTTP_CODE_CREATED; tries++) { |
|
|
|
|
|
|
|
httpclient.begin(url); |
|
|
|
httpclient.addHeader("Content-Type", "application/json"); |
|
|
|
HTTPClient httpclient; |
|
|
|
char url[100]; |
|
|
|
sprintf(url, "http://%s/boxes/%s/data", server, SENSEBOX_ID); |
|
|
|
|
|
|
|
int httpCode = httpclient.POST(buffer); |
|
|
|
httpclient.begin(url); |
|
|
|
httpclient.addHeader("Content-Type", "application/json"); |
|
|
|
|
|
|
|
if (httpCode > 0) { |
|
|
|
if (httpCode == HTTP_CODE_CREATED) { |
|
|
|
httpclient.writeToStream(&Serial); |
|
|
|
Serial.println(); |
|
|
|
} else { |
|
|
|
Serial.printf("[HTTP] POST... failed, error: %s\n", httpclient.errorToString(httpCode).c_str()); |
|
|
|
httpCode = httpclient.POST(buffer); |
|
|
|
|
|
|
|
if (httpCode > 0) { |
|
|
|
if (httpCode == HTTP_CODE_CREATED) { |
|
|
|
httpclient.writeToStream(&Serial); |
|
|
|
Serial.println(); |
|
|
|
} else { |
|
|
|
Serial.printf("[HTTP] POST... failed, error: %s\n", httpclient.errorToString(httpCode).c_str()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
httpclient.end(); |
|
|
|
httpclient.end(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
WiFi.disconnect(); |
|
|
|
WiFi.mode(WIFI_OFF); |
|
|
|