mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-30 03:49:13 +03:00
GoogleSheet только для esp32
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
#include "classes/IoTItem.h"
|
#include "classes/IoTItem.h"
|
||||||
|
|
||||||
String URL = "https://script.google.com/macros/s/";
|
String URL = "https://script.google.com/macros/s/";
|
||||||
long interval;
|
|
||||||
|
|
||||||
class GoogleSheet : public IoTItem
|
class GoogleSheet : public IoTItem
|
||||||
{
|
{
|
||||||
@@ -13,6 +13,8 @@ private:
|
|||||||
String scid = "";
|
String scid = "";
|
||||||
String shname = "";
|
String shname = "";
|
||||||
bool init = false;
|
bool init = false;
|
||||||
|
int interval = 1;
|
||||||
|
// long interval;
|
||||||
public:
|
public:
|
||||||
GoogleSheet(String parameters) : IoTItem(parameters)
|
GoogleSheet(String parameters) : IoTItem(parameters)
|
||||||
{
|
{
|
||||||
@@ -21,7 +23,7 @@ public:
|
|||||||
jsonRead(parameters, F("scid"), scid);
|
jsonRead(parameters, F("scid"), scid);
|
||||||
jsonRead(parameters, F("shname"), shname);
|
jsonRead(parameters, F("shname"), shname);
|
||||||
jsonRead(parameters, F("int"), interval);
|
jsonRead(parameters, F("int"), interval);
|
||||||
interval = interval * 1000 * 60; // приводим к милисекундам
|
interval = interval * 1000 * 60; // так как у нас в минутах
|
||||||
}
|
}
|
||||||
|
|
||||||
void doByInterval()
|
void doByInterval()
|
||||||
@@ -45,16 +47,17 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
SerialPrint("I", F("GoogleSheet"), "connection failed ");
|
SerialPrint("I", F("GoogleSheet"), "connection failed ");
|
||||||
}
|
}
|
||||||
http.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS);
|
http.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS); // HTTPC_STRICT_FOLLOW_REDIRECTS HTTPC_FORCE_FOLLOW_REDIRECTS
|
||||||
http.addHeader("Content-Type", "application/x-www-form-urlencoded");
|
http.addHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||||
int httpCode = http.GET();
|
int httpCode = http.GET();
|
||||||
String payload = http.getString();
|
// String payload = http.getString();
|
||||||
SerialPrint("<-", F("GoogleSheet"), "URL: " + urlFinal);
|
SerialPrint("<-", F("GoogleSheet"), "URL: " + urlFinal);
|
||||||
SerialPrint("->", F("GoogleSheet"), "URL: " + urlFinal + ", server: " + httpCode);
|
SerialPrint("->", F("GoogleSheet"), "server: " + (String)httpCode); /*"URL: " + urlFinal + */
|
||||||
if (httpCode > 0)
|
/* if (httpCode > 0)
|
||||||
{
|
{
|
||||||
SerialPrint("->", F("GoogleSheet"), "msg from server: " + (String)payload.c_str());
|
SerialPrint("->", F("GoogleSheet"), "msg from server: " + (String)payload.c_str());
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
http.end();
|
http.end();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
"descr": "",
|
"descr": "",
|
||||||
"int": 5,
|
"int": 5,
|
||||||
"logid": "id",
|
"logid": "id",
|
||||||
"scid": "Script_ID",
|
"scid": "AKfycbzAsuM-4Keb-DxZ6yqwmqSeiXRJJAqndijayZQfmx9pfh6wGAejjT6u7gTAIxrbxPBxyw",
|
||||||
"shname": "Logger"
|
"shname": "Logger"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user