mirror of https://github.com/arendst/Tasmota.git
Berry better error messages
This commit is contained in:
parent
88c2d369d8
commit
dc3636be00
|
@ -498,65 +498,32 @@ static const bclosure add_rule_closure = {
|
|||
/********************************************************************
|
||||
** Solidified function: remove_rule
|
||||
********************************************************************/
|
||||
|
||||
be_define_local_const_str(remove_rule_str_name, "remove_rule", -838755968, 11);
|
||||
be_define_local_const_str(remove_rule_str_source, "string", 398550328, 6);
|
||||
be_define_local_const_str(remove_rule_str_0, "_rules", -28750191, 6);
|
||||
be_define_local_const_str(remove_rule_str_1, "remove", -611183107, 6);
|
||||
|
||||
static const bvalue remove_rule_ktab[2] = {
|
||||
{ { .s=be_local_const_str(remove_rule_str_0) }, BE_STRING},
|
||||
{ { .s=be_local_const_str(remove_rule_str_1) }, BE_STRING},
|
||||
};
|
||||
|
||||
static const uint32_t remove_rule_code[7] = {
|
||||
0x88080100, // 0000 GETMBR R2 R0 R256
|
||||
0x780A0003, // 0001 JMPF R2 #0006
|
||||
0x88080100, // 0002 GETMBR R2 R0 R256
|
||||
0x8C080501, // 0003 GETMET R2 R2 R257
|
||||
0x5C100200, // 0004 MOVE R4 R1
|
||||
0x7C080400, // 0005 CALL R2 2
|
||||
0x80000000, // 0006 RET 0 R0
|
||||
};
|
||||
|
||||
static const bproto remove_rule_proto = {
|
||||
NULL, // bgcobject *next
|
||||
8, // type
|
||||
0x08, // marked
|
||||
5, // nstack
|
||||
0, // nupvals
|
||||
2, // argc
|
||||
0, // varg
|
||||
NULL, // bgcobject *gray
|
||||
NULL, // bupvaldesc *upvals
|
||||
(bvalue*) &remove_rule_ktab, // ktab
|
||||
NULL, // bproto **ptab
|
||||
(binstruction*) &remove_rule_code, // code
|
||||
be_local_const_str(remove_rule_str_name), // name
|
||||
7, // codesize
|
||||
2, // nconst
|
||||
0, // nproto
|
||||
be_local_const_str(remove_rule_str_source), // source
|
||||
#if BE_DEBUG_RUNTIME_INFO /* debug information */
|
||||
NULL, // lineinfo
|
||||
0, // nlineinfo
|
||||
#endif
|
||||
#if BE_DEBUG_VAR_INFO
|
||||
NULL, // varinfo
|
||||
0, // nvarinfo
|
||||
#endif
|
||||
};
|
||||
|
||||
static const bclosure remove_rule_closure = {
|
||||
NULL, // bgcobject *next
|
||||
36, // type
|
||||
0x08, // marked
|
||||
0, // nupvals
|
||||
NULL, // bgcobject *gray
|
||||
(bproto*) &remove_rule_proto, // proto
|
||||
{ NULL } // upvals
|
||||
};
|
||||
|
||||
be_local_closure(remove_rule, /* name */
|
||||
be_nested_proto(
|
||||
5, /* nstack */
|
||||
2, /* argc */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 2]) { /* upvals */
|
||||
{ { .s=be_nested_const_str("_rules", -28750191, 6) }, BE_STRING},
|
||||
{ { .s=be_nested_const_str("remove", -611183107, 6) }, BE_STRING},
|
||||
}),
|
||||
(be_nested_const_str("remove_rule", -838755968, 11)),
|
||||
(be_nested_const_str("string", 398550328, 6)),
|
||||
( &(const binstruction[ 7]) { /* code */
|
||||
0x88080100, // 0000 GETMBR R2 R0 R256
|
||||
0x780A0003, // 0001 JMPF R2 #0006
|
||||
0x88080100, // 0002 GETMBR R2 R0 R256
|
||||
0x8C080501, // 0003 GETMET R2 R2 R257
|
||||
0x5C100200, // 0004 MOVE R4 R1
|
||||
0x7C080400, // 0005 CALL R2 2
|
||||
0x80000000, // 0006 RET 0 R0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
|
@ -965,76 +932,42 @@ const bclosure exec_rules_closure = {
|
|||
/********************************************************************
|
||||
** Solidified function: set_timer
|
||||
********************************************************************/
|
||||
|
||||
be_define_local_const_str(set_timer_str_name, "set_timer", 2135414533, 9);
|
||||
be_define_local_const_str(set_timer_str_source, "string", 398550328, 6);
|
||||
be_define_local_const_str(set_timer_str_0, "_timers", -1694866380, 7);
|
||||
be_define_local_const_str(set_timer_str_1, "push", -2022703139, 4);
|
||||
be_define_local_const_str(set_timer_str_2, "millis", 1214679063, 6);
|
||||
|
||||
static const bvalue set_timer_ktab[3] = {
|
||||
{ { .s=be_local_const_str(set_timer_str_0) }, BE_STRING},
|
||||
{ { .s=be_local_const_str(set_timer_str_1) }, BE_STRING},
|
||||
{ { .s=be_local_const_str(set_timer_str_2) }, BE_STRING},
|
||||
};
|
||||
|
||||
static const uint32_t set_timer_code[16] = {
|
||||
0x880C0100, // 0000 GETMBR R3 R0 R256
|
||||
0x740E0002, // 0001 JMPT R3 #0005
|
||||
0x600C000A, // 0002 GETGBL R3 G10
|
||||
0x7C0C0000, // 0003 CALL R3 0
|
||||
0x90020003, // 0004 SETMBR R0 R256 R3
|
||||
0x880C0100, // 0005 GETMBR R3 R0 R256
|
||||
0x8C0C0701, // 0006 GETMET R3 R3 R257
|
||||
0x6014000A, // 0007 GETGBL R5 G10
|
||||
0x7C140000, // 0008 CALL R5 0
|
||||
0x8C180102, // 0009 GETMET R6 R0 R258
|
||||
0x5C200200, // 000A MOVE R8 R1
|
||||
0x7C180400, // 000B CALL R6 2
|
||||
0x40180A06, // 000C CONNECT R6 R5 R6
|
||||
0x40180A02, // 000D CONNECT R6 R5 R2
|
||||
0x7C0C0400, // 000E CALL R3 2
|
||||
0x80000000, // 000F RET 0 R0
|
||||
};
|
||||
|
||||
static const bproto set_timer_proto = {
|
||||
NULL, // bgcobject *next
|
||||
8, // type
|
||||
0x08, // marked
|
||||
9, // nstack
|
||||
0, // nupvals
|
||||
3, // argc
|
||||
0, // varg
|
||||
NULL, // bgcobject *gray
|
||||
NULL, // bupvaldesc *upvals
|
||||
(bvalue*) &set_timer_ktab, // ktab
|
||||
NULL, // bproto **ptab
|
||||
(binstruction*) &set_timer_code, // code
|
||||
be_local_const_str(set_timer_str_name), // name
|
||||
16, // codesize
|
||||
3, // nconst
|
||||
0, // nproto
|
||||
be_local_const_str(set_timer_str_source), // source
|
||||
#if BE_DEBUG_RUNTIME_INFO /* debug information */
|
||||
NULL, // lineinfo
|
||||
0, // nlineinfo
|
||||
#endif
|
||||
#if BE_DEBUG_VAR_INFO
|
||||
NULL, // varinfo
|
||||
0, // nvarinfo
|
||||
#endif
|
||||
};
|
||||
|
||||
const bclosure set_timer_closure = {
|
||||
NULL, // bgcobject *next
|
||||
36, // type
|
||||
0x08, // marked
|
||||
0, // nupvals
|
||||
NULL, // bgcobject *gray
|
||||
(bproto*) &set_timer_proto, // proto
|
||||
{ NULL } // upvals
|
||||
};
|
||||
|
||||
be_local_closure(set_timer, /* name */
|
||||
be_nested_proto(
|
||||
9, /* nstack */
|
||||
3, /* argc */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 3]) { /* upvals */
|
||||
{ { .s=be_nested_const_str("_timers", -1694866380, 7) }, BE_STRING},
|
||||
{ { .s=be_nested_const_str("push", -2022703139, 4) }, BE_STRING},
|
||||
{ { .s=be_nested_const_str("millis", 1214679063, 6) }, BE_STRING},
|
||||
}),
|
||||
(be_nested_const_str("set_timer", 2135414533, 9)),
|
||||
(be_nested_const_str("string", 398550328, 6)),
|
||||
( &(const binstruction[16]) { /* code */
|
||||
0x880C0100, // 0000 GETMBR R3 R0 R256
|
||||
0x740E0002, // 0001 JMPT R3 #0005
|
||||
0x600C000A, // 0002 GETGBL R3 G10
|
||||
0x7C0C0000, // 0003 CALL R3 0
|
||||
0x90020003, // 0004 SETMBR R0 R256 R3
|
||||
0x880C0100, // 0005 GETMBR R3 R0 R256
|
||||
0x8C0C0701, // 0006 GETMET R3 R3 R257
|
||||
0x6014000A, // 0007 GETGBL R5 G10
|
||||
0x7C140000, // 0008 CALL R5 0
|
||||
0x8C180102, // 0009 GETMET R6 R0 R258
|
||||
0x5C200200, // 000A MOVE R8 R1
|
||||
0x7C180400, // 000B CALL R6 2
|
||||
0x40180A06, // 000C CONNECT R6 R5 R6
|
||||
0x40180A02, // 000D CONNECT R6 R5 R2
|
||||
0x7C0C0400, // 000E CALL R3 2
|
||||
0x80000000, // 000F RET 0 R0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
|
@ -1244,68 +1177,36 @@ static const bclosure add_cmd_closure = {
|
|||
"end "
|
||||
"end "
|
||||
********************************************************************/
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: remove_cmd
|
||||
********************************************************************/
|
||||
|
||||
be_define_local_const_str(remove_cmd_str_name, "remove_cmd", -462651594, 10);
|
||||
be_define_local_const_str(remove_cmd_str_source, "string", 398550328, 6);
|
||||
be_define_local_const_str(remove_cmd_str_0, "_ccmd", -2131545883, 5);
|
||||
be_define_local_const_str(remove_cmd_str_1, "remove", -611183107, 6);
|
||||
|
||||
static const bvalue remove_cmd_ktab[2] = {
|
||||
{ { .s=be_local_const_str(remove_cmd_str_0) }, BE_STRING},
|
||||
{ { .s=be_local_const_str(remove_cmd_str_1) }, BE_STRING},
|
||||
};
|
||||
|
||||
static const uint32_t remove_cmd_code[7] = {
|
||||
0x88080100, // 0000 GETMBR R2 R0 R256
|
||||
0x780A0003, // 0001 JMPF R2 #0006
|
||||
0x88080100, // 0002 GETMBR R2 R0 R256
|
||||
0x8C080501, // 0003 GETMET R2 R2 R257
|
||||
0x5C100200, // 0004 MOVE R4 R1
|
||||
0x7C080400, // 0005 CALL R2 2
|
||||
0x80000000, // 0006 RET 0 R0
|
||||
};
|
||||
|
||||
static const bproto remove_cmd_proto = {
|
||||
NULL, // bgcobject *next
|
||||
8, // type
|
||||
0x08, // marked
|
||||
5, // nstack
|
||||
0, // nupvals
|
||||
2, // argc
|
||||
0, // varg
|
||||
NULL, // bgcobject *gray
|
||||
NULL, // bupvaldesc *upvals
|
||||
(bvalue*) &remove_cmd_ktab, // ktab
|
||||
NULL, // bproto **ptab
|
||||
(binstruction*) &remove_cmd_code, // code
|
||||
be_local_const_str(remove_cmd_str_name), // name
|
||||
7, // codesize
|
||||
2, // nconst
|
||||
0, // nproto
|
||||
be_local_const_str(remove_cmd_str_source), // source
|
||||
#if BE_DEBUG_RUNTIME_INFO /* debug information */
|
||||
NULL, // lineinfo
|
||||
0, // nlineinfo
|
||||
#endif
|
||||
#if BE_DEBUG_VAR_INFO
|
||||
NULL, // varinfo
|
||||
0, // nvarinfo
|
||||
#endif
|
||||
};
|
||||
|
||||
static const bclosure remove_cmd_closure = {
|
||||
NULL, // bgcobject *next
|
||||
36, // type
|
||||
0x08, // marked
|
||||
0, // nupvals
|
||||
NULL, // bgcobject *gray
|
||||
(bproto*) &remove_cmd_proto, // proto
|
||||
{ NULL } // upvals
|
||||
};
|
||||
|
||||
be_local_closure(remove_cmd, /* name */
|
||||
be_nested_proto(
|
||||
5, /* nstack */
|
||||
2, /* argc */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 2]) { /* upvals */
|
||||
{ { .s=be_nested_const_str("_ccmd", -2131545883, 5) }, BE_STRING},
|
||||
{ { .s=be_nested_const_str("remove", -611183107, 6) }, BE_STRING},
|
||||
}),
|
||||
(be_nested_const_str("remove_cmd", -462651594, 10)),
|
||||
(be_nested_const_str("string", 398550328, 6)),
|
||||
( &(const binstruction[ 7]) { /* code */
|
||||
0x88080100, // 0000 GETMBR R2 R0 R256
|
||||
0x780A0003, // 0001 JMPF R2 #0006
|
||||
0x88080100, // 0002 GETMBR R2 R0 R256
|
||||
0x8C080501, // 0003 GETMET R2 R2 R257
|
||||
0x5C100200, // 0004 MOVE R4 R1
|
||||
0x7C080400, // 0005 CALL R2 2
|
||||
0x80000000, // 0006 RET 0 R0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
/********************************************************************
|
||||
|
@ -1467,7 +1368,7 @@ be_local_closure(event, /* name */
|
|||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[29]) { /* upvals */
|
||||
( &(const bvalue[23]) { /* upvals */
|
||||
{ { .s=be_nested_const_str("cmd", -158181397, 3) }, BE_STRING},
|
||||
{ { .s=be_nested_const_str("exec_cmd", 493567399, 8) }, BE_STRING},
|
||||
{ { .s=be_nested_const_str("rule", -64077613, 4) }, BE_STRING},
|
||||
|
@ -1481,26 +1382,20 @@ be_local_closure(event, /* name */
|
|||
{ { .s=be_nested_const_str("every_100ms", 1546407804, 11) }, BE_STRING},
|
||||
{ { .s=be_nested_const_str("web_add_button", -757092238, 14) }, BE_STRING},
|
||||
{ { .s=be_nested_const_str("web_add_main_button", -334599632, 19) }, BE_STRING},
|
||||
{ { .s=be_nested_const_str("web_add_management_button", -1556090110, 25) }, BE_STRING},
|
||||
{ { .s=be_nested_const_str("web_add_config_button", 639674325, 21) }, BE_STRING},
|
||||
{ { .s=be_nested_const_str("web_add_console_button", -813531104, 22) }, BE_STRING},
|
||||
{ { .s=be_nested_const_str("save_before_restart", 1253239338, 19) }, BE_STRING},
|
||||
{ { .s=be_nested_const_str("web_add_handler", -304792334, 15) }, BE_STRING},
|
||||
{ { .s=be_nested_const_str("web_sensor", -1394870324, 10) }, BE_STRING},
|
||||
{ { .s=be_nested_const_str("json_append", -1292948012, 11) }, BE_STRING},
|
||||
{ { .s=be_nested_const_str("button_pressed", 1694209616, 14) }, BE_STRING},
|
||||
{ { .s=be_nested_const_str("button_preselif", 491115394, 15) }, BE_STRING},
|
||||
{ { .s=be_nested_const_str("display", 1164572437, 7) }, BE_STRING},
|
||||
{ { .s=be_nested_const_str("string", 398550328, 6) }, BE_STRING},
|
||||
{ { .s=be_nested_const_str("log", 1062293841, 3) }, BE_STRING},
|
||||
{ { .s=be_nested_const_str("format", -1180859054, 6) }, BE_STRING},
|
||||
{ { .s=be_nested_const_str("BRY: exception %s - %m", -1290966132, 22) }, BE_STRING},
|
||||
{ { .i=3 }, BE_INT},
|
||||
{ { .s=be_nested_const_str("BRY: Exception> '%s' - %s", -2047976332, 25) }, BE_STRING},
|
||||
{ { .s=be_nested_const_str("stop_iteration", -121173395, 14) }, BE_STRING},
|
||||
}),
|
||||
(be_nested_const_str("event", -30355297, 5)),
|
||||
(be_nested_const_str("input", -103256197, 5)),
|
||||
( &(const binstruction[153]) { /* code */
|
||||
( &(const binstruction[137]) { /* code */
|
||||
0x1C140300, // 0000 EQ R5 R1 R256
|
||||
0x78160006, // 0001 JMPF R5 #0009
|
||||
0x8C140101, // 0002 GETMET R5 R0 R257
|
||||
|
@ -1509,151 +1404,135 @@ be_local_closure(event, /* name */
|
|||
0x5C240800, // 0005 MOVE R9 R4
|
||||
0x7C140800, // 0006 CALL R5 4
|
||||
0x80040A00, // 0007 RET 1 R5
|
||||
0x7002008E, // 0008 JMP #0098
|
||||
0x7002007E, // 0008 JMP #0088
|
||||
0x1C140302, // 0009 EQ R5 R1 R258
|
||||
0x78160004, // 000A JMPF R5 #0010
|
||||
0x8C140103, // 000B GETMET R5 R0 R259
|
||||
0x5C1C0800, // 000C MOVE R7 R4
|
||||
0x7C140400, // 000D CALL R5 2
|
||||
0x80040A00, // 000E RET 1 R5
|
||||
0x70020087, // 000F JMP #0098
|
||||
0x70020077, // 000F JMP #0088
|
||||
0x1C140304, // 0010 EQ R5 R1 R260
|
||||
0x78160002, // 0011 JMPF R5 #0015
|
||||
0x4C140000, // 0012 LDNIL 5
|
||||
0x80040A00, // 0013 RET 1 R5
|
||||
0x70020082, // 0014 JMP #0098
|
||||
0x70020072, // 0014 JMP #0088
|
||||
0x1C140305, // 0015 EQ R5 R1 R261
|
||||
0x78160003, // 0016 JMPF R5 #001B
|
||||
0x8C140105, // 0017 GETMET R5 R0 R261
|
||||
0x7C140200, // 0018 CALL R5 1
|
||||
0x80040A00, // 0019 RET 1 R5
|
||||
0x7002007C, // 001A JMP #0098
|
||||
0x7002006C, // 001A JMP #0088
|
||||
0x1C140306, // 001B EQ R5 R1 R262
|
||||
0x78160003, // 001C JMPF R5 #0021
|
||||
0x8C140107, // 001D GETMET R5 R0 R263
|
||||
0x7C140200, // 001E CALL R5 1
|
||||
0x80040A00, // 001F RET 1 R5
|
||||
0x70020076, // 0020 JMP #0098
|
||||
0x70020066, // 0020 JMP #0088
|
||||
0x88140108, // 0021 GETMBR R5 R0 R264
|
||||
0x78160074, // 0022 JMPF R5 #0098
|
||||
0x78160064, // 0022 JMPF R5 #0088
|
||||
0x60140000, // 0023 GETGBL R5 G0
|
||||
0x88180108, // 0024 GETMBR R6 R0 R264
|
||||
0x7C140200, // 0025 CALL R5 1
|
||||
0xA802006D, // 0026 EXBLK 0 #0095
|
||||
0xA802005D, // 0026 EXBLK 0 #0085
|
||||
0x5C180A00, // 0027 MOVE R6 R5
|
||||
0x7C180000, // 0028 CALL R6 0
|
||||
0xA802005E, // 0029 EXBLK 0 #0089
|
||||
0xA802004D, // 0029 EXBLK 0 #0078
|
||||
0x1C1C0309, // 002A EQ R7 R1 R265
|
||||
0x781E0004, // 002B JMPF R7 #0031
|
||||
0x881C0D09, // 002C GETMBR R7 R6 R265
|
||||
0x781E0002, // 002D JMPF R7 #0031
|
||||
0x8C1C0D09, // 002E GETMET R7 R6 R265
|
||||
0x7C1C0200, // 002F CALL R7 1
|
||||
0x70020055, // 0030 JMP #0087
|
||||
0x70020044, // 0030 JMP #0076
|
||||
0x1C1C030A, // 0031 EQ R7 R1 R266
|
||||
0x781E0004, // 0032 JMPF R7 #0038
|
||||
0x881C0D0A, // 0033 GETMBR R7 R6 R266
|
||||
0x781E0002, // 0034 JMPF R7 #0038
|
||||
0x8C1C0D0A, // 0035 GETMET R7 R6 R266
|
||||
0x7C1C0200, // 0036 CALL R7 1
|
||||
0x7002004E, // 0037 JMP #0087
|
||||
0x7002003D, // 0037 JMP #0076
|
||||
0x1C1C030B, // 0038 EQ R7 R1 R267
|
||||
0x781E0004, // 0039 JMPF R7 #003F
|
||||
0x881C0D0B, // 003A GETMBR R7 R6 R267
|
||||
0x781E0002, // 003B JMPF R7 #003F
|
||||
0x8C1C0D0B, // 003C GETMET R7 R6 R267
|
||||
0x7C1C0200, // 003D CALL R7 1
|
||||
0x70020047, // 003E JMP #0087
|
||||
0x70020036, // 003E JMP #0076
|
||||
0x1C1C030C, // 003F EQ R7 R1 R268
|
||||
0x781E0004, // 0040 JMPF R7 #0046
|
||||
0x881C0D0C, // 0041 GETMBR R7 R6 R268
|
||||
0x781E0002, // 0042 JMPF R7 #0046
|
||||
0x8C1C0D0C, // 0043 GETMET R7 R6 R268
|
||||
0x7C1C0200, // 0044 CALL R7 1
|
||||
0x70020040, // 0045 JMP #0087
|
||||
0x7002002F, // 0045 JMP #0076
|
||||
0x1C1C030D, // 0046 EQ R7 R1 R269
|
||||
0x781E0004, // 0047 JMPF R7 #004D
|
||||
0x881C0D0D, // 0048 GETMBR R7 R6 R269
|
||||
0x781E0002, // 0049 JMPF R7 #004D
|
||||
0x8C1C0D0D, // 004A GETMET R7 R6 R269
|
||||
0x7C1C0200, // 004B CALL R7 1
|
||||
0x70020039, // 004C JMP #0087
|
||||
0x70020028, // 004C JMP #0076
|
||||
0x1C1C030E, // 004D EQ R7 R1 R270
|
||||
0x781E0004, // 004E JMPF R7 #0054
|
||||
0x881C0D0E, // 004F GETMBR R7 R6 R270
|
||||
0x781E0002, // 0050 JMPF R7 #0054
|
||||
0x8C1C0D0E, // 0051 GETMET R7 R6 R270
|
||||
0x7C1C0200, // 0052 CALL R7 1
|
||||
0x70020032, // 0053 JMP #0087
|
||||
0x70020021, // 0053 JMP #0076
|
||||
0x1C1C030F, // 0054 EQ R7 R1 R271
|
||||
0x781E0004, // 0055 JMPF R7 #005B
|
||||
0x881C0D0F, // 0056 GETMBR R7 R6 R271
|
||||
0x781E0002, // 0057 JMPF R7 #005B
|
||||
0x8C1C0D0F, // 0058 GETMET R7 R6 R271
|
||||
0x7C1C0200, // 0059 CALL R7 1
|
||||
0x7002002B, // 005A JMP #0087
|
||||
0x7002001A, // 005A JMP #0076
|
||||
0x1C1C0310, // 005B EQ R7 R1 R272
|
||||
0x781E0004, // 005C JMPF R7 #0062
|
||||
0x881C0D10, // 005D GETMBR R7 R6 R272
|
||||
0x781E0002, // 005E JMPF R7 #0062
|
||||
0x8C1C0D10, // 005F GETMET R7 R6 R272
|
||||
0x7C1C0200, // 0060 CALL R7 1
|
||||
0x70020024, // 0061 JMP #0087
|
||||
0x70020013, // 0061 JMP #0076
|
||||
0x1C1C0311, // 0062 EQ R7 R1 R273
|
||||
0x781E0004, // 0063 JMPF R7 #0069
|
||||
0x881C0D11, // 0064 GETMBR R7 R6 R273
|
||||
0x781E0002, // 0065 JMPF R7 #0069
|
||||
0x8C1C0D11, // 0066 GETMET R7 R6 R273
|
||||
0x7C1C0200, // 0067 CALL R7 1
|
||||
0x7002001D, // 0068 JMP #0087
|
||||
0x1C1C0312, // 0069 EQ R7 R1 R274
|
||||
0x7002000C, // 0068 JMP #0076
|
||||
0x1C1C030E, // 0069 EQ R7 R1 R270
|
||||
0x781E0004, // 006A JMPF R7 #0070
|
||||
0x881C0D12, // 006B GETMBR R7 R6 R274
|
||||
0x781E0002, // 006C JMPF R7 #0070
|
||||
0x8C1C0D12, // 006D GETMET R7 R6 R274
|
||||
0x7C1C0200, // 006E CALL R7 1
|
||||
0x70020016, // 006F JMP #0087
|
||||
0x1C1C0313, // 0070 EQ R7 R1 R275
|
||||
0x781E0004, // 0071 JMPF R7 #0077
|
||||
0x881C0D13, // 0072 GETMBR R7 R6 R275
|
||||
0x781E0002, // 0073 JMPF R7 #0077
|
||||
0x8C1C0D13, // 0074 GETMET R7 R6 R275
|
||||
0x70020005, // 006F JMP #0076
|
||||
0x1C1C0312, // 0070 EQ R7 R1 R274
|
||||
0x781E0003, // 0071 JMPF R7 #0076
|
||||
0x881C0D12, // 0072 GETMBR R7 R6 R274
|
||||
0x781E0001, // 0073 JMPF R7 #0076
|
||||
0x8C1C0D12, // 0074 GETMET R7 R6 R274
|
||||
0x7C1C0200, // 0075 CALL R7 1
|
||||
0x7002000F, // 0076 JMP #0087
|
||||
0x1C1C0314, // 0077 EQ R7 R1 R276
|
||||
0x781E0007, // 0078 JMPF R7 #0081
|
||||
0x881C0D14, // 0079 GETMBR R7 R6 R276
|
||||
0x781E0005, // 007A JMPF R7 #0081
|
||||
0x1C1C0311, // 007B EQ R7 R1 R273
|
||||
0x781DFFFE, // 007C JMPF R7 #007C
|
||||
0x881C0D16, // 007D GETMBR R7 R6 R278
|
||||
0x8C1C0D16, // 007E GETMET R7 R6 R278
|
||||
0x7C1C0200, // 007F CALL R7 1
|
||||
0x70020005, // 0080 JMP #0087
|
||||
0x1C1C0316, // 0081 EQ R7 R1 R278
|
||||
0x781E0003, // 0082 JMPF R7 #0087
|
||||
0x881C0D16, // 0083 GETMBR R7 R6 R278
|
||||
0x781E0001, // 0084 JMPF R7 #0087
|
||||
0x8C1C0D16, // 0085 GETMET R7 R6 R278
|
||||
0x7C1C0200, // 0086 CALL R7 1
|
||||
0xA8040001, // 0087 EXBLK 1 1
|
||||
0x7002000A, // 0088 JMP #0094
|
||||
0xAC1C0002, // 0089 CATCH R7 0 2
|
||||
0x70020007, // 008A JMP #0093
|
||||
0xA4262E00, // 008B IMPORT R9 R279
|
||||
0x8C280118, // 008C GETMET R10 R0 R280
|
||||
0x8C301319, // 008D GETMET R12 R9 R281
|
||||
0x5838001A, // 008E LDCONST R14 K26
|
||||
0x583C001B, // 008F LDCONST R15 K27
|
||||
0x7C300600, // 0090 CALL R12 3
|
||||
0x7C280400, // 0091 CALL R10 2
|
||||
0x70020000, // 0092 JMP #0094
|
||||
0xB0080000, // 0093 RAISE 2 R0 R0
|
||||
0x7001FF91, // 0094 JMP #0027
|
||||
0x5814001C, // 0095 LDCONST R5 K28
|
||||
0xAC140200, // 0096 CATCH R5 1 0
|
||||
0xB0080000, // 0097 RAISE 2 R0 R0
|
||||
0x80000000, // 0098 RET 0 R0
|
||||
0xA8040001, // 0076 EXBLK 1 1
|
||||
0x7002000B, // 0077 JMP #0084
|
||||
0xAC1C0002, // 0078 CATCH R7 0 2
|
||||
0x70020008, // 0079 JMP #0083
|
||||
0xA4262600, // 007A IMPORT R9 R275
|
||||
0x6028000F, // 007B GETGBL R10 G15
|
||||
0x8C2C1314, // 007C GETMET R11 R9 R276
|
||||
0x58340015, // 007D LDCONST R13 K21
|
||||
0x5C380E00, // 007E MOVE R14 R7
|
||||
0x5C3C1000, // 007F MOVE R15 R8
|
||||
0x7C2C0800, // 0080 CALL R11 4
|
||||
0x7C280200, // 0081 CALL R10 1
|
||||
0x70020000, // 0082 JMP #0084
|
||||
0xB0080000, // 0083 RAISE 2 R0 R0
|
||||
0x7001FFA1, // 0084 JMP #0027
|
||||
0x58140016, // 0085 LDCONST R5 K22
|
||||
0xAC140200, // 0086 CATCH R5 1 0
|
||||
0xB0080000, // 0087 RAISE 2 R0 R0
|
||||
0x80000000, // 0088 RET 0 R0
|
||||
})
|
||||
)
|
||||
);
|
||||
|
@ -1731,119 +1610,107 @@ const bclosure add_driver_closure = {
|
|||
/********************************************************************
|
||||
** Solidified function: load
|
||||
********************************************************************/
|
||||
|
||||
/********** Solidified proto: load */
|
||||
be_define_local_const_str(load_str_name, "load", -435725847, 4);
|
||||
be_define_local_const_str(load_str_source, "input", -103256197, 5);
|
||||
be_define_local_const_str(load_str_0, "string", 398550328, 6);
|
||||
be_define_local_const_str(load_str_1, "split", -2017972765, 5);
|
||||
be_define_local_const_str(load_str_2, ".", 722245873, 1);
|
||||
be_define_local_const_str(load_str_4, "be", 942383232, 2);
|
||||
be_define_local_const_str(load_str_5, "bec", 1336821081, 3);
|
||||
be_define_local_const_str(load_str_6, "io_error", 1970281036, 8);
|
||||
be_define_local_const_str(load_str_7, "file extension is not '.be' or '.bec'", -1199247657, 37);
|
||||
be_define_local_const_str(load_str_8, "c", -435409838, 1);
|
||||
be_define_local_const_str(load_str_9, "r", -150190315, 1);
|
||||
be_define_local_const_str(load_str_10, "close", 667630371, 5);
|
||||
be_define_local_const_str(load_str_11, "file", -1427482813, 4);
|
||||
be_define_local_const_str(load_str_12, "save", -855671224, 4);
|
||||
be_define_local_const_str(load_str_13, "log", 1062293841, 3);
|
||||
be_define_local_const_str(load_str_14, "format", -1180859054, 6);
|
||||
be_define_local_const_str(load_str_15, "BRY: could not save compiled file %s (%s)", 736659787, 41);
|
||||
|
||||
static const bvalue load_ktab[16] = {
|
||||
{ { .s=be_local_const_str(load_str_0) }, BE_STRING},
|
||||
{ { .s=be_local_const_str(load_str_1) }, BE_STRING},
|
||||
{ { .s=be_local_const_str(load_str_2) }, BE_STRING},
|
||||
{ { .i=1 }, BE_INT},
|
||||
{ { .s=be_local_const_str(load_str_4) }, BE_STRING},
|
||||
{ { .s=be_local_const_str(load_str_5) }, BE_STRING},
|
||||
{ { .s=be_local_const_str(load_str_6) }, BE_STRING},
|
||||
{ { .s=be_local_const_str(load_str_7) }, BE_STRING},
|
||||
{ { .s=be_local_const_str(load_str_8) }, BE_STRING},
|
||||
{ { .s=be_local_const_str(load_str_9) }, BE_STRING},
|
||||
{ { .s=be_local_const_str(load_str_10) }, BE_STRING},
|
||||
{ { .s=be_local_const_str(load_str_11) }, BE_STRING},
|
||||
{ { .s=be_local_const_str(load_str_12) }, BE_STRING},
|
||||
{ { .s=be_local_const_str(load_str_13) }, BE_STRING},
|
||||
{ { .s=be_local_const_str(load_str_14) }, BE_STRING},
|
||||
{ { .s=be_local_const_str(load_str_15) }, BE_STRING},
|
||||
};
|
||||
|
||||
static const uint32_t load_code[68] = {
|
||||
0xA40A0000, // 0000 IMPORT R2 R256
|
||||
0x8C0C0501, // 0001 GETMET R3 R2 R257
|
||||
0x5C140200, // 0002 MOVE R5 R1
|
||||
0x58180002, // 0003 LDCONST R6 K2
|
||||
0x7C0C0600, // 0004 CALL R3 3
|
||||
0x60100012, // 0005 GETGBL R4 G18
|
||||
0x5C140600, // 0006 MOVE R5 R3
|
||||
0x7C100200, // 0007 CALL R4 1
|
||||
0x18100903, // 0008 LE R4 R4 R259
|
||||
0x74120007, // 0009 JMPT R4 #0012
|
||||
0x5411FFFE, // 000A LDINT R4 -1
|
||||
0x94100604, // 000B GETIDX R4 R3 R4
|
||||
0x20100904, // 000C NE R4 R4 R260
|
||||
0x78120004, // 000D JMPF R4 #0013
|
||||
0x5411FFFE, // 000E LDINT R4 -1
|
||||
0x94100604, // 000F GETIDX R4 R3 R4
|
||||
0x20100905, // 0010 NE R4 R4 R261
|
||||
0x78120000, // 0011 JMPF R4 #0013
|
||||
0xB0060D07, // 0012 RAISE 1 R262 R263
|
||||
0x60100012, // 0013 GETGBL R4 G18
|
||||
0x5C140200, // 0014 MOVE R5 R1
|
||||
0x7C100200, // 0015 CALL R4 1
|
||||
0x4100903, // 0016 SUB R4 R4 R259
|
||||
0x94100204, // 0017 GETIDX R4 R1 R4
|
||||
0x1C100908, // 0018 EQ R4 R4 R264
|
||||
0xA8020007, // 0019 EXBLK 0 #0022
|
||||
0x6014000E, // 001A GETGBL R5 G14
|
||||
0x5C180200, // 001B MOVE R6 R1
|
||||
0x581C0009, // 001C LDCONST R7 K9
|
||||
0x7C140400, // 001D CALL R5 2
|
||||
0x8C180B0A, // 001E GETMET R6 R5 R266
|
||||
0x7C180200, // 001F CALL R6 1
|
||||
0xA8040001, // 0020 EXBLK 1 1
|
||||
0x70020006, // 0021 JMP #0029
|
||||
0x58140006, // 0022 LDCONST R5 K6
|
||||
0xAC140200, // 0023 CATCH R5 1 0
|
||||
0x70020002, // 0024 JMP #0028
|
||||
0x50140000, // 0025 LDBOOL R5 0 0
|
||||
0x80040A00, // 0026 RET 1 R5
|
||||
0x70020000, // 0027 JMP #0029
|
||||
0xB0080000, // 0028 RAISE 2 R0 R0
|
||||
0x60140005, // 0029 GETGBL R5 G5
|
||||
0x5C180200, // 002A MOVE R6 R1
|
||||
0x581C000B, // 002B LDCONST R7 K11
|
||||
0x7C140400, // 002C CALL R5 2
|
||||
0x74120011, // 002D JMPT R4 #0040
|
||||
0xA8020005, // 002E EXBLK 0 #0035
|
||||
0x8C18010C, // 002F GETMET R6 R0 R268
|
||||
0x200308, // 0030 ADD R8 R1 R264
|
||||
0x5C240A00, // 0031 MOVE R9 R5
|
||||
0x7C180600, // 0032 CALL R6 3
|
||||
0xA8040001, // 0033 EXBLK 1 1
|
||||
0x7002000A, // 0034 JMP #0040
|
||||
0xAC180001, // 0035 CATCH R6 0 1
|
||||
0x70020007, // 0036 JMP #003F
|
||||
0x8C1C010D, // 0037 GETMET R7 R0 R269
|
||||
0x8C24050E, // 0038 GETMET R9 R2 R270
|
||||
0x582C000F, // 0039 LDCONST R11 K15
|
||||
0x300308, // 003A ADD R12 R1 R264
|
||||
0x5C340C00, // 003B MOVE R13 R6
|
||||
0x7C240800, // 003C CALL R9 4
|
||||
0x7C1C0400, // 003D CALL R7 2
|
||||
0x70020000, // 003E JMP #0040
|
||||
0xB0080000, // 003F RAISE 2 R0 R0
|
||||
0x5C180A00, // 0040 MOVE R6 R5
|
||||
0x7C180000, // 0041 CALL R6 0
|
||||
0x50180200, // 0042 LDBOOL R6 1 0
|
||||
0x80040C00, // 0043 RET 1 R6
|
||||
};
|
||||
|
||||
be_define_local_proto(load, 14, 2, 1, 0, 0);
|
||||
be_define_local_closure(load);
|
||||
|
||||
be_local_closure(load, /* name */
|
||||
be_nested_proto(
|
||||
14, /* nstack */
|
||||
2, /* argc */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[16]) { /* upvals */
|
||||
{ { .s=be_nested_const_str("string", 398550328, 6) }, BE_STRING},
|
||||
{ { .s=be_nested_const_str("split", -2017972765, 5) }, BE_STRING},
|
||||
{ { .s=be_nested_const_str(".", 722245873, 1) }, BE_STRING},
|
||||
{ { .i=1 }, BE_INT},
|
||||
{ { .s=be_nested_const_str("be", 942383232, 2) }, BE_STRING},
|
||||
{ { .s=be_nested_const_str("bec", 1336821081, 3) }, BE_STRING},
|
||||
{ { .s=be_nested_const_str("io_error", 1970281036, 8) }, BE_STRING},
|
||||
{ { .s=be_nested_const_str("file extension is not '.be' or '.bec'", -1199247657, 37) }, BE_STRING},
|
||||
{ { .s=be_nested_const_str("c", -435409838, 1) }, BE_STRING},
|
||||
{ { .s=be_nested_const_str("r", -150190315, 1) }, BE_STRING},
|
||||
{ { .s=be_nested_const_str("close", 667630371, 5) }, BE_STRING},
|
||||
{ { .s=be_nested_const_str("file", -1427482813, 4) }, BE_STRING},
|
||||
{ { .s=be_nested_const_str("save", -855671224, 4) }, BE_STRING},
|
||||
{ { .s=be_nested_const_str("log", 1062293841, 3) }, BE_STRING},
|
||||
{ { .s=be_nested_const_str("format", -1180859054, 6) }, BE_STRING},
|
||||
{ { .s=be_nested_const_str("BRY: could not save compiled file %s (%s)", 736659787, 41) }, BE_STRING},
|
||||
}),
|
||||
(be_nested_const_str("load", -435725847, 4)),
|
||||
(be_nested_const_str("input", -103256197, 5)),
|
||||
( &(const binstruction[68]) { /* code */
|
||||
0xA40A0000, // 0000 IMPORT R2 R256
|
||||
0x8C0C0501, // 0001 GETMET R3 R2 R257
|
||||
0x5C140200, // 0002 MOVE R5 R1
|
||||
0x58180002, // 0003 LDCONST R6 K2
|
||||
0x7C0C0600, // 0004 CALL R3 3
|
||||
0x60100012, // 0005 GETGBL R4 G18
|
||||
0x5C140600, // 0006 MOVE R5 R3
|
||||
0x7C100200, // 0007 CALL R4 1
|
||||
0x18100903, // 0008 LE R4 R4 R259
|
||||
0x74120007, // 0009 JMPT R4 #0012
|
||||
0x5411FFFE, // 000A LDINT R4 -1
|
||||
0x94100604, // 000B GETIDX R4 R3 R4
|
||||
0x20100904, // 000C NE R4 R4 R260
|
||||
0x78120004, // 000D JMPF R4 #0013
|
||||
0x5411FFFE, // 000E LDINT R4 -1
|
||||
0x94100604, // 000F GETIDX R4 R3 R4
|
||||
0x20100905, // 0010 NE R4 R4 R261
|
||||
0x78120000, // 0011 JMPF R4 #0013
|
||||
0xB0060D07, // 0012 RAISE 1 R262 R263
|
||||
0x60100012, // 0013 GETGBL R4 G18
|
||||
0x5C140200, // 0014 MOVE R5 R1
|
||||
0x7C100200, // 0015 CALL R4 1
|
||||
0x04100903, // 0016 SUB R4 R4 R259
|
||||
0x94100204, // 0017 GETIDX R4 R1 R4
|
||||
0x1C100908, // 0018 EQ R4 R4 R264
|
||||
0xA8020007, // 0019 EXBLK 0 #0022
|
||||
0x6014000E, // 001A GETGBL R5 G14
|
||||
0x5C180200, // 001B MOVE R6 R1
|
||||
0x581C0009, // 001C LDCONST R7 K9
|
||||
0x7C140400, // 001D CALL R5 2
|
||||
0x8C180B0A, // 001E GETMET R6 R5 R266
|
||||
0x7C180200, // 001F CALL R6 1
|
||||
0xA8040001, // 0020 EXBLK 1 1
|
||||
0x70020006, // 0021 JMP #0029
|
||||
0x58140006, // 0022 LDCONST R5 K6
|
||||
0xAC140200, // 0023 CATCH R5 1 0
|
||||
0x70020002, // 0024 JMP #0028
|
||||
0x50140000, // 0025 LDBOOL R5 0 0
|
||||
0x80040A00, // 0026 RET 1 R5
|
||||
0x70020000, // 0027 JMP #0029
|
||||
0xB0080000, // 0028 RAISE 2 R0 R0
|
||||
0x60140005, // 0029 GETGBL R5 G5
|
||||
0x5C180200, // 002A MOVE R6 R1
|
||||
0x581C000B, // 002B LDCONST R7 K11
|
||||
0x7C140400, // 002C CALL R5 2
|
||||
0x74120011, // 002D JMPT R4 #0040
|
||||
0xA8020005, // 002E EXBLK 0 #0035
|
||||
0x8C18010C, // 002F GETMET R6 R0 R268
|
||||
0x00200308, // 0030 ADD R8 R1 R264
|
||||
0x5C240A00, // 0031 MOVE R9 R5
|
||||
0x7C180600, // 0032 CALL R6 3
|
||||
0xA8040001, // 0033 EXBLK 1 1
|
||||
0x7002000A, // 0034 JMP #0040
|
||||
0xAC180001, // 0035 CATCH R6 0 1
|
||||
0x70020007, // 0036 JMP #003F
|
||||
0x8C1C010D, // 0037 GETMET R7 R0 R269
|
||||
0x8C24050E, // 0038 GETMET R9 R2 R270
|
||||
0x582C000F, // 0039 LDCONST R11 K15
|
||||
0x00300308, // 003A ADD R12 R1 R264
|
||||
0x5C340C00, // 003B MOVE R13 R6
|
||||
0x7C240800, // 003C CALL R9 4
|
||||
0x7C1C0400, // 003D CALL R7 2
|
||||
0x70020000, // 003E JMP #0040
|
||||
0xB0080000, // 003F RAISE 2 R0 R0
|
||||
0x5C180A00, // 0040 MOVE R6 R5
|
||||
0x7C180000, // 0041 CALL R6 0
|
||||
0x50180200, // 0042 LDBOOL R6 1 0
|
||||
0x80040C00, // 0043 RET 1 R6
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
/********************************************************************
|
||||
|
|
|
@ -3,6 +3,209 @@
|
|||
|
||||
class Tasmota2 : Tasmota
|
||||
|
||||
# add `chars_in_string(s:string,c:string) -> int``
|
||||
# looks for any char in c, and return the position of the first char
|
||||
# or -1 if not found
|
||||
# inv is optional and inverses the behavior, i.e. look for chars not in the list
|
||||
def chars_in_string(s,c,inv)
|
||||
var inverted = inv ? true : false
|
||||
for i:0..size(s)-1
|
||||
var found = false
|
||||
for j:0..size(c)-1
|
||||
if s[i] == c[j] found = true end
|
||||
end
|
||||
if inverted != found return i end
|
||||
end
|
||||
return -1
|
||||
end
|
||||
|
||||
# find a key in map, case insensitive, return actual key or nil if not found
|
||||
def find_key_i(m,keyi)
|
||||
import string
|
||||
var keyu = string.toupper(keyi)
|
||||
if classof(m) == map
|
||||
for k:m.keys()
|
||||
if string.toupper(k)==keyu || keyi=='?'
|
||||
return k
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# split the item when there is an operator, returns a list of (left,op,right)
|
||||
# ex: "Dimmer>50" -> ["Dimmer",tasmota_gt,"50"]
|
||||
def find_op(item)
|
||||
import string
|
||||
var op_chars = '=<>!'
|
||||
var pos = self.chars_in_string(item, op_chars)
|
||||
if pos >= 0
|
||||
var op_split = string.split(item,pos)
|
||||
var op_left = op_split[0]
|
||||
var op_rest = op_split[1]
|
||||
pos = self.chars_in_string(op_rest, op_chars, true)
|
||||
if pos >= 0
|
||||
var op_split2 = string.split(op_rest,pos)
|
||||
var op_middle = op_split2[0]
|
||||
var op_right = op_split2[1]
|
||||
return [op_left,op_middle,op_right]
|
||||
end
|
||||
end
|
||||
return [item, nil, nil]
|
||||
end
|
||||
|
||||
# Rules
|
||||
def add_rule(pat,f)
|
||||
if !self._rules
|
||||
self._rules={}
|
||||
end
|
||||
if type(f) == 'function'
|
||||
self._rules[pat] = f
|
||||
else
|
||||
raise 'value_error', 'the second argument is not a function'
|
||||
end
|
||||
end
|
||||
|
||||
def remove_rule(pat)
|
||||
if self._rules
|
||||
self._rules.remove(pat)
|
||||
end
|
||||
end
|
||||
|
||||
# Rules trigger if match. return true if match, false if not
|
||||
def try_rule(event, rule, f)
|
||||
import string
|
||||
var rl_list = self.find_op(rule)
|
||||
var sub_event = event
|
||||
var rl = string.split(rl_list[0],'#')
|
||||
for it:rl
|
||||
found=self.find_key_i(sub_event,it)
|
||||
if found == nil return false end
|
||||
sub_event = sub_event[found]
|
||||
end
|
||||
var op=rl_list[1]
|
||||
var op2=rl_list[2]
|
||||
if op
|
||||
if op=='=='
|
||||
if str(sub_event) != str(op2) return false end
|
||||
elif op=='!=='
|
||||
if str(sub_event) == str(op2) return false end
|
||||
elif op=='='
|
||||
if real(sub_event) != real(op2) return false end
|
||||
elif op=='!='
|
||||
if real(sub_event) == real(op2) return false end
|
||||
elif op=='>'
|
||||
if real(sub_event) <= real(op2) return false end
|
||||
elif op=='>='
|
||||
if real(sub_event) < real(op2) return false end
|
||||
elif op=='<'
|
||||
if real(sub_event) >= real(op2) return false end
|
||||
elif op=='<='
|
||||
if real(sub_event) > real(op2) return false end
|
||||
end
|
||||
end
|
||||
f(sub_event, rl_list[0], event)
|
||||
return true
|
||||
end
|
||||
|
||||
# Run rules, i.e. check each individual rule
|
||||
# Returns true if at least one rule matched, false if none
|
||||
def exec_rules(ev_json)
|
||||
if self._rules
|
||||
import json
|
||||
var ev = json.load(ev_json)
|
||||
var ret = false
|
||||
if ev == nil
|
||||
print('BRY: ERROR, bad json: '+ev_json, 3)
|
||||
else
|
||||
for r: self._rules.keys()
|
||||
ret = self.try_rule(ev,r,self._rules[r]) || ret
|
||||
end
|
||||
end
|
||||
return ret
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
def set_timer(delay,f)
|
||||
if !self._timers self._timers=[] end
|
||||
self._timers.push([self.millis(delay),f])
|
||||
end
|
||||
|
||||
# run every 50ms tick
|
||||
def run_deferred()
|
||||
if self._timers
|
||||
var i=0
|
||||
while i<self._timers.size()
|
||||
if self.time_reached(self._timers[i][0])
|
||||
f=self._timers[i][1]
|
||||
self._timers.remove(i)
|
||||
f()
|
||||
else
|
||||
i=i+1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Add command to list
|
||||
def add_cmd(c,f)
|
||||
if !self._ccmd
|
||||
self._ccmd={}
|
||||
end
|
||||
if type(f) == 'function'
|
||||
self._ccmd[c]=f
|
||||
else
|
||||
raise 'value_error', 'the second argument is not a function'
|
||||
end
|
||||
end
|
||||
|
||||
# Remove command from list
|
||||
def remove_cmd(c)
|
||||
if self._ccmd
|
||||
self._ccmd.remove(c)
|
||||
end
|
||||
end
|
||||
|
||||
# Execute custom command
|
||||
def exec_cmd(cmd, idx, payload)
|
||||
if self._ccmd
|
||||
import json
|
||||
var payload_json = json.load(payload)
|
||||
var cmd_found = self.find_key_i(self._ccmd, cmd)
|
||||
if cmd_found != nil
|
||||
self.resolvecmnd(cmd_found) # set the command name in XdrvMailbox.command
|
||||
self._ccmd[cmd_found](cmd_found, idx, payload, payload_json)
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
# Force gc and return allocated memory
|
||||
def gc()
|
||||
import gc
|
||||
gc.collect()
|
||||
return gc.allocated()
|
||||
end
|
||||
|
||||
# tasmota.wire_scan(addr:int [, index:int]) -> wire1 or wire2 or nil
|
||||
# scan for the first occurrence of the addr, starting with bus1 then bus2
|
||||
# optional: skip if index is disabled via I2CEnable
|
||||
def wire_scan(addr,idx)
|
||||
# skip if the I2C index is disabled
|
||||
if idx != nil && !self.i2c_enabled(idx) return nil end
|
||||
if self.wire1.detect(addr) return self.wire1 end
|
||||
if self.wire2.detect(addr) return self.wire2 end
|
||||
return nil
|
||||
end
|
||||
|
||||
def time_str(time)
|
||||
import string
|
||||
var tm = self.time_dump(time)
|
||||
return string.format("%04d-%02d-%02dT%02d:%02d:%02d", tm['year'], tm['month'], tm['day'], tm['hour'], tm['min'], tm['sec'])
|
||||
end
|
||||
|
||||
def load(f)
|
||||
import string
|
||||
|
||||
|
@ -64,7 +267,7 @@ class Tasmota2 : Tasmota
|
|||
end
|
||||
except .. as e,m
|
||||
import string
|
||||
self.log(string.format('BRY: exception %s - %m',3))
|
||||
print(string.format("BRY: Exception> '%s' - %s", e, m))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue