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