mirror of https://github.com/arendst/Tasmota.git
Merge branch 'arendst:development' into python-pio-updates
This commit is contained in:
commit
40aaed6dbf
|
@ -3,7 +3,11 @@ All notable changes to this project will be documented in this file.
|
|||
|
||||
## [Unreleased] - Development
|
||||
|
||||
## [9.5.0.5]
|
||||
## [9.5.0.6]
|
||||
### Added
|
||||
- Version bump to monitor possible HTTP issues releated to ``SetOption128``
|
||||
|
||||
## [9.5.0.5] 20210815
|
||||
### Added
|
||||
- Inital support for Wi-Fi extender (#12784)
|
||||
- Neopool commands ``NPPHRes``, ``NPCLRes`` and ``NPIonRes`` (#12813)
|
||||
|
|
|
@ -98,7 +98,7 @@ 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 v9.5.0.5
|
||||
## Changelog v9.5.0.6
|
||||
### Added
|
||||
- Release of [Tasmota WebInstaller](https://arendst.github.io/Tasmota-firmware/)
|
||||
- Command ``SetOption127 1`` to force Wi-Fi in no-sleep mode even if ``Sleep 0`` is not enabled
|
||||
|
|
|
@ -973,115 +973,61 @@ be_local_closure(set_timer, /* name */
|
|||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
// 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 "
|
||||
********************************************************************/
|
||||
/********************************************************************
|
||||
** Solidified function: run_deferred
|
||||
********************************************************************/
|
||||
|
||||
be_define_local_const_str(run_deferred_str_name, "run_deferred", 371594696, 12);
|
||||
be_define_local_const_str(run_deferred_str_source, "string", 398550328, 6);
|
||||
be_define_local_const_str(run_deferred_str_0, "_timers", -1694866380, 7);
|
||||
be_define_local_const_str(run_deferred_str_2, "size", 597743964, 4);
|
||||
be_define_local_const_str(run_deferred_str_3, "time_reached", 2075136773, 12);
|
||||
be_define_local_const_str(run_deferred_str_5, "remove", -611183107, 6);
|
||||
|
||||
static const bvalue run_deferred_ktab[6] = {
|
||||
{ { .s=be_local_const_str(run_deferred_str_0) }, BE_STRING},
|
||||
{ { .i=0 }, BE_INT},
|
||||
{ { .s=be_local_const_str(run_deferred_str_2) }, BE_STRING},
|
||||
{ { .s=be_local_const_str(run_deferred_str_3) }, BE_STRING},
|
||||
{ { .i=1 }, BE_INT},
|
||||
{ { .s=be_local_const_str(run_deferred_str_5) }, BE_STRING},
|
||||
};
|
||||
|
||||
static const uint32_t run_deferred_code[27] = {
|
||||
0x88040100, // 0000 GETMBR R1 R0 R256
|
||||
0x78060017, // 0001 JMPF R1 #001A
|
||||
0x58040001, // 0002 LDCONST R1 K1
|
||||
0x88080100, // 0003 GETMBR R2 R0 R256
|
||||
0x8C080502, // 0004 GETMET R2 R2 R258
|
||||
0x7C080200, // 0005 CALL R2 1
|
||||
0x14080202, // 0006 LT R2 R1 R2
|
||||
0x780A0011, // 0007 JMPF R2 #001A
|
||||
0x8C080103, // 0008 GETMET R2 R0 R259
|
||||
0x88100100, // 0009 GETMBR R4 R0 R256
|
||||
0x94100801, // 000A GETIDX R4 R4 R1
|
||||
0x94100901, // 000B GETIDX R4 R4 R257
|
||||
0x7C080400, // 000C CALL R2 2
|
||||
0x780A0009, // 000D JMPF R2 #0018
|
||||
0x88080100, // 000E GETMBR R2 R0 R256
|
||||
0x94080401, // 000F GETIDX R2 R2 R1
|
||||
0x94080504, // 0010 GETIDX R2 R2 R260
|
||||
0x880C0100, // 0011 GETMBR R3 R0 R256
|
||||
0x8C0C0705, // 0012 GETMET R3 R3 R261
|
||||
0x5C140200, // 0013 MOVE R5 R1
|
||||
0x7C0C0400, // 0014 CALL R3 2
|
||||
0x5C0C0400, // 0015 MOVE R3 R2
|
||||
0x7C0C0000, // 0016 CALL R3 0
|
||||
0x70020000, // 0017 JMP #0019
|
||||
0x40304, // 0018 ADD R1 R1 R260
|
||||
0x7001FFE8, // 0019 JMP #0003
|
||||
0x80000000, // 001A RET 0 R0
|
||||
};
|
||||
|
||||
static const bproto run_deferred_proto = {
|
||||
NULL, // bgcobject *next
|
||||
8, // type
|
||||
0x08, // marked
|
||||
6, // nstack
|
||||
0, // nupvals
|
||||
1, // argc
|
||||
0, // varg
|
||||
NULL, // bgcobject *gray
|
||||
NULL, // bupvaldesc *upvals
|
||||
(bvalue*) &run_deferred_ktab, // ktab
|
||||
NULL, // bproto **ptab
|
||||
(binstruction*) &run_deferred_code, // code
|
||||
be_local_const_str(run_deferred_str_name), // name
|
||||
27, // codesize
|
||||
6, // nconst
|
||||
0, // nproto
|
||||
be_local_const_str(run_deferred_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 run_deferred_closure = {
|
||||
NULL, // bgcobject *next
|
||||
36, // type
|
||||
0x08, // marked
|
||||
0, // nupvals
|
||||
NULL, // bgcobject *gray
|
||||
(bproto*) &run_deferred_proto, // proto
|
||||
{ NULL } // upvals
|
||||
};
|
||||
|
||||
be_local_closure(run_deferred, /* name */
|
||||
be_nested_proto(
|
||||
6, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 6]) { /* constants */
|
||||
be_nested_string("_timers", -1694866380, 7), /* R256 - K0 */
|
||||
be_const_int(0), /* R257 - K1 */
|
||||
be_nested_string("size", 597743964, 4), /* R258 - K2 */
|
||||
be_nested_string("time_reached", 2075136773, 12), /* R259 - K3 */
|
||||
be_const_int(1), /* R260 - K4 */
|
||||
be_nested_string("remove", -611183107, 6), /* R261 - K5 */
|
||||
}),
|
||||
(be_nested_const_str("run_deferred", 371594696, 12)),
|
||||
(be_nested_const_str("string", 398550328, 6)),
|
||||
( &(const binstruction[27]) { /* code */
|
||||
0x88040100, // 0000 GETMBR R1 R0 R256
|
||||
0x78060017, // 0001 JMPF R1 #001A
|
||||
0x58040001, // 0002 LDCONST R1 K1
|
||||
0x88080100, // 0003 GETMBR R2 R0 R256
|
||||
0x8C080502, // 0004 GETMET R2 R2 R258
|
||||
0x7C080200, // 0005 CALL R2 1
|
||||
0x14080202, // 0006 LT R2 R1 R2
|
||||
0x780A0011, // 0007 JMPF R2 #001A
|
||||
0x8C080103, // 0008 GETMET R2 R0 R259
|
||||
0x88100100, // 0009 GETMBR R4 R0 R256
|
||||
0x94100801, // 000A GETIDX R4 R4 R1
|
||||
0x94100901, // 000B GETIDX R4 R4 R257
|
||||
0x7C080400, // 000C CALL R2 2
|
||||
0x780A0009, // 000D JMPF R2 #0018
|
||||
0x88080100, // 000E GETMBR R2 R0 R256
|
||||
0x94080401, // 000F GETIDX R2 R2 R1
|
||||
0x94080504, // 0010 GETIDX R2 R2 R260
|
||||
0x880C0100, // 0011 GETMBR R3 R0 R256
|
||||
0x8C0C0705, // 0012 GETMET R3 R3 R261
|
||||
0x5C140200, // 0013 MOVE R5 R1
|
||||
0x7C0C0400, // 0014 CALL R3 2
|
||||
0x5C0C0400, // 0015 MOVE R3 R2
|
||||
0x7C0C0000, // 0016 CALL R3 0
|
||||
0x70020000, // 0017 JMP #0019
|
||||
0x00040304, // 0018 ADD R1 R1 R260
|
||||
0x7001FFE8, // 0019 JMP #0003
|
||||
0x80000000, // 001A RET 0 R0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
// Add command to list
|
||||
"def add_cmd(c,f) "
|
||||
|
@ -1212,113 +1158,60 @@ be_local_closure(remove_cmd, /* name */
|
|||
);
|
||||
/*******************************************************************/
|
||||
|
||||
/********************************************************************
|
||||
// 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 "
|
||||
********************************************************************/
|
||||
/********************************************************************
|
||||
** Solidified function: exec_cmd
|
||||
********************************************************************/
|
||||
|
||||
be_define_local_const_str(exec_cmd_str_name, "exec_cmd", 493567399, 8);
|
||||
be_define_local_const_str(exec_cmd_str_source, "string", 398550328, 6);
|
||||
be_define_local_const_str(exec_cmd_str_0, "_ccmd", -2131545883, 5);
|
||||
be_define_local_const_str(exec_cmd_str_1, "json", 916562499, 4);
|
||||
be_define_local_const_str(exec_cmd_str_2, "load", -435725847, 4);
|
||||
be_define_local_const_str(exec_cmd_str_3, "find_key_i", 850136726, 10);
|
||||
be_define_local_const_str(exec_cmd_str_4, "resolvecmnd", 993361485, 11);
|
||||
|
||||
static const bvalue exec_cmd_ktab[5] = {
|
||||
{ { .s=be_local_const_str(exec_cmd_str_0) }, BE_STRING},
|
||||
{ { .s=be_local_const_str(exec_cmd_str_1) }, BE_STRING},
|
||||
{ { .s=be_local_const_str(exec_cmd_str_2) }, BE_STRING},
|
||||
{ { .s=be_local_const_str(exec_cmd_str_3) }, BE_STRING},
|
||||
{ { .s=be_local_const_str(exec_cmd_str_4) }, BE_STRING},
|
||||
};
|
||||
|
||||
static const uint32_t exec_cmd_code[27] = {
|
||||
0x88100100, // 0000 GETMBR R4 R0 R256
|
||||
0x78120016, // 0001 JMPF R4 #0019
|
||||
0xA4120200, // 0002 IMPORT R4 R257
|
||||
0x8C140902, // 0003 GETMET R5 R4 R258
|
||||
0x5C1C0600, // 0004 MOVE R7 R3
|
||||
0x7C140400, // 0005 CALL R5 2
|
||||
0x8C180103, // 0006 GETMET R6 R0 R259
|
||||
0x88200100, // 0007 GETMBR R8 R0 R256
|
||||
0x5C240200, // 0008 MOVE R9 R1
|
||||
0x7C180600, // 0009 CALL R6 3
|
||||
0x4C1C0000, // 000A LDNIL 7
|
||||
0x201C0C07, // 000B NE R7 R6 R7
|
||||
0x781E000B, // 000C JMPF R7 #0019
|
||||
0x8C1C0104, // 000D GETMET R7 R0 R260
|
||||
0x5C240C00, // 000E MOVE R9 R6
|
||||
0x7C1C0400, // 000F CALL R7 2
|
||||
0x881C0100, // 0010 GETMBR R7 R0 R256
|
||||
0x941C0E06, // 0011 GETIDX R7 R7 R6
|
||||
0x5C200C00, // 0012 MOVE R8 R6
|
||||
0x5C240400, // 0013 MOVE R9 R2
|
||||
0x5C280600, // 0014 MOVE R10 R3
|
||||
0x5C2C0A00, // 0015 MOVE R11 R5
|
||||
0x7C1C0800, // 0016 CALL R7 4
|
||||
0x501C0200, // 0017 LDBOOL R7 1 0
|
||||
0x80040E00, // 0018 RET 1 R7
|
||||
0x50100000, // 0019 LDBOOL R4 0 0
|
||||
0x80040800, // 001A RET 1 R4
|
||||
};
|
||||
|
||||
static const bproto exec_cmd_proto = {
|
||||
NULL, // bgcobject *next
|
||||
8, // type
|
||||
0x08, // marked
|
||||
12, // nstack
|
||||
0, // nupvals
|
||||
4, // argc
|
||||
0, // varg
|
||||
NULL, // bgcobject *gray
|
||||
NULL, // bupvaldesc *upvals
|
||||
(bvalue*) &exec_cmd_ktab, // ktab
|
||||
NULL, // bproto **ptab
|
||||
(binstruction*) &exec_cmd_code, // code
|
||||
be_local_const_str(exec_cmd_str_name), // name
|
||||
27, // codesize
|
||||
5, // nconst
|
||||
0, // nproto
|
||||
be_local_const_str(exec_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 exec_cmd_closure = {
|
||||
NULL, // bgcobject *next
|
||||
36, // type
|
||||
0x08, // marked
|
||||
0, // nupvals
|
||||
NULL, // bgcobject *gray
|
||||
(bproto*) &exec_cmd_proto, // proto
|
||||
{ NULL } // upvals
|
||||
};
|
||||
|
||||
be_local_closure(exec_cmd, /* name */
|
||||
be_nested_proto(
|
||||
12, /* nstack */
|
||||
4, /* argc */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 5]) { /* constants */
|
||||
be_nested_string("_ccmd", -2131545883, 5), /* R256 - K0 */
|
||||
be_nested_string("json", 916562499, 4), /* R257 - K1 */
|
||||
be_nested_string("load", -435725847, 4), /* R258 - K2 */
|
||||
be_nested_string("find_key_i", 850136726, 10), /* R259 - K3 */
|
||||
be_nested_string("resolvecmnd", 993361485, 11), /* R260 - K4 */
|
||||
}),
|
||||
(be_nested_const_str("exec_cmd", 493567399, 8)),
|
||||
(be_nested_const_str("string", 398550328, 6)),
|
||||
( &(const binstruction[27]) { /* code */
|
||||
0x88100100, // 0000 GETMBR R4 R0 R256
|
||||
0x78120016, // 0001 JMPF R4 #0019
|
||||
0xA4120200, // 0002 IMPORT R4 R257
|
||||
0x8C140902, // 0003 GETMET R5 R4 R258
|
||||
0x5C1C0600, // 0004 MOVE R7 R3
|
||||
0x7C140400, // 0005 CALL R5 2
|
||||
0x8C180103, // 0006 GETMET R6 R0 R259
|
||||
0x88200100, // 0007 GETMBR R8 R0 R256
|
||||
0x5C240200, // 0008 MOVE R9 R1
|
||||
0x7C180600, // 0009 CALL R6 3
|
||||
0x4C1C0000, // 000A LDNIL 7
|
||||
0x201C0C07, // 000B NE R7 R6 R7
|
||||
0x781E000B, // 000C JMPF R7 #0019
|
||||
0x8C1C0104, // 000D GETMET R7 R0 R260
|
||||
0x5C240C00, // 000E MOVE R9 R6
|
||||
0x7C1C0400, // 000F CALL R7 2
|
||||
0x881C0100, // 0010 GETMBR R7 R0 R256
|
||||
0x941C0E06, // 0011 GETIDX R7 R7 R6
|
||||
0x5C200C00, // 0012 MOVE R8 R6
|
||||
0x5C240400, // 0013 MOVE R9 R2
|
||||
0x5C280600, // 0014 MOVE R10 R3
|
||||
0x5C2C0A00, // 0015 MOVE R11 R5
|
||||
0x7C1C0800, // 0016 CALL R7 4
|
||||
0x501C0200, // 0017 LDBOOL R7 1 0
|
||||
0x80040E00, // 0018 RET 1 R7
|
||||
0x50100000, // 0019 LDBOOL R4 0 0
|
||||
0x80040800, // 001A RET 1 R4
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
// Force gc and return allocated memory
|
||||
"def gc() "
|
||||
|
@ -1478,70 +1371,37 @@ be_local_closure(event, /* name */
|
|||
/********************************************************************
|
||||
** Solidified function: add_driver
|
||||
********************************************************************/
|
||||
|
||||
be_define_local_const_str(add_driver_str_name, "add_driver", 1654458371, 10);
|
||||
be_define_local_const_str(add_driver_str_source, "string", 398550328, 6);
|
||||
be_define_local_const_str(add_driver_str_0, "_drivers", -1034638311, 8);
|
||||
be_define_local_const_str(add_driver_str_1, "push", -2022703139, 4);
|
||||
|
||||
static const bvalue add_driver_ktab[2] = {
|
||||
{ { .s=be_local_const_str(add_driver_str_0) }, BE_STRING},
|
||||
{ { .s=be_local_const_str(add_driver_str_1) }, BE_STRING},
|
||||
};
|
||||
|
||||
static const uint32_t add_driver_code[12] = {
|
||||
0x88080100, // 0000 GETMBR R2 R0 R256
|
||||
0x780A0004, // 0001 JMPF R2 #0007
|
||||
0x88080100, // 0002 GETMBR R2 R0 R256
|
||||
0x8C080501, // 0003 GETMET R2 R2 R257
|
||||
0x5C100200, // 0004 MOVE R4 R1
|
||||
0x7C080400, // 0005 CALL R2 2
|
||||
0x70020003, // 0006 JMP #000B
|
||||
0x6008000A, // 0007 GETGBL R2 G10
|
||||
0x7C080000, // 0008 CALL R2 0
|
||||
0x400C0401, // 0009 CONNECT R3 R2 R1
|
||||
0x90020002, // 000A SETMBR R0 R256 R2
|
||||
0x80000000, // 000B RET 0 R0
|
||||
};
|
||||
|
||||
static const bproto add_driver_proto = {
|
||||
NULL, // bgcobject *next
|
||||
8, // type
|
||||
0x08, // marked
|
||||
5, // nstack
|
||||
0, // nupvals
|
||||
2, // argc
|
||||
0, // varg
|
||||
NULL, // bgcobject *gray
|
||||
NULL, // bupvaldesc *upvals
|
||||
(bvalue*) &add_driver_ktab, // ktab
|
||||
NULL, // bproto **ptab
|
||||
(binstruction*) &add_driver_code, // code
|
||||
be_local_const_str(add_driver_str_name), // name
|
||||
12, // codesize
|
||||
2, // nconst
|
||||
0, // nproto
|
||||
be_local_const_str(add_driver_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 add_driver_closure = {
|
||||
NULL, // bgcobject *next
|
||||
36, // type
|
||||
0x08, // marked
|
||||
0, // nupvals
|
||||
NULL, // bgcobject *gray
|
||||
(bproto*) &add_driver_proto, // proto
|
||||
{ NULL } // upvals
|
||||
};
|
||||
|
||||
be_local_closure(add_driver, /* 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]) { /* constants */
|
||||
be_nested_string("_drivers", -1034638311, 8), /* R256 - K0 */
|
||||
be_nested_string("push", -2022703139, 4), /* R257 - K1 */
|
||||
}),
|
||||
(be_nested_const_str("add_driver", 1654458371, 10)),
|
||||
(be_nested_const_str("string", 398550328, 6)),
|
||||
( &(const binstruction[12]) { /* code */
|
||||
0x88080100, // 0000 GETMBR R2 R0 R256
|
||||
0x780A0004, // 0001 JMPF R2 #0007
|
||||
0x88080100, // 0002 GETMBR R2 R0 R256
|
||||
0x8C080501, // 0003 GETMET R2 R2 R257
|
||||
0x5C100200, // 0004 MOVE R4 R1
|
||||
0x7C080400, // 0005 CALL R2 2
|
||||
0x70020003, // 0006 JMP #000B
|
||||
0x6008000A, // 0007 GETGBL R2 G10
|
||||
0x7C080000, // 0008 CALL R2 0
|
||||
0x400C0401, // 0009 CONNECT R3 R2 R1
|
||||
0x90020002, // 000A SETMBR R0 R256 R2
|
||||
0x80000000, // 000B RET 0 R0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
/********************************************************************
|
||||
|
|
|
@ -265,6 +265,47 @@ class Tasmota
|
|||
end
|
||||
end
|
||||
|
||||
def add_driver(d)
|
||||
if self._drivers
|
||||
self._drivers.push(d)
|
||||
else
|
||||
self._drivers = [d]
|
||||
end
|
||||
end
|
||||
|
||||
# cmd high-level function
|
||||
def cmd(command)
|
||||
import json
|
||||
var ret = self._cmd(command)
|
||||
var j = json.load(ret)
|
||||
if type(j) == 'instance'
|
||||
return j
|
||||
else
|
||||
return {'response':j}
|
||||
end
|
||||
end
|
||||
|
||||
# set_light and get_light deprecetaion
|
||||
def get_light(l)
|
||||
print('tasmota.get_light() is deprecated, use light.get()')
|
||||
import light
|
||||
if l != nil
|
||||
return light.get(l)
|
||||
else
|
||||
return light.get()
|
||||
end
|
||||
end
|
||||
def set_light(v,l)
|
||||
print('tasmota.set_light() is deprecated, use light.set()')
|
||||
import light
|
||||
if l != nil
|
||||
return light.set(v,l)
|
||||
else
|
||||
return light.set(v)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
#- dispatch callback number n, with parameters v0,v1,v2,v3 -#
|
||||
def cb_dispatch(n,v0,v1,v2,v3)
|
||||
if self._cb == nil return 0 end
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
#define min(a, b) ((a) < (b) ? (a) : (b))
|
||||
#define notexpr(e) isset((e)->not, NOT_EXPR)
|
||||
#define notmask(e) isset((e)->not, NOT_MASK)
|
||||
#define exp2anyreg(f, e) exp2reg(f, e, (f)->freereg)
|
||||
#define var2anyreg(f, e) var2reg(f, e, (f)->freereg)
|
||||
#define exp2anyreg(f, e) exp2reg(f, e, -1) /* -1 means allocate a new register if needed */
|
||||
#define var2anyreg(f, e) var2reg(f, e, -1) /* -1 means allocate a new register if needed */
|
||||
#define hasjump(e) ((e)->t != (e)->f || notexpr(e))
|
||||
#define code_bool(f, r, b, j) codeABC(f, OP_LDBOOL, r, b, j)
|
||||
#define code_call(f, a, b) codeABC(f, OP_CALL, a, b, 0)
|
||||
|
@ -321,9 +321,38 @@ static void free_suffix(bfuncinfo *finfo, bexpdesc *e)
|
|||
}
|
||||
}
|
||||
|
||||
static int suffix_destreg(bfuncinfo *finfo, bexpdesc *e1, int dst)
|
||||
{
|
||||
int cand_dst = dst; /* candidate for new dst */
|
||||
int nlocal = be_list_count(finfo->local);
|
||||
int reg1 = (e1->v.ss.tt == ETREG) ? e1->v.ss.obj : -1; /* check if obj is ETREG or -1 */
|
||||
int reg2 = (!isK(e1->v.ss.idx) && e1->v.ss.idx >= nlocal) ? e1->v.ss.idx : -1; /* check if idx is ETREG or -1 */
|
||||
|
||||
if (reg1 >= 0 && reg2 >= 0) {
|
||||
/* both are ETREG, we keep the lowest and discard the other */
|
||||
if (reg1 != reg2) {
|
||||
cand_dst = min(reg1, reg2);
|
||||
be_code_freeregs(finfo, 1); /* and free the other one */
|
||||
} else {
|
||||
cand_dst = reg1; /* both ETREG are equal, we return its value */
|
||||
}
|
||||
} else if (reg1 >= 0) {
|
||||
cand_dst = reg1;
|
||||
} else if (reg2 >= 0) {
|
||||
cand_dst = reg2;
|
||||
} else {
|
||||
// dst unchanged
|
||||
}
|
||||
|
||||
if (dst >= finfo->freereg) {
|
||||
dst = cand_dst; /* if dst was allocating a new register, use the more precise candidate */
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
|
||||
static int code_suffix(bfuncinfo *finfo, bopcode op, bexpdesc *e, int dst)
|
||||
{
|
||||
free_suffix(finfo, e); /* free temporary registers */
|
||||
dst = suffix_destreg(finfo, e, dst);
|
||||
if (dst > finfo->freereg) {
|
||||
dst = finfo->freereg;
|
||||
}
|
||||
|
@ -351,6 +380,9 @@ static bbool constint(bfuncinfo *finfo, bint i)
|
|||
|
||||
static int var2reg(bfuncinfo *finfo, bexpdesc *e, int dst)
|
||||
{
|
||||
if (dst < 0) { /* if unspecified, allocate a new register if needed */
|
||||
dst = finfo->freereg;
|
||||
}
|
||||
be_assert(e != NULL);
|
||||
switch (e->type) {
|
||||
case ETINT:
|
||||
|
@ -420,28 +452,37 @@ static int exp2reg(bfuncinfo *finfo, bexpdesc *e, int dst)
|
|||
return reg;
|
||||
}
|
||||
|
||||
static int codedestreg(bfuncinfo *finfo, bexpdesc *e1, bexpdesc *e2)
|
||||
static int codedestreg(bfuncinfo *finfo, bexpdesc *e1, bexpdesc *e2, int dst)
|
||||
{
|
||||
int dst, con1 = e1->type == ETREG, con2 = e2->type == ETREG;
|
||||
int cand_dst = dst;
|
||||
int con1 = e1->type == ETREG, con2 = e2->type == ETREG;
|
||||
|
||||
if (con1 && con2) {
|
||||
dst = min(e1->v.idx, e2->v.idx);
|
||||
cand_dst = min(e1->v.idx, e2->v.idx);
|
||||
be_code_freeregs(finfo, 1);
|
||||
} else if (con1) {
|
||||
dst = e1->v.idx;
|
||||
cand_dst = e1->v.idx;
|
||||
} else if (con2) {
|
||||
dst = e2->v.idx;
|
||||
cand_dst = e2->v.idx;
|
||||
} else {
|
||||
dst = be_code_allocregs(finfo, 1);
|
||||
if (dst >= finfo->freereg) {
|
||||
cand_dst = be_code_allocregs(finfo, 1);
|
||||
return cand_dst;
|
||||
}
|
||||
}
|
||||
if (dst >= finfo->freereg) {
|
||||
return cand_dst;
|
||||
} else {
|
||||
return dst;
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
|
||||
static void binaryexp(bfuncinfo *finfo, bopcode op, bexpdesc *e1, bexpdesc *e2)
|
||||
static void binaryexp(bfuncinfo *finfo, bopcode op, bexpdesc *e1, bexpdesc *e2, int dst)
|
||||
{
|
||||
int src1 = exp2anyreg(finfo, e1);
|
||||
if (dst < 0) { dst = finfo->freereg; }
|
||||
int src1 = exp2reg(finfo, e1, dst); /* potentially force the target for src1 reg */
|
||||
int src2 = exp2anyreg(finfo, e2);
|
||||
int dst = codedestreg(finfo, e1, e2);
|
||||
dst = codedestreg(finfo, e1, e2, dst);
|
||||
codeABC(finfo, op, dst, src1, src2);
|
||||
e1->type = ETREG;
|
||||
e1->v.idx = dst;
|
||||
|
@ -462,7 +503,7 @@ void be_code_prebinop(bfuncinfo *finfo, int op, bexpdesc *e)
|
|||
}
|
||||
}
|
||||
|
||||
void be_code_binop(bfuncinfo *finfo, int op, bexpdesc *e1, bexpdesc *e2)
|
||||
void be_code_binop(bfuncinfo *finfo, int op, bexpdesc *e1, bexpdesc *e2, int dst)
|
||||
{
|
||||
switch (op) {
|
||||
case OptAnd:
|
||||
|
@ -480,7 +521,7 @@ void be_code_binop(bfuncinfo *finfo, int op, bexpdesc *e1, bexpdesc *e2)
|
|||
case OptNE: case OptGT: case OptGE: case OptConnect:
|
||||
case OptBitAnd: case OptBitOr: case OptBitXor:
|
||||
case OptShiftL: case OptShiftR:
|
||||
binaryexp(finfo, (bopcode)(op - OptAdd), e1, e2);
|
||||
binaryexp(finfo, (bopcode)(op - OptAdd), e1, e2, dst);
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
|
@ -586,7 +627,7 @@ static void setsfxvar(bfuncinfo *finfo, bopcode op, bexpdesc *e1, int src)
|
|||
int be_code_setvar(bfuncinfo *finfo, bexpdesc *e1, bexpdesc *e2)
|
||||
{
|
||||
int src = exp2reg(finfo, e2,
|
||||
e1->type == ETLOCAL ? e1->v.idx : finfo->freereg);
|
||||
e1->type == ETLOCAL ? e1->v.idx : -1);
|
||||
|
||||
if (e1->type != ETLOCAL || e1->v.idx != src) {
|
||||
free_expreg(finfo, e2); /* free source (only ETREG) */
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
int be_code_allocregs(bfuncinfo *finfo, int count);
|
||||
void be_code_prebinop(bfuncinfo *finfo, int op, bexpdesc *e);
|
||||
void be_code_binop(bfuncinfo *finfo, int op, bexpdesc *e1, bexpdesc *e2);
|
||||
void be_code_binop(bfuncinfo *finfo, int op, bexpdesc *e1, bexpdesc *e2, int dst);
|
||||
int be_code_unop(bfuncinfo *finfo, int op, bexpdesc *e);
|
||||
int be_code_setvar(bfuncinfo *finfo, bexpdesc *e1, bexpdesc *e2);
|
||||
int be_code_nextreg(bfuncinfo *finfo, bexpdesc *e);
|
||||
|
|
|
@ -610,7 +610,7 @@ static void list_nextmember(bparser *parser, bexpdesc *l)
|
|||
bfuncinfo *finfo = parser->finfo;
|
||||
expr(parser, &e); /* value */
|
||||
check_var(parser, &e);
|
||||
be_code_binop(finfo, OptConnect, &v, &e);
|
||||
be_code_binop(finfo, OptConnect, &v, &e, -1);
|
||||
be_code_freeregs(finfo, 1);
|
||||
}
|
||||
|
||||
|
@ -823,9 +823,11 @@ static void suffix_alloc_reg(bparser *parser, bexpdesc *l)
|
|||
/* compound assignment */
|
||||
static void compound_assign(bparser *parser, int op, bexpdesc *l, bexpdesc *r)
|
||||
{
|
||||
int dst = -1; /* destination register in case of compound assignment */
|
||||
if (op != OptAssign) { /* check left variable */
|
||||
check_var(parser, l);
|
||||
/* cache the register of the object when continuously assigning */
|
||||
dst = parser->finfo->freereg;
|
||||
suffix_alloc_reg(parser, l);
|
||||
}
|
||||
expr(parser, r); /* right expression */
|
||||
|
@ -834,7 +836,7 @@ static void compound_assign(bparser *parser, int op, bexpdesc *l, bexpdesc *r)
|
|||
bexpdesc e = *l;
|
||||
op = op < OptAndAssign ? op - OptAddAssign + OptAdd
|
||||
: op - OptAndAssign + OptBitAnd;
|
||||
be_code_binop(parser->finfo, op, &e, r); /* coding operation */
|
||||
be_code_binop(parser->finfo, op, &e, r, dst); /* coding operation */
|
||||
*r = e;
|
||||
}
|
||||
}
|
||||
|
@ -938,7 +940,7 @@ static void sub_expr(bparser *parser, bexpdesc *e, int prio)
|
|||
init_exp(&e2, ETVOID, 0);
|
||||
sub_expr(parser, &e2, binary_op_prio(op));
|
||||
check_var(parser, &e2);
|
||||
be_code_binop(finfo, op, e, &e2); /* encode binary op */
|
||||
be_code_binop(finfo, op, e, &e2, -1); /* encode binary op */
|
||||
op = get_binop(parser);
|
||||
}
|
||||
if (prio == ASSIGN_OP_PRIO) {
|
||||
|
|
|
@ -352,6 +352,17 @@ typedef struct bntvmodule {
|
|||
PROTO_VAR_INFO_BLOCK \
|
||||
}
|
||||
|
||||
#define be_define_local_closure(_name) \
|
||||
const bclosure _name##_closure = { \
|
||||
NULL, /* bgcobject *next */ \
|
||||
BE_CLOSURE, /* type BE_CLOSURE */ \
|
||||
GC_CONST, /* marked GC_CONST */ \
|
||||
0, /* nupvals */ \
|
||||
NULL, /* bgcobject *gray */ \
|
||||
(bproto*) &_name##_proto, /* proto */ \
|
||||
{ NULL } /* upvals */ \
|
||||
}
|
||||
|
||||
/* new version for more compact literals */
|
||||
#define be_local_closure(_name, _proto) \
|
||||
static const bclosure _name##_closure = { \
|
||||
|
|
|
@ -316,7 +316,7 @@ float CharToFloat(const char *str)
|
|||
char *pt = strbuf;
|
||||
if (*pt == '\0') { return 0.0; }
|
||||
|
||||
while ((*pt != '\0') && isblank(*pt)) { pt++; } // Trim leading spaces
|
||||
while ((*pt != '\0') && isspace(*pt)) { pt++; } // Trim leading spaces
|
||||
|
||||
signed char sign = 1;
|
||||
if (*pt == '-') { sign = -1; }
|
||||
|
@ -524,17 +524,18 @@ bool StrCaseStr_P(const char* source, const char* search) {
|
|||
}
|
||||
|
||||
bool IsNumeric(const char* value) {
|
||||
// Test for characters '-.0123456789'
|
||||
char *digit = (char*)value;
|
||||
while (isdigit(*digit) || *digit == '.' || *digit == '-') { digit++; }
|
||||
return (*digit == '\0');
|
||||
}
|
||||
|
||||
char* Trim(char* p)
|
||||
{
|
||||
char* Trim(char* p) {
|
||||
// Remove leading and trailing tab, \n, \v, \f, \r and space
|
||||
if (*p != '\0') {
|
||||
while ((*p != '\0') && isblank(*p)) { p++; } // Trim leading spaces
|
||||
while ((*p != '\0') && isspace(*p)) { p++; } // Trim leading spaces
|
||||
char* q = p + strlen(p) -1;
|
||||
while ((q >= p) && isblank(*q)) { q--; } // Trim trailing spaces
|
||||
while ((q >= p) && isspace(*q)) { q--; } // Trim trailing spaces
|
||||
q++;
|
||||
*q = '\0';
|
||||
}
|
||||
|
|
|
@ -20,6 +20,6 @@
|
|||
#ifndef _TASMOTA_VERSION_H_
|
||||
#define _TASMOTA_VERSION_H_
|
||||
|
||||
const uint32_t VERSION = 0x09050005;
|
||||
const uint32_t VERSION = 0x09050006;
|
||||
|
||||
#endif // _TASMOTA_VERSION_H_
|
||||
|
|
|
@ -84,7 +84,7 @@ struct {
|
|||
String _serverUrl; // Connection info
|
||||
String _writeUrl; // Cached full write url
|
||||
String _lastErrorResponse; // Server reponse or library error message for last failed request
|
||||
uint32_t _lastRequestTime = 0; // Last time in ms we made are a request to server
|
||||
uint32_t _lastRequestTime = 0; // Last time in ms we made a request to server
|
||||
int interval = 0;
|
||||
int _lastStatusCode = 0; // HTTP status code of last request to server
|
||||
int _lastRetryAfter = 0; // Store retry timeout suggested by server after last request
|
||||
|
@ -161,7 +161,7 @@ void InfluxDbAfterRequest(int expectedStatusCode, bool modifyLastConnStatus) {
|
|||
IFDB._lastRequestTime = millis();
|
||||
// AddLog(LOG_LEVEL_DEBUG, PSTR("IFX: HTTP status code %d"), IFDB._lastStatusCode);
|
||||
IFDB._lastRetryAfter = 0;
|
||||
if (IFDB._lastStatusCode >= 429) { //retryable server errors
|
||||
if (IFDB._lastStatusCode >= 429) { // Retryable server errors
|
||||
if (IFDBhttpClient->hasHeader(RetryAfter)) {
|
||||
IFDB._lastRetryAfter = IFDBhttpClient->header(RetryAfter).toInt();
|
||||
AddLog(LOG_LEVEL_DEBUG, PSTR("IFX: Reply after %d"), IFDB._lastRetryAfter);
|
||||
|
@ -171,12 +171,12 @@ void InfluxDbAfterRequest(int expectedStatusCode, bool modifyLastConnStatus) {
|
|||
IFDB._lastErrorResponse = "";
|
||||
if (IFDB._lastStatusCode != expectedStatusCode) {
|
||||
if (IFDB._lastStatusCode > 0) {
|
||||
IFDB._lastErrorResponse = IFDBhttpClient->getString();
|
||||
AddLog(LOG_LEVEL_INFO, PSTR("IFX: %s"), IFDB._lastErrorResponse.c_str()); // {"error":"database not found: \"db\""}
|
||||
IFDB._lastErrorResponse = IFDBhttpClient->getString(); // {"error":"database not found: \"db\""}\n
|
||||
} else {
|
||||
IFDB._lastErrorResponse = IFDBhttpClient->errorToString(IFDB._lastStatusCode);
|
||||
AddLog(LOG_LEVEL_INFO, PSTR("IFX: Error %s"), IFDB._lastErrorResponse.c_str());
|
||||
}
|
||||
IFDB._lastErrorResponse.trim(); // Remove trailing \n
|
||||
AddLog(LOG_LEVEL_INFO, PSTR("IFX: Error %s"), IFDB._lastErrorResponse.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -191,8 +191,6 @@ bool InfluxDbValidateConnection(void) {
|
|||
if (1 == Settings->influxdb_version) {
|
||||
url += InfluxDbAuth();
|
||||
}
|
||||
// on version 1.8.9 /health works fine
|
||||
// String url = IFDB._serverUrl + "/health";
|
||||
AddLog(LOG_LEVEL_INFO, PSTR("IFX: Validating connection to %s"), url.c_str());
|
||||
|
||||
if (!IFDBhttpClient->begin(*IFDBwifiClient, url)) {
|
||||
|
@ -221,6 +219,7 @@ int InfluxDbPostData(const char *data) {
|
|||
return false;
|
||||
}
|
||||
|
||||
Trim((char*)data); // Remove trailing \n
|
||||
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("IFX: Sending\n%s"), data);
|
||||
IFDBhttpClient->addHeader(F("Content-Type"), F("text/plain"));
|
||||
InfluxDbBeforeRequest();
|
||||
|
@ -294,36 +293,38 @@ void InfluxDbProcessJson(void) {
|
|||
} else {
|
||||
// Level 2
|
||||
// { ... "ANALOG":{"Temperature":184.72},"DS18B20":{"Id":"01144A0CB2AA","Temperature":24.88},"HTU21":{"Temperature":25.32,"Humidity":49.2,"DewPoint":13.88},"Global":{"Temperature":24.88,"Humidity":49.2,"DewPoint":13.47}, ... }
|
||||
bool isarray = value2.isArray();
|
||||
const char* value = InfluxDbNumber(number, (isarray) ? (value2.getArray())[0].getStr() : value2.getStr());
|
||||
LowerCase(type, key2.getStr());
|
||||
bool is_id = (!strcmp_P(type, PSTR("id"))); // Index for DS18B20
|
||||
bool is_array = value2.isArray();
|
||||
const char* value = nullptr;
|
||||
if (is_id && !is_array) {
|
||||
snprintf_P(sensor_id, sizeof(sensor_id), PSTR(",id=%s"), value2.getStr());
|
||||
} else {
|
||||
value = InfluxDbNumber(number, (is_array) ? (value2.getArray())[0].getStr() : value2.getStr());
|
||||
}
|
||||
if (value != nullptr) {
|
||||
LowerCase(sensor, key1.getStr());
|
||||
LowerCase(type, key2.getStr());
|
||||
|
||||
// AddLog(LOG_LEVEL_DEBUG, PSTR("IFX2: sensor %s (%s), type %s (%s)"), key1.getStr(), sensor, key2.getStr(), type);
|
||||
|
||||
if (strcmp(type, "id") == 0) { // Index for DS18B20
|
||||
snprintf_P(sensor_id, sizeof(sensor_id), PSTR(",id=%s"), value);
|
||||
} else {
|
||||
if (isarray) {
|
||||
JsonParserArray arr = value2.getArray();
|
||||
uint32_t i = 0;
|
||||
for (auto val : arr) {
|
||||
i++;
|
||||
// power1,device=shelly25,sensor=energy value=0.00
|
||||
// power2,device=shelly25,sensor=energy value=4.12
|
||||
snprintf_P(linebuf, sizeof(linebuf), PSTR("%s%d,device=%s,sensor=%s%s value=%s\n"),
|
||||
type, i, TasmotaGlobal.mqtt_topic, sensor, sensor_id, val.getStr());
|
||||
data += linebuf;
|
||||
}
|
||||
} else {
|
||||
// temperature,device=demo,sensor=ds18b20,id=01144A0CB2AA value=22.63
|
||||
snprintf_P(linebuf, sizeof(linebuf), PSTR("%s,device=%s,sensor=%s%s value=%s\n"),
|
||||
type, TasmotaGlobal.mqtt_topic, sensor, sensor_id, value);
|
||||
if (is_array) {
|
||||
JsonParserArray arr = value2.getArray();
|
||||
uint32_t i = 0;
|
||||
for (auto val : arr) {
|
||||
i++;
|
||||
// power1,device=shelly25,sensor=energy value=0.00
|
||||
// power2,device=shelly25,sensor=energy value=4.12
|
||||
snprintf_P(linebuf, sizeof(linebuf), PSTR("%s%d,device=%s,sensor=%s%s value=%s\n"),
|
||||
type, i, TasmotaGlobal.mqtt_topic, sensor, sensor_id, val.getStr());
|
||||
data += linebuf;
|
||||
}
|
||||
sensor_id[0] = '\0';
|
||||
} else {
|
||||
// temperature,device=demo,sensor=ds18b20,id=01144A0CB2AA value=22.63
|
||||
snprintf_P(linebuf, sizeof(linebuf), PSTR("%s,device=%s,sensor=%s%s value=%s\n"),
|
||||
type, TasmotaGlobal.mqtt_topic, sensor, sensor_id, value);
|
||||
data += linebuf;
|
||||
}
|
||||
sensor_id[0] = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1198,7 +1198,7 @@ double CharToDouble(const char *str)
|
|||
|
||||
strlcpy(strbuf, str, sizeof(strbuf));
|
||||
char *pt = strbuf;
|
||||
while ((*pt != '\0') && isblank(*pt)) { pt++; } // Trim leading spaces
|
||||
while ((*pt != '\0') && isspace(*pt)) { pt++; } // Trim leading spaces
|
||||
|
||||
signed char sign = 1;
|
||||
if (*pt == '-') { sign = -1; }
|
||||
|
|
Loading…
Reference in New Issue