mirror of https://github.com/arendst/Tasmota.git
Add Berry `tasmota.web_send()` (#12197)
* Add Berry `tasmota.web_send()` * Fix compilation Co-authored-by: Stephan Hadinger <stephan.hadinger@gmail.com>
This commit is contained in:
parent
fa4d09d362
commit
90330a5000
|
@ -27,6 +27,7 @@ extern int l_respCmndFailed(bvm *vm);
|
|||
extern int l_resolveCmnd(bvm *vm);
|
||||
|
||||
extern int l_respAppend(bvm *vm);
|
||||
extern int l_webSend(bvm *vm);
|
||||
extern int l_webSendDecimal(bvm *vm);
|
||||
|
||||
extern int l_getlight(bvm *vm);
|
||||
|
@ -2435,6 +2436,7 @@ void be_load_tasmota_ntvlib(bvm *vm)
|
|||
{ "resolvecmnd", l_resolveCmnd },
|
||||
|
||||
{ "response_append", l_respAppend },
|
||||
{ "web_send", l_webSend },
|
||||
{ "web_send_decimal", l_webSendDecimal },
|
||||
|
||||
{ "get_power", l_getpower },
|
||||
|
@ -2508,6 +2510,7 @@ class be_class_tasmota (scope: global, name: Tasmota) {
|
|||
resolvecmnd, func(l_resolveCmnd)
|
||||
|
||||
response_append, func(l_respAppend)
|
||||
web_send, func(l_webSend)
|
||||
web_send_decimal, func(l_webSendDecimal)
|
||||
|
||||
get_power, func(l_getpower)
|
||||
|
|
|
@ -434,6 +434,7 @@ extern const bcstring be_const_str_SSPI_MISO;
|
|||
extern const bcstring be_const_str_SYMBOL_BATTERY_EMPTY;
|
||||
extern const bcstring be_const_str_PZEM016_RX;
|
||||
extern const bcstring be_const_str_tan;
|
||||
extern const bcstring be_const_str_web_send;
|
||||
extern const bcstring be_const_str_wire;
|
||||
extern const bcstring be_const_str_P9813_CLK;
|
||||
extern const bcstring be_const_str_SM2135_CLK;
|
||||
|
|
|
@ -433,7 +433,8 @@ be_define_const_str(super, "super", 4152230356u, 0, 5, NULL);
|
|||
be_define_const_str(SSPI_MISO, "SSPI_MISO", 2485347173u, 0, 9, &be_const_str_SYMBOL_BATTERY_EMPTY);
|
||||
be_define_const_str(SYMBOL_BATTERY_EMPTY, "SYMBOL_BATTERY_EMPTY", 3945064277u, 0, 20, NULL);
|
||||
be_define_const_str(PZEM016_RX, "PZEM016_RX", 1004012055u, 0, 10, NULL);
|
||||
be_define_const_str(tan, "tan", 2633446552u, 0, 3, &be_const_str_wire);
|
||||
be_define_const_str(tan, "tan", 2633446552u, 0, 3, &be_const_str_web_send);
|
||||
be_define_const_str(web_send, "web_send", 2989941448u, 0, 8, &be_const_str_wire);
|
||||
be_define_const_str(wire, "wire", 4082753944u, 0, 4, NULL);
|
||||
be_define_const_str(P9813_CLK, "P9813_CLK", 2455391001u, 0, 9, NULL);
|
||||
be_define_const_str(SM2135_CLK, "SM2135_CLK", 2383410011u, 0, 10, &be_const_str_wire1);
|
||||
|
@ -841,6 +842,6 @@ static const bstring* const m_string_table[] = {
|
|||
|
||||
static const struct bconststrtab m_const_string_table = {
|
||||
.size = 272,
|
||||
.count = 544,
|
||||
.count = 545,
|
||||
.table = m_string_table
|
||||
};
|
||||
|
|
|
@ -1,62 +1,63 @@
|
|||
#include "be_constobj.h"
|
||||
|
||||
static be_define_const_map_slots(be_class_tasmota_map) {
|
||||
{ be_const_key(log, 25), be_const_func(l_logInfo) },
|
||||
{ be_const_key(find_op, -1), be_const_closure(find_op_closure) },
|
||||
{ be_const_key(gc, -1), be_const_closure(gc_closure) },
|
||||
{ be_const_key(get_power, -1), be_const_func(l_getpower) },
|
||||
{ be_const_key(_cmd, -1), be_const_func(l_cmd) },
|
||||
{ be_const_key(scale_uint, -1), be_const_func(l_scaleuint) },
|
||||
{ be_const_key(event, 4), be_const_closure(event_closure) },
|
||||
{ be_const_key(exec_cmd, 20), be_const_closure(exec_cmd_closure) },
|
||||
{ be_const_key(find_key_i, -1), be_const_closure(find_key_i_closure) },
|
||||
{ be_const_key(resolvecmnd, -1), be_const_func(l_resolveCmnd) },
|
||||
{ be_const_key(set_timer, -1), be_const_closure(set_timer_closure) },
|
||||
{ be_const_key(add_driver, 37), be_const_closure(add_driver_closure) },
|
||||
{ be_const_key(resp_cmnd, -1), be_const_func(l_respCmnd) },
|
||||
{ be_const_key(resp_cmnd_str, -1), be_const_func(l_respCmndStr) },
|
||||
{ be_const_key(add_cmd, -1), be_const_closure(add_cmd_closure) },
|
||||
{ be_const_key(chars_in_string, -1), be_const_closure(chars_in_string_closure) },
|
||||
{ be_const_key(add_rule, 47), be_const_closure(add_rule_closure) },
|
||||
{ be_const_key(try_rule, 34), be_const_closure(try_rule_closure) },
|
||||
{ be_const_key(get_option, -1), be_const_func(l_getoption) },
|
||||
{ be_const_key(wire1, -1), be_const_int(0) },
|
||||
{ be_const_key(remove_cmd, -1), be_const_closure(remove_cmd_closure) },
|
||||
{ be_const_key(resp_cmnd_done, -1), be_const_func(l_respCmndDone) },
|
||||
{ be_const_key(wire_scan, -1), be_const_closure(wire_scan_closure) },
|
||||
{ be_const_key(_timers, -1), be_const_int(1) },
|
||||
{ be_const_key(exec_rules, -1), be_const_closure(exec_rules_closure) },
|
||||
{ be_const_key(response_append, 43), be_const_func(l_respAppend) },
|
||||
{ be_const_key(time_dump, 31), be_const_func(l_time_dump) },
|
||||
{ be_const_key(millis, -1), be_const_func(l_millis) },
|
||||
{ be_const_key(wire2, -1), be_const_int(2) },
|
||||
{ be_const_key(remove_rule, 8), be_const_closure(remove_rule_closure) },
|
||||
{ be_const_key(delay, 13), be_const_func(l_delay) },
|
||||
{ be_const_key(run_deferred, -1), be_const_closure(run_deferred_closure) },
|
||||
{ be_const_key(i2c_enabled, 19), be_const_func(l_i2cenabled) },
|
||||
{ be_const_key(_drivers, -1), be_const_int(3) },
|
||||
{ be_const_key(time_reached, -1), be_const_func(l_timereached) },
|
||||
{ be_const_key(publish, -1), be_const_func(l_publish) },
|
||||
{ be_const_key(_ccmd, -1), be_const_int(4) },
|
||||
{ be_const_key(yield, -1), be_const_func(l_yield) },
|
||||
{ be_const_key(web_send, 41), be_const_func(l_webSend) },
|
||||
{ be_const_key(wire2, -1), be_const_int(0) },
|
||||
{ be_const_key(remove_cmd, 6), be_const_closure(remove_cmd_closure) },
|
||||
{ be_const_key(get_free_heap, -1), be_const_func(l_getFreeHeap) },
|
||||
{ be_const_key(resp_cmnd_failed, -1), be_const_func(l_respCmndFailed) },
|
||||
{ be_const_key(_rules, -1), be_const_int(5) },
|
||||
{ be_const_key(time_str, -1), be_const_closure(time_str_closure) },
|
||||
{ be_const_key(set_power, -1), be_const_func(l_setpower) },
|
||||
{ be_const_key(cmd, -1), be_const_closure(cmd_closure) },
|
||||
{ be_const_key(get_light, -1), be_const_closure(get_light_closure) },
|
||||
{ be_const_key(save, -1), be_const_func(l_save) },
|
||||
{ be_const_key(rtc, 23), be_const_func(l_rtc) },
|
||||
{ be_const_key(resp_cmnd_error, 33), be_const_func(l_respCmndError) },
|
||||
{ be_const_key(web_send_decimal, 15), be_const_func(l_webSendDecimal) },
|
||||
{ be_const_key(load, 14), be_const_closure(load_closure) },
|
||||
{ be_const_key(set_timer, 8), be_const_closure(set_timer_closure) },
|
||||
{ be_const_key(resp_cmnd, -1), be_const_func(l_respCmnd) },
|
||||
{ be_const_key(add_driver, 26), be_const_closure(add_driver_closure) },
|
||||
{ be_const_key(try_rule, -1), be_const_closure(try_rule_closure) },
|
||||
{ be_const_key(i2c_enabled, 29), be_const_func(l_i2cenabled) },
|
||||
{ be_const_key(find_key_i, -1), be_const_closure(find_key_i_closure) },
|
||||
{ be_const_key(wire1, 20), be_const_int(1) },
|
||||
{ be_const_key(chars_in_string, -1), be_const_closure(chars_in_string_closure) },
|
||||
{ be_const_key(get_power, 3), be_const_func(l_getpower) },
|
||||
{ be_const_key(resp_cmnd_str, -1), be_const_func(l_respCmndStr) },
|
||||
{ be_const_key(resp_cmnd_done, -1), be_const_func(l_respCmndDone) },
|
||||
{ be_const_key(exec_rules, -1), be_const_closure(exec_rules_closure) },
|
||||
{ be_const_key(_drivers, -1), be_const_int(2) },
|
||||
{ be_const_key(run_deferred, -1), be_const_closure(run_deferred_closure) },
|
||||
{ be_const_key(add_rule, -1), be_const_closure(add_rule_closure) },
|
||||
{ be_const_key(event, -1), be_const_closure(event_closure) },
|
||||
{ be_const_key(time_reached, -1), be_const_func(l_timereached) },
|
||||
{ be_const_key(_cmd, -1), be_const_func(l_cmd) },
|
||||
{ be_const_key(_timers, 45), be_const_int(3) },
|
||||
{ be_const_key(remove_rule, -1), be_const_closure(remove_rule_closure) },
|
||||
{ be_const_key(resolvecmnd, -1), be_const_func(l_resolveCmnd) },
|
||||
{ be_const_key(response_append, 47), be_const_func(l_respAppend) },
|
||||
{ be_const_key(time_dump, -1), be_const_func(l_time_dump) },
|
||||
{ be_const_key(set_light, -1), be_const_closure(set_light_closure) },
|
||||
{ be_const_key(get_option, -1), be_const_func(l_getoption) },
|
||||
{ be_const_key(rtc, 34), be_const_func(l_rtc) },
|
||||
{ be_const_key(set_power, -1), be_const_func(l_setpower) },
|
||||
{ be_const_key(time_str, -1), be_const_closure(time_str_closure) },
|
||||
{ be_const_key(_rules, -1), be_const_int(4) },
|
||||
{ be_const_key(delay, -1), be_const_func(l_delay) },
|
||||
{ be_const_key(add_cmd, -1), be_const_closure(add_cmd_closure) },
|
||||
{ be_const_key(web_send_decimal, 23), be_const_func(l_webSendDecimal) },
|
||||
{ be_const_key(log, 40), be_const_func(l_logInfo) },
|
||||
{ be_const_key(resp_cmnd_failed, 1), be_const_func(l_respCmndFailed) },
|
||||
{ be_const_key(millis, 42), be_const_func(l_millis) },
|
||||
{ be_const_key(load, 31), be_const_closure(load_closure) },
|
||||
{ be_const_key(wire_scan, -1), be_const_closure(wire_scan_closure) },
|
||||
{ be_const_key(exec_cmd, -1), be_const_closure(exec_cmd_closure) },
|
||||
{ be_const_key(gc, -1), be_const_closure(gc_closure) },
|
||||
{ be_const_key(get_light, 18), be_const_closure(get_light_closure) },
|
||||
{ be_const_key(find_op, -1), be_const_closure(find_op_closure) },
|
||||
{ be_const_key(scale_uint, 2), be_const_func(l_scaleuint) },
|
||||
{ be_const_key(resp_cmnd_error, -1), be_const_func(l_respCmndError) },
|
||||
{ be_const_key(publish, 30), be_const_func(l_publish) },
|
||||
{ be_const_key(_ccmd, -1), be_const_int(5) },
|
||||
{ be_const_key(yield, -1), be_const_func(l_yield) },
|
||||
{ be_const_key(cmd, -1), be_const_closure(cmd_closure) },
|
||||
};
|
||||
|
||||
static be_define_const_map(
|
||||
be_class_tasmota_map,
|
||||
51
|
||||
52
|
||||
);
|
||||
|
||||
BE_EXPORT_VARIABLE be_define_const_class(
|
||||
|
|
|
@ -267,6 +267,18 @@ extern "C" {
|
|||
be_raise(vm, kTypeError, nullptr);
|
||||
}
|
||||
|
||||
// web append with decimal conversion
|
||||
int32_t l_webSend(bvm *vm);
|
||||
int32_t l_webSend(bvm *vm) {
|
||||
int32_t top = be_top(vm); // Get the number of arguments
|
||||
if (top == 2 && be_isstring(vm, 2)) {
|
||||
const char *msg = be_tostring(vm, 2);
|
||||
WSContentSend_P(PSTR("%s"), msg);
|
||||
be_return_nil(vm); // Return nil when something goes wrong
|
||||
}
|
||||
be_raise(vm, kTypeError, nullptr);
|
||||
}
|
||||
|
||||
// web append with decimal conversion
|
||||
int32_t l_webSendDecimal(bvm *vm);
|
||||
int32_t l_webSendDecimal(bvm *vm) {
|
||||
|
|
Loading…
Reference in New Issue