mirror of
https://github.com/openshwprojects/OpenBK7231T_App.git
synced 2026-03-09 08:47:55 +01:00
* Update obk_config.h * Update obk_config.h * shared * fx * he * fix * fx * ffff * F * T * tre * fcx * leeed * ww * w * fx * t * ENABLE_OLD_YAML_GENERATOR * w * startyuip[ * dis all * remove test post * ENABLE_HTTP_SEND * extra guard * ENABLE_TCP_COMMANDLINE * better OBK_DISABLE_ALL_DRIVERS * tr * ENABLE_PING_WATCHDOG * ENABLE_HA_DISCOVERY * TEST WITH EMPTY USER_MAIN * fx * no mqtt * nm * tr * ENABLE_MQTT * Update cmd_newLEDDriver.c * tr * header * fx * Update user_main.c * t * Update hal_main_bk7231.c * w * ENABLE_DRIVER_IR * RESTORE * fx * #warning "Platform not defined" * fx 1 * Update obk_config.h * ENABLE_DRIVER_TESTPOWER * DS1820 * fx * fx * enable DHT on W800 * Update Makefile * ntp w800 * ntp * ssdp * OWM AND CHARTS * why utils net has flash pub included * nmakefile only, no refs * makefile only * drv * Update Makefile * drcs * ENABLE_DRIVER_BMP280 * Update Makefile * d * ENABLE_I2C * Update Makefile * fin
62 lines
2.5 KiB
C
62 lines
2.5 KiB
C
#include "../new_pins.h"
|
|
#include "../new_cfg.h"
|
|
#include "../logging/logging.h"
|
|
#include "../httpclient/http_client.h"
|
|
#include "cmd_local.h"
|
|
|
|
#if ENABLE_SEND_POSTANDGET
|
|
|
|
// SendGet http://192.168.0.112/cm?cmnd=Power0%20Toggle
|
|
// addRepeatingEvent 5 -1 SendGet http://192.168.0.112/cm?cmnd=Power0%20Toggle
|
|
// addEventHandler OnClick 8 SendGet http://192.168.0.112/cm?cmnd=Power0%20Toggle
|
|
// Following command will just send get:
|
|
// SendGet http://example.com/
|
|
// Following command will send get and save result to file:
|
|
// SendGet http://example.com/ myFile.html
|
|
// test code: addRepeatingEvent 30 -1 SendGet http://example.com/ myFile.html
|
|
static commandResult_t CMD_SendGET(const void* context, const char* cmd, const char* args, int cmdFlags) {
|
|
ADDLOG_INFO(LOG_FEATURE_CMD, " CMD_SendGET received with args %s", args);
|
|
|
|
Tokenizer_TokenizeString(args, TOKENIZER_ALLOW_QUOTES | TOKENIZER_ALLOW_ESCAPING_QUOTATIONS);
|
|
|
|
HTTPClient_Async_SendGet(Tokenizer_GetArg(0), Tokenizer_GetArg(1));
|
|
|
|
return CMD_RES_OK;
|
|
}
|
|
// SendPOST http://localhost:3000/ 3000 "application/json" "{ \"a\":123, \"b\":77 }"
|
|
static commandResult_t CMD_SendPOST(const void* context, const char* cmd, const char* args, int cmdFlags) {
|
|
ADDLOG_INFO(LOG_FEATURE_CMD, " CMD_SendPOST received with args %s", args);
|
|
|
|
Tokenizer_TokenizeString(args, TOKENIZER_ALLOW_QUOTES | TOKENIZER_ALLOW_ESCAPING_QUOTATIONS);
|
|
|
|
HTTPClient_Async_SendPost(Tokenizer_GetArg(0),
|
|
Tokenizer_GetArgIntegerDefault(1, 80),
|
|
Tokenizer_GetArg(2),
|
|
Tokenizer_GetArg(3),
|
|
Tokenizer_GetArg(4));
|
|
|
|
return CMD_RES_OK;
|
|
}
|
|
|
|
int CMD_InitSendCommands() {
|
|
//cmddetail:{"name":"sendGet","args":"[TargetURL]",
|
|
//cmddetail:"descr":"Sends a HTTP GET request to target URL. May include GET arguments. Can be used to control devices by Tasmota HTTP protocol. Command supports argument expansion, so $CH11 changes to value of channel 11, etc, etc.",
|
|
//cmddetail:"fn":"CMD_SendGET","file":"cmnds/cmd_send.c","requires":"",
|
|
//cmddetail:"examples":""}
|
|
CMD_RegisterCommand("sendGet", CMD_SendGET, NULL);
|
|
|
|
// TODO example
|
|
// SendPost "http://192.168.0.1/write?db=energy" 8086 "application/octet-stream" "current,clientid=A0:92:08:CB:41:E1 value=$current""
|
|
|
|
//cmddetail:{"name":"sendPOST","args":"[TargetURL] [HTTP Port] [Content Type] [Post Content]",
|
|
//cmddetail:"descr":"Sends a HTTP POST request to target URL. Arguments can contain variable expansion.",
|
|
//cmddetail:"fn":"CMD_SendPOST","file":"cmnds/cmd_send.c","requires":"",
|
|
//cmddetail:"examples":""}
|
|
CMD_RegisterCommand("sendPOST", CMD_SendPOST, NULL);
|
|
|
|
return 0;
|
|
}
|
|
|
|
#endif
|
|
|