Skip to content

Commit b99cb41

Browse files
authored
Merge branch 'arendst:development' into IDF54
2 parents 2afc61d + 5089922 commit b99cb41

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+2533
-608
lines changed

BUILDS.md

+2
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,9 @@ Note: the `minimal` variant is not listed as it shouldn't be used outside of the
229229
| USE_MIEL_HVAC | - | - / - | - | - | - | - |
230230
| USE_PROJECTOR_CTRL | - | - / - | - | - | - | - |
231231
| USE_AS608 | - | - / - | - | - | - | - |
232+
| USE_LD2402 | - | - / - | - | - | - | - |
232233
| USE_LD2410 | - | - / - | - | - | - | - |
234+
| USE_LD2410S | - | - / - | - | - | - | - |
233235
| USE_GM861 | - | - / - | - | - | - | - |
234236
| USE_TCP_BRIDGE | - | - / - | - | - | - | - | zbbridge / zbbrdgpro |
235237
| USE_HC8 | - | - / - | - | - | - | - |

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ All notable changes to this project will be documented in this file.
66
## [14.5.0.2]
77
### Added
88
- Berry load `.tapp` files in `/.extensions/` then in `/` (#23113)
9+
- Support Vango Technologies V924x ultralow power, single-phase, power measurement (#23127)
10+
- Support for HLK-LD2402 24GHz smart wave motion sensor (#23133)
911

1012
### Breaking Changed
1113
- Berry remove `Leds.create_matrix` from the standard library waiting for reimplementation (#23114)
@@ -14,6 +16,8 @@ All notable changes to this project will be documented in this file.
1416
- ESP32 Platform from 2025.02.30 to 2025.03.30, Framework (Arduino Core) from v3.1.1.250203 to v3.1.3.250302 and IDF from v5.3.2.250120 to 5.3.2.250228 (#23088)
1517
- ESP32 enable webcam version 2 (#18732)
1618
- ESP8266 enable FTP for >= 4MB variants (#23120)
19+
- Berry update flasher for Sonoff ZBBridge Pro (#23136)
20+
- Berry `re` now accepts `bytes()` as precompiled patterns, added `re.compilebytes()` (#23149)
1721

1822
### Fixed
1923
- Berry prevent `import` from hiding a solidified class (#23112)

RELEASENOTES.md

+4
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm
116116

117117
## Changelog v14.5.0.2
118118
### Added
119+
- Support Vango Technologies V924x ultralow power, single-phase, power measurement [#23127](https://github.com/arendst/Tasmota/issues/23127)
120+
- Support for HLK-LD2402 24GHz smart wave motion sensor [#23133](https://github.com/arendst/Tasmota/issues/23133)
119121
- Allow acl in mqtt when client certificate is in use with `#define USE_MQTT_CLIENT_CERT` [#22998](https://github.com/arendst/Tasmota/issues/22998)
120122
- Berry experimental driver for AXP2101 for M5Core2v1.1 [#23039](https://github.com/arendst/Tasmota/issues/23039)
121123
- Berry `tasmota.when_network_up()` and simplified Matter using it [#23057](https://github.com/arendst/Tasmota/issues/23057)
@@ -132,6 +134,8 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm
132134
- GPIOViewer from v1.6.1 to v1.6.2 (No functional change)
133135
- ESP8266 enable FTP for >= 4MB variants [#23120](https://github.com/arendst/Tasmota/issues/23120)
134136
- ESP32 enable webcam version 2 [#18732](https://github.com/arendst/Tasmota/issues/18732)
137+
- Berry update flasher for Sonoff ZBBridge Pro [#23136](https://github.com/arendst/Tasmota/issues/23136)
138+
- Berry `re` now accepts `bytes()` as precompiled patterns, added `re.compilebytes()` [#23149](https://github.com/arendst/Tasmota/issues/23149)
135139
- LVGL, prepare for HASPmota theme, change: no-grow when clicked, DPI set to 160 [#23040](https://github.com/arendst/Tasmota/issues/23040)
136140
- LVGL Mirroring add checkbox to enable/disable the feature (in the iterim for a better solution) [#23047](https://github.com/arendst/Tasmota/issues/23047)
137141
- Leds Panel add checkbox to enable/disable the feature (in the iterim for a better solution) [#23048](https://github.com/arendst/Tasmota/issues/23048)

lib/libesp32/berry/default/be_modtab.c

-2
Original file line numberDiff line numberDiff line change
@@ -283,15 +283,13 @@ BERRY_LOCAL bclass_array be_class_table = {
283283
&be_native_class(AXP2102),
284284
#endif // USE_I2C
285285
&be_native_class(md5),
286-
#ifdef USE_WEBCLIENT
287286
&be_native_class(udp),
288287
&be_native_class(webclient),
289288
&be_native_class(tcpclient),
290289
&be_native_class(tcpclientasync),
291290
#ifdef USE_BERRY_DEBUG
292291
&be_native_class(webserver_async), // include only when USE_BERRY_DEBUG is enabled
293292
#endif // USE_BERRY_DEBUG
294-
#endif // USE_WEBCLIENT
295293
#ifdef USE_BERRY_TCPSERVER
296294
&be_native_class(tcpserver),
297295
#endif // USE_BERRY_TCPSERVER

lib/libesp32/berry/default/be_re_lib.c

+89-43
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,25 @@ int be_re_compile(bvm *vm) {
6464
be_raise(vm, "type_error", NULL);
6565
}
6666

67+
// Native functions be_const_func()
68+
// Berry: `re.compilebytes(pattern:string) -> instance(bytes)`
69+
int be_re_compilebytes(bvm *vm) {
70+
int32_t argc = be_top(vm); // Get the number of arguments
71+
if (argc >= 1 && be_isstring(vm, 1)) {
72+
const char * regex_str = be_tostring(vm, 1);
73+
int sz = re1_5_sizecode(regex_str);
74+
if (sz < 0) {
75+
be_raise(vm, "internal_error", "error in regex");
76+
}
77+
78+
be_pushbytes(vm, NULL, sizeof(ByteProg) + sz);
79+
ByteProg *code = (ByteProg*) be_tobytes(vm, -1, NULL);
80+
re1_5_compilecode(code, regex_str);
81+
be_return(vm);
82+
}
83+
be_raise(vm, "type_error", NULL);
84+
}
85+
6786
// pushes either a list if matched, else `nil`
6887
// return index of next offset, or -1 if not found
6988
const char *be_re_match_search_run(bvm *vm, ByteProg *code, const char *hay, bbool is_anchored, bbool size_only) {
@@ -99,9 +118,10 @@ const char *be_re_match_search_run(bvm *vm, ByteProg *code, const char *hay, bbo
99118

100119
int be_re_match_search(bvm *vm, bbool is_anchored, bbool size_only) {
101120
int32_t argc = be_top(vm); // Get the number of arguments
102-
if (argc >= 2 && be_isstring(vm, 1) && be_isstring(vm, 2)) {
103-
const char * regex_str = be_tostring(vm, 1);
121+
if (argc >= 2 && (be_isstring(vm, 1) || be_isbytes(vm, 1)) && be_isstring(vm, 2)) {
104122
const char * hay = be_tostring(vm, 2);
123+
ByteProg *code = NULL;
124+
105125
int32_t offset = 0;
106126
if (argc >= 3 && be_isint(vm, 3)) {
107127
offset = be_toint(vm, 3);
@@ -111,49 +131,64 @@ int be_re_match_search(bvm *vm, bbool is_anchored, bbool size_only) {
111131
if (offset >= hay_len) { be_return_nil(vm); } // any match of empty string returns nil, this catches implicitly when hay_len == 0
112132
hay += offset; // shift to offset
113133

114-
int sz = re1_5_sizecode(regex_str);
115-
if (sz < 0) {
116-
be_raise(vm, "internal_error", "error in regex");
117-
}
134+
if (be_isstring(vm, 1)) {
135+
const char * regex_str = be_tostring(vm, 1);
136+
int sz = re1_5_sizecode(regex_str);
137+
if (sz < 0) {
138+
be_raise(vm, "internal_error", "error in regex");
139+
}
118140

119-
ByteProg *code = be_os_malloc(sizeof(ByteProg) + sz);
120-
if (code == NULL) {
121-
be_throw(vm, BE_MALLOC_FAIL); /* lack of heap space */
141+
code = be_os_malloc(sizeof(ByteProg) + sz);
142+
if (code == NULL) {
143+
be_throw(vm, BE_MALLOC_FAIL); /* lack of heap space */
144+
}
145+
int ret = re1_5_compilecode(code, regex_str);
146+
if (ret != 0) {
147+
be_os_free(code);
148+
be_raise(vm, "internal_error", "error in regex");
149+
}
150+
} else {
151+
code = (ByteProg *) be_tobytes(vm, 1, NULL);
122152
}
123-
int ret = re1_5_compilecode(code, regex_str);
124-
if (ret != 0) {
153+
// do the match
154+
be_re_match_search_run(vm, code, hay, is_anchored, size_only);
155+
// cleanup
156+
if (be_isstring(vm, 1)) {
125157
be_os_free(code);
126-
be_raise(vm, "internal_error", "error in regex");
127158
}
128-
be_re_match_search_run(vm, code, hay, is_anchored, size_only);
129-
be_os_free(code);
130159
be_return(vm);
131160
}
132161
be_raise(vm, "type_error", NULL);
133162
}
134163

135164
int be_re_match_search_all(bvm *vm, bbool is_anchored) {
136165
int32_t argc = be_top(vm); // Get the number of arguments
137-
if (argc >= 2 && be_isstring(vm, 1) && be_isstring(vm, 2)) {
138-
const char * regex_str = be_tostring(vm, 1);
166+
if (argc >= 2 && (be_isstring(vm, 1) || be_isbytes(vm, 1)) && be_isstring(vm, 2)) {
139167
const char * hay = be_tostring(vm, 2);
168+
ByteProg *code = NULL;
140169
int limit = -1;
141170
if (argc >= 3) {
142171
limit = be_toint(vm, 3);
143172
}
144-
int sz = re1_5_sizecode(regex_str);
145-
if (sz < 0) {
146-
be_raise(vm, "internal_error", "error in regex");
147-
}
148173

149-
ByteProg *code = be_os_malloc(sizeof(ByteProg) + sz);
150-
if (code == NULL) {
151-
be_throw(vm, BE_MALLOC_FAIL); /* lack of heap space */
152-
}
153-
int ret = re1_5_compilecode(code, regex_str);
154-
if (ret != 0) {
155-
be_os_free(code);
156-
be_raise(vm, "internal_error", "error in regex");
174+
if (be_isstring(vm, 1)) {
175+
const char * regex_str = be_tostring(vm, 1);
176+
int sz = re1_5_sizecode(regex_str);
177+
if (sz < 0) {
178+
be_raise(vm, "internal_error", "error in regex");
179+
}
180+
181+
code = be_os_malloc(sizeof(ByteProg) + sz);
182+
if (code == NULL) {
183+
be_throw(vm, BE_MALLOC_FAIL); /* lack of heap space */
184+
}
185+
int ret = re1_5_compilecode(code, regex_str);
186+
if (ret != 0) {
187+
be_os_free(code);
188+
be_raise(vm, "internal_error", "error in regex");
189+
}
190+
} else {
191+
code = (ByteProg *) be_tobytes(vm, 1, NULL);
157192
}
158193

159194
be_newobject(vm, "list");
@@ -165,7 +200,10 @@ int be_re_match_search_all(bvm *vm, bbool is_anchored) {
165200
be_pop(vm, 1);
166201
}
167202
be_pop(vm, 1);
168-
be_os_free(code);
203+
// cleanup
204+
if (be_isstring(vm, 1)) {
205+
be_os_free(code);
206+
}
169207
be_return(vm);
170208
}
171209
be_raise(vm, "type_error", NULL);
@@ -329,29 +367,36 @@ int re_pattern_split(bvm *vm) {
329367
// Berry: `re.split(pattern:string, s:string [, split_limit:int]) -> list(string)`
330368
int be_re_split(bvm *vm) {
331369
int32_t argc = be_top(vm); // Get the number of arguments
332-
if (argc >= 2 && be_isstring(vm, 1) && be_isstring(vm, 2)) {
333-
const char * regex_str = be_tostring(vm, 1);
370+
if (argc >= 2 && (be_isstring(vm, 1) || be_isbytes(vm, 1)) && be_isstring(vm, 2)) {
334371
const char * hay = be_tostring(vm, 2);
372+
ByteProg *code = NULL;
335373
int split_limit = -1;
336374
if (argc >= 3) {
337375
split_limit = be_toint(vm, 3);
338376
}
339-
int sz = re1_5_sizecode(regex_str);
340-
if (sz < 0) {
341-
be_raise(vm, "internal_error", "error in regex");
342-
}
377+
if (be_isstring(vm, 1)) {
378+
const char * regex_str = be_tostring(vm, 1);
379+
int sz = re1_5_sizecode(regex_str);
380+
if (sz < 0) {
381+
be_raise(vm, "internal_error", "error in regex");
382+
}
343383

344-
ByteProg *code = be_os_malloc(sizeof(ByteProg) + sz);
345-
if (code == NULL) {
346-
be_throw(vm, BE_MALLOC_FAIL); /* lack of heap space */
384+
code = be_os_malloc(sizeof(ByteProg) + sz);
385+
if (code == NULL) {
386+
be_throw(vm, BE_MALLOC_FAIL); /* lack of heap space */
387+
}
388+
int ret = re1_5_compilecode(code, regex_str);
389+
if (ret != 0) {
390+
be_os_free(code);
391+
be_raise(vm, "internal_error", "error in regex");
392+
}
393+
} else {
394+
code = (ByteProg *) be_tobytes(vm, 1, NULL);
347395
}
348-
int ret = re1_5_compilecode(code, regex_str);
349-
if (ret != 0) {
396+
int ret = re_pattern_split_run(vm, code, hay, split_limit);
397+
if (be_isstring(vm, 1)) {
350398
be_os_free(code);
351-
be_raise(vm, "internal_error", "error in regex");
352399
}
353-
ret = re_pattern_split_run(vm, code, hay, split_limit);
354-
be_os_free(code);
355400
return ret;
356401
}
357402
be_raise(vm, "type_error", NULL);
@@ -363,6 +408,7 @@ int be_re_split(bvm *vm) {
363408
@const_object_info_begin
364409
module re (scope: global) {
365410
compile, func(be_re_compile)
411+
compilebytes, func(be_re_compilebytes)
366412
search, func(be_re_search)
367413
searchall, func(be_re_search_all)
368414
match, func(be_re_match)

lib/libesp32/berry/default/berry.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ int main(int argc, char *argv[])
405405
{
406406
int res;
407407
bvm *vm = be_vm_new(); /* create a virtual machine instance */
408-
be_set_ctype_func_hanlder(vm, be_call_ctype_func);
408+
be_set_ctype_func_handler(vm, be_call_ctype_func);
409409
res = analysis_args(vm, argc, argv);
410410
be_vm_delete(vm); /* free all objects and vm */
411411
return res;

lib/libesp32/berry/src/be_vm.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1408,7 +1408,7 @@ BERRY_API void be_set_obs_micros(bvm *vm, bmicrosfnct micros)
14081408
vm->microsfnct = micros;
14091409
}
14101410

1411-
BERRY_API void be_set_ctype_func_hanlder(bvm *vm, bctypefunc handler)
1411+
BERRY_API void be_set_ctype_func_handler(bvm *vm, bctypefunc handler)
14121412
{
14131413
vm->ctypefunc = handler;
14141414
}

lib/libesp32/berry/src/berry.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -2168,14 +2168,14 @@ BERRY_API void be_set_obs_micros(bvm *vm, bmicrosfnct micros);
21682168

21692169

21702170
/**
2171-
* @fn void be_set_ctype_func_hanlder(bvm*, bctypefunc)
2171+
* @fn void be_set_ctype_func_handler(bvm*, bctypefunc)
21722172
* @note Observability hook
21732173
* @brief (???)
21742174
*
21752175
* @param vm virtual machine instance
21762176
* @param handler
21772177
*/
2178-
BERRY_API void be_set_ctype_func_hanlder(bvm *vm, bctypefunc handler);
2178+
BERRY_API void be_set_ctype_func_handler(bvm *vm, bctypefunc handler);
21792179

21802180
/**
21812181
* @fn bctypefunc be_get_ctype_func_hanlder(bvm*)

lib/libesp32/berry/tests/re.be

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# test regex from re1.5
2+
import re
3+
4+
# standard use of lib
5+
assert(re.search("a.*?b(z+)", "zaaaabbbccbbzzzee") == ['aaaabbbccbbzzz', 'zzz'])
6+
assert(re.searchall('<([a-zA-Z]+)>', '<abc> yeah <xyz>') == [['<abc>', 'abc'], ['<xyz>', 'xyz']])
7+
8+
assert(re.match("a.*?b(z+)", "aaaabbbccbbzzzee") == ['aaaabbbccbbzzz', 'zzz'])
9+
assert(re.match2("a.*?b(z+)", "aaaabbbccbbzzzee") == [14, 'zzz'])
10+
assert(re.matchall('<([a-zA-Z]+)>', '<abc> yeah <xyz>') == [['<abc>', 'abc']])
11+
assert(re.matchall('<([a-zA-Z]+)>', '<abc><xyz>') == [['<abc>', 'abc'], ['<xyz>', 'xyz']])
12+
assert(re.split('/', "foo/bar//baz") == ['foo', 'bar', '', 'baz'])
13+
14+
# pre-compile
15+
var rr
16+
rr = re.compile("a.*?b(z+)")
17+
assert(rr.search("zaaaabbbccbbzzzee") == ['aaaabbbccbbzzz', 'zzz'])
18+
rr = re.compile('<([a-zA-Z]+)>')
19+
assert(rr.searchall('<abc> yeah <xyz>') == [['<abc>', 'abc'], ['<xyz>', 'xyz']])
20+
21+
rr = re.compile("a.*?b(z+)")
22+
assert(rr.match("aaaabbbccbbzzzee") == ['aaaabbbccbbzzz', 'zzz'])
23+
assert(rr.match2("aaaabbbccbbzzzee") == [14, 'zzz'])
24+
rr = re.compile('<([a-zA-Z]+)>')
25+
assert(rr.matchall('<abc> yeah <xyz>') == [['<abc>', 'abc']])
26+
assert(rr.matchall('<abc><xyz>') == [['<abc>', 'abc'], ['<xyz>', 'xyz']])
27+
rr = re.compile('/')
28+
assert(rr.split("foo/bar//baz") == ['foo', 'bar', '', 'baz'])
29+
30+
# compile to bytes
31+
var rb
32+
rb = re.compilebytes("a.*?b(z+)")
33+
assert(re.search(rb, "zaaaabbbccbbzzzee") == ['aaaabbbccbbzzz', 'zzz'])
34+
assert(rb == bytes('1B0000000F0000000100000062030260FB7E00016162030260FB01627E02017A62FC7E037E017F'))
35+
36+
rb = re.compilebytes('<([a-zA-Z]+)>')
37+
assert(re.searchall(rb, '<abc> yeah <xyz>') == [['<abc>', 'abc'], ['<xyz>', 'xyz']])
38+
assert(rb == bytes('1A0000000C0000000100000062030260FB7E00013C7E020302617A415A62F87E03013E7E017F'))
39+
40+
rb = re.compilebytes("a.*?b(z+)")
41+
assert(re.match(rb, "aaaabbbccbbzzzee") == ['aaaabbbccbbzzz', 'zzz'])
42+
assert(re.match2(rb, "aaaabbbccbbzzzee") == [14, 'zzz'])
43+
assert(rb == bytes('1B0000000F0000000100000062030260FB7E00016162030260FB01627E02017A62FC7E037E017F'))
44+
45+
rb = re.compilebytes('<([a-zA-Z]+)>')
46+
assert(re.matchall(rb, '<abc> yeah <xyz>') == [['<abc>', 'abc']])
47+
assert(re.matchall(rb, '<abc><xyz>') == [['<abc>', 'abc'], ['<xyz>', 'xyz']])
48+
assert(rb == bytes('1A0000000C0000000100000062030260FB7E00013C7E020302617A415A62F87E03013E7E017F'))
49+
50+
rb = re.compilebytes('/')
51+
assert(re.split(rb, "foo/bar//baz") == ['foo', 'bar', '', 'baz'])
52+
assert(rb == bytes('0C000000070000000000000062030260FB7E00012F7E017F'))

lib/libesp32/berry_mapping/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ You need to register the ctype function handler at the launch of the Berry VM:
171171
void berry_launch(boid)
172172
{
173173
bvm *vm = be_vm_new(); /* Construct a VM */
174-
be_set_ctype_func_hanlder(berry.vm, be_call_ctype_func); /* register the ctype function handler */
174+
be_set_ctype_func_handler(berry.vm, be_call_ctype_func); /* register the ctype function handler */
175175
}
176176
```
177177

lib/libesp32/berry_tasmota/src/be_tcpclient_lib.c

-4
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
*******************************************************************/
77
#include "be_constobj.h"
88

9-
#ifdef USE_WEBCLIENT
10-
119
extern int wc_tcp_init(bvm *vm);
1210
extern int wc_tcp_deinit(bvm *vm);
1311

@@ -44,5 +42,3 @@ class be_class_tcpclient (scope: global, name: tcpclient) {
4442
readbytes, func(wc_tcp_readbytes)
4543
}
4644
@const_object_info_end */
47-
48-
#endif // USE_WEBCLIENT

lib/libesp32/berry_tasmota/src/be_tcpclientasyc_lib.c

-4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
*******************************************************************/
66
#include "be_constobj.h"
77

8-
#ifdef USE_WEBCLIENT
9-
108
extern int wc_tcpasync_init(bvm *vm);
119
extern int wc_tcpasync_deinit(bvm *vm);
1210

@@ -42,5 +40,3 @@ class be_class_tcpclientasync (scope: global, name: tcpclientasync) {
4240
readbytes, func(wc_tcpasync_readbytes)
4341
}
4442
@const_object_info_end */
45-
46-
#endif // USE_WEBCLIENT

0 commit comments

Comments
 (0)