Merge branch 'development' of https://github.com/arendst/Tasmota into development

This commit is contained in:
Stephan Hadinger 2021-11-14 11:17:37 +01:00
commit 75d6f4ed89
24 changed files with 3077 additions and 1024 deletions

View File

@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
## [Unreleased] - Development
## [10.0.0.3]
### Added
- Autoconfiguration for ESP32 and variants
### Changed
- ESP8266 Gratuitous ARP enabled and set to 60 seconds (#13623)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,29 @@
/********************************************************************
* Tasmota lib
*
* To use: `import display`
*
* Initialize Universal Display driver
*******************************************************************/
#include "be_constobj.h"
#ifdef USE_DISPLAY
// Tasmota specific
extern int be_disp_start(bvm *vm);
/********************************************************************
** Solidified module: display
********************************************************************/
be_local_module(display,
"display",
be_nested_map(1,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_nested_key("start", 1697318111, 5, -1), be_const_func(be_disp_start) },
}))
);
BE_EXPORT_VARIABLE be_define_const_native_module(display);
/********************************************************************/
#endif // USE_DISPLAY

View File

@ -26,8 +26,10 @@ be_extern_native_module(strict);
/* Tasmota specific */
be_extern_native_module(python_compat);
be_extern_native_module(persist);
be_extern_native_module(autoconf);
be_extern_native_module(light);
be_extern_native_module(gpio);
be_extern_native_module(display);
be_extern_native_module(energy);
be_extern_native_module(webserver);
be_extern_native_module(flash);
@ -85,7 +87,13 @@ BERRY_LOCAL const bntvmodule* const be_module_table[] = {
&be_native_module(python_compat),
&be_native_module(path),
&be_native_module(persist),
#ifdef USE_AUTOCONF
&be_native_module(autoconf),
#endif // USE_AUTOCONF
&be_native_module(gpio),
#ifdef USE_DISPLAY
&be_native_module(display),
#endif // USE_DISPLAY
#ifdef USE_LIGHT
&be_native_module(light),
#endif

View File

@ -141,7 +141,7 @@ be_local_closure(init, /* name */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[11]) { /* constants */
( &(const bvalue[13]) { /* constants */
/* K0 */ be_nested_string("global", 503252654, 6),
/* K1 */ be_nested_string("ctypes_bytes_dyn", 915205307, 16),
/* K2 */ be_nested_string("_global_addr", 533766721, 12),
@ -153,10 +153,12 @@ be_local_closure(init, /* name */
/* K8 */ be_nested_string("settings", 1745255176, 8),
/* K9 */ be_nested_string("toptr", -915119842, 5),
/* K10 */ be_nested_string("_settings_def", -519406989, 13),
/* K11 */ be_nested_string("wd", 1531424278, 2),
/* K12 */ be_nested_string("", -2128831035, 0),
}),
((bstring*) &be_const_str_init),
(be_nested_const_str("tasmota.be", 1128870755, 10)),
( &(const binstruction[23]) { /* code */
(be_nested_const_str("init", 380752755, 4)),
((bstring*) &be_const_str_input),
( &(const binstruction[24]) { /* code */
0xB8060200, // 0000 GETNGBL R1 K1
0x88080102, // 0001 GETMBR R2 R0 K2
0x880C0103, // 0002 GETMBR R3 R0 K3
@ -179,7 +181,8 @@ be_local_closure(init, /* name */
0x8814010A, // 0013 GETMBR R5 R0 K10
0x7C0C0400, // 0014 CALL R3 2
0x90021003, // 0015 SETMBR R0 K8 R3
0x80000000, // 0016 RET 0
0x9002170C, // 0016 SETMBR R0 K11 K12
0x80000000, // 0017 RET 0
})
)
);
@ -850,7 +853,7 @@ be_local_closure(time_str, /* name */
********************************************************************/
be_local_closure(load, /* name */
be_nested_proto(
15, /* nstack */
19, /* nstack */
2, /* argc */
0, /* varg */
0, /* has upvals */
@ -858,116 +861,140 @@ be_local_closure(load, /* name */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[18]) { /* constants */
( &(const bvalue[21]) { /* constants */
/* K0 */ be_nested_string("string", 398550328, 6),
/* K1 */ be_nested_string("path", -2071507658, 4),
/* K2 */ be_nested_string("find", -1108310694, 4),
/* K3 */ be_nested_string(".", 722245873, 1),
/* K4 */ be_const_int(0),
/* K5 */ be_nested_string(".be", 1325797348, 3),
/* K6 */ be_nested_string("split", -2017972765, 5),
/* K7 */ be_const_int(1),
/* K8 */ be_nested_string("be", 942383232, 2),
/* K9 */ be_nested_string("bec", 1336821081, 3),
/* K10 */ be_nested_string("io_error", 1970281036, 8),
/* K11 */ be_nested_string("file extension is not '.be' or '.bec'", -1199247657, 37),
/* K12 */ be_nested_string("c", -435409838, 1),
/* K2 */ be_const_int(0),
/* K3 */ be_nested_string("/", 705468254, 1),
/* K4 */ be_nested_string("split", -2017972765, 5),
/* K5 */ be_nested_string("#", 638357778, 1),
/* K6 */ be_const_int(1),
/* K7 */ be_nested_string("find", -1108310694, 4),
/* K8 */ be_nested_string(".", 722245873, 1),
/* K9 */ be_nested_string(".be", 1325797348, 3),
/* K10 */ be_nested_string(".bec", -309694075, 4),
/* K11 */ be_nested_string("io_error", 1970281036, 8),
/* K12 */ be_nested_string("file extension is not '.be' or '.bec'", -1199247657, 37),
/* K13 */ be_nested_string("last_modified", 772177145, 13),
/* K14 */ be_nested_string("file", -1427482813, 4),
/* K15 */ be_nested_string("save", -855671224, 4),
/* K16 */ be_nested_string("format", -1180859054, 6),
/* K17 */ be_nested_string("BRY: could not save compiled file %s (%s)", 736659787, 41),
/* K14 */ be_nested_string("c", -435409838, 1),
/* K15 */ be_nested_string("wd", 1531424278, 2),
/* K16 */ be_nested_string("", -2128831035, 0),
/* K17 */ be_nested_string("file", -1427482813, 4),
/* K18 */ be_nested_string("save", -855671224, 4),
/* K19 */ be_nested_string("format", -1180859054, 6),
/* K20 */ be_nested_string("BRY: could not save compiled file %s (%s)", 736659787, 41),
}),
(be_nested_const_str("load", -435725847, 4)),
((bstring*) &be_const_str_input),
( &(const binstruction[87]) { /* code */
( &(const binstruction[108]) { /* code */
0xA40A0000, // 0000 IMPORT R2 K0
0xA40E0200, // 0001 IMPORT R3 K1
0x8C100502, // 0002 GETMET R4 R2 K2
0x5C180200, // 0003 MOVE R6 R1
0x581C0003, // 0004 LDCONST R7 K3
0x7C100600, // 0005 CALL R4 3
0x14100904, // 0006 LT R4 R4 K4
0x78120000, // 0007 JMPF R4 #0009
0x00040305, // 0008 ADD R1 R1 K5
0x8C100506, // 0009 GETMET R4 R2 K6
0x5C180200, // 000A MOVE R6 R1
0x581C0003, // 000B LDCONST R7 K3
0x7C100600, // 000C CALL R4 3
0x6014000C, // 000D GETGBL R5 G12
0x5C180800, // 000E MOVE R6 R4
0x7C140200, // 000F CALL R5 1
0x18140B07, // 0010 LE R5 R5 K7
0x74160007, // 0011 JMPT R5 #001A
0x5415FFFE, // 0012 LDINT R5 -1
0x94140805, // 0013 GETIDX R5 R4 R5
0x20140B08, // 0014 NE R5 R5 K8
0x78160004, // 0015 JMPF R5 #001B
0x5415FFFE, // 0016 LDINT R5 -1
0x94140805, // 0017 GETIDX R5 R4 R5
0x20140B09, // 0018 NE R5 R5 K9
0x78160000, // 0019 JMPF R5 #001B
0xB006150B, // 001A RAISE 1 K10 K11
0x5415FFFE, // 001B LDINT R5 -1
0x94140205, // 001C GETIDX R5 R1 R5
0x1C140B0C, // 001D EQ R5 R5 K12
0x8C18070D, // 001E GETMET R6 R3 K13
0x5C200200, // 001F MOVE R8 R1
0x7C180400, // 0020 CALL R6 2
0x78160005, // 0021 JMPF R5 #0028
0x4C1C0000, // 0022 LDNIL R7
0x1C1C0C07, // 0023 EQ R7 R6 R7
0x781E0001, // 0024 JMPF R7 #0027
0x501C0000, // 0025 LDBOOL R7 0 0
0x80040E00, // 0026 RET 1 R7
0x70020013, // 0027 JMP #003C
0x8C1C070D, // 0028 GETMET R7 R3 K13
0x0024030C, // 0029 ADD R9 R1 K12
0x7C1C0400, // 002A CALL R7 2
0x4C200000, // 002B LDNIL R8
0x1C200C08, // 002C EQ R8 R6 R8
0x78220004, // 002D JMPF R8 #0033
0x4C200000, // 002E LDNIL R8
0x1C200E08, // 002F EQ R8 R7 R8
0x78220001, // 0030 JMPF R8 #0033
0x50200000, // 0031 LDBOOL R8 0 0
0x80041000, // 0032 RET 1 R8
0x4C200000, // 0033 LDNIL R8
0x20200E08, // 0034 NE R8 R7 R8
0x78220005, // 0035 JMPF R8 #003C
0x4C200000, // 0036 LDNIL R8
0x1C200C08, // 0037 EQ R8 R6 R8
0x74220001, // 0038 JMPT R8 #003B
0x28200E06, // 0039 GE R8 R7 R6
0x78220000, // 003A JMPF R8 #003C
0x50140200, // 003B LDBOOL R5 1 0
0x601C000D, // 003C GETGBL R7 G13
0x5C200200, // 003D MOVE R8 R1
0x5824000E, // 003E LDCONST R9 K14
0x7C1C0400, // 003F CALL R7 2
0x74160011, // 0040 JMPT R5 #0053
0xA8020005, // 0041 EXBLK 0 #0048
0x8C20010F, // 0042 GETMET R8 R0 K15
0x0028030C, // 0043 ADD R10 R1 K12
0x5C2C0E00, // 0044 MOVE R11 R7
0x7C200600, // 0045 CALL R8 3
0xA8040001, // 0046 EXBLK 1 1
0x7002000A, // 0047 JMP #0053
0xAC200001, // 0048 CATCH R8 0 1
0x70020007, // 0049 JMP #0052
0x60240001, // 004A GETGBL R9 G1
0x8C280510, // 004B GETMET R10 R2 K16
0x58300011, // 004C LDCONST R12 K17
0x0034030C, // 004D ADD R13 R1 K12
0x5C381000, // 004E MOVE R14 R8
0x7C280800, // 004F CALL R10 4
0x7C240200, // 0050 CALL R9 1
0x70020000, // 0051 JMP #0053
0xB0080000, // 0052 RAISE 2 R0 R0
0x5C200E00, // 0053 MOVE R8 R7
0x7C200000, // 0054 CALL R8 0
0x50200200, // 0055 LDBOOL R8 1 0
0x80041000, // 0056 RET 1 R8
0x6010000C, // 0002 GETGBL R4 G12
0x5C140200, // 0003 MOVE R5 R1
0x7C100200, // 0004 CALL R4 1
0x1C100902, // 0005 EQ R4 R4 K2
0x78120001, // 0006 JMPF R4 #0009
0x50100000, // 0007 LDBOOL R4 0 0
0x80040800, // 0008 RET 1 R4
0x94100302, // 0009 GETIDX R4 R1 K2
0x20100903, // 000A NE R4 R4 K3
0x78120000, // 000B JMPF R4 #000D
0x00060601, // 000C ADD R1 K3 R1
0x8C100504, // 000D GETMET R4 R2 K4
0x5C180200, // 000E MOVE R6 R1
0x581C0005, // 000F LDCONST R7 K5
0x7C100600, // 0010 CALL R4 3
0x94140902, // 0011 GETIDX R5 R4 K2
0x5419FFFE, // 0012 LDINT R6 -1
0x94180806, // 0013 GETIDX R6 R4 R6
0x601C000C, // 0014 GETGBL R7 G12
0x5C200800, // 0015 MOVE R8 R4
0x7C1C0200, // 0016 CALL R7 1
0x241C0F06, // 0017 GT R7 R7 K6
0x8C200507, // 0018 GETMET R8 R2 K7
0x5C280C00, // 0019 MOVE R10 R6
0x582C0008, // 001A LDCONST R11 K8
0x7C200600, // 001B CALL R8 3
0x14201102, // 001C LT R8 R8 K2
0x78220001, // 001D JMPF R8 #0020
0x00040309, // 001E ADD R1 R1 K9
0x00180D09, // 001F ADD R6 R6 K9
0x5421FFFC, // 0020 LDINT R8 -3
0x5425FFFE, // 0021 LDINT R9 -1
0x40201009, // 0022 CONNECT R8 R8 R9
0x94200C08, // 0023 GETIDX R8 R6 R8
0x1C201109, // 0024 EQ R8 R8 K9
0x5425FFFB, // 0025 LDINT R9 -4
0x5429FFFE, // 0026 LDINT R10 -1
0x4024120A, // 0027 CONNECT R9 R9 R10
0x94240C09, // 0028 GETIDX R9 R6 R9
0x1C24130A, // 0029 EQ R9 R9 K10
0x74220001, // 002A JMPT R8 #002D
0x74260000, // 002B JMPT R9 #002D
0xB006170C, // 002C RAISE 1 K11 K12
0x8C28070D, // 002D GETMET R10 R3 K13
0x5C300A00, // 002E MOVE R12 R5
0x7C280400, // 002F CALL R10 2
0x78260005, // 0030 JMPF R9 #0037
0x4C2C0000, // 0031 LDNIL R11
0x1C2C140B, // 0032 EQ R11 R10 R11
0x782E0001, // 0033 JMPF R11 #0036
0x502C0000, // 0034 LDBOOL R11 0 0
0x80041600, // 0035 RET 1 R11
0x70020013, // 0036 JMP #004B
0x8C2C070D, // 0037 GETMET R11 R3 K13
0x0034030E, // 0038 ADD R13 R1 K14
0x7C2C0400, // 0039 CALL R11 2
0x4C300000, // 003A LDNIL R12
0x1C30140C, // 003B EQ R12 R10 R12
0x78320004, // 003C JMPF R12 #0042
0x4C300000, // 003D LDNIL R12
0x1C30160C, // 003E EQ R12 R11 R12
0x78320001, // 003F JMPF R12 #0042
0x50300000, // 0040 LDBOOL R12 0 0
0x80041800, // 0041 RET 1 R12
0x4C300000, // 0042 LDNIL R12
0x2030160C, // 0043 NE R12 R11 R12
0x78320005, // 0044 JMPF R12 #004B
0x4C300000, // 0045 LDNIL R12
0x1C30140C, // 0046 EQ R12 R10 R12
0x74320001, // 0047 JMPT R12 #004A
0x2830160A, // 0048 GE R12 R11 R10
0x78320000, // 0049 JMPF R12 #004B
0x50240200, // 004A LDBOOL R9 1 0
0x781E0002, // 004B JMPF R7 #004F
0x002C0B05, // 004C ADD R11 R5 K5
0x90021E0B, // 004D SETMBR R0 K15 R11
0x70020000, // 004E JMP #0050
0x90021F10, // 004F SETMBR R0 K15 K16
0x602C000D, // 0050 GETGBL R11 G13
0x5C300200, // 0051 MOVE R12 R1
0x58340011, // 0052 LDCONST R13 K17
0x7C2C0400, // 0053 CALL R11 2
0x74260012, // 0054 JMPT R9 #0068
0x741E0011, // 0055 JMPT R7 #0068
0xA8020005, // 0056 EXBLK 0 #005D
0x8C300112, // 0057 GETMET R12 R0 K18
0x0038030E, // 0058 ADD R14 R1 K14
0x5C3C1600, // 0059 MOVE R15 R11
0x7C300600, // 005A CALL R12 3
0xA8040001, // 005B EXBLK 1 1
0x7002000A, // 005C JMP #0068
0xAC300001, // 005D CATCH R12 0 1
0x70020007, // 005E JMP #0067
0x60340001, // 005F GETGBL R13 G1
0x8C380513, // 0060 GETMET R14 R2 K19
0x58400014, // 0061 LDCONST R16 K20
0x0044030E, // 0062 ADD R17 R1 K14
0x5C481800, // 0063 MOVE R18 R12
0x7C380800, // 0064 CALL R14 4
0x7C340200, // 0065 CALL R13 1
0x70020000, // 0066 JMP #0068
0xB0080000, // 0067 RAISE 2 R0 R0
0x5C301600, // 0068 MOVE R12 R11
0x7C300000, // 0069 CALL R12 0
0x50300200, // 006A LDBOOL R12 1 0
0x80041800, // 006B RET 1 R12
})
)
);
@ -1856,6 +1883,7 @@ class be_class_tasmota (scope: global, name: Tasmota) {
global, var
settings, var
cmd_res, var
wd, var
_global_def, comptr(&be_tasmota_global_struct)
_settings_def, comptr(&be_tasmota_settings_struct)

View File

@ -27,6 +27,7 @@ class Tasmota
var cmd_res # store the command result, nil if disables, true if capture enabled, contains return value
var global # mapping to TasmotaGlobal
var settings
var wd # last working directory
def init()
# instanciate the mapping object to TasmotaGlobal
@ -36,6 +37,7 @@ class Tasmota
if settings_addr
self.settings = ctypes_bytes_dyn(introspect.toptr(settings_addr), self._settings_def)
end
self.wd = ""
end
# create a specific sub-class for rules: pattern(string) -> closure
@ -324,21 +326,39 @@ class Tasmota
import string
import path
# if the filename has no '.' append '.be'
if string.find(f, '.') < 0
# fail if empty string
if size(f) == 0 return false end
# Ex: f = 'app.zip#autoexec'
# add leading '/' if absent
if f[0] != '/' f = '/' + f end
# Ex: f = '/app.zip#autoexec'
var f_items = string.split(f, '#')
var f_prefix = f_items[0]
var f_suffix = f_items[-1] # last token
var f_archive = size(f_items) > 1 # is the file in an archive
# if no dot, add the default '.be' extension
if string.find(f_suffix, '.') < 0 # does the final file has a '.'
f += ".be"
f_suffix += ".be"
end
# Ex: f = '/app.zip#autoexec.be'
# if the filename has no '.' append '.be'
var suffix_be = f_suffix[-3..-1] == '.be'
var suffix_bec = f_suffix[-4..-1] == '.bec'
# Ex: f = '/app.zip#autoexec.be', f_suffix = 'autoexec.be', suffix_be = true, suffix_bec = false
# check that the file ends with '.be' of '.bec'
var fl = string.split(f,'.')
if (size(fl) <= 1 || (fl[-1] != 'be' && fl[-1] != 'bec'))
if !suffix_be && !suffix_bec
raise "io_error", "file extension is not '.be' or '.bec'"
end
var is_bytecode = f[-1] == 'c' # file is Berry source and not bytecode
var f_time = path.last_modified(f)
var f_time = path.last_modified(f_prefix)
if is_bytecode
if suffix_bec
if f_time == nil return false end # file does not exist
# f is the right file, continue
else
@ -348,13 +368,20 @@ class Tasmota
# bytecode exists and is more recent than berry source, use bytecode
##### temporarily disable loading from bec file
# f = f + "c" # use bytecode name
is_bytecode = true
suffix_bec = true
end
end
# recall the working directory
if f_archive
self.wd = f_prefix + "#"
else
self.wd = ""
end
var c = compile(f, 'file')
# save the compiled bytecode
if !is_bytecode
if !suffix_bec && !f_archive
try
self.save(f + 'c', c)
except .. as e

View File

@ -0,0 +1,387 @@
#- autocong module for Berry -#
#- -#
#- To solidify: -#
#-
# load only persis_module and persist_module.init
import autoconf
solidify.dump(autoconf_module)
# copy and paste into `be_autoconf_lib.c`
-#
#-
# For external compile:
display = module("display")
self = nil
tasmota = nil
def load() end
-#
var autoconf_module = module("autoconf")
autoconf_module.init = def (m)
class Autoconf
var _archive
var _error
def init()
import path
import string
var dir = path.listdir("/")
var entry
tasmota.add_driver(self)
var i = 0
while i < size(dir)
if string.find(dir[i], "_autoconf.zip") > 0 # does the file contain '*_autoconf.zip'
if entry != nil
# we have multiple configuration files, not allowed
print(string.format("CFG: multiple autoconf files found, aborting ('%s' + '%s')", entry, dir[i]))
self._error = true
return nil
end
entry = dir[i]
end
i += 1
end
if entry == nil
print("CFG: no '*_autoconf.zip' file found")
return nil
end
self._archive = entry
end
# ####################################################################################################
# Manage first time marker
# ####################################################################################################
def is_first_time()
import path
return !path.exists("/.autoconf")
end
def set_first_time()
var f = open("/.autoconf", "w")
f.close()
end
def clear_first_time()
import path
path.remove("/.autoconf")
end
# ####################################################################################################
# Delete all autoconfig files present
# ####################################################################################################
def delete_all_configs()
import path
import string
var dir = path.listdir("/")
for d:dir
if string.find(d, "_autoconf.zip") > 0 # does the file contain '*_autoconf.zip'
path.remove(d)
end
end
end
# ####################################################################################################
# Get current module
# contains the name of the archive without leading `/`, ex: `M5Stack_Fire_autoconf.zip`
# or `nil` if none
# ####################################################################################################
def get_current_module_path()
return self._archive
end
def get_current_module_name()
return self._archive[0..-13]
end
# ####################################################################################################
# Load templates from Github
# ####################################################################################################
def load_templates()
import string
import json
try
var url = string.format("https://raw.githubusercontent.com/tasmota/autoconf/main/%s_manifest.json", tasmota.arch())
tasmota.log(string.format("CFG: loading '%s'", url), 3)
# load the template
var cl = webclient()
cl.begin(url)
var r = cl.GET()
if r != 200
tasmota.log(string.format("CFG: return_code=%i", r), 2)
return nil
end
var s = cl.get_string()
cl.close()
# convert to json
var j = json.load(s)
tasmota.log(string.format("CFG: loaded '%s'", str(j)), 3)
var t = j.find("zip")
if isinstance(t, list)
return t
end
return nil
except .. as e, m
tasmota.log(string.format("CFG: exception '%s' - '%s'", e, m), 2)
return nil
end
end
# ####################################################################################################
# Init web handlers
# ####################################################################################################
# Displays a "Autocong" button on the configuration page
def web_add_config_button()
import webserver
webserver.content_send("<p><form id=ac action='ac' style='display: block;' method='get'><button>&#129668; Auto-configuration</button></form></p>")
end
# This HTTP GET manager controls which web controls are displayed
def page_autoconf_mgr()
import webserver
import string
if !webserver.check_privileged_access() return nil end
webserver.content_start('Auto-configuration')
webserver.content_send_style()
webserver.content_send("<p><small>&nbsp;(This feature requires an internet connection)</small></p>")
var cur_module = self.get_current_module_path()
var cur_module_display = cur_module ? string.tr(self.get_current_module_path(), "_", " ") : self._error ? "&lt;Error: apply new or remove&gt;" : "&lt;None&gt;"
webserver.content_send("<fieldset><style>.bdis{background:#888;}.bdis:hover{background:#888;}</style>")
webserver.content_send(string.format("<legend><b title='Autoconfiguration'>&nbsp;Current auto-configuration</b></legend>"))
webserver.content_send(string.format("<p>Current configuration: </p><p><b>%s</b></p>", cur_module_display))
if cur_module
# add button to reapply template
webserver.content_send("<p><form id=reapply style='display: block;' action='/ac' method='post' ")
webserver.content_send("onsubmit='return confirm(\"This will cause a restart.\");'>")
webserver.content_send("<button name='reapply' class='button bgrn'>Re-apply current configuration</button>")
webserver.content_send("</form></p>")
end
webserver.content_send("<p></p></fieldset><p></p>")
webserver.content_send("<fieldset><style>.bdis{background:#888;}.bdis:hover{background:#888;}</style>")
webserver.content_send(string.format("<legend><b title='New autoconf'>&nbsp;Select new auto-configuration</b></legend>"))
webserver.content_send("<p><form id=zip style='display: block;' action='/ac' method='post' ")
webserver.content_send("onsubmit='return confirm(\"This will change the current configuration and cause a restart.\");'>")
webserver.content_send("<label>Choose a device configuration:</label><br>")
webserver.content_send("<select name='zip'>")
var templates = self.load_templates()
webserver.content_send("<option value='reset'>&lt;Remove autoconf&gt;</option>")
for t:templates
webserver.content_send(string.format("<option value='%s'>%s</option>", t, string.tr(t, "_", " ")))
end
webserver.content_send("</select><p></p>")
webserver.content_send("<button name='zipapply' class='button bgrn'>Apply configuration</button>")
# webserver.content_send(string.format("<input name='ota' type='hidden' value='%d'>", ota_num))
webserver.content_send("</form></p>")
webserver.content_send("<p></p></fieldset><p></p>")
webserver.content_button(webserver.BUTTON_CONFIGURATION)
webserver.content_stop()
end
# ####################################################################################################
# Web controller
#
# Applies the changes and restart
# ####################################################################################################
# This HTTP POST manager handles the submitted web form data
def page_autoconf_ctl()
import webserver
import string
import path
if !webserver.check_privileged_access() return nil end
try
if webserver.has_arg("reapply")
tasmota.log("CFG: removing first time marker", 2);
# print("CFG: removing first time marker")
self.clear_first_time()
#- and force restart -#
webserver.redirect("/?rst=")
elif webserver.has_arg("zip")
# remove any remaining autoconf file
tasmota.log("CFG: removing autoconf files", 2);
# print("CFG: removing autoconf files")
self.delete_all_configs()
# get the name of the configuration file
var arch_name = webserver.arg("zip")
if arch_name != "reset"
var url = string.format("https://raw.githubusercontent.com/tasmota/autoconf/main/%s/%s_autoconf.zip", tasmota.arch(), arch_name)
tasmota.log(string.format("CFG: downloading '%s'", url), 2);
var local_file = string.format("%s_autoconf.zip", arch_name)
# download file and write directly to file system
var cl = webclient()
cl.begin(url)
var r = cl.GET()
if r != 200 raise "connection_error", string.format("return code=%i", r) end
cl.write_file(local_file)
cl.close()
end
# remove marker to reapply template
self.clear_first_time()
#- and force restart -#
webserver.redirect("/?rst=")
else
raise "value_error", "Unknown command"
end
except .. as e, m
print(string.format("CFG: Exception> '%s' - %s", e, m))
#- display error page -#
webserver.content_start("Parameter error") #- title of the web page -#
webserver.content_send_style() #- send standard Tasmota styles -#
webserver.content_send(string.format("<p style='width:340px;'><b>Exception:</b><br>'%s'<br>%s</p>", e, m))
webserver.content_button(webserver.BUTTON_CONFIGURATION) #- button back to management page -#
webserver.content_stop() #- end of web page -#
end
end
# Add HTTP POST and GET handlers
def web_add_handler()
import webserver
webserver.on('/ac', / -> self.page_autoconf_mgr(), webserver.HTTP_GET)
webserver.on('/ac', / -> self.page_autoconf_ctl(), webserver.HTTP_POST)
end
# reset the configuration information (but don't restart)
# i.e. remove any autoconf file
def reset()
import path
import string
var dir = path.listdir("/")
var entry
var i = 0
while i < size(dir)
var fname = dir[i]
if string.find(fname, "_autoconf.zip") > 0 # does the file contain '*_autoconf.zip'
path.remove(fname)
print(string.format("CFG: removed file '%s'", fname))
end
i += 1
end
self._archive = nil
self._error = nil
end
def preinit()
if self._archive == nil return end
# try to launch `preinit.be`
import path
var fname = self._archive + '#preinit.be'
if path.exists(fname)
tasmota.log("CFG: loading "+fname, 3)
load(fname)
tasmota.log("CFG: loaded "+fname, 3)
end
end
def run_bat(fname) # read a '*.bat' file and run each command
import string
var f
try
f = open(fname, "r") # open file in read-only mode, it is expected to exist
while true
var line = f.readline() # read each line, can contain a terminal '\n', empty if end of file
if size(line) == 0 break end # end of file
if line[-1] == "\n" line = line[0..-2] end # remove any trailing '\n'
if size(line) > 0
tasmota.cmd(line) # run the command
end
end
f.close() # close, we don't expect exception with read-only, could be added later though
except .. as e, m
print(string.format('CFG: could not run %s (%s - %s)', fname, e, m))
f.close()
end
end
def autoexec()
if self._archive == nil return end
# try to launch `preinit.be`
import path
# Step 1. if first run, only apply `init.bat`
var fname = self._archive + '#init.bat'
if self.is_first_time() && path.exists(fname)
# create the '.autoconf' file to avoid running it again, even if it crashed
self.set_first_time()
# if path.exists(fname) # we know it exists from initial test
self.run_bat(fname)
tasmota.log("CFG: 'init.bat' done, restarting", 2)
tasmota.cmd("Restart 1")
return # if init was run, force a restart anyways and don't run the remaining code
# end
end
# Step 2. if 'display.ini' is present, launch Universal Display
fname = self._archive + '#display.ini'
if gpio.pin_used(gpio.OPTION_A, 2) && path.exists(fname)
if path.exists("display.ini")
tasmota.log("CFG: skipping 'display.ini' because already present in file-system", 2)
else
import display
var f = open(fname,"r")
var desc = f.read()
f.close()
display.start(desc)
end
end
# Step 3. if 'autoexec.bat' is present, run it
fname = self._archive + '#autoexec.bat'
if path.exists(fname)
tasmota.log("CFG: running "+fname, 3)
self.run_bat(fname)
tasmota.log("CFG: ran "+fname, 3)
end
# Step 4. if 'autoexec.be' is present, load it
fname = self._archive + '#autoexec.be'
if path.exists(fname)
tasmota.log("CFG: loading "+fname, 3)
load(fname)
tasmota.log("CFG: loaded "+fname, 3)
end
end
end
return Autoconf() # return an instance of this class
end
aa = autoconf_module.init(autoconf_module)
import webserver
webserver.on('/ac2', / -> aa.page_autoconf_mgr(), webserver.HTTP_GET)
return autoconf_module

View File

@ -1,343 +1,346 @@
extern const bcstring be_const_str_SERIAL_5N1;
extern const bcstring be_const_str__global_addr;
extern const bcstring be_const_str_setmember;
extern const bcstring be_const_str_OneWire;
extern const bcstring be_const_str__get_cb;
extern const bcstring be_const_str_classof;
extern const bcstring be_const_str_SERIAL_8O2;
extern const bcstring be_const_str___upper__;
extern const bcstring be_const_str_gamma10;
extern const bcstring be_const_str_copy;
extern const bcstring be_const_str_tostring;
extern const bcstring be_const_str_dot_p1;
extern const bcstring be_const_str_item;
extern const bcstring be_const_str_read8;
extern const bcstring be_const_str_setbits;
extern const bcstring be_const_str_upper;
extern const bcstring be_const_str_rad;
extern const bcstring be_const_str_web_send;
extern const bcstring be_const_str_load;
extern const bcstring be_const_str_opt_add;
extern const bcstring be_const_str_hex;
extern const bcstring be_const_str_read12;
extern const bcstring be_const_str_end;
extern const bcstring be_const_str_chars_in_string;
extern const bcstring be_const_str_write8;
extern const bcstring be_const_str_def;
extern const bcstring be_const_str_select;
extern const bcstring be_const_str_type;
extern const bcstring be_const_str_global;
extern const bcstring be_const_str_yield;
extern const bcstring be_const_str_opt_eq;
extern const bcstring be_const_str_SERIAL_8E1;
extern const bcstring be_const_str_rtc;
extern const bcstring be_const_str_else;
extern const bcstring be_const_str_get_power;
extern const bcstring be_const_str_addr;
extern const bcstring be_const_str_allocated;
extern const bcstring be_const_str_finish;
extern const bcstring be_const_str_dot_p;
extern const bcstring be_const_str_getbits;
extern const bcstring be_const_str_tag;
extern const bcstring be_const_str_add;
extern const bcstring be_const_str_pin;
extern const bcstring be_const_str_set_timeouts;
extern const bcstring be_const_str_import;
extern const bcstring be_const_str_SERIAL_6N1;
extern const bcstring be_const_str_SERIAL_8O1;
extern const bcstring be_const_str__settings_ptr;
extern const bcstring be_const_str_remove_cmd;
extern const bcstring be_const_str___iterator__;
extern const bcstring be_const_str_atan2;
extern const bcstring be_const_str_ctypes_bytes;
extern const bcstring be_const_str_millis;
extern const bcstring be_const_str_available;
extern const bcstring be_const_str_delay;
extern const bcstring be_const_str_imin;
extern const bcstring be_const_str_shared_key;
extern const bcstring be_const_str_wire;
extern const bcstring be_const_str__drivers;
extern const bcstring be_const_str_last_modified;
extern const bcstring be_const_str_serial;
extern const bcstring be_const_str_opt_call;
extern const bcstring be_const_str_webclient;
extern const bcstring be_const_str_SERIAL_6E2;
extern const bcstring be_const_str_ctypes_bytes_dyn;
extern const bcstring be_const_str_time_dump;
extern const bcstring be_const_str_static;
extern const bcstring be_const_str_classname;
extern const bcstring be_const_str_isrunning;
extern const bcstring be_const_str_top;
extern const bcstring be_const_str_remove;
extern const bcstring be_const_str_begin;
extern const bcstring be_const_str_content_stop;
extern const bcstring be_const_str_deg;
extern const bcstring be_const_str_gc;
extern const bcstring be_const_str_gen_cb;
extern const bcstring be_const_str_reset;
extern const bcstring be_const_str_clear;
extern const bcstring be_const_str_skip;
extern const bcstring be_const_str_SERIAL_5E1;
extern const bcstring be_const_str_has;
extern const bcstring be_const_str_raise;
extern const bcstring be_const_str_setitem;
extern const bcstring be_const_str_write_bit;
extern const bcstring be_const_str_stop;
extern const bcstring be_const_str_AES_GCM;
extern const bcstring be_const_str_exec_cmd;
extern const bcstring be_const_str_iter;
extern const bcstring be_const_str_ceil;
extern const bcstring be_const_str_exp;
extern const bcstring be_const_str_tob64;
extern const bcstring be_const_str_wire_scan;
extern const bcstring be_const_str_call;
extern const bcstring be_const_str_cmd_res;
extern const bcstring be_const_str_opt_connect;
extern const bcstring be_const_str_arch;
extern const bcstring be_const_str_resolvecmnd;
extern const bcstring be_const_str_SERIAL_6E1;
extern const bcstring be_const_str_try;
extern const bcstring be_const_str__cb;
extern const bcstring be_const_str_AudioOutput;
extern const bcstring be_const_str_check_privileged_access;
extern const bcstring be_const_str_SERIAL_6O2;
extern const bcstring be_const_str_content_send;
extern const bcstring be_const_str_tolower;
extern const bcstring be_const_str_detect;
extern const bcstring be_const_str_imax;
extern const bcstring be_const_str_set_auth;
extern const bcstring be_const_str_depower;
extern const bcstring be_const_str_read24;
extern const bcstring be_const_str_add_header;
extern const bcstring be_const_str_kv;
extern const bcstring be_const_str_pin_used;
extern const bcstring be_const_str_publish_result;
extern const bcstring be_const_str_do;
extern const bcstring be_const_str_pow;
extern const bcstring be_const_str_read_bytes;
extern const bcstring be_const_str_SERIAL_5E2;
extern const bcstring be_const_str_scale_uint;
extern const bcstring be_const_str_get;
extern const bcstring be_const_str_remove_timer;
extern const bcstring be_const_str_dot_len;
extern const bcstring be_const_str_Wire;
extern const bcstring be_const_str__begin_transmission;
extern const bcstring be_const_str_toupper;
extern const bcstring be_const_str_SERIAL_5N2;
extern const bcstring be_const_str_arg_size;
extern const bcstring be_const_str_AudioFileSource;
extern const bcstring be_const_str_I2C_Driver;
extern const bcstring be_const_str_decrypt;
extern const bcstring be_const_str_digital_write;
extern const bcstring be_const_str_input;
extern const bcstring be_const_str_char;
extern const bcstring be_const_str_floor;
extern const bcstring be_const_str_real;
extern const bcstring be_const_str_AudioGenerator;
extern const bcstring be_const_str__cmd;
extern const bcstring be_const_str_enabled;
extern const bcstring be_const_str_int;
extern const bcstring be_const_str_byte;
extern const bcstring be_const_str_resp_cmnd_error;
extern const bcstring be_const_str_dot_size;
extern const bcstring be_const_str_list;
extern const bcstring be_const_str_reset_search;
extern const bcstring be_const_str_SERIAL_7N2;
extern const bcstring be_const_str_set;
extern const bcstring be_const_str_elif;
extern const bcstring be_const_str_Tasmota;
extern const bcstring be_const_str_get_switch;
extern const bcstring be_const_str_read;
extern const bcstring be_const_str___lower__;
extern const bcstring be_const_str__read;
extern const bcstring be_const_str_asin;
extern const bcstring be_const_str_POST;
extern const bcstring be_const_str_arg;
extern const bcstring be_const_str_reduce;
extern const bcstring be_const_str_deinit;
extern const bcstring be_const_str_save;
extern const bcstring be_const_str_SERIAL_8E2;
extern const bcstring be_const_str_get_size;
extern const bcstring be_const_str_search;
extern const bcstring be_const_str_srand;
extern const bcstring be_const_str_isnan;
extern const bcstring be_const_str_resp_cmnd_done;
extern const bcstring be_const_str_top;
extern const bcstring be_const_str_content_start;
extern const bcstring be_const_str_deg;
extern const bcstring be_const_str_fromptr;
extern const bcstring be_const_str_time_dump;
extern const bcstring be_const_str_compile;
extern const bcstring be_const_str_members;
extern const bcstring be_const_str_arg_name;
extern const bcstring be_const_str_content_flush;
extern const bcstring be_const_str_get_light;
extern const bcstring be_const_str_sqrt;
extern const bcstring be_const_str__end_transmission;
extern const bcstring be_const_str_listdir;
extern const bcstring be_const_str_log10;
extern const bcstring be_const_str_real;
extern const bcstring be_const_str_insert;
extern const bcstring be_const_str_open;
extern const bcstring be_const_str_ctypes_bytes;
extern const bcstring be_const_str_tag;
extern const bcstring be_const_str_reset;
extern const bcstring be_const_str_toupper;
extern const bcstring be_const_str_POST;
extern const bcstring be_const_str_SERIAL_6O2;
extern const bcstring be_const_str_iter;
extern const bcstring be_const_str_load;
extern const bcstring be_const_str_available;
extern const bcstring be_const_str_ceil;
extern const bcstring be_const_str_clear;
extern const bcstring be_const_str_digital_read;
extern const bcstring be_const_str__get_cb;
extern const bcstring be_const_str_bytes;
extern const bcstring be_const_str_settings;
extern const bcstring be_const_str_get_string;
extern const bcstring be_const_str_asstring;
extern const bcstring be_const_str_pin_used;
extern const bcstring be_const_str_pop;
extern const bcstring be_const_str_read32;
extern const bcstring be_const_str_for;
extern const bcstring be_const_str_exec_tele;
extern const bcstring be_const_str_static;
extern const bcstring be_const_str_AES_GCM;
extern const bcstring be_const_str_SERIAL_8N2;
extern const bcstring be_const_str_close;
extern const bcstring be_const_str_set_power;
extern const bcstring be_const_str_find_op;
extern const bcstring be_const_str_get;
extern const bcstring be_const_str_print;
extern const bcstring be_const_str_publish_result;
extern const bcstring be_const_str_target_search;
extern const bcstring be_const_str__ccmd;
extern const bcstring be_const_str_fromb64;
extern const bcstring be_const_str_module;
extern const bcstring be_const_str_allocated;
extern const bcstring be_const_str_GET;
extern const bcstring be_const_str_SERIAL_8E1;
extern const bcstring be_const_str_classof;
extern const bcstring be_const_str_cos;
extern const bcstring be_const_str_assert;
extern const bcstring be_const_str_content_send;
extern const bcstring be_const_str_read13;
extern const bcstring be_const_str_reverse;
extern const bcstring be_const_str_set_timer;
extern const bcstring be_const_str_class;
extern const bcstring be_const_str_codedump;
extern const bcstring be_const_str_isrunning;
extern const bcstring be_const_str_publish;
extern const bcstring be_const_str_range;
extern const bcstring be_const_str_write;
extern const bcstring be_const_str_opt_connect;
extern const bcstring be_const_str_SERIAL_7O1;
extern const bcstring be_const_str_update;
extern const bcstring be_const_str__cmd;
extern const bcstring be_const_str_isnan;
extern const bcstring be_const_str_resp_cmnd_failed;
extern const bcstring be_const_str_SERIAL_5O1;
extern const bcstring be_const_str_abs;
extern const bcstring be_const_str_SERIAL_7E2;
extern const bcstring be_const_str_SERIAL_6N1;
extern const bcstring be_const_str__cb;
extern const bcstring be_const_str_depower;
extern const bcstring be_const_str_Tasmota;
extern const bcstring be_const_str_item;
extern const bcstring be_const_str_set_useragent;
extern const bcstring be_const_str_wire2;
extern const bcstring be_const_str_time_reached;
extern const bcstring be_const_str_chars_in_string;
extern const bcstring be_const_str_false;
extern const bcstring be_const_str_add_rule;
extern const bcstring be_const_str_setbits;
extern const bcstring be_const_str_write_file;
extern const bcstring be_const_str_SERIAL_8O1;
extern const bcstring be_const_str_wd;
extern const bcstring be_const_str_wire_scan;
extern const bcstring be_const_str_AudioFileSourceFS;
extern const bcstring be_const_str_get_free_heap;
extern const bcstring be_const_str_AudioGenerator;
extern const bcstring be_const_str_SERIAL_5E2;
extern const bcstring be_const_str__global_addr;
extern const bcstring be_const_str_content_send_style;
extern const bcstring be_const_str_remove_timer;
extern const bcstring be_const_str_tr;
extern const bcstring be_const_str_dot_w;
extern const bcstring be_const_str_MD5;
extern const bcstring be_const_str_break;
extern const bcstring be_const_str_digital_write;
extern const bcstring be_const_str_asin;
extern const bcstring be_const_str__def;
extern const bcstring be_const_str_exec_cmd;
extern const bcstring be_const_str_exists;
extern const bcstring be_const_str_flush;
extern const bcstring be_const_str_as;
extern const bcstring be_const_str_set_light;
extern const bcstring be_const_str_time_str;
extern const bcstring be_const_str_arg_size;
extern const bcstring be_const_str_bus;
extern const bcstring be_const_str_opt_eq;
extern const bcstring be_const_str_try_rule;
extern const bcstring be_const_str_kv;
extern const bcstring be_const_str_reverse_gamma10;
extern const bcstring be_const_str_tostring;
extern const bcstring be_const_str_format;
extern const bcstring be_const_str_tob64;
extern const bcstring be_const_str_continue;
extern const bcstring be_const_str_log;
extern const bcstring be_const_str_SERIAL_7N1;
extern const bcstring be_const_str_lower;
extern const bcstring be_const_str_stop;
extern const bcstring be_const_str_count;
extern const bcstring be_const_str_encrypt;
extern const bcstring be_const_str_resp_cmnd_str;
extern const bcstring be_const_str_byte;
extern const bcstring be_const_str_fromstring;
extern const bcstring be_const_str_run_deferred;
extern const bcstring be_const_str_setitem;
extern const bcstring be_const_str_cmd;
extern const bcstring be_const_str_event;
extern const bcstring be_const_str_SERIAL_6E1;
extern const bcstring be_const_str_SERIAL_6O1;
extern const bcstring be_const_str_remove_driver;
extern const bcstring be_const_str_EC_C25519;
extern const bcstring be_const_str_read12;
extern const bcstring be_const_str__write;
extern const bcstring be_const_str_opt_call;
extern const bcstring be_const_str_AudioOutput;
extern const bcstring be_const_str_attrdump;
extern const bcstring be_const_str_int;
extern const bcstring be_const_str_AudioGeneratorMP3;
extern const bcstring be_const_str_add_header;
extern const bcstring be_const_str_ctypes_bytes_dyn;
extern const bcstring be_const_str_keys;
extern const bcstring be_const_str_set_auth;
extern const bcstring be_const_str_def;
extern const bcstring be_const_str_;
extern const bcstring be_const_str_SERIAL_5N2;
extern const bcstring be_const_str__rules;
extern const bcstring be_const_str_has;
extern const bcstring be_const_str_set;
extern const bcstring be_const_str_public_key;
extern const bcstring be_const_str_get_power;
extern const bcstring be_const_str_type;
extern const bcstring be_const_str_opt_add;
extern const bcstring be_const_str_dot_size;
extern const bcstring be_const_str_set_timeouts;
extern const bcstring be_const_str_tomap;
extern const bcstring be_const_str_getbits;
extern const bcstring be_const_str_sinh;
extern const bcstring be_const_str_sqrt;
extern const bcstring be_const_str_dot_p1;
extern const bcstring be_const_str_begin;
extern const bcstring be_const_str_delay;
extern const bcstring be_const_str_scan;
extern const bcstring be_const_str_for;
extern const bcstring be_const_str_read8;
extern const bcstring be_const_str_AudioGeneratorWAV;
extern const bcstring be_const_str_get_light;
extern const bcstring be_const_str__global_def;
extern const bcstring be_const_str_map;
extern const bcstring be_const_str_redirect;
extern const bcstring be_const_str_format;
extern const bcstring be_const_str_pi;
extern const bcstring be_const_str_range;
extern const bcstring be_const_str_SERIAL_7E2;
extern const bcstring be_const_str_count;
extern const bcstring be_const_str_update;
extern const bcstring be_const_str_SERIAL_7N1;
extern const bcstring be_const_str_find_key_i;
extern const bcstring be_const_str_content_button;
extern const bcstring be_const_str_AudioGeneratorMP3;
extern const bcstring be_const_str_AudioGeneratorWAV;
extern const bcstring be_const_str__buffer;
extern const bcstring be_const_str_remove_driver;
extern const bcstring be_const_str_false;
extern const bcstring be_const_str_fromptr;
extern const bcstring be_const_str_geti;
extern const bcstring be_const_str_lower;
extern const bcstring be_const_str_nan;
extern const bcstring be_const_str_assert;
extern const bcstring be_const_str_time_str;
extern const bcstring be_const_str_exists;
extern const bcstring be_const_str_read13;
extern const bcstring be_const_str_set_power;
extern const bcstring be_const_str_seti;
extern const bcstring be_const_str_toptr;
extern const bcstring be_const_str_acos;
extern const bcstring be_const_str_find_op;
extern const bcstring be_const_str__ptr;
extern const bcstring be_const_str_isinstance;
extern const bcstring be_const_str_cb_dispatch;
extern const bcstring be_const_str_SERIAL_5O2;
extern const bcstring be_const_str_bytes;
extern const bcstring be_const_str_public_key;
extern const bcstring be_const_str_continue;
extern const bcstring be_const_str_;
extern const bcstring be_const_str__available;
extern const bcstring be_const_str__def;
extern const bcstring be_const_str_i2c_enabled;
extern const bcstring be_const_str_reverse;
extern const bcstring be_const_str_true;
extern const bcstring be_const_str_dac_voltage;
extern const bcstring be_const_str_name;
extern const bcstring be_const_str_reverse_gamma10;
extern const bcstring be_const_str_add_rule;
extern const bcstring be_const_str_dump;
extern const bcstring be_const_str_AudioOutputI2S;
extern const bcstring be_const_str_attrdump;
extern const bcstring be_const_str_fromstring;
extern const bcstring be_const_str_publish;
extern const bcstring be_const_str_wifi;
extern const bcstring be_const_str__write;
extern const bcstring be_const_str_resp_cmnd;
extern const bcstring be_const_str_tomap;
extern const bcstring be_const_str_content_start;
extern const bcstring be_const_str_traceback;
extern const bcstring be_const_str_as;
extern const bcstring be_const_str_memory;
extern const bcstring be_const_str_pin_mode;
extern const bcstring be_const_str_EC_C25519;
extern const bcstring be_const_str_str;
extern const bcstring be_const_str_tanh;
extern const bcstring be_const_str_write_bytes;
extern const bcstring be_const_str_except;
extern const bcstring be_const_str_get_option;
extern const bcstring be_const_str_dot_w;
extern const bcstring be_const_str_SERIAL_7O1;
extern const bcstring be_const_str_SERIAL_8N1;
extern const bcstring be_const_str_init;
extern const bcstring be_const_str__timers;
extern const bcstring be_const_str_super;
extern const bcstring be_const_str_GET;
extern const bcstring be_const_str_fromb64;
extern const bcstring be_const_str_break;
extern const bcstring be_const_str__global_def;
extern const bcstring be_const_str_bus;
extern const bcstring be_const_str_find;
extern const bcstring be_const_str_resp_cmnd_failed;
extern const bcstring be_const_str_SERIAL_6N2;
extern const bcstring be_const_str__request_from;
extern const bcstring be_const_str_cos;
extern const bcstring be_const_str_cosh;
extern const bcstring be_const_str_set_useragent;
extern const bcstring be_const_str_pin;
extern const bcstring be_const_str_size;
extern const bcstring be_const_str_web_send_decimal;
extern const bcstring be_const_str_write;
extern const bcstring be_const_str_module;
extern const bcstring be_const_str_try_rule;
extern const bcstring be_const_str_var;
extern const bcstring be_const_str_content_send_style;
extern const bcstring be_const_str_sinh;
extern const bcstring be_const_str_state;
extern const bcstring be_const_str_dot_p;
extern const bcstring be_const_str__drivers;
extern const bcstring be_const_str_erase;
extern const bcstring be_const_str_I2C_Driver;
extern const bcstring be_const_str_addr;
extern const bcstring be_const_str_copy;
extern const bcstring be_const_str_find_key_i;
extern const bcstring be_const_str_pin_mode;
extern const bcstring be_const_str_setrange;
extern const bcstring be_const_str_SERIAL_8N1;
extern const bcstring be_const_str_char;
extern const bcstring be_const_str_concat;
extern const bcstring be_const_str_remove;
extern const bcstring be_const_str_serial;
extern const bcstring be_const_str_SERIAL_5O2;
extern const bcstring be_const_str__read;
extern const bcstring be_const_str_cmd_res;
extern const bcstring be_const_str_contains;
extern const bcstring be_const_str_imax;
extern const bcstring be_const_str_super;
extern const bcstring be_const_str_try;
extern const bcstring be_const_str_last_modified;
extern const bcstring be_const_str_return;
extern const bcstring be_const_str_asstring;
extern const bcstring be_const_str_digital_read;
extern const bcstring be_const_str_has_arg;
extern const bcstring be_const_str_number;
extern const bcstring be_const_str_remove_rule;
extern const bcstring be_const_str_get_string;
extern const bcstring be_const_str_SERIAL_6N2;
extern const bcstring be_const_str_call;
extern const bcstring be_const_str_resize;
extern const bcstring be_const_str_encrypt;
extern const bcstring be_const_str_opt_neq;
extern const bcstring be_const_str_add_driver;
extern const bcstring be_const_str_close;
extern const bcstring be_const_str_escape;
extern const bcstring be_const_str_upper;
extern const bcstring be_const_str_end;
extern const bcstring be_const_str_gamma8;
extern const bcstring be_const_str_memory;
extern const bcstring be_const_str_wifi;
extern const bcstring be_const_str_yield;
extern const bcstring be_const_str_get_option;
extern const bcstring be_const_str_init;
extern const bcstring be_const_str_read;
extern const bcstring be_const_str__settings_ptr;
extern const bcstring be_const_str__timers;
extern const bcstring be_const_str_finish;
extern const bcstring be_const_str___upper__;
extern const bcstring be_const_str_dump;
extern const bcstring be_const_str_save;
extern const bcstring be_const_str___lower__;
extern const bcstring be_const_str_listdir;
extern const bcstring be_const_str_check_privileged_access;
extern const bcstring be_const_str_rand;
extern const bcstring be_const_str_web_send;
extern const bcstring be_const_str_i2c_enabled;
extern const bcstring be_const_str_wire1;
extern const bcstring be_const_str_dac_voltage;
extern const bcstring be_const_str_imin;
extern const bcstring be_const_str_log10;
extern const bcstring be_const_str_skip;
extern const bcstring be_const_str_else;
extern const bcstring be_const_str_except;
extern const bcstring be_const_str_nil;
extern const bcstring be_const_str_resp_cmnd_error;
extern const bcstring be_const_str_calldepth;
extern const bcstring be_const_str_do;
extern const bcstring be_const_str___iterator__;
extern const bcstring be_const_str_true;
extern const bcstring be_const_str_rad;
extern const bcstring be_const_str_import;
extern const bcstring be_const_str_SERIAL_8O2;
extern const bcstring be_const_str_gamma10;
extern const bcstring be_const_str_elif;
extern const bcstring be_const_str_resp_cmnd;
extern const bcstring be_const_str_shared_key;
extern const bcstring be_const_str_web_send_decimal;
extern const bcstring be_const_str_write8;
extern const bcstring be_const_str_SERIAL_5E1;
extern const bcstring be_const_str_member;
extern const bcstring be_const_str_response_append;
extern const bcstring be_const_str_sin;
extern const bcstring be_const_str_OneWire;
extern const bcstring be_const_str_SERIAL_7O2;
extern const bcstring be_const_str__begin_transmission;
extern const bcstring be_const_str_get_switch;
extern const bcstring be_const_str_name;
extern const bcstring be_const_str_nan;
extern const bcstring be_const_str_add;
extern const bcstring be_const_str_eth;
extern const bcstring be_const_str_find;
extern const bcstring be_const_str_read32;
extern const bcstring be_const_str_remove_cmd;
extern const bcstring be_const_str_gc;
extern const bcstring be_const_str_reset_search;
extern const bcstring be_const_str_content_stop;
extern const bcstring be_const_str_counters;
extern const bcstring be_const_str_detect;
extern const bcstring be_const_str_exp;
extern const bcstring be_const_str_on;
extern const bcstring be_const_str_arg;
extern const bcstring be_const_str_reduce;
extern const bcstring be_const_str_split;
extern const bcstring be_const_str_strftime;
extern const bcstring be_const_str_exec_rules;
extern const bcstring be_const_str_AudioFileSourceFS;
extern const bcstring be_const_str__ccmd;
extern const bcstring be_const_str_set_timer;
extern const bcstring be_const_str_time_reached;
extern const bcstring be_const_str_SERIAL_7O2;
extern const bcstring be_const_str_SERIAL_8N2;
extern const bcstring be_const_str_raise;
extern const bcstring be_const_str_AudioOutputI2S;
extern const bcstring be_const_str_if;
extern const bcstring be_const_str__ptr;
extern const bcstring be_const_str_insert;
extern const bcstring be_const_str_print;
extern const bcstring be_const_str_run_deferred;
extern const bcstring be_const_str_scan;
extern const bcstring be_const_str_settings;
extern const bcstring be_const_str_arch;
extern const bcstring be_const_str_open;
extern const bcstring be_const_str_cmd;
extern const bcstring be_const_str_loop;
extern const bcstring be_const_str_wire1;
extern const bcstring be_const_str_nil;
extern const bcstring be_const_str_SERIAL_7E1;
extern const bcstring be_const_str_keys;
extern const bcstring be_const_str_sin;
extern const bcstring be_const_str_calldepth;
extern const bcstring be_const_str_while;
extern const bcstring be_const_str_counters;
extern const bcstring be_const_str_members;
extern const bcstring be_const_str_on;
extern const bcstring be_const_str__rules;
extern const bcstring be_const_str_collect;
extern const bcstring be_const_str_url_encode;
extern const bcstring be_const_str_codedump;
extern const bcstring be_const_str_dot_p2;
extern const bcstring be_const_str_MD5;
extern const bcstring be_const_str_cb_dispatch;
extern const bcstring be_const_str_exec_tele;
extern const bcstring be_const_str_srand;
extern const bcstring be_const_str_write_bytes;
extern const bcstring be_const_str__settings_def;
extern const bcstring be_const_str_erase;
extern const bcstring be_const_str_gamma8;
extern const bcstring be_const_str_rand;
extern const bcstring be_const_str_resp_cmnd_str;
extern const bcstring be_const_str_state;
extern const bcstring be_const_str_SERIAL_6O1;
extern const bcstring be_const_str_contains;
extern const bcstring be_const_str_set_light;
extern const bcstring be_const_str_setrange;
extern const bcstring be_const_str_tan;
extern const bcstring be_const_str_target_search;
extern const bcstring be_const_str_abs;
extern const bcstring be_const_str_resp_cmnd_done;
extern const bcstring be_const_str_eth;
extern const bcstring be_const_str_SERIAL_5O1;
extern const bcstring be_const_str_concat;
extern const bcstring be_const_str_flush;
extern const bcstring be_const_str_get_free_heap;
extern const bcstring be_const_str_push;
extern const bcstring be_const_str_compile;
extern const bcstring be_const_str_wire2;
extern const bcstring be_const_str_cosh;
extern const bcstring be_const_str_pi;
extern const bcstring be_const_str_remove_rule;
extern const bcstring be_const_str_scale_uint;
extern const bcstring be_const_str_var;
extern const bcstring be_const_str_SERIAL_8E2;
extern const bcstring be_const_str_acos;
extern const bcstring be_const_str_gen_cb;
extern const bcstring be_const_str_read_bytes;
extern const bcstring be_const_str_AudioFileSource;
extern const bcstring be_const_str_SERIAL_5N1;
extern const bcstring be_const_str_wire;
extern const bcstring be_const_str_while;
extern const bcstring be_const_str_SERIAL_7N2;
extern const bcstring be_const_str_get_size;
extern const bcstring be_const_str_exec_rules;
extern const bcstring be_const_str__available;
extern const bcstring be_const_str_search;
extern const bcstring be_const_str_global;
extern const bcstring be_const_str_collect;
extern const bcstring be_const_str_input;
extern const bcstring be_const_str_response_append;
extern const bcstring be_const_str_str;
extern const bcstring be_const_str_SERIAL_6E2;
extern const bcstring be_const_str_SERIAL_7E1;
extern const bcstring be_const_str_content_button;
extern const bcstring be_const_str_number;
extern const bcstring be_const_str_tanh;
extern const bcstring be_const_str_toptr;
extern const bcstring be_const_str_write_bit;
extern const bcstring be_const_str_add_cmd;
extern const bcstring be_const_str_select;
extern const bcstring be_const_str_traceback;
extern const bcstring be_const_str_atan2;
extern const bcstring be_const_str_loop;
extern const bcstring be_const_str_millis;
extern const bcstring be_const_str_url_encode;
extern const bcstring be_const_str__end_transmission;
extern const bcstring be_const_str_deinit;
extern const bcstring be_const_str_tan;
extern const bcstring be_const_str_geti;
extern const bcstring be_const_str_seti;
extern const bcstring be_const_str__buffer;
extern const bcstring be_const_str_atan;
extern const bcstring be_const_str_event;
extern const bcstring be_const_str_content_flush;
extern const bcstring be_const_str_list;
extern const bcstring be_const_str_tolower;
extern const bcstring be_const_str_dot_len;
extern const bcstring be_const_str__request_from;
extern const bcstring be_const_str_has_arg;
extern const bcstring be_const_str_pow;
extern const bcstring be_const_str_push;
extern const bcstring be_const_str_read24;
extern const bcstring be_const_str_enabled;
extern const bcstring be_const_str_webclient;
extern const bcstring be_const_str_opt_neq;
extern const bcstring be_const_str_dot_p2;
extern const bcstring be_const_str_Wire;
extern const bcstring be_const_str_decrypt;
extern const bcstring be_const_str_floor;
extern const bcstring be_const_str_issubclass;
extern const bcstring be_const_str_write_file;
extern const bcstring be_const_str_class;
extern const bcstring be_const_str_classname;
extern const bcstring be_const_str_rtc;
extern const bcstring be_const_str_add_driver;

File diff suppressed because it is too large Load Diff

View File

@ -1,91 +1,92 @@
#include "be_constobj.h"
static be_define_const_map_slots(be_class_tasmota_map) {
{ be_const_key(resp_cmnd_done, -1), be_const_func(l_respCmndDone) },
{ be_const_key(settings, 70), be_const_var(0) },
{ be_const_key(set_light, -1), be_const_closure(set_light_closure) },
{ be_const_key(gc, 35), be_const_closure(gc_closure) },
{ be_const_key(add_cmd, -1), be_const_closure(add_cmd_closure) },
{ be_const_key(try_rule, -1), be_const_closure(try_rule_closure) },
{ be_const_key(publish, 20), be_const_func(l_publish) },
{ be_const_key(_settings_ptr, 28), be_const_comptr(&Settings) },
{ be_const_key(exec_tele, 36), be_const_closure(exec_tele_closure) },
{ be_const_key(delay, -1), be_const_func(l_delay) },
{ be_const_key(_drivers, -1), be_const_var(1) },
{ be_const_key(find_key_i, -1), be_const_closure(find_key_i_closure) },
{ be_const_key(resp_cmnd_failed, -1), be_const_func(l_respCmndFailed) },
{ be_const_key(wire2, 64), be_const_var(2) },
{ be_const_key(gen_cb, 56), be_const_closure(gen_cb_closure) },
{ be_const_key(resp_cmnd_str, -1), be_const_func(l_respCmndStr) },
{ be_const_key(_timers, 25), be_const_var(3) },
{ be_const_key(kv, -1), be_const_closure(kv_closure) },
{ be_const_key(set_power, -1), be_const_func(l_setpower) },
{ be_const_key(cmd, 38), be_const_closure(cmd_closure) },
{ be_const_key(global, -1), be_const_var(4) },
{ be_const_key(response_append, -1), be_const_func(l_respAppend) },
{ be_const_key(_get_cb, -1), be_const_func(l_get_cb) },
{ be_const_key(time_reached, -1), be_const_func(l_timereached) },
{ be_const_key(wifi, 19), be_const_func(l_wifi) },
{ be_const_key(rtc, -1), be_const_func(l_rtc) },
{ be_const_key(i2c_enabled, 8), be_const_func(l_i2cenabled) },
{ be_const_key(publish_result, 34), be_const_func(l_publish_result) },
{ be_const_key(_settings_def, -1), be_const_comptr(&be_tasmota_settings_struct) },
{ be_const_key(yield, 6), be_const_func(l_yield) },
{ be_const_key(init, -1), be_const_closure(init_closure) },
{ be_const_key(eth, -1), be_const_func(l_eth) },
{ be_const_key(get_free_heap, -1), be_const_func(l_getFreeHeap) },
{ be_const_key(get_option, -1), be_const_func(l_getoption) },
{ be_const_key(get_power, -1), be_const_func(l_getpower) },
{ be_const_key(run_deferred, -1), be_const_closure(run_deferred_closure) },
{ be_const_key(get_light, 11), be_const_closure(get_light_closure) },
{ be_const_key(cmd_res, -1), be_const_var(5) },
{ be_const_key(event, -1), be_const_closure(event_closure) },
{ be_const_key(load, -1), be_const_closure(load_closure) },
{ be_const_key(remove_timer, -1), be_const_closure(remove_timer_closure) },
{ be_const_key(wire_scan, -1), be_const_closure(wire_scan_closure) },
{ be_const_key(_cb, 50), be_const_var(6) },
{ be_const_key(remove_driver, 67), be_const_closure(remove_driver_closure) },
{ be_const_key(wire1, 61), be_const_var(7) },
{ be_const_key(memory, -1), be_const_func(l_memory) },
{ be_const_key(_global_addr, -1), be_const_comptr(&TasmotaGlobal) },
{ be_const_key(time_dump, -1), be_const_func(l_time_dump) },
{ be_const_key(_ccmd, -1), be_const_var(8) },
{ be_const_key(exec_cmd, 39), be_const_closure(exec_cmd_closure) },
{ be_const_key(exec_rules, 68), be_const_closure(exec_rules_closure) },
{ be_const_key(resp_cmnd, 14), be_const_func(l_respCmnd) },
{ be_const_key(remove_cmd, -1), be_const_closure(remove_cmd_closure) },
{ be_const_key(remove_rule, 69), be_const_closure(remove_rule_closure) },
{ be_const_key(web_send_decimal, -1), be_const_func(l_webSendDecimal) },
{ be_const_key(_rules, 41), be_const_var(9) },
{ be_const_key(strftime, 59), be_const_func(l_strftime) },
{ be_const_key(chars_in_string, -1), be_const_closure(chars_in_string_closure) },
{ be_const_key(set_timer, -1), be_const_closure(set_timer_closure) },
{ be_const_key(_global_def, -1), be_const_comptr(&be_tasmota_global_struct) },
{ be_const_key(resolvecmnd, -1), be_const_func(l_resolveCmnd) },
{ be_const_key(exec_rules, 20), be_const_closure(exec_rules_closure) },
{ be_const_key(publish_result, 75), be_const_func(l_publish_result) },
{ be_const_key(scale_uint, -1), be_const_func(l_scaleuint) },
{ be_const_key(time_str, -1), be_const_closure(time_str_closure) },
{ be_const_key(millis, 48), be_const_func(l_millis) },
{ be_const_key(resp_cmnd_error, -1), be_const_func(l_respCmndError) },
{ be_const_key(arch, -1), be_const_func(l_arch) },
{ be_const_key(log, -1), be_const_func(l_logInfo) },
{ be_const_key(add_rule, -1), be_const_closure(add_rule_closure) },
{ be_const_key(_cmd, 17), be_const_func(l_cmd) },
{ be_const_key(get_switch, -1), be_const_func(l_getswitch) },
{ be_const_key(strftime, 6), be_const_func(l_strftime) },
{ be_const_key(remove_driver, -1), be_const_closure(remove_driver_closure) },
{ be_const_key(get_free_heap, -1), be_const_func(l_getFreeHeap) },
{ be_const_key(time_dump, -1), be_const_func(l_time_dump) },
{ be_const_key(add_driver, 37), be_const_closure(add_driver_closure) },
{ be_const_key(find_op, -1), be_const_closure(find_op_closure) },
{ be_const_key(add_driver, 3), be_const_closure(add_driver_closure) },
{ be_const_key(save, 65), be_const_func(l_save) },
{ be_const_key(web_send, -1), be_const_func(l_webSend) },
{ be_const_key(arch, 38), be_const_func(l_arch) },
{ be_const_key(eth, 26), be_const_func(l_eth) },
{ be_const_key(response_append, -1), be_const_func(l_respAppend) },
{ be_const_key(_timers, -1), be_const_var(0) },
{ be_const_key(try_rule, -1), be_const_closure(try_rule_closure) },
{ be_const_key(_settings_ptr, -1), be_const_comptr(&Settings) },
{ be_const_key(resp_cmnd_error, -1), be_const_func(l_respCmndError) },
{ be_const_key(publish, -1), be_const_func(l_publish) },
{ be_const_key(time_reached, 32), be_const_func(l_timereached) },
{ be_const_key(_get_cb, -1), be_const_func(l_get_cb) },
{ be_const_key(wire1, 27), be_const_var(1) },
{ be_const_key(rtc, 43), be_const_func(l_rtc) },
{ be_const_key(web_send_decimal, -1), be_const_func(l_webSendDecimal) },
{ be_const_key(cmd_res, -1), be_const_var(2) },
{ be_const_key(add_rule, -1), be_const_closure(add_rule_closure) },
{ be_const_key(delay, 40), be_const_func(l_delay) },
{ be_const_key(_global_addr, -1), be_const_comptr(&TasmotaGlobal) },
{ be_const_key(set_light, -1), be_const_closure(set_light_closure) },
{ be_const_key(add_cmd, 74), be_const_closure(add_cmd_closure) },
{ be_const_key(global, -1), be_const_var(3) },
{ be_const_key(get_power, -1), be_const_func(l_getpower) },
{ be_const_key(wire2, -1), be_const_var(4) },
{ be_const_key(cmd, -1), be_const_closure(cmd_closure) },
{ be_const_key(get_option, 48), be_const_func(l_getoption) },
{ be_const_key(set_power, -1), be_const_func(l_setpower) },
{ be_const_key(wd, 28), be_const_var(5) },
{ be_const_key(remove_timer, -1), be_const_closure(remove_timer_closure) },
{ be_const_key(wire_scan, 61), be_const_closure(wire_scan_closure) },
{ be_const_key(_settings_def, -1), be_const_comptr(&be_tasmota_settings_struct) },
{ be_const_key(exec_tele, 69), be_const_closure(exec_tele_closure) },
{ be_const_key(gen_cb, -1), be_const_closure(gen_cb_closure) },
{ be_const_key(chars_in_string, 66), be_const_closure(chars_in_string_closure) },
{ be_const_key(log, -1), be_const_func(l_logInfo) },
{ be_const_key(find_key_i, -1), be_const_closure(find_key_i_closure) },
{ be_const_key(get_light, -1), be_const_closure(get_light_closure) },
{ be_const_key(time_str, -1), be_const_closure(time_str_closure) },
{ be_const_key(_rules, 73), be_const_var(6) },
{ be_const_key(remove_cmd, 50), be_const_closure(remove_cmd_closure) },
{ be_const_key(_cb, -1), be_const_var(7) },
{ be_const_key(_ccmd, -1), be_const_var(8) },
{ be_const_key(i2c_enabled, 53), be_const_func(l_i2cenabled) },
{ be_const_key(resp_cmnd_str, -1), be_const_func(l_respCmndStr) },
{ be_const_key(init, -1), be_const_closure(init_closure) },
{ be_const_key(save, 10), be_const_func(l_save) },
{ be_const_key(set_timer, -1), be_const_closure(set_timer_closure) },
{ be_const_key(resp_cmnd, -1), be_const_func(l_respCmnd) },
{ be_const_key(resp_cmnd_done, -1), be_const_func(l_respCmndDone) },
{ be_const_key(get_switch, 21), be_const_func(l_getswitch) },
{ be_const_key(load, -1), be_const_closure(load_closure) },
{ be_const_key(_cmd, 72), be_const_func(l_cmd) },
{ be_const_key(event, -1), be_const_closure(event_closure) },
{ be_const_key(run_deferred, -1), be_const_closure(run_deferred_closure) },
{ be_const_key(web_send, 1), be_const_func(l_webSend) },
{ be_const_key(memory, -1), be_const_func(l_memory) },
{ be_const_key(cb_dispatch, -1), be_const_closure(cb_dispatch_closure) },
{ be_const_key(remove_rule, 36), be_const_closure(remove_rule_closure) },
{ be_const_key(resolvecmnd, -1), be_const_func(l_resolveCmnd) },
{ be_const_key(wifi, -1), be_const_func(l_wifi) },
{ be_const_key(exec_cmd, -1), be_const_closure(exec_cmd_closure) },
{ be_const_key(settings, 60), be_const_var(9) },
{ be_const_key(_global_def, -1), be_const_comptr(&be_tasmota_global_struct) },
{ be_const_key(resp_cmnd_failed, -1), be_const_func(l_respCmndFailed) },
{ be_const_key(gc, -1), be_const_closure(gc_closure) },
{ be_const_key(yield, -1), be_const_func(l_yield) },
{ be_const_key(_drivers, -1), be_const_var(10) },
{ be_const_key(millis, -1), be_const_func(l_millis) },
{ be_const_key(kv, -1), be_const_closure(kv_closure) },
};
static be_define_const_map(
be_class_tasmota_map,
75
76
);
BE_EXPORT_VARIABLE be_define_const_class(
be_class_tasmota,
10,
11,
NULL,
Tasmota
);

View File

@ -1,20 +1,22 @@
#include "be_constobj.h"
static be_define_const_map_slots(m_libstring_map) {
{ be_const_key(tolower, -1), be_const_func(str_tolower) },
{ be_const_key(count, -1), be_const_func(str_count) },
{ be_const_key(hex, -1), be_const_func(str_i2hex) },
{ be_const_key(split, 5), be_const_func(str_split) },
{ be_const_key(char, -1), be_const_func(str_char) },
{ be_const_key(tr, -1), be_const_func(str_tr) },
{ be_const_key(count, 4), be_const_func(str_count) },
{ be_const_key(format, 7), be_const_func(str_format) },
{ be_const_key(escape, -1), be_const_func(str_escape) },
{ be_const_key(byte, -1), be_const_func(str_byte) },
{ be_const_key(char, 6), be_const_func(str_char) },
{ be_const_key(toupper, 1), be_const_func(str_toupper) },
{ be_const_key(toupper, -1), be_const_func(str_toupper) },
{ be_const_key(hex, -1), be_const_func(str_i2hex) },
{ be_const_key(find, -1), be_const_func(str_find) },
{ be_const_key(format, -1), be_const_func(str_format) },
{ be_const_key(split, 1), be_const_func(str_split) },
{ be_const_key(tolower, -1), be_const_func(str_tolower) },
};
static be_define_const_map(
m_libstring_map,
9
11
);
static be_define_const_module(

View File

@ -25,7 +25,7 @@ extern const bclass be_class_map;
#include <inttypes.h>
#ifndef INST_BUF_SIZE
#define INST_BUF_SIZE 96
#define INST_BUF_SIZE 288
#endif
#define logbuf(...) snprintf(__lbuf, sizeof(__lbuf), __VA_ARGS__)
@ -115,13 +115,15 @@ static void m_solidify_bvalue(bvm *vm, bvalue * value, const char *classname, co
break;
case BE_STRING:
{
logfmt("be_nested_string(\"");
be_writestring(str(var_tostr(value)));
size_t len = strlen(str(var_tostr(value)));
if (len >= 255) {
be_raise(vm, "internal_error", "Strings greater than 255 chars not supported yet");
}
logfmt("\", %i, %zu)", be_strhash(var_tostr(value)), len >= 255 ? 255 : len);
be_pushstring(vm, str(var_tostr(value)));
be_toescape(vm, -1, 'u');
logfmt("be_nested_string(%s", be_tostring(vm, -1));
be_pop(vm, 1);
logfmt(", %i, %zu)", be_strhash(var_tostr(value)), len >= 255 ? 255 : len);
}
break;
case BE_CLOSURE:

View File

@ -788,6 +788,53 @@ static int str_toupper(bvm *vm) {
return str_touplower(vm, btrue);
}
static int str_tr(bvm *vm)
{
if (be_top(vm) == 3 && be_isstring(vm, 1) && be_isstring(vm, 2) && be_isstring(vm, 3)) {
const char *p, *s = be_tostring(vm, 1);
const char *t1 = be_tostring(vm, 2);
const char *t2 = be_tostring(vm, 3);
if (strlen(t2) < strlen(t1)) {
be_raise(vm, "value_error", "invalid translation pattern");
}
size_t len = (size_t)be_strlen(vm, 1);
char *buf, *q;
buf = be_pushbuffer(vm, len);
/* convert each char */
for (p = s, q = buf; *p != '\0'; ++p, ++q) {
const char *p1, *p2;
*q = *p; /* default to no change */
for (p1=t1, p2=t2; *p1 != '\0'; ++p1, ++p2) {
if (*p == *p1) {
*q = *p2;
break;
}
}
}
be_pushnstring(vm, buf, len); /* make escape string from buffer */
be_remove(vm, 2); /* remove buffer */
be_return(vm);
}
be_return_nil(vm);
}
static int str_escape(bvm *vm)
{
int top = be_top(vm);
if (top >= 1 && be_isstring(vm, 1)) {
int quote = 'u';
if (top >= 2 && be_isbool(vm, 2)) {
if (be_tobool(vm, 1)) {
quote = 'x';
}
}
be_tostring(vm, 1);
be_toescape(vm, 1, quote);
be_pushvalue(vm, 1);
be_return(vm);
}
be_return_nil(vm);
}
#if !BE_USE_PRECOMPILED_OBJECT
be_native_module_attr_table(string) {
@ -800,6 +847,8 @@ be_native_module_attr_table(string) {
be_native_module_function("char", str_char),
be_native_module_function("tolower", str_tolower),
be_native_module_function("toupper", str_toupper),
be_native_module_function("tr", str_tr),
be_native_module_function("escape", str_escape),
};
be_define_native_module(string, NULL);
@ -815,6 +864,8 @@ module string (scope: global, depend: BE_USE_STRING_MODULE) {
char, func(str_char)
tolower, func(str_tolower)
toupper, func(str_toupper)
tr, func(str_tr)
escape, func(str_escape)
}
@const_object_info_end */
#include "../generate/be_fixed_string.h"

View File

@ -371,7 +371,7 @@ bool ZipArchive::parse(void) {
entry.last_mod = dos2unixtime((header.last_mod_date << 16) | header.last_mod_time);
offset += header.size_uncompressed;
AddLog(LOG_LEVEL_DEBUG, "ZIP: found file '%s' (%i bytes - offset %i) - next entry %i", &fname[0], header.size_uncompressed, entry.file_start, offset);
AddLog(LOG_LEVEL_DEBUG_MORE, "ZIP: found file '%s' (%i bytes - offset %i) - next entry %i", &fname[0], header.size_uncompressed, entry.file_start, offset);
}
return true;

View File

@ -990,6 +990,7 @@
//#define USE_IBEACON_ESP32
//#define USE_WEBCAM // Add support for webcam
// #define USE_AUTOCONF // Enable Esp32 autoconf feature, requires USE_BERRY and USE_WEBCLIENT_HTTPS (12KB Flash)
#define USE_BERRY // Enable Berry scripting language
#define USE_BERRY_PYTHON_COMPAT // Enable by default `import python_compat`
#define USE_BERRY_TIMEOUT 4000 // Timeout in ms, will raise an exception if running time exceeds this timeout
@ -1091,6 +1092,19 @@
#error "Select either USE_RULES or USE_SCRIPT. They can't both be used at the same time"
#endif
/*********************************************************************************************\
* Post-process compile options for Autoconf
\*********************************************************************************************/
#if defined(USE_AUTOCONF)
#ifndef USE_BERRY
#define USE_BERRY
#endif
#ifndef USE_WEBCLIENT_HTTPS
#define USE_WEBCLIENT_HTTPS
#endif
#endif // USE_AUTOCONF
/*********************************************************************************************\
* Post-process compile options for TLS
\*********************************************************************************************/

View File

@ -67,7 +67,7 @@ struct MULTI_DISP {
uint8_t used;
} displays[MAX_MULTI_DISPLAYS];
uint8_t cur_display;
Renderer *Init_uDisplay(const char *desc, int8_t cs);
Renderer *Init_uDisplay(const char *desc, int8_t cs = -1);
void Set_display(uint8_t index) {
displays[index].display = renderer;
@ -631,7 +631,7 @@ void DisplayText(void)
srot = Settings->display_rotate;
Settings->display_rotate = rot;
}
renderer = Init_uDisplay(fdesc, -1);
renderer = Init_uDisplay(fdesc);
if (rot >= 0) {
Settings->display_rotate = srot;
}

View File

@ -631,8 +631,12 @@ int32_t ShutterCalculatePosition(uint32_t i)
case SHT_TIME:
case SHT_TIME_UP_DOWN:
case SHT_TIME_GARAGE:
if (Shutter[i].time <= Shutter[i].venetian_delay && Shutter[i].tilt_config[2] > 0) {
Shutter[i].tilt_real_pos = (Shutter[i].tilt_start_pos + ((Shutter[i].direction * (int16_t)Shutter[i].time * (Shutter[i].tilt_config[1]-Shutter[i].tilt_config[0])) / Shutter[i].tilt_config[2]));
if (Shutter[i].tilt_config[2] > 0) {
if (Shutter[i].time <= Shutter[i].venetian_delay) {
Shutter[i].tilt_real_pos = (Shutter[i].tilt_start_pos + ((Shutter[i].direction * (int16_t)Shutter[i].time * (Shutter[i].tilt_config[1]-Shutter[i].tilt_config[0])) / Shutter[i].tilt_config[2]));
} else {
Shutter[i].tilt_real_pos = Shutter[i].direction == 1 ? Shutter[i].tilt_config[1] : Shutter[i].tilt_config[0];
}
}
return Shutter[i].start_position + ( (Shutter[i].time - tmin(Shutter[i].venetian_delay+Shutter[i].motordelay, Shutter[i].time)) * (Shutter[i].direction > 0 ? RESOLUTION : -Shutter[i].close_velocity));
break;

View File

@ -21,6 +21,7 @@
#ifdef USE_BERRY
#include <berry.h>
#include <LList.h>
#define BERRY_CONSOLE_CMD_DELIMITER "\x01"

View File

@ -0,0 +1,63 @@
/*
xdrv_52_3_berry_display.ino - Berry scripting language, native fucnctions
Copyright (C) 2021 Stephan Hadinger, Berry language by Guan Wenliang https://github.com/Skiars/berry
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef USE_BERRY
#ifdef USE_DISPLAY
#include <berry.h>
#ifdef USE_UNIVERSAL_DISPLAY
Renderer *Init_uDisplay(const char *desc, int8_t cs = -1);
#endif // USE_UNIVERSAL_DISPLAY
/*********************************************************************************************\
* Native functions mapped to Berry functions
*
* import display
* display.start(string) -> comptr or nil if failed
*
\*********************************************************************************************/
extern "C" {
int be_disp_start(bvm *vm);
int be_disp_start(bvm *vm) {
#ifdef USE_UNIVERSAL_DISPLAY
int32_t argc = be_top(vm); // Get the number of arguments
if (argc >= 1 && be_isstring(vm, 1)) {
const char * desc = be_tostring(vm, 1);
// remove all objects on stack to avoid warnings in subsequent calls to Berry
be_pop(vm, argc);
Renderer * renderer = Init_uDisplay(desc);
if (renderer) {
be_pushcomptr(vm, renderer);
} else {
be_pushnil(vm);
}
be_return(vm);
}
be_raise(vm, kTypeError, nullptr);
#else // USE_UNIVERSAL_DISPLAY
be_raise(vm, "internal_error", "universal display driver not present");
#endif // USE_UNIVERSAL_DISPLAY
}
}
#endif // USE_DISPLAY
#endif // USE_BERRY

View File

@ -43,6 +43,11 @@ const char berry_prog[] =
"def log(m,l) tasmota.log(m,l) end "
"def load(f) return tasmota.load(f) end "
#ifdef USE_AUTOCONF
// autoconf
"import autoconf "
#endif // USE_AUTOCONF
#ifdef USE_LVGL
"import lv "
// create the '_lvgl' global singleton

View File

@ -241,6 +241,34 @@ int32_t callBerryEventDispatcher(const char *type, const char *cmd, int32_t idx,
return ret;
}
// call a method in autoconf
int32_t callBerryAutoconf(const char * method) {
int32_t ret = 0;
bvm *vm = berry.vm;
if (nullptr == vm) { return ret; }
checkBeTop();
be_getglobal(vm, "autoconf");
if (!be_isnil(vm, -1)) {
be_getmethod(vm, -1, method);
if (!be_isnil(vm, -1)) {
be_pushvalue(vm, -2);
BrTimeoutStart();
ret = be_pcall(vm, 1); // 1 arg
BrTimeoutReset();
if (ret != 0) {
BerryDumpErrorAndClear(vm, false); // log in Tasmota console only
return ret;
}
be_pop(vm, 1); // remove instance
}
be_pop(vm, 1); // remove method
}
be_pop(vm, 1); // remove instance object
checkBeTop();
return ret;
}
/*********************************************************************************************\
* VM Observability
\*********************************************************************************************/
@ -336,6 +364,9 @@ void BerryInit(void) {
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_BERRY "Berry initialized, RAM used=%u"), callBerryGC());
berry_init_ok = true;
// Run 'autoconf.preinit()'
callBerryAutoconf("preinit");
// Run pre-init
BrLoad("preinit.be"); // run 'preinit.be' if present
} while (0);
@ -759,6 +790,9 @@ bool Xdrv52(uint8_t function)
// break;
case FUNC_LOOP:
if (!berry.autoexec_done) {
// Run 'autoconf.preinit()'
callBerryAutoconf("autoexec");
BrLoad("autoexec.be"); // run autoexec.be at first tick, so we know all modules are initialized
berry.autoexec_done = true;
}

View File

@ -364,9 +364,6 @@ extern "C" {
* display ecosystem.
************************************************************/
Renderer *Init_uDisplay(const char *desc, int8_t cs);
void start_lvgl(const char * uconfig);
void start_lvgl(const char * uconfig) {
@ -377,7 +374,7 @@ void start_lvgl(const char * uconfig) {
if (!renderer || uconfig) {
#ifdef USE_UNIVERSAL_DISPLAY // TODO - we will probably support only UNIV_DISPLAY
renderer = Init_uDisplay((char*)uconfig, -1);
renderer = Init_uDisplay((char*)uconfig);
if (!renderer) return;
#else
return;

View File

@ -26,7 +26,7 @@
bool ili9488_init_done = false;
Renderer *Init_uDisplay(const char *desc, int8_t cs);
Renderer *Init_uDisplay(const char *desc, int8_t cs = -1);
void udisp_CheckTouch(void);
/*********************************************************************************************/

View File

@ -433,7 +433,7 @@ bool Xdsp17(uint8_t function) {
bool result = false;
if (FUNC_DISPLAY_INIT_DRIVER == function) {
Init_uDisplay(0, -1);
Init_uDisplay(nullptr);
}
else if (udisp_init_done && (XDSP_17 == Settings->display_model)) {
switch (function) {