mirror of https://github.com/arendst/Tasmota.git
Merge branch 'development' into twdt_to_tasmota
This commit is contained in:
commit
9e612dcb8b
|
@ -7,7 +7,7 @@
|
|||
- [ ] Only relevant files were touched
|
||||
- [ ] Only one feature/fix was added per PR and the code change compiles without warnings
|
||||
- [ ] The code change is tested and works with Tasmota core ESP8266 V.2.7.4.9
|
||||
- [ ] The code change is tested and works with Tasmota core ESP32 V.1.0.7.4
|
||||
- [ ] The code change is tested and works with Tasmota core ESP32 V.1.0.7.5
|
||||
- [ ] I accept the [CLA](https://github.com/arendst/Tasmota/blob/development/CONTRIBUTING.md#contributor-license-agreement-cla).
|
||||
|
||||
_NOTE: The code change must pass CI tests. **Your PR cannot be merged unless tests pass**_
|
||||
|
|
|
@ -3,8 +3,12 @@ All notable changes to this project will be documented in this file.
|
|||
|
||||
## [Unreleased] - Development
|
||||
|
||||
## [10.0.0.0]
|
||||
## [10.0.0.1]
|
||||
### Added
|
||||
- Berry add module ``python_compat`` to be closer to Python syntax (#13428)
|
||||
|
||||
### Changed
|
||||
- File editor no-wrap (#13427)
|
||||
|
||||
## [Released]
|
||||
|
||||
|
|
|
@ -98,11 +98,13 @@ The latter links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmo
|
|||
|
||||
[Complete list](BUILDS.md) of available feature and sensors.
|
||||
|
||||
## Changelog v10.0.0.0
|
||||
## Changelog v10.0.0.1
|
||||
### Added
|
||||
- ESP32 Berry add module ``python_compat`` to be closer to Python syntax [#13428](https://github.com/arendst/Tasmota/issues/13428)
|
||||
|
||||
### Breaking Changed
|
||||
|
||||
### Changed
|
||||
- File editor no-wrap [#13427](https://github.com/arendst/Tasmota/issues/13427)
|
||||
|
||||
### Fixed
|
||||
|
|
|
@ -24,6 +24,7 @@ be_extern_native_module(introspect);
|
|||
be_extern_native_module(strict);
|
||||
|
||||
/* Tasmota specific */
|
||||
be_extern_native_module(python_compat);
|
||||
be_extern_native_module(persist);
|
||||
be_extern_native_module(light);
|
||||
be_extern_native_module(gpio);
|
||||
|
@ -80,6 +81,7 @@ BERRY_LOCAL const bntvmodule* const be_module_table[] = {
|
|||
#endif
|
||||
/* user-defined modules register start */
|
||||
|
||||
&be_native_module(python_compat),
|
||||
&be_native_module(path),
|
||||
&be_native_module(persist),
|
||||
&be_native_module(gpio),
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
/********************************************************************
|
||||
* Berry python compatibility module
|
||||
*
|
||||
* `import python_compat`
|
||||
*******************************************************************/
|
||||
#include "be_constobj.h"
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: _anonymous_
|
||||
********************************************************************/
|
||||
be_local_closure(_anonymous_, /* name */
|
||||
be_nested_proto(
|
||||
3, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 5]) { /* constants */
|
||||
/* K0 */ be_nested_string("global", 503252654, 6),
|
||||
/* K1 */ be_nested_string("True", -841064955, 4),
|
||||
/* K2 */ be_nested_string("False", -1753917960, 5),
|
||||
/* K3 */ be_nested_string("None", 810547195, 4),
|
||||
/* K4 */ be_nested_string("b", -418632219, 1),
|
||||
}),
|
||||
(be_nested_const_str("_anonymous_", 1957281476, 11)),
|
||||
(be_nested_const_str("python_compat.be", -225667571, 16)),
|
||||
( &(const binstruction[10]) { /* code */
|
||||
0xA4060000, // 0000 IMPORT R1 K0
|
||||
0x50080200, // 0001 LDBOOL R2 1 0
|
||||
0x90060202, // 0002 SETMBR R1 K1 R2
|
||||
0x50080000, // 0003 LDBOOL R2 0 0
|
||||
0x90060402, // 0004 SETMBR R1 K2 R2
|
||||
0x4C080000, // 0005 LDNIL R2
|
||||
0x90060602, // 0006 SETMBR R1 K3 R2
|
||||
0x60080015, // 0007 GETGBL R2 G21
|
||||
0x90060802, // 0008 SETMBR R1 K4 R2
|
||||
0x80040000, // 0009 RET 1 R0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified module: python_compat
|
||||
********************************************************************/
|
||||
be_local_module(python_compat,
|
||||
"python_compat",
|
||||
be_nested_map(1,
|
||||
( (struct bmapnode*) &(const bmapnode[]) {
|
||||
{ be_nested_key("init", 380752755, 4, -1), be_const_closure(_anonymous__closure) },
|
||||
}))
|
||||
);
|
||||
BE_EXPORT_VARIABLE be_define_const_native_module(python_compat, NULL);
|
||||
/********************************************************************/
|
|
@ -7,7 +7,9 @@
|
|||
|
||||
struct dummy_struct {}; // we need a struct name but don't need any meaningful content, we just take the address
|
||||
extern struct TasmotaGlobal_t TasmotaGlobal;
|
||||
extern struct TSettings * Settings;
|
||||
extern struct dummy_struct be_tasmota_global_struct;
|
||||
extern struct dummy_struct be_tasmota_settings_struct;
|
||||
|
||||
extern int l_getFreeHeap(bvm *vm);
|
||||
extern int l_publish(bvm *vm);
|
||||
|
@ -53,7 +55,7 @@ extern int l_i2cenabled(bvm *vm);
|
|||
********************************************************************/
|
||||
be_local_closure(init, /* name */
|
||||
be_nested_proto(
|
||||
4, /* nstack */
|
||||
7, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
|
@ -61,21 +63,45 @@ be_local_closure(init, /* name */
|
|||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 4]) { /* constants */
|
||||
( &(const bvalue[11]) { /* 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),
|
||||
/* K3 */ be_nested_string("_global_def", 646007001, 11),
|
||||
/* K4 */ be_nested_string("introspect", 164638290, 10),
|
||||
/* K5 */ be_nested_string("_settings_ptr", 1825772182, 13),
|
||||
/* K6 */ be_nested_string("get", 1410115415, 3),
|
||||
/* K7 */ be_const_int(0),
|
||||
/* K8 */ be_nested_string("settings", 1745255176, 8),
|
||||
/* K9 */ be_nested_string("toptr", -915119842, 5),
|
||||
/* K10 */ be_nested_string("_settings_def", -519406989, 13),
|
||||
}),
|
||||
(be_nested_const_str("init", 380752755, 4)),
|
||||
(be_nested_const_str("input", -103256197, 5)),
|
||||
( &(const binstruction[ 6]) { /* code */
|
||||
(be_nested_const_str("tasmota.be", 1128870755, 10)),
|
||||
( &(const binstruction[23]) { /* code */
|
||||
0xB8060200, // 0000 GETNGBL R1 K1
|
||||
0x88080102, // 0001 GETMBR R2 R0 K2
|
||||
0x880C0103, // 0002 GETMBR R3 R0 K3
|
||||
0x7C040400, // 0003 CALL R1 2
|
||||
0x90020001, // 0004 SETMBR R0 K0 R1
|
||||
0x80000000, // 0005 RET 0
|
||||
0xA4060800, // 0005 IMPORT R1 K4
|
||||
0x60080015, // 0006 GETGBL R2 G21
|
||||
0x880C0105, // 0007 GETMBR R3 R0 K5
|
||||
0x54120003, // 0008 LDINT R4 4
|
||||
0x7C080400, // 0009 CALL R2 2
|
||||
0x8C080506, // 000A GETMET R2 R2 K6
|
||||
0x58100007, // 000B LDCONST R4 K7
|
||||
0x54160003, // 000C LDINT R5 4
|
||||
0x7C080600, // 000D CALL R2 3
|
||||
0x780A0006, // 000E JMPF R2 #0016
|
||||
0xB80E0200, // 000F GETNGBL R3 K1
|
||||
0x8C100309, // 0010 GETMET R4 R1 K9
|
||||
0x5C180400, // 0011 MOVE R6 R2
|
||||
0x7C100400, // 0012 CALL R4 2
|
||||
0x8814010A, // 0013 GETMBR R5 R0 K10
|
||||
0x7C0C0400, // 0014 CALL R3 2
|
||||
0x90021003, // 0015 SETMBR R0 K8 R3
|
||||
0x80000000, // 0016 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
|
@ -1118,6 +1144,111 @@ be_local_closure(exec_rules, /* name */
|
|||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: exec_tele
|
||||
********************************************************************/
|
||||
be_local_closure(exec_tele, /* name */
|
||||
be_nested_proto(
|
||||
10, /* nstack */
|
||||
2, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
1, /* has sup protos */
|
||||
( &(const struct bproto*[ 1]) {
|
||||
be_nested_proto(
|
||||
8, /* nstack */
|
||||
3, /* argc */
|
||||
0, /* varg */
|
||||
1, /* has upvals */
|
||||
( &(const bupvaldesc[ 2]) { /* upvals */
|
||||
be_local_const_upval(1, 0),
|
||||
be_local_const_upval(1, 3),
|
||||
}),
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 1]) { /* constants */
|
||||
/* K0 */ be_nested_string("try_rule", 1986449405, 8),
|
||||
}),
|
||||
(be_nested_const_str("<lambda>", 607256038, 8)),
|
||||
(be_nested_const_str("tasmota.be", 1128870755, 10)),
|
||||
( &(const binstruction[11]) { /* code */
|
||||
0x680C0000, // 0000 GETUPV R3 U0
|
||||
0x8C0C0700, // 0001 GETMET R3 R3 K0
|
||||
0x68140001, // 0002 GETUPV R5 U1
|
||||
0x5C180000, // 0003 MOVE R6 R0
|
||||
0x5C1C0200, // 0004 MOVE R7 R1
|
||||
0x7C0C0800, // 0005 CALL R3 4
|
||||
0x740E0001, // 0006 JMPT R3 #0009
|
||||
0x740A0000, // 0007 JMPT R2 #0009
|
||||
0x50080001, // 0008 LDBOOL R2 0 1
|
||||
0x50080200, // 0009 LDBOOL R2 1 0
|
||||
0x80040400, // 000A RET 1 R2
|
||||
})
|
||||
),
|
||||
}),
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 9]) { /* constants */
|
||||
/* K0 */ be_nested_string("_rules", -28750191, 6),
|
||||
/* K1 */ be_nested_string("json", 916562499, 4),
|
||||
/* K2 */ be_nested_string("load", -435725847, 4),
|
||||
/* K3 */ be_nested_string("log", 1062293841, 3),
|
||||
/* K4 */ be_nested_string("BRY: ERROR, bad json: ", -1579831487, 22),
|
||||
/* K5 */ be_const_int(3),
|
||||
/* K6 */ be_nested_string("Tele", 1329980653, 4),
|
||||
/* K7 */ be_nested_string("reduce", 2002030311, 6),
|
||||
/* K8 */ be_nested_string("stop_iteration", -121173395, 14),
|
||||
}),
|
||||
(be_nested_const_str("exec_tele", 1020751601, 9)),
|
||||
(be_nested_const_str("tasmota.be", 1128870755, 10)),
|
||||
( &(const binstruction[40]) { /* code */
|
||||
0x88080100, // 0000 GETMBR R2 R0 K0
|
||||
0x780A0022, // 0001 JMPF R2 #0025
|
||||
0xA40A0200, // 0002 IMPORT R2 K1
|
||||
0x8C0C0502, // 0003 GETMET R3 R2 K2
|
||||
0x5C140200, // 0004 MOVE R5 R1
|
||||
0x7C0C0400, // 0005 CALL R3 2
|
||||
0x50100000, // 0006 LDBOOL R4 0 0
|
||||
0x4C140000, // 0007 LDNIL R5
|
||||
0x1C140605, // 0008 EQ R5 R3 R5
|
||||
0x78160004, // 0009 JMPF R5 #000F
|
||||
0x8C140103, // 000A GETMET R5 R0 K3
|
||||
0x001E0801, // 000B ADD R7 K4 R1
|
||||
0x58200005, // 000C LDCONST R8 K5
|
||||
0x7C140600, // 000D CALL R5 3
|
||||
0x5C0C0200, // 000E MOVE R3 R1
|
||||
0x60140013, // 000F GETGBL R5 G19
|
||||
0x7C140000, // 0010 CALL R5 0
|
||||
0x98160C03, // 0011 SETIDX R5 K6 R3
|
||||
0x5C0C0A00, // 0012 MOVE R3 R5
|
||||
0xA8020008, // 0013 EXBLK 0 #001D
|
||||
0x88140100, // 0014 GETMBR R5 R0 K0
|
||||
0x8C140B07, // 0015 GETMET R5 R5 K7
|
||||
0x841C0000, // 0016 CLOSURE R7 P0
|
||||
0x4C200000, // 0017 LDNIL R8
|
||||
0x50240000, // 0018 LDBOOL R9 0 0
|
||||
0x7C140800, // 0019 CALL R5 4
|
||||
0x5C100A00, // 001A MOVE R4 R5
|
||||
0xA8040001, // 001B EXBLK 1 1
|
||||
0x70020004, // 001C JMP #0022
|
||||
0x58140008, // 001D LDCONST R5 K8
|
||||
0xAC140200, // 001E CATCH R5 1 0
|
||||
0x70020000, // 001F JMP #0021
|
||||
0x70020000, // 0020 JMP #0022
|
||||
0xB0080000, // 0021 RAISE 2 R0 R0
|
||||
0xA0000000, // 0022 CLOSE R0
|
||||
0x80040800, // 0023 RET 1 R4
|
||||
0xA0080000, // 0024 CLOSE R2
|
||||
0x50080000, // 0025 LDBOOL R2 0 0
|
||||
0xA0000000, // 0026 CLOSE R0
|
||||
0x80040400, // 0027 RET 1 R2
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: remove_driver
|
||||
********************************************************************/
|
||||
|
@ -1433,7 +1564,7 @@ be_local_closure(event, /* name */
|
|||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[21]) { /* constants */
|
||||
( &(const bvalue[23]) { /* constants */
|
||||
/* K0 */ be_nested_string("introspect", 164638290, 10),
|
||||
/* K1 */ be_nested_string("debug", 1483009432, 5),
|
||||
/* K2 */ be_nested_string("string", 398550328, 6),
|
||||
|
@ -1441,24 +1572,26 @@ be_local_closure(event, /* name */
|
|||
/* K4 */ be_nested_string("run_deferred", 371594696, 12),
|
||||
/* K5 */ be_nested_string("cmd", -158181397, 3),
|
||||
/* K6 */ be_nested_string("exec_cmd", 493567399, 8),
|
||||
/* K7 */ be_nested_string("rule", -64077613, 4),
|
||||
/* K8 */ be_nested_string("exec_rules", 1445221092, 10),
|
||||
/* K9 */ be_nested_string("gc", 1042313471, 2),
|
||||
/* K10 */ be_nested_string("_drivers", -1034638311, 8),
|
||||
/* K11 */ be_const_int(0),
|
||||
/* K12 */ be_nested_string("get", 1410115415, 3),
|
||||
/* K13 */ be_nested_string("function", -1630125495, 8),
|
||||
/* K14 */ be_nested_string("format", -1180859054, 6),
|
||||
/* K15 */ be_nested_string("BRY: Exception> '%s' - %s", -2047976332, 25),
|
||||
/* K16 */ be_nested_string("traceback", -909779187, 9),
|
||||
/* K17 */ be_const_int(1),
|
||||
/* K18 */ be_nested_string("save_before_restart", 1253239338, 19),
|
||||
/* K19 */ be_nested_string("persist", -377883517, 7),
|
||||
/* K20 */ be_nested_string("save", -855671224, 4),
|
||||
/* K7 */ be_nested_string("tele", -820509235, 4),
|
||||
/* K8 */ be_nested_string("exec_tele", 1020751601, 9),
|
||||
/* K9 */ be_nested_string("rule", -64077613, 4),
|
||||
/* K10 */ be_nested_string("exec_rules", 1445221092, 10),
|
||||
/* K11 */ be_nested_string("gc", 1042313471, 2),
|
||||
/* K12 */ be_nested_string("_drivers", -1034638311, 8),
|
||||
/* K13 */ be_const_int(0),
|
||||
/* K14 */ be_nested_string("get", 1410115415, 3),
|
||||
/* K15 */ be_nested_string("function", -1630125495, 8),
|
||||
/* K16 */ be_nested_string("format", -1180859054, 6),
|
||||
/* K17 */ be_nested_string("BRY: Exception> '%s' - %s", -2047976332, 25),
|
||||
/* K18 */ be_nested_string("traceback", -909779187, 9),
|
||||
/* K19 */ be_const_int(1),
|
||||
/* K20 */ be_nested_string("save_before_restart", 1253239338, 19),
|
||||
/* K21 */ be_nested_string("persist", -377883517, 7),
|
||||
/* K22 */ be_nested_string("save", -855671224, 4),
|
||||
}),
|
||||
(be_nested_const_str("event", -30355297, 5)),
|
||||
(be_nested_const_str("input", -103256197, 5)),
|
||||
( &(const binstruction[84]) { /* code */
|
||||
(be_nested_const_str("tasmota.be", 1128870755, 10)),
|
||||
( &(const binstruction[91]) { /* code */
|
||||
0xA41A0000, // 0000 IMPORT R6 K0
|
||||
0xA41E0200, // 0001 IMPORT R7 K1
|
||||
0xA4220400, // 0002 IMPORT R8 K2
|
||||
|
@ -1475,74 +1608,81 @@ be_local_closure(event, /* name */
|
|||
0x5C380800, // 000D MOVE R14 R4
|
||||
0x7C280800, // 000E CALL R10 4
|
||||
0x80041400, // 000F RET 1 R10
|
||||
0x7002003C, // 0010 JMP #004E
|
||||
0x70020043, // 0010 JMP #0055
|
||||
0x1C280307, // 0011 EQ R10 R1 K7
|
||||
0x782A0004, // 0012 JMPF R10 #0018
|
||||
0x8C280108, // 0013 GETMET R10 R0 K8
|
||||
0x5C300800, // 0014 MOVE R12 R4
|
||||
0x7C280400, // 0015 CALL R10 2
|
||||
0x80041400, // 0016 RET 1 R10
|
||||
0x70020035, // 0017 JMP #004E
|
||||
0x7002003C, // 0017 JMP #0055
|
||||
0x1C280309, // 0018 EQ R10 R1 K9
|
||||
0x782A0003, // 0019 JMPF R10 #001E
|
||||
0x8C280109, // 001A GETMET R10 R0 K9
|
||||
0x7C280200, // 001B CALL R10 1
|
||||
0x80041400, // 001C RET 1 R10
|
||||
0x7002002F, // 001D JMP #004E
|
||||
0x8828010A, // 001E GETMBR R10 R0 K10
|
||||
0x782A002D, // 001F JMPF R10 #004E
|
||||
0x5828000B, // 0020 LDCONST R10 K11
|
||||
0x602C000C, // 0021 GETGBL R11 G12
|
||||
0x8830010A, // 0022 GETMBR R12 R0 K10
|
||||
0x7C2C0200, // 0023 CALL R11 1
|
||||
0x142C140B, // 0024 LT R11 R10 R11
|
||||
0x782E0027, // 0025 JMPF R11 #004E
|
||||
0x882C010A, // 0026 GETMBR R11 R0 K10
|
||||
0x942C160A, // 0027 GETIDX R11 R11 R10
|
||||
0x8C300D0C, // 0028 GETMET R12 R6 K12
|
||||
0x5C381600, // 0029 MOVE R14 R11
|
||||
0x5C3C0200, // 002A MOVE R15 R1
|
||||
0x7C300600, // 002B CALL R12 3
|
||||
0x60340004, // 002C GETGBL R13 G4
|
||||
0x5C381800, // 002D MOVE R14 R12
|
||||
0x7C340200, // 002E CALL R13 1
|
||||
0x1C341B0D, // 002F EQ R13 R13 K13
|
||||
0x7836001A, // 0030 JMPF R13 #004C
|
||||
0xA802000C, // 0031 EXBLK 0 #003F
|
||||
0x5C341800, // 0032 MOVE R13 R12
|
||||
0x5C381600, // 0033 MOVE R14 R11
|
||||
0x5C3C0400, // 0034 MOVE R15 R2
|
||||
0x5C400600, // 0035 MOVE R16 R3
|
||||
0x5C440800, // 0036 MOVE R17 R4
|
||||
0x5C480A00, // 0037 MOVE R18 R5
|
||||
0x7C340A00, // 0038 CALL R13 5
|
||||
0x5C241A00, // 0039 MOVE R9 R13
|
||||
0x78260001, // 003A JMPF R9 #003D
|
||||
0xA8040001, // 003B EXBLK 1 1
|
||||
0x70020010, // 003C JMP #004E
|
||||
0xA8040001, // 003D EXBLK 1 1
|
||||
0x7002000C, // 003E JMP #004C
|
||||
0xAC340002, // 003F CATCH R13 0 2
|
||||
0x70020009, // 0040 JMP #004B
|
||||
0x603C0001, // 0041 GETGBL R15 G1
|
||||
0x8C40110E, // 0042 GETMET R16 R8 K14
|
||||
0x5848000F, // 0043 LDCONST R18 K15
|
||||
0x5C4C1A00, // 0044 MOVE R19 R13
|
||||
0x5C501C00, // 0045 MOVE R20 R14
|
||||
0x7C400800, // 0046 CALL R16 4
|
||||
0x7C3C0200, // 0047 CALL R15 1
|
||||
0x8C3C0F10, // 0048 GETMET R15 R7 K16
|
||||
0x7C3C0200, // 0049 CALL R15 1
|
||||
0x70020000, // 004A JMP #004C
|
||||
0xB0080000, // 004B RAISE 2 R0 R0
|
||||
0x00281511, // 004C ADD R10 R10 K17
|
||||
0x7001FFD2, // 004D JMP #0021
|
||||
0x1C280312, // 004E EQ R10 R1 K18
|
||||
0x782A0002, // 004F JMPF R10 #0053
|
||||
0xA42A2600, // 0050 IMPORT R10 K19
|
||||
0x8C2C1514, // 0051 GETMET R11 R10 K20
|
||||
0x7C2C0200, // 0052 CALL R11 1
|
||||
0x80041200, // 0053 RET 1 R9
|
||||
0x782A0004, // 0019 JMPF R10 #001F
|
||||
0x8C28010A, // 001A GETMET R10 R0 K10
|
||||
0x5C300800, // 001B MOVE R12 R4
|
||||
0x7C280400, // 001C CALL R10 2
|
||||
0x80041400, // 001D RET 1 R10
|
||||
0x70020035, // 001E JMP #0055
|
||||
0x1C28030B, // 001F EQ R10 R1 K11
|
||||
0x782A0003, // 0020 JMPF R10 #0025
|
||||
0x8C28010B, // 0021 GETMET R10 R0 K11
|
||||
0x7C280200, // 0022 CALL R10 1
|
||||
0x80041400, // 0023 RET 1 R10
|
||||
0x7002002F, // 0024 JMP #0055
|
||||
0x8828010C, // 0025 GETMBR R10 R0 K12
|
||||
0x782A002D, // 0026 JMPF R10 #0055
|
||||
0x5828000D, // 0027 LDCONST R10 K13
|
||||
0x602C000C, // 0028 GETGBL R11 G12
|
||||
0x8830010C, // 0029 GETMBR R12 R0 K12
|
||||
0x7C2C0200, // 002A CALL R11 1
|
||||
0x142C140B, // 002B LT R11 R10 R11
|
||||
0x782E0027, // 002C JMPF R11 #0055
|
||||
0x882C010C, // 002D GETMBR R11 R0 K12
|
||||
0x942C160A, // 002E GETIDX R11 R11 R10
|
||||
0x8C300D0E, // 002F GETMET R12 R6 K14
|
||||
0x5C381600, // 0030 MOVE R14 R11
|
||||
0x5C3C0200, // 0031 MOVE R15 R1
|
||||
0x7C300600, // 0032 CALL R12 3
|
||||
0x60340004, // 0033 GETGBL R13 G4
|
||||
0x5C381800, // 0034 MOVE R14 R12
|
||||
0x7C340200, // 0035 CALL R13 1
|
||||
0x1C341B0F, // 0036 EQ R13 R13 K15
|
||||
0x7836001A, // 0037 JMPF R13 #0053
|
||||
0xA802000C, // 0038 EXBLK 0 #0046
|
||||
0x5C341800, // 0039 MOVE R13 R12
|
||||
0x5C381600, // 003A MOVE R14 R11
|
||||
0x5C3C0400, // 003B MOVE R15 R2
|
||||
0x5C400600, // 003C MOVE R16 R3
|
||||
0x5C440800, // 003D MOVE R17 R4
|
||||
0x5C480A00, // 003E MOVE R18 R5
|
||||
0x7C340A00, // 003F CALL R13 5
|
||||
0x5C241A00, // 0040 MOVE R9 R13
|
||||
0x78260001, // 0041 JMPF R9 #0044
|
||||
0xA8040001, // 0042 EXBLK 1 1
|
||||
0x70020010, // 0043 JMP #0055
|
||||
0xA8040001, // 0044 EXBLK 1 1
|
||||
0x7002000C, // 0045 JMP #0053
|
||||
0xAC340002, // 0046 CATCH R13 0 2
|
||||
0x70020009, // 0047 JMP #0052
|
||||
0x603C0001, // 0048 GETGBL R15 G1
|
||||
0x8C401110, // 0049 GETMET R16 R8 K16
|
||||
0x58480011, // 004A LDCONST R18 K17
|
||||
0x5C4C1A00, // 004B MOVE R19 R13
|
||||
0x5C501C00, // 004C MOVE R20 R14
|
||||
0x7C400800, // 004D CALL R16 4
|
||||
0x7C3C0200, // 004E CALL R15 1
|
||||
0x8C3C0F12, // 004F GETMET R15 R7 K18
|
||||
0x7C3C0200, // 0050 CALL R15 1
|
||||
0x70020000, // 0051 JMP #0053
|
||||
0xB0080000, // 0052 RAISE 2 R0 R0
|
||||
0x00281513, // 0053 ADD R10 R10 K19
|
||||
0x7001FFD2, // 0054 JMP #0028
|
||||
0x1C280314, // 0055 EQ R10 R1 K20
|
||||
0x782A0002, // 0056 JMPF R10 #005A
|
||||
0xA42A2A00, // 0057 IMPORT R10 K21
|
||||
0x8C2C1516, // 0058 GETMET R11 R10 K22
|
||||
0x7C2C0200, // 0059 CALL R11 1
|
||||
0x80041200, // 005A RET 1 R9
|
||||
})
|
||||
)
|
||||
);
|
||||
|
@ -1659,10 +1799,13 @@ class be_class_tasmota (scope: global, name: Tasmota) {
|
|||
wire1, var
|
||||
wire2, var
|
||||
global, var
|
||||
settings, var
|
||||
cmd_res, var
|
||||
|
||||
_global_def, comptr(&be_tasmota_global_struct)
|
||||
_settings_def, comptr(&be_tasmota_settings_struct)
|
||||
_global_addr, comptr(&TasmotaGlobal)
|
||||
_settings_ptr, comptr(&Settings)
|
||||
|
||||
init, closure(init_closure)
|
||||
|
||||
|
@ -1711,6 +1854,7 @@ class be_class_tasmota (scope: global, name: Tasmota) {
|
|||
remove_rule, closure(remove_rule_closure)
|
||||
try_rule, closure(try_rule_closure)
|
||||
exec_rules, closure(exec_rules_closure)
|
||||
exec_tele, closure(exec_tele_closure)
|
||||
set_timer, closure(set_timer_closure)
|
||||
run_deferred, closure(run_deferred_closure)
|
||||
remove_timer, closure(remove_timer_closure)
|
||||
|
|
|
@ -26,10 +26,16 @@ class Tasmota
|
|||
var wire2
|
||||
var cmd_res # store the command result, nil if disables, true if capture enabled, contains return value
|
||||
var global # mapping to TasmotaGlobal
|
||||
var settings
|
||||
|
||||
def init()
|
||||
# instanciate the mapping object to TasmotaGlobal
|
||||
self.global = ctypes_bytes_dyn(self._global_addr, self._global_def)
|
||||
import introspect
|
||||
var settings_addr = bytes(self._settings_ptr, 4).get(0,4)
|
||||
if settings_addr
|
||||
self.settings = ctypes_bytes_dyn(introspect.toptr(settings_addr), self._settings_def)
|
||||
end
|
||||
end
|
||||
|
||||
# add `chars_in_string(s:string,c:string) -> int``
|
||||
|
@ -175,6 +181,28 @@ class Tasmota
|
|||
return false
|
||||
end
|
||||
|
||||
# Run tele rules
|
||||
def exec_tele(ev_json)
|
||||
if self._rules
|
||||
import json
|
||||
var ev = json.load(ev_json) # returns nil if invalid JSON
|
||||
var ret = false
|
||||
if ev == nil
|
||||
self.log('BRY: ERROR, bad json: '+ev_json, 3)
|
||||
ev = ev_json # revert to string
|
||||
end
|
||||
# insert tele prefix
|
||||
ev = { "Tele": ev }
|
||||
try
|
||||
ret = self._rules.reduce( /k,v,r-> self.try_rule(ev,k,v) || r, nil, false)
|
||||
except "stop_iteration"
|
||||
# silence stop_iteration which means that the map was resized during iteration
|
||||
end
|
||||
return ret
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
def set_timer(delay,f,id)
|
||||
if !self._timers self._timers=[] end
|
||||
self._timers.push(Timer(self.millis(delay),f,id))
|
||||
|
@ -323,6 +351,7 @@ class Tasmota
|
|||
|
||||
var done = false
|
||||
if event_type=='cmd' return self.exec_cmd(cmd, idx, payload)
|
||||
elif event_type=='tele' return self.exec_tele(payload)
|
||||
elif event_type=='rule' return self.exec_rules(payload)
|
||||
elif event_type=='gc' return self.gc()
|
||||
elif self._drivers
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,85 +1,89 @@
|
|||
#include "be_constobj.h"
|
||||
|
||||
static be_define_const_map_slots(be_class_tasmota_map) {
|
||||
{ be_const_key(response_append, 44), be_const_func(l_respAppend) },
|
||||
{ be_const_key(add_rule, -1), be_const_closure(add_rule_closure) },
|
||||
{ be_const_key(resp_cmnd_str, 10), be_const_func(l_respCmndStr) },
|
||||
{ be_const_key(_cb, 33), be_const_var(0) },
|
||||
{ be_const_key(set_timer, 66), be_const_closure(set_timer_closure) },
|
||||
{ be_const_key(publish, -1), be_const_func(l_publish) },
|
||||
{ be_const_key(add_rule, 52), be_const_closure(add_rule_closure) },
|
||||
{ be_const_key(_global_addr, -1), be_const_comptr(&TasmotaGlobal) },
|
||||
{ be_const_key(web_send, 14), be_const_func(l_webSend) },
|
||||
{ be_const_key(settings, -1), be_const_var(0) },
|
||||
{ be_const_key(set_power, -1), be_const_func(l_setpower) },
|
||||
{ be_const_key(add_cmd, 32), be_const_closure(add_cmd_closure) },
|
||||
{ be_const_key(find_key_i, -1), be_const_closure(find_key_i_closure) },
|
||||
{ be_const_key(chars_in_string, 35), be_const_closure(chars_in_string_closure) },
|
||||
{ be_const_key(gen_cb, 48), be_const_closure(gen_cb_closure) },
|
||||
{ be_const_key(set_light, -1), be_const_closure(set_light_closure) },
|
||||
{ be_const_key(resp_cmnd_error, -1), be_const_func(l_respCmndError) },
|
||||
{ be_const_key(wire_scan, -1), be_const_closure(wire_scan_closure) },
|
||||
{ be_const_key(yield, -1), be_const_func(l_yield) },
|
||||
{ be_const_key(exec_rules, -1), be_const_closure(exec_rules_closure) },
|
||||
{ be_const_key(log, -1), be_const_func(l_logInfo) },
|
||||
{ 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(remove_cmd, -1), be_const_closure(remove_cmd_closure) },
|
||||
{ be_const_key(get_light, -1), be_const_closure(get_light_closure) },
|
||||
{ be_const_key(_global_def, -1), be_const_comptr(&be_tasmota_global_struct) },
|
||||
{ be_const_key(eth, -1), be_const_func(l_eth) },
|
||||
{ be_const_key(gc, -1), be_const_closure(gc_closure) },
|
||||
{ be_const_key(resp_cmnd_failed, 2), be_const_func(l_respCmndFailed) },
|
||||
{ be_const_key(_get_cb, -1), be_const_func(l_get_cb) },
|
||||
{ be_const_key(run_deferred, -1), be_const_closure(run_deferred_closure) },
|
||||
{ be_const_key(millis, 37), be_const_func(l_millis) },
|
||||
{ be_const_key(_rules, -1), be_const_var(1) },
|
||||
{ be_const_key(time_dump, -1), be_const_func(l_time_dump) },
|
||||
{ be_const_key(cb_dispatch, -1), be_const_closure(cb_dispatch_closure) },
|
||||
{ be_const_key(add_cmd, -1), be_const_closure(add_cmd_closure) },
|
||||
{ be_const_key(publish, 13), be_const_func(l_publish) },
|
||||
{ be_const_key(remove_timer, -1), be_const_closure(remove_timer_closure) },
|
||||
{ be_const_key(remove_driver, -1), be_const_closure(remove_driver_closure) },
|
||||
{ be_const_key(memory, -1), be_const_func(l_memory) },
|
||||
{ be_const_key(load, -1), be_const_closure(load_closure) },
|
||||
{ be_const_key(get_option, -1), be_const_func(l_getoption) },
|
||||
{ be_const_key(resp_cmnd_done, 53), be_const_func(l_respCmndDone) },
|
||||
{ be_const_key(delay, 55), be_const_func(l_delay) },
|
||||
{ be_const_key(add_driver, 62), be_const_closure(add_driver_closure) },
|
||||
{ be_const_key(cmd_res, -1), be_const_var(2) },
|
||||
{ be_const_key(_global_addr, 12), be_const_comptr(&TasmotaGlobal) },
|
||||
{ be_const_key(time_str, 30), be_const_closure(time_str_closure) },
|
||||
{ be_const_key(save, -1), be_const_func(l_save) },
|
||||
{ be_const_key(cmd, -1), be_const_closure(cmd_closure) },
|
||||
{ be_const_key(event, -1), be_const_closure(event_closure) },
|
||||
{ be_const_key(publish_result, -1), be_const_func(l_publish_result) },
|
||||
{ be_const_key(time_reached, 59), be_const_func(l_timereached) },
|
||||
{ be_const_key(scale_uint, -1), be_const_func(l_scaleuint) },
|
||||
{ be_const_key(wifi, -1), be_const_func(l_wifi) },
|
||||
{ be_const_key(_drivers, 4), be_const_var(3) },
|
||||
{ be_const_key(global, -1), be_const_var(4) },
|
||||
{ be_const_key(_cmd, 6), be_const_func(l_cmd) },
|
||||
{ be_const_key(web_send, -1), be_const_func(l_webSend) },
|
||||
{ be_const_key(_ccmd, -1), be_const_var(5) },
|
||||
{ be_const_key(web_send_decimal, -1), be_const_func(l_webSendDecimal) },
|
||||
{ be_const_key(resp_cmnd, -1), be_const_func(l_respCmnd) },
|
||||
{ be_const_key(try_rule, -1), be_const_closure(try_rule_closure) },
|
||||
{ be_const_key(get_power, 43), be_const_func(l_getpower) },
|
||||
{ be_const_key(rtc, -1), be_const_func(l_rtc) },
|
||||
{ be_const_key(get_free_heap, -1), be_const_func(l_getFreeHeap) },
|
||||
{ be_const_key(init, -1), be_const_closure(init_closure) },
|
||||
{ be_const_key(wire2, -1), be_const_var(6) },
|
||||
{ be_const_key(get_switch, -1), be_const_func(l_getswitch) },
|
||||
{ be_const_key(strftime, 16), be_const_func(l_strftime) },
|
||||
{ be_const_key(find_op, 39), be_const_closure(find_op_closure) },
|
||||
{ be_const_key(resp_cmnd, 55), be_const_func(l_respCmnd) },
|
||||
{ be_const_key(i2c_enabled, -1), be_const_func(l_i2cenabled) },
|
||||
{ be_const_key(exec_cmd, -1), be_const_closure(exec_cmd_closure) },
|
||||
{ be_const_key(_timers, -1), be_const_var(7) },
|
||||
{ be_const_key(wire1, 46), be_const_var(8) },
|
||||
{ be_const_key(time_reached, 38), be_const_func(l_timereached) },
|
||||
{ be_const_key(resp_cmnd_error, 3), be_const_func(l_respCmndError) },
|
||||
{ be_const_key(init, -1), be_const_closure(init_closure) },
|
||||
{ be_const_key(eth, 35), be_const_func(l_eth) },
|
||||
{ be_const_key(time_dump, -1), be_const_func(l_time_dump) },
|
||||
{ be_const_key(_rules, 29), be_const_var(1) },
|
||||
{ be_const_key(millis, 41), be_const_func(l_millis) },
|
||||
{ be_const_key(get_option, -1), be_const_func(l_getoption) },
|
||||
{ be_const_key(exec_cmd, 49), be_const_closure(exec_cmd_closure) },
|
||||
{ be_const_key(_cb, -1), be_const_var(2) },
|
||||
{ be_const_key(wire_scan, -1), be_const_closure(wire_scan_closure) },
|
||||
{ be_const_key(response_append, 58), be_const_func(l_respAppend) },
|
||||
{ be_const_key(add_driver, 44), be_const_closure(add_driver_closure) },
|
||||
{ be_const_key(find_key_i, 28), be_const_closure(find_key_i_closure) },
|
||||
{ be_const_key(remove_driver, 34), be_const_closure(remove_driver_closure) },
|
||||
{ be_const_key(get_power, -1), be_const_func(l_getpower) },
|
||||
{ be_const_key(resp_cmnd_str, -1), be_const_func(l_respCmndStr) },
|
||||
{ be_const_key(find_op, 21), be_const_closure(find_op_closure) },
|
||||
{ be_const_key(resolvecmnd, -1), be_const_func(l_resolveCmnd) },
|
||||
{ be_const_key(cb_dispatch, 40), be_const_closure(cb_dispatch_closure) },
|
||||
{ be_const_key(get_free_heap, -1), be_const_func(l_getFreeHeap) },
|
||||
{ be_const_key(log, -1), be_const_func(l_logInfo) },
|
||||
{ be_const_key(cmd_res, 45), be_const_var(3) },
|
||||
{ be_const_key(wire1, 43), be_const_var(4) },
|
||||
{ be_const_key(get_light, -1), be_const_closure(get_light_closure) },
|
||||
{ be_const_key(strftime, -1), be_const_func(l_strftime) },
|
||||
{ be_const_key(set_light, -1), be_const_closure(set_light_closure) },
|
||||
{ be_const_key(global, -1), be_const_var(5) },
|
||||
{ be_const_key(publish_result, -1), be_const_func(l_publish_result) },
|
||||
{ be_const_key(cmd, -1), be_const_closure(cmd_closure) },
|
||||
{ be_const_key(_settings_def, 46), be_const_comptr(&be_tasmota_settings_struct) },
|
||||
{ be_const_key(load, -1), be_const_closure(load_closure) },
|
||||
{ be_const_key(resp_cmnd_done, 23), be_const_func(l_respCmndDone) },
|
||||
{ be_const_key(event, 25), be_const_closure(event_closure) },
|
||||
{ be_const_key(run_deferred, 57), be_const_closure(run_deferred_closure) },
|
||||
{ be_const_key(_ccmd, -1), be_const_var(6) },
|
||||
{ be_const_key(exec_rules, -1), be_const_closure(exec_rules_closure) },
|
||||
{ be_const_key(exec_tele, -1), be_const_closure(exec_tele_closure) },
|
||||
{ be_const_key(remove_rule, 63), be_const_closure(remove_rule_closure) },
|
||||
{ be_const_key(_get_cb, -1), be_const_func(l_get_cb) },
|
||||
{ be_const_key(try_rule, -1), be_const_closure(try_rule_closure) },
|
||||
{ be_const_key(time_str, -1), be_const_closure(time_str_closure) },
|
||||
{ be_const_key(scale_uint, -1), be_const_func(l_scaleuint) },
|
||||
{ be_const_key(gc, -1), be_const_closure(gc_closure) },
|
||||
{ be_const_key(yield, -1), be_const_func(l_yield) },
|
||||
{ be_const_key(web_send_decimal, -1), be_const_func(l_webSendDecimal) },
|
||||
{ be_const_key(_timers, 32), be_const_var(7) },
|
||||
{ be_const_key(get_switch, -1), be_const_func(l_getswitch) },
|
||||
{ be_const_key(remove_cmd, -1), be_const_closure(remove_cmd_closure) },
|
||||
{ be_const_key(memory, -1), be_const_func(l_memory) },
|
||||
{ be_const_key(save, 9), be_const_func(l_save) },
|
||||
{ be_const_key(_settings_ptr, 26), be_const_comptr(&Settings) },
|
||||
{ be_const_key(wire2, -1), be_const_var(8) },
|
||||
{ be_const_key(_cmd, -1), be_const_func(l_cmd) },
|
||||
{ be_const_key(set_timer, -1), be_const_closure(set_timer_closure) },
|
||||
{ be_const_key(_drivers, 1), be_const_var(9) },
|
||||
{ be_const_key(chars_in_string, -1), be_const_closure(chars_in_string_closure) },
|
||||
{ be_const_key(rtc, -1), be_const_func(l_rtc) },
|
||||
{ be_const_key(gen_cb, -1), be_const_closure(gen_cb_closure) },
|
||||
{ be_const_key(wifi, -1), be_const_func(l_wifi) },
|
||||
{ be_const_key(delay, -1), be_const_func(l_delay) },
|
||||
{ be_const_key(_global_def, 37), be_const_comptr(&be_tasmota_global_struct) },
|
||||
{ be_const_key(resp_cmnd_failed, 39), be_const_func(l_respCmndFailed) },
|
||||
};
|
||||
|
||||
static be_define_const_map(
|
||||
be_class_tasmota_map,
|
||||
69
|
||||
73
|
||||
);
|
||||
|
||||
BE_EXPORT_VARIABLE be_define_const_class(
|
||||
be_class_tasmota,
|
||||
9,
|
||||
10,
|
||||
NULL,
|
||||
Tasmota
|
||||
);
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "be_decoder.h"
|
||||
#include "be_debug.h"
|
||||
#include "be_exec.h"
|
||||
#include <limits.h>
|
||||
|
||||
#define OP_NOT_BINARY TokenNone
|
||||
#define OP_NOT_UNARY TokenNone
|
||||
|
@ -30,6 +31,17 @@
|
|||
#define FUNC_METHOD 1
|
||||
#define FUNC_ANONYMOUS 2
|
||||
|
||||
#if BE_INTGER_TYPE == 0 /* int */
|
||||
#define M_IMAX INT_MAX
|
||||
#define M_IMIN INT_MIN
|
||||
#elif BE_INTGER_TYPE == 1 /* long */
|
||||
#define M_IMAX LONG_MAX
|
||||
#define M_IMIN LONG_MIN
|
||||
#else /* int64_t (long long) */
|
||||
#define M_IMAX LLONG_MAX
|
||||
#define M_IMIN LLONG_MIN
|
||||
#endif
|
||||
|
||||
/* get binary operator priority */
|
||||
#define binary_op_prio(op) (binary_op_prio_tab[cast_int(op) - OptAdd])
|
||||
|
||||
|
@ -877,6 +889,30 @@ static void primary_expr(bparser *parser, bexpdesc *e)
|
|||
}
|
||||
}
|
||||
|
||||
/* parse a single string literal as parameter */
|
||||
static void call_single_string_expr(bparser *parser, bexpdesc *e)
|
||||
{
|
||||
bexpdesc arg;
|
||||
bfuncinfo *finfo = parser->finfo;
|
||||
int base;
|
||||
|
||||
/* func 'string_literal' */
|
||||
check_var(parser, e);
|
||||
if (e->type == ETMEMBER) {
|
||||
push_error(parser, "method not allowed for string prefix");
|
||||
}
|
||||
|
||||
base = be_code_nextreg(finfo, e); /* allocate a new base reg if not at top already */
|
||||
simple_expr(parser, &arg);
|
||||
be_code_nextreg(finfo, &arg); /* move result to next reg */
|
||||
|
||||
be_code_call(finfo, base, 1); /* only one arg */
|
||||
if (e->type != ETREG) {
|
||||
e->type = ETREG;
|
||||
e->v.idx = base;
|
||||
}
|
||||
}
|
||||
|
||||
static void suffix_expr(bparser *parser, bexpdesc *e)
|
||||
{
|
||||
primary_expr(parser, e);
|
||||
|
@ -891,6 +927,9 @@ static void suffix_expr(bparser *parser, bexpdesc *e)
|
|||
case OptLSB: /* '[' index */
|
||||
index_expr(parser, e);
|
||||
break;
|
||||
case TokenString:
|
||||
call_single_string_expr(parser, e); /* " string literal */
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
@ -1047,7 +1086,11 @@ static void sub_expr(bparser *parser, bexpdesc *e, int prio)
|
|||
be_code_prebinop(finfo, op, e); /* and or */
|
||||
init_exp(&e2, ETVOID, 0);
|
||||
sub_expr(parser, &e2, binary_op_prio(op)); /* parse right side */
|
||||
check_var(parser, &e2); /* check if valid */
|
||||
if ((e2.type == ETVOID) && (op == OptConnect)) {
|
||||
init_exp(&e2, ETINT, M_IMAX);
|
||||
} else {
|
||||
check_var(parser, &e2); /* check if valid */
|
||||
}
|
||||
be_code_binop(finfo, op, e, &e2, -1); /* encode binary op */
|
||||
op = get_binop(parser); /* is there a following binop? */
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ check(45.e+2, 4500)
|
|||
|
||||
test_source('x = 5; 0...x;', 'unexpected symbol near \'.\'')
|
||||
test_source('x = 5; 0...x;', 'unexpected symbol near \'.\'')
|
||||
test_source('45..', 'unexpected symbol near \'EOS\'')
|
||||
# test_source('45..', 'unexpected symbol near \'EOS\'')
|
||||
test_source('0xg', 'invalid hexadecimal number')
|
||||
test_source('"\\x5g"', 'invalid hexadecimal number')
|
||||
test_source('0x5g', 'malformed number')
|
||||
|
|
|
@ -34,3 +34,8 @@ assert(s.format("%i%%", 12) == "12%")
|
|||
assert(s.format("%i%%%i", 12, 13) == "12%13")
|
||||
assert(s.format("%s%%", "foo") == "foo%")
|
||||
assert(s.format("%.1f%%", 3.5) == "3.5%")
|
||||
|
||||
s="azerty"
|
||||
assert(s[1..2] == "ze")
|
||||
assert(s[1..] == "zerty")
|
||||
assert(s[1..-1] == "zerty")
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
; *** BETA ESP32 Tasmota version ***
|
||||
; *** expect the unexpected. Some features not working!!! ***
|
||||
; *** ESP32 Tasmota version ***
|
||||
|
||||
[esp32_defaults]
|
||||
build_unflags = ${esp_defaults.build_unflags}
|
||||
|
@ -29,7 +28,7 @@ build_flags = ${esp_defaults.build_flags}
|
|||
|
||||
[core32]
|
||||
platform = espressif32 @ 3.3.1
|
||||
platform_packages = framework-arduinoespressif32 @ https://github.com/tasmota/arduino-esp32/releases/download/1.0.7.4/tasmota-arduinoespressif32-release_v3.3.5.tar.gz
|
||||
platform_packages = framework-arduinoespressif32 @ https://github.com/tasmota/arduino-esp32/releases/download/1.0.7.5/tasmota-arduinoespressif32-release_v3.3.5.tar.gz
|
||||
platformio/tool-mklittlefs @ ~1.203.200522
|
||||
build_unflags = ${esp32_defaults.build_unflags}
|
||||
build_flags = ${esp32_defaults.build_flags}
|
||||
|
|
|
@ -50,7 +50,7 @@ build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_TASMOTA32
|
|||
|
||||
[env:tasmota32solo1]
|
||||
extends = env:tasmota32_base
|
||||
platform_packages = framework-arduinoespressif32 @ https://github.com/tasmota/arduino-esp32/releases/download/1.0.7.4/tasmota-arduinoespressif32-solo1-release_v3.3.5.tar.gz
|
||||
platform_packages = framework-arduinoespressif32 @ https://github.com/tasmota/arduino-esp32/releases/download/1.0.7.5/tasmota-arduinoespressif32-solo1-release_v3.3.5.tar.gz
|
||||
platformio/tool-esptoolpy @ ~1.30100
|
||||
platformio/tool-mklittlefs @ ~1.203.200522
|
||||
build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_TASMOTA32
|
||||
|
|
|
@ -991,7 +991,8 @@
|
|||
//#define USE_WEBCAM // Add support for webcam
|
||||
|
||||
#define USE_BERRY // Enable Berry scripting language
|
||||
#define USE_BERRY_TIMEOUT 4000 // Timeout in ms, will raise an exception if running time exceeds this timeout. Must be lower than `WATCHDOG_TASK_SECONDS * 1000` or the hardwware watchdog will fire first
|
||||
#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
|
||||
#define USE_BERRY_PSRAM // Allocate Berry memory in PSRAM if PSRAM is connected - this might be slightly slower but leaves main memory intact
|
||||
// #define USE_BERRY_DEBUG // Compile Berry bytecode with line number information, makes exceptions easier to debug. Adds +8% of memory consumption for compiled code
|
||||
#define USE_WEBCLIENT // Enable `webclient` to make HTTP/HTTPS requests. Can be disabled for security reasons.
|
||||
|
|
|
@ -20,6 +20,6 @@
|
|||
#ifndef _TASMOTA_VERSION_H_
|
||||
#define _TASMOTA_VERSION_H_
|
||||
|
||||
const uint32_t VERSION = 0x0A000000;
|
||||
const uint32_t VERSION = 0x0A000001;
|
||||
|
||||
#endif // _TASMOTA_VERSION_H_
|
||||
|
|
|
@ -806,7 +806,7 @@ bool RulesProcessEvent(const char *json_event)
|
|||
{
|
||||
#ifdef USE_BERRY
|
||||
// events are passed to Berry before Rules engine
|
||||
callBerryRule(json_event);
|
||||
callBerryRule(json_event, Rules.teleperiod);
|
||||
#endif
|
||||
|
||||
if (Rules.busy) { return false; }
|
||||
|
|
|
@ -601,7 +601,7 @@ const char HTTP_EDITOR_FORM_START[] PROGMEM =
|
|||
"<fieldset><legend><b> " D_EDIT_FILE " </b></legend>"
|
||||
"<form>"
|
||||
"<label for='name'>" D_FILE ":</label><input type='text' id='name' name='name' value='%s'><br><hr width='98%%'>"
|
||||
"<textarea id='content' name='content' rows='8' cols='80' style='font-size: 12pt'>";
|
||||
"<textarea id='content' name='content' wrap='off' rows='8' cols='80' style='font-size: 12pt'>";
|
||||
|
||||
const char HTTP_EDITOR_FORM_END[] PROGMEM =
|
||||
"</textarea>"
|
||||
|
|
|
@ -33,11 +33,18 @@ extern "C" {
|
|||
|
||||
extern const be_ctypes_structure_t be_tasmota_global_struct = {
|
||||
sizeof(TasmotaGlobal), /* size in bytes */
|
||||
2, /* number of elements */
|
||||
1, /* number of elements */
|
||||
nullptr,
|
||||
(const be_ctypes_structure_item_t[2]) {
|
||||
{ "energy_driver", offsetof(TasmotaGlobal_t, energy_driver), 0, 0, ctypes_u8, 0 },
|
||||
{ "uptime", offsetof(TasmotaGlobal_t, uptime), 0, 0, ctypes_u32, 0 },
|
||||
{ "sleep", offsetof(TasmotaGlobal_t, sleep), 0, 0, ctypes_u8, 0 },
|
||||
}};
|
||||
|
||||
extern const be_ctypes_structure_t be_tasmota_settings_struct = {
|
||||
sizeof(TSettings), /* size in bytes */
|
||||
1, /* number of elements */
|
||||
nullptr,
|
||||
(const be_ctypes_structure_item_t[2]) {
|
||||
{ "sleep", offsetof(TSettings, sleep), 0, 0, ctypes_u8, 0 },
|
||||
}};
|
||||
|
||||
}
|
||||
|
|
|
@ -26,65 +26,18 @@
|
|||
\*********************************************************************************************/
|
||||
|
||||
const char berry_prog[] =
|
||||
"import persist "
|
||||
// create a 'ntv' module to allow functions to be registered in a safe namespace
|
||||
// "ntv = module('ntv') "
|
||||
|
||||
// auto-import modules
|
||||
// // import alias
|
||||
#ifdef USE_BERRY_PYTHON_COMPAT
|
||||
// enable python syntax compatibility mode
|
||||
"import python_compat "
|
||||
#endif
|
||||
// persistance module
|
||||
"import persist "
|
||||
|
||||
#ifdef USE_ENERGY_SENSOR
|
||||
"import energy "
|
||||
#endif
|
||||
|
||||
|
||||
// // Force gc and return allocated memory
|
||||
// "def gc() "
|
||||
// "import gc "
|
||||
// "gc.collect() "
|
||||
// "return gc.allocated() "
|
||||
// // "end "
|
||||
// // simple wrapper to load a file
|
||||
// // prefixes '/' if needed, and simpler to use than `compile()`
|
||||
// "def load(f) "
|
||||
// "import string "
|
||||
// "try "
|
||||
// // check that the file ends with '.be' of '.bec'
|
||||
// "var fl = string.split(f,'.') "
|
||||
// "if (size(fl) <= 1 || (fl[-1] != 'be' && fl[-1] != 'bec')) "
|
||||
// "raise \"file extension is not '.be' or '.bec'\" "
|
||||
// "end "
|
||||
// "var native = f[size(f)-1] == 'c' "
|
||||
// // add prefix if needed
|
||||
// "if f[0] != '/' f = '/' + f end "
|
||||
// // load - works the same for .be and .bec
|
||||
// "var c = compile(f,'file') "
|
||||
// // save the compiled bytecode
|
||||
// "if !native "
|
||||
// "try "
|
||||
// "self.save(f+'c', c) "
|
||||
// "except .. as e "
|
||||
// "self.log(string.format('BRY: could not save compiled file %s (%s)',f+'c',e)) "
|
||||
// "end "
|
||||
// "end "
|
||||
// // call the compiled code
|
||||
// "c() "
|
||||
// "self.log(string.format(\"BRY: sucessfully loaded '%s'\",f)) "
|
||||
// "except .. as e "
|
||||
// "raise \"io_error\",string.format(\"Could not load file '%s'\",f) "
|
||||
// "end "
|
||||
|
||||
// "end "
|
||||
|
||||
|
||||
// // Monkey patch `Driver` class - To be continued
|
||||
// "class Driver2 : Driver "
|
||||
// "def add_cmd(c, f) "
|
||||
// "var tasmota = self.get_tasmota() "
|
||||
// "tasmota.add_cmd(c, / cmd, idx, payload, payload_json -> f(self, cmd, idx, payload, payload_json)) "
|
||||
// "end "
|
||||
// "end "
|
||||
// "Driver = Driver2 "
|
||||
|
||||
// Instantiate tasmota object
|
||||
"tasmota = Tasmota() "
|
||||
"def log(m,l) tasmota.log(m,l) end "
|
||||
|
@ -97,29 +50,6 @@ const char berry_prog[] =
|
|||
|
||||
#endif // USE_LVGL
|
||||
|
||||
// Wire class
|
||||
// "class Wire : Wire_ntv "
|
||||
// // read bytes as `bytes()` object
|
||||
// "def read_bytes(addr,reg,size) "
|
||||
// "self._begin_transmission(addr) "
|
||||
// "self._write(reg) "
|
||||
// "self._end_transmission(false) "
|
||||
// "self._request_from(addr,size) "
|
||||
// "var ret=bytes(size) "
|
||||
// "while (self._available()) "
|
||||
// "ret..self._read() "
|
||||
// "end "
|
||||
// "return ret "
|
||||
// "end "
|
||||
// // write bytes from `bytes` object
|
||||
// "def write_bytes(addr,reg,b) "
|
||||
// "self._begin_transmission(addr) "
|
||||
// "self._write(reg) "
|
||||
// "self._write(b) "
|
||||
// "self._end_transmission() "
|
||||
// "end "
|
||||
// "end "
|
||||
|
||||
#ifdef USE_I2C
|
||||
"tasmota.wire1 = Wire(1) "
|
||||
"tasmota.wire2 = Wire(2) "
|
||||
|
|
|
@ -95,12 +95,12 @@ extern "C" {
|
|||
// // call a function (if exists) of type void -> void
|
||||
|
||||
// If event == nullptr, then take XdrvMailbox.data
|
||||
bool callBerryRule(const char *event) {
|
||||
bool callBerryRule(const char *event, bool teleperiod) {
|
||||
if (berry.rules_busy) { return false; }
|
||||
berry.rules_busy = true;
|
||||
char * json_event = XdrvMailbox.data;
|
||||
bool serviced = false;
|
||||
serviced = callBerryEventDispatcher(PSTR("rule"), nullptr, 0, event ? event : XdrvMailbox.data);
|
||||
serviced = callBerryEventDispatcher(teleperiod ? "tele" : "rule", nullptr, 0, event ? event : XdrvMailbox.data);
|
||||
berry.rules_busy = false;
|
||||
return serviced; // TODO event not handled
|
||||
}
|
||||
|
@ -760,7 +760,10 @@ bool Xdrv52(uint8_t function)
|
|||
|
||||
// Berry wide commands and events
|
||||
case FUNC_RULES_PROCESS:
|
||||
result = callBerryRule(nullptr);
|
||||
result = callBerryRule(nullptr, false);
|
||||
break;
|
||||
case FUNC_TELEPERIOD_RULES_PROCESS:
|
||||
result = callBerryRule(nullptr, true);
|
||||
break;
|
||||
case FUNC_MQTT_DATA:
|
||||
result = callBerryEventDispatcher(PSTR("mqtt_data"), XdrvMailbox.topic, 0, XdrvMailbox.data, XdrvMailbox.data_len);
|
||||
|
|
Loading…
Reference in New Issue