-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fa54691
commit 195c434
Showing
12 changed files
with
117 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/** | ||
* @file sender_waterius.h | ||
* @brief Функции отправки сведений в облако waterius.ru по htpp/https | ||
* @version 0.1 | ||
* @date 2023-11-01 | ||
* | ||
* @copyright Copyright (c) 2023 | ||
* | ||
*/ | ||
#ifndef SENDERWATERIUS_h_ | ||
#define SENDERWATERIUS_h_ | ||
#ifndef WATERIUS_RU_DISABLED | ||
#include <ESP8266WiFi.h> | ||
#include "setup.h" | ||
#include "master_i2c.h" | ||
#include "Logging.h" | ||
#include "json.h" | ||
#include "https_helpers.h" | ||
|
||
#define HTTP_SEND_ATTEMPTS 3 | ||
|
||
bool send_waterius(const Settings &sett, DynamicJsonDocument &jsonData) | ||
{ | ||
if (!(sett.waterius_on && sett.waterius_host[0] && sett.waterius_key[0])) | ||
{ | ||
LOG_INFO(F("WATR: SKIP")); | ||
return false; | ||
}; | ||
|
||
uint32_t start_time = millis(); | ||
|
||
LOG_INFO(F("-- START -- ")); | ||
LOG_INFO(F("WATR: Send new data")); | ||
|
||
String payload = ""; | ||
serializeJson(jsonData, payload); | ||
String url = sett.waterius_host; | ||
|
||
int attempts = HTTP_SEND_ATTEMPTS; | ||
bool result = false; | ||
do | ||
{ | ||
LOG_INFO(F("WATR: Attempt #") << HTTP_SEND_ATTEMPTS - attempts + 1 << F(" from ") << HTTP_SEND_ATTEMPTS); | ||
result = post_data(url, sett.waterius_key, sett.waterius_email, payload); | ||
|
||
} while (!result && --attempts); | ||
|
||
if (result) | ||
{ | ||
LOG_INFO(F("WATR: Data sent. Time ") << millis() - start_time << F(" ms")); | ||
} | ||
else | ||
{ | ||
LOG_ERROR(F("WATR: Failed send data. Time ") << millis() - start_time << F(" ms")); | ||
} | ||
|
||
LOG_INFO(F("-- END --")); | ||
|
||
return result; | ||
} | ||
|
||
#endif | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters