Skip to content

Commit cbc74ab

Browse files
committed
Merge branch 'development' into pre-release-9.5.0
2 parents 9299445 + 542074e commit cbc74ab

File tree

10 files changed

+105
-101
lines changed

10 files changed

+105
-101
lines changed

lib/libesp32/Berry/src/be_class.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ static binstance* newobjself(bvm *vm, bclass *c)
165165
while (v < end) { var_setnil(v); ++v; }
166166
obj->_class = c;
167167
obj->super = NULL;
168+
obj->sub = NULL;
168169
}
169170
return obj;
170171
}
@@ -178,6 +179,7 @@ static binstance* newobject(bvm *vm, bclass *c)
178179
be_incrtop(vm); /* protect new objects from GC */
179180
for (c = c->super; c; c = c->super) {
180181
prev->super = newobjself(vm, c);
182+
prev->super->sub = prev;
181183
prev = prev->super;
182184
}
183185
be_stackpop(vm, 1);

lib/libesp32/Berry/src/be_class.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@
1818
#define be_class_members(cl) ((cl)->members)
1919
#define be_class_super(cl) ((cl)->super)
2020
#define be_class_setsuper(self, sup) ((self)->super = (sup))
21+
#define be_class_setsub(self, sub) ((self)->sub = (sub))
2122
#define be_instance_name(obj) ((obj)->_class->name)
2223
#define be_instance_class(obj) ((obj)->_class)
2324
#define be_instance_members(obj) ((obj)->members)
2425
#define be_instance_member_count(obj) ((obj)->_class->nvar)
2526
#define be_instance_super(obj) ((obj)->super)
27+
#define be_instance_sub(obj) ((obj)->sub)
2628

2729
struct bclass {
2830
bcommon_header;
@@ -41,6 +43,7 @@ struct bclass {
4143
struct binstance {
4244
bcommon_header;
4345
struct binstance *super;
46+
struct binstance *sub;
4447
bclass *_class;
4548
bgcobject *gray; /* for gc gray list */
4649
bvalue members[1]; /* members variable data field */

lib/libesp32/Berry/src/be_func.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,22 @@ void be_initupvals(bvm *vm, bclosure *cl)
5454
void be_upvals_close(bvm *vm, bvalue *level)
5555
{
5656
bupval *node = vm->upvalist, *next;
57-
while (node && node->value >= level) {
57+
bupval **prev = &vm->upvalist;
58+
while (node) {
5859
next = node->u.next;
59-
if (!node->refcnt) {
60-
be_free(vm, node, sizeof(bupval));
60+
if (node->value >= level) {
61+
if (!node->refcnt) {
62+
be_free(vm, node, sizeof(bupval));
63+
} else {
64+
node->u.value = *node->value; /* move value to upvalue slot */
65+
node->value = &node->u.value;
66+
}
67+
*prev = next; /* remove from linked list */
6168
} else {
62-
node->u.value = *node->value; /* move value to upvalue slot */
63-
node->value = &node->u.value;
69+
prev = &node->u.next;
6470
}
6571
node = next;
6672
}
67-
vm->upvalist = node;
6873
}
6974

7075
void be_release_upvalues(bvm *vm, bclosure *cl)

lib/libesp32/Berry/src/be_vm.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,11 @@ static void vm_exec(bvm *vm)
779779
int type = obj_attribute(vm, b, c, a);
780780
reg = vm->reg;
781781
if (basetype(type) == BE_FUNCTION) {
782+
/* check if the object is a superinstance, if so get the lowest possible subclass */
783+
while (obj->sub) {
784+
obj = obj->sub;
785+
}
786+
var_setobj(&self, var_type(&self), obj); /* replace superinstance by lowest subinstance */
782787
a[1] = self;
783788
} else {
784789
vm_error(vm, "attribute_error",

lib/libesp32/Berry/tests/closure.be

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#- test for issue #105 -#
2+
3+
l=[]
4+
def tick()
5+
var start=100
6+
for i : 1..3
7+
l.push(def () return [i, start] end)
8+
end
9+
end
10+
tick()
11+
assert(l[0]() == [1, 100])
12+
assert(l[1]() == [2, 100])
13+
assert(l[2]() == [3, 100])

tasmota/xdrv_01_webserver.ino

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,9 @@ void WebSliderColdWarm(void)
10171017

10181018
void HandleRoot(void)
10191019
{
1020+
#ifndef NO_CAPTIVE_PORTAL
10201021
if (CaptivePortal()) { return; } // If captive portal redirect instead of displaying the page.
1022+
#endif // NO_CAPTIVE_PORTAL
10211023

10221024
if (Webserver->hasArg(F("rst"))) {
10231025
WebRestart(0);
@@ -2941,8 +2943,9 @@ void HandleConsoleRefresh(void)
29412943
void HandleNotFound(void)
29422944
{
29432945
// AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP "Not found (%s)"), Webserver->uri().c_str());
2944-
2946+
#ifndef NO_CAPTIVE_PORTAL
29452947
if (CaptivePortal()) { return; } // If captive portal redirect instead of displaying the error page.
2948+
#endif // NO_CAPTIVE_PORTAL
29462949

29472950
#ifdef USE_EMULATION
29482951
#ifdef USE_EMULATION_HUE
@@ -2962,6 +2965,7 @@ void HandleNotFound(void)
29622965
}
29632966
}
29642967

2968+
#ifndef NO_CAPTIVE_PORTAL
29652969
/* Redirect to captive portal if we got a request for another domain. Return true in that case so the page handler do not try to handle the request again. */
29662970
bool CaptivePortal(void)
29672971
{
@@ -2976,6 +2980,7 @@ bool CaptivePortal(void)
29762980
}
29772981
return false;
29782982
}
2983+
#endif // NO_CAPTIVE_PORTAL
29792984

29802985
/*********************************************************************************************/
29812986

tasmota/xdrv_04_light.ino

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2497,11 +2497,18 @@ void CmndSupportColor(void)
24972497
else {
24982498
#endif // USE_LIGHT_PALETTE
24992499
uint32_t old_bri = light_state.getBri();
2500+
uint32_t old_bri_rgb = light_state.getBriRGB();
25002501
// change all channels to specified values
25012502
light_controller.changeChannels(Light.entry_color);
25022503
if (2 == XdrvMailbox.index) {
25032504
// If Color2, set back old brightness
2504-
LightSetBriScaled(old_bri);
2505+
if (light_controller.isCTRGBLinked()) {
2506+
// RGB and white are linked, adjust brightness of all channels
2507+
LightSetBriScaled(old_bri);
2508+
} else {
2509+
// RGB and white are unlinked, adjust brightness only of RGB channels
2510+
LightSetBri(Light.device, old_bri_rgb);
2511+
}
25052512
}
25062513
#ifdef USE_LIGHT_PALETTE
25072514
}

tasmota/xdrv_52_9_berry.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ const char HTTP_BERRY_FORM_CMND[] PROGMEM =
593593
"<br>"
594594
"<div contenteditable='false' class='br0 bro' readonly id='t1' cols='340' wrap='off'>"
595595
"<div class='br1'>Welcome to the Berry Scripting console. "
596-
"Check the <a href='https://tasmota.github.io/docs/Berry-Scripting/' target='_blank'>documentation</a>."
596+
"Check the <a href='https://tasmota.github.io/docs/Berry/' target='_blank'>documentation</a>."
597597
"</div>"
598598
"</div>"
599599
// "<textarea readonly id='t1' cols='340' wrap='off'></textarea>"

tasmota/xdrv_79_esp32_ble.ino

Lines changed: 55 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,22 +1408,16 @@ class BLEAdvCallbacks: public NimBLEAdvertisedDeviceCallbacks {
14081408

14091409
// call anyone who asked about advertisements
14101410
for (int i = 0; i < advertismentCallbacks.size(); i++) {
1411-
try {
1412-
ADVERTISMENT_CALLBACK* pFN;
1413-
pFN = advertismentCallbacks[i];
1414-
int res = pFN(&BLEAdvertisment);
1411+
ADVERTISMENT_CALLBACK* pFN;
1412+
pFN = advertismentCallbacks[i];
1413+
int res = pFN(&BLEAdvertisment);
14151414

1416-
// if this callback wants to stop here, then do so.
1417-
if (1 == res) break;
1415+
// if this callback wants to stop here, then do so.
1416+
if (1 == res) break;
14181417

1419-
// if this callback wants to kill this device
1420-
if (2 == res) {
1421-
//BLEScan->erase(address);
1422-
}
1423-
} catch(const std::exception& e){
1424-
#ifdef BLE_ESP32_DEBUG
1425-
AddLog(LOG_LEVEL_ERROR,PSTR("BLE: exception in advertismentCallbacks"));
1426-
#endif
1418+
// if this callback wants to kill this device
1419+
if (2 == res) {
1420+
//BLEScan->erase(address);
14271421
}
14281422
}
14291423

@@ -1444,17 +1438,11 @@ static void BLEscanEndedCB(NimBLEScanResults results){
14441438
if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: Scan ended"));
14451439
#endif
14461440
for (int i = 0; i < scancompleteCallbacks.size(); i++){
1447-
try {
1448-
SCANCOMPLETE_CALLBACK *pFn = scancompleteCallbacks[i];
1449-
int callbackres = pFn(results);
1450-
#ifdef BLE_ESP32_DEBUG
1451-
if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: scancompleteCallbacks %d %d"), i, callbackres);
1452-
#endif
1453-
} catch(const std::exception& e){
1441+
SCANCOMPLETE_CALLBACK *pFn = scancompleteCallbacks[i];
1442+
int callbackres = pFn(results);
14541443
#ifdef BLE_ESP32_DEBUG
1455-
AddLog(LOG_LEVEL_ERROR,PSTR("BLE: exception in operationsCallbacks"));
1444+
if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: scancompleteCallbacks %d %d"), i, callbackres);
14561445
#endif
1457-
}
14581446
}
14591447

14601448
BLERunningScan = 2;
@@ -1659,23 +1647,17 @@ static void BLETaskStopStartNimBLE(NimBLEClient **ppClient, bool start = true){
16591647

16601648
(*ppClient)->setClientCallbacks(nullptr, false);
16611649

1662-
try {
1663-
if ((*ppClient)->isConnected()){
1664-
#ifdef BLE_ESP32_DEBUG
1665-
AddLog(LOG_LEVEL_INFO,PSTR("BLE: disconnecting connected client"));
1666-
#endif
1667-
(*ppClient)->disconnect();
1668-
}
1669-
NimBLEDevice::deleteClient((*ppClient));
1670-
(*ppClient) = nullptr;
1650+
if ((*ppClient)->isConnected()){
16711651
#ifdef BLE_ESP32_DEBUG
1672-
AddLog(LOG_LEVEL_INFO,PSTR("BLE: deleted client"));
1652+
AddLog(LOG_LEVEL_INFO,PSTR("BLE: disconnecting connected client"));
16731653
#endif
1674-
} catch(const std::exception& e){
1654+
(*ppClient)->disconnect();
1655+
}
1656+
NimBLEDevice::deleteClient((*ppClient));
1657+
(*ppClient) = nullptr;
16751658
#ifdef BLE_ESP32_DEBUG
1676-
AddLog(LOG_LEVEL_ERROR,PSTR("BLE: Stopping NimBLE:exception in delete client"));
1659+
AddLog(LOG_LEVEL_INFO,PSTR("BLE: deleted client"));
16771660
#endif
1678-
}
16791661

16801662
if (ble32Scan){
16811663
ble32Scan->setAdvertisedDeviceCallbacks(nullptr,true);
@@ -2089,47 +2071,41 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe
20892071

20902072
// for safety's sake, only call from the run task
20912073
static void BLETaskRunTaskDoneOperation(BLE_ESP32::generic_sensor_t** op, NimBLEClient **ppClient){
2092-
try {
2093-
if ((*ppClient)->isConnected()){
2074+
if ((*ppClient)->isConnected()){
20942075
#ifdef BLE_ESP32_DEBUG
2095-
if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: runTaskDoneOperation: disconnecting connected client"));
2076+
if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: runTaskDoneOperation: disconnecting connected client"));
20962077
#endif
2097-
(*ppClient)->disconnect();
2098-
// wait for 1/2 second after disconnect
2099-
int waits = 0;
2100-
do {
2101-
vTaskDelay(500/ portTICK_PERIOD_MS);
2102-
if (waits) {
2103-
//(*ppClient)->disconnect();
2104-
// we will stall here forever!!! - as testing
2078+
(*ppClient)->disconnect();
2079+
// wait for 1/2 second after disconnect
2080+
int waits = 0;
2081+
do {
2082+
vTaskDelay(500/ portTICK_PERIOD_MS);
2083+
if (waits) {
2084+
//(*ppClient)->disconnect();
2085+
// we will stall here forever!!! - as testing
21052086
#ifdef BLE_ESP32_DEBUG
2106-
AddLog(LOG_LEVEL_ERROR,PSTR("BLE: wait discon%d"), waits);
2087+
AddLog(LOG_LEVEL_ERROR,PSTR("BLE: wait discon%d"), waits);
21072088
#endif
2108-
vTaskDelay(500/ portTICK_PERIOD_MS);
2109-
}
2110-
waits++;
2111-
if (waits == 5){
2112-
int conn_id = (*ppClient)->getConnId();
2113-
ble_gap_conn_broken(conn_id, -1);
2089+
vTaskDelay(500/ portTICK_PERIOD_MS);
2090+
}
2091+
waits++;
2092+
if (waits == 5){
2093+
int conn_id = (*ppClient)->getConnId();
2094+
ble_gap_conn_broken(conn_id, -1);
21142095
#ifdef BLE_ESP32_DEBUG
2115-
AddLog(LOG_LEVEL_ERROR,PSTR("BLE: wait discon%d - kill connection"), waits);
2096+
AddLog(LOG_LEVEL_ERROR,PSTR("BLE: wait discon%d - kill connection"), waits);
21162097
#endif
2117-
}
2118-
if (waits == 60){
2119-
AddLog(LOG_LEVEL_ERROR,PSTR("BLE: >60s waiting -> BLE Failed, restart Tasmota %d"), waits);
2120-
BLEStop = 1;
2121-
BLEStopAt = esp_timer_get_time();
2098+
}
2099+
if (waits == 60){
2100+
AddLog(LOG_LEVEL_ERROR,PSTR("BLE: >60s waiting -> BLE Failed, restart Tasmota %d"), waits);
2101+
BLEStop = 1;
2102+
BLEStopAt = esp_timer_get_time();
21222103

2123-
BLERestartTasmota = 10;
2124-
BLERestartTasmotaReason = BLE_RESTART_TEAMOTA_REASON_BLE_DISCONNECT_FAIL;
2125-
break;
2126-
}
2127-
} while ((*ppClient)->isConnected());
2128-
}
2129-
} catch(const std::exception& e){
2130-
#ifdef BLE_ESP32_DEBUG
2131-
AddLog(LOG_LEVEL_ERROR,PSTR("BLE: runTaskDoneOperation: exception in disconnect"));
2132-
#endif
2104+
BLERestartTasmota = 10;
2105+
BLERestartTasmotaReason = BLE_RESTART_TEAMOTA_REASON_BLE_DISCONNECT_FAIL;
2106+
break;
2107+
}
2108+
} while ((*ppClient)->isConnected());
21332109
}
21342110

21352111

@@ -3322,35 +3298,23 @@ static void mainThreadOpCallbacks() {
33223298

33233299
if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: op->completecallback is %u opid %d"), op->completecallback, op->opid);
33243300
if (op->completecallback){
3325-
try {
3326-
OPCOMPLETE_CALLBACK *pFn = (OPCOMPLETE_CALLBACK *)(op->completecallback);
3327-
callbackres = pFn(op);
3301+
OPCOMPLETE_CALLBACK *pFn = (OPCOMPLETE_CALLBACK *)(op->completecallback);
3302+
callbackres = pFn(op);
33283303
#ifdef BLE_ESP32_DEBUG
3329-
if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: op->completecallback %d opid %d"), callbackres, op->opid);
3304+
if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: op->completecallback %d opid %d"), callbackres, op->opid);
33303305
#endif
3331-
} catch(const std::exception& e){
3332-
#ifdef BLE_ESP32_DEBUG
3333-
AddLog(LOG_LEVEL_ERROR,PSTR("BLE: exception in op->completecallback"));
3334-
#endif
3335-
}
33363306
}
33373307

33383308
if (!callbackres){
33393309
for (int i = 0; i < operationsCallbacks.size(); i++){
3340-
try {
3341-
if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: operationsCallbacks %d is %u"), i, operationsCallbacks[i]);
3342-
OPCOMPLETE_CALLBACK *pFn = operationsCallbacks[i];
3343-
callbackres = pFn(op);
3344-
#ifdef BLE_ESP32_DEBUG
3345-
if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: operationsCallbacks %d %d"), i, callbackres);
3346-
#endif
3347-
if (callbackres){
3348-
break; // this callback ate the op.
3349-
}
3350-
} catch(const std::exception& e){
3310+
if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: operationsCallbacks %d is %u"), i, operationsCallbacks[i]);
3311+
OPCOMPLETE_CALLBACK *pFn = operationsCallbacks[i];
3312+
callbackres = pFn(op);
33513313
#ifdef BLE_ESP32_DEBUG
3352-
AddLog(LOG_LEVEL_ERROR,PSTR("BLE: exception in operationsCallbacks"));
3314+
if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: operationsCallbacks %d %d"), i, callbackres);
33533315
#endif
3316+
if (callbackres){
3317+
break; // this callback ate the op.
33543318
}
33553319
}
33563320
}

tasmota/xlgt_01_ws2812.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void (* const Ws2812Command[])(void) PROGMEM = {
6969
#elif (USE_WS2812_CTYPE == NEO_RBG)
7070
#define NEO_FEATURE_TYPE Rbg
7171
#elif (USE_WS2812_CTYPE == NEO_RGBW)
72-
#define NEO_FEATURE_TYPE Rbgw
72+
#define NEO_FEATURE_TYPE Rgbw
7373
#elif (USE_WS2812_CTYPE == NEO_GRBW)
7474
#define NEO_FEATURE_TYPE Grbw
7575
#else

0 commit comments

Comments
 (0)