Browse Source

make httpclient retry

lightsleep
Hendrik Langer 7 years ago
parent
commit
f9e954b3d8
  1. 7
      src/main.cpp

7
src/main.cpp

@ -174,6 +174,9 @@ void ICACHE_FLASH_ATTR sendValues() {
char buffer[500];
array.printTo(buffer, sizeof(buffer));
int httpCode = 0;
for (int tries=0; tries<3 && httpCode != HTTP_CODE_CREATED; tries++) {
HTTPClient httpclient;
char url[100];
sprintf(url, "http://%s/boxes/%s/data", server, SENSEBOX_ID);
@ -181,7 +184,7 @@ void ICACHE_FLASH_ATTR sendValues() {
httpclient.begin(url);
httpclient.addHeader("Content-Type", "application/json");
int httpCode = httpclient.POST(buffer);
httpCode = httpclient.POST(buffer);
if (httpCode > 0) {
if (httpCode == HTTP_CODE_CREATED) {
@ -194,6 +197,8 @@ void ICACHE_FLASH_ATTR sendValues() {
httpclient.end();
}
WiFi.disconnect();
WiFi.mode(WIFI_OFF);
WiFi.forceSleepBegin();

Loading…
Cancel
Save