mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
@@ -202,6 +202,10 @@
|
||||
"path": "src/modules/exec/EspCam",
|
||||
"active": false
|
||||
},
|
||||
{
|
||||
"path": "src/modules/exec/HttpGet",
|
||||
"active": false
|
||||
},
|
||||
{
|
||||
"path": "src/modules/exec/IoTServo",
|
||||
"active": true
|
||||
|
||||
100
src/modules/exec/HttpGet/HttpGet.cpp
Normal file
100
src/modules/exec/HttpGet/HttpGet.cpp
Normal file
@@ -0,0 +1,100 @@
|
||||
#include "Global.h"
|
||||
#include "classes/IoTItem.h"
|
||||
|
||||
class HttpGet : public IoTItem
|
||||
{
|
||||
public:
|
||||
HttpGet(String parameters) : IoTItem(parameters)
|
||||
{
|
||||
}
|
||||
|
||||
void sendHttpPOST(String url, String msg)
|
||||
{
|
||||
if (WiFi.status() == WL_CONNECTED)
|
||||
{
|
||||
|
||||
WiFiClient client;
|
||||
HTTPClient http;
|
||||
http.begin(client, url);
|
||||
http.addHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
String httpRequestData = msg;
|
||||
int httpResponseCode = http.POST(httpRequestData);
|
||||
String payload = http.getString();
|
||||
SerialPrint("<-", F("HttpPOST"), "URL: " + url + ", msg: " + msg);
|
||||
SerialPrint("->", F("HttpPOST"), "URL: " + url + ", server: " + httpResponseCode);
|
||||
|
||||
if (httpResponseCode > 0)
|
||||
{
|
||||
value.valS = payload;
|
||||
SerialPrint("->", F("HttpPOST"), "msg from server: " + (String)payload.c_str());
|
||||
value.valS = payload;
|
||||
regEvent(value.valS, "HttpGet");
|
||||
}
|
||||
http.end();
|
||||
}
|
||||
}
|
||||
void sendHttpGET(String url)
|
||||
{
|
||||
WiFiClient client;
|
||||
HTTPClient http;
|
||||
#if defined ESP8266
|
||||
if (!http.begin(client, url))
|
||||
{
|
||||
#elif defined ESP32
|
||||
if (!http.begin(url))
|
||||
{
|
||||
#endif
|
||||
|
||||
SerialPrint("I", F("HttpGet"), "connection failed ");
|
||||
}
|
||||
http.addHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
int httpResponseCode = http.GET();
|
||||
String payload = http.getString();
|
||||
SerialPrint("<-", F("HttpGET"), "URL: " + url);
|
||||
SerialPrint("->", F("HttpGET"), "URL: " + url + ", server: " + httpResponseCode);
|
||||
if (httpResponseCode > 0)
|
||||
{
|
||||
value.valS = payload;
|
||||
SerialPrint("->", F("HttpGET"), "msg from server: " + (String)payload.c_str());
|
||||
value.valS = payload;
|
||||
regEvent(value.valS, "HttpGet");
|
||||
}
|
||||
http.end();
|
||||
}
|
||||
|
||||
IoTValue execute(String command, std::vector<IoTValue> ¶m)
|
||||
{
|
||||
if (param.size() > 0)
|
||||
{
|
||||
if (command == "get")
|
||||
{
|
||||
if (param.size())
|
||||
{
|
||||
sendHttpGET(param[0].valS);
|
||||
}
|
||||
}
|
||||
else if (command == "post")
|
||||
{
|
||||
if (param.size())
|
||||
{
|
||||
sendHttpPOST(param[0].valS, param[1].valS);
|
||||
}
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
~HttpGet(){};
|
||||
};
|
||||
|
||||
void *getAPI_HttpGet(String subtype, String param)
|
||||
{
|
||||
if (subtype == F("HttpGet"))
|
||||
{
|
||||
return new HttpGet(param);
|
||||
}
|
||||
else
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
58
src/modules/exec/HttpGet/modinfo.json
Normal file
58
src/modules/exec/HttpGet/modinfo.json
Normal file
@@ -0,0 +1,58 @@
|
||||
{
|
||||
"menuSection": "Исполнительные устройства",
|
||||
"configItem": [
|
||||
{
|
||||
"global": 0,
|
||||
"name": "HttpGet",
|
||||
"type": "Writing",
|
||||
"subtype": "HttpGet",
|
||||
"id": "http",
|
||||
"widget": "",
|
||||
"page": "",
|
||||
"descr": "",
|
||||
"token": "",
|
||||
"chatID": ""
|
||||
}
|
||||
],
|
||||
"about": {
|
||||
"authorName": "AVAKS",
|
||||
"authorContact": "https://t.me/@avaks_dev",
|
||||
"authorGit": "https://github.com/avaksru",
|
||||
"specialThanks": "",
|
||||
"moduleName": "HttpGet",
|
||||
"moduleVersion": "1",
|
||||
"usedRam": {
|
||||
"esp32_4mb": 15,
|
||||
"esp8266_4mb": 15
|
||||
},
|
||||
"title": "Отправка запросов по http",
|
||||
"moduleDesc": "Запросы по протоколу https НЕ РАБОТАЮТ!",
|
||||
"propInfo": {},
|
||||
"retInfo": "",
|
||||
"funcInfo": [
|
||||
{
|
||||
"name": "get",
|
||||
"descr": "Отправить http запрос методом GET.",
|
||||
"params": [
|
||||
"http.get('URL')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "post",
|
||||
"descr": "Отправить http запрос методом POST.",
|
||||
"params": [
|
||||
"http.post('URL','message')"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"defActive": false,
|
||||
"usedLibs": {
|
||||
"esp32_4mb": [],
|
||||
"esp8266_4mb": [],
|
||||
"esp8266_1mb": [],
|
||||
"esp8266_1mb_ota": [],
|
||||
"esp8285_1mb": [],
|
||||
"esp8285_1mb_ota": []
|
||||
}
|
||||
}
|
||||
1
webConfigMyProfile/build/bundle.css
Normal file
1
webConfigMyProfile/build/bundle.css
Normal file
@@ -0,0 +1 @@
|
||||
.board.svelte-185rejv.svelte-185rejv{max-width:36em;margin:0 auto}.left.svelte-185rejv.svelte-185rejv,.right.svelte-185rejv.svelte-185rejv{float:left;width:50%;padding:0 1em 0 0;box-sizing:border-box}h2.svelte-185rejv.svelte-185rejv{font-size:2em;font-weight:200;user-select:none}label.svelte-185rejv.svelte-185rejv{top:0;left:0;display:block;font-size:1em;line-height:1;padding:0.5em;margin:0 auto 0.5em auto;border-radius:2px;background-color:#eee;user-select:none}input.svelte-185rejv.svelte-185rejv{margin:0 }.right.svelte-185rejv label.svelte-185rejv{background-color:rgb(180,240,100)}button.svelte-185rejv.svelte-185rejv{float:right;height:1em;box-sizing:border-box;padding:0 0.5em;line-height:1;background-color:transparent;border:none;color:rgb(170,30,30);opacity:0;transition:opacity 0.2s}label.svelte-185rejv:hover button.svelte-185rejv{opacity:1}.gauge.svelte-1er7lpr{position:relative;width:4em;height:2em;box-sizing:border-box;display:inline-block}.gauge-fill.svelte-1er7lpr{position:absolute;z-index:2;width:100%;height:100%;border-radius:2em 2em 0 0;transition:transform 0.2s;transform-origin:50% 100%}.gauge-bg.svelte-1er7lpr{z-index:1;box-shadow:inset 0 0 20px -15px #000a}.gauge-overflow.svelte-1er7lpr{position:absolute;width:100%;height:100%;overflow:hidden}.gauge-value.svelte-1er7lpr{position:absolute;z-index:4;bottom:0;left:0;right:0;text-align:center;font-weight:bold;line-height:1em}.gauge-white.svelte-1er7lpr{position:absolute;z-index:3;top:15%;left:8%;width:85%;height:182%;border-radius:100%;background:white}.modal-background.svelte-5a6h72{position:fixed;z-index:6;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.3)}.modal.svelte-5a6h72{position:absolute;z-index:6;left:50%;top:50%;width:calc(100vw - 4em);max-width:32em;max-height:calc(100vh - 4em);overflow:auto;transform:translate(-50%,-50%);padding:1em;border-radius:0.2em;background:white}button.svelte-5a6h72{display:block}.box.svelte-1q88uwi{margin:0 auto;display:inline-block;vertical-align:top;width:auto;border:0px solid #aaa;border-radius:1px;box-shadow:1px 1px 4px rgba(0,0,0,0.1);padding:1em;margin:10 2em 1em 0;height:auto}
|
||||
16
webConfigMyProfile/build/bundle.js
Normal file
16
webConfigMyProfile/build/bundle.js
Normal file
File diff suppressed because one or more lines are too long
BIN
webConfigMyProfile/favicon.ico
Normal file
BIN
webConfigMyProfile/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
63
webConfigMyProfile/global.css
Normal file
63
webConfigMyProfile/global.css
Normal file
@@ -0,0 +1,63 @@
|
||||
html, body {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
color: #333;
|
||||
margin: 0;
|
||||
padding: 8px;
|
||||
box-sizing: border-box;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
|
||||
}
|
||||
|
||||
a {
|
||||
color: rgb(0,100,200);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
a:visited {
|
||||
color: rgb(0,80,160);
|
||||
}
|
||||
|
||||
label {
|
||||
display: block;
|
||||
}
|
||||
|
||||
input, button, select, textarea {
|
||||
font-family: inherit;
|
||||
font-size: inherit;
|
||||
-webkit-padding: 0.4em 0;
|
||||
padding: 0.4em;
|
||||
margin: 0 0 0.5em 0;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
input:disabled {
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
button {
|
||||
color: #333;
|
||||
background-color: #f4f4f4;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
button:disabled {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
button:not(:disabled):active {
|
||||
background-color: #ddd;
|
||||
}
|
||||
|
||||
button:focus {
|
||||
border-color: #666;
|
||||
}
|
||||
18
webConfigMyProfile/index.html
Normal file
18
webConfigMyProfile/index.html
Normal file
@@ -0,0 +1,18 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||
|
||||
|
||||
<title>Конфигуратор прошивки</title>
|
||||
|
||||
<link rel="icon" type="image/png" href="favicon.ico" />
|
||||
<link rel="stylesheet" href="global.css" />
|
||||
<link rel="stylesheet" href="build/bundle.css?0.01" />
|
||||
|
||||
<script defer src="build/bundle.js?0.01"></script>
|
||||
</head>
|
||||
|
||||
<body></body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user