Merge branch 'development' into mjpeg_auth

This commit is contained in:
Nemobi 2022-05-24 21:09:36 +00:00
commit 28bed5ca4b
79 changed files with 2793 additions and 1582 deletions

View File

@ -39,6 +39,9 @@ jobs:
- tasmota32-lvgl
- tasmota32c3
- tasmota32c3usb
- tasmota32s2
- tasmota32s3
- tasmota32s3usb
- tasmota32solo1
- tasmota32solo1-safeboot
- tasmota32-safeboot
@ -46,6 +49,7 @@ jobs:
- tasmota32c3usb-safeboot
- tasmota32s2-safeboot
- tasmota32s3-safeboot
- tasmota32s3usb-safeboot
steps:
- uses: actions/checkout@v3
with:
@ -124,6 +128,8 @@ jobs:
[ ! -f ./mv_firmware/firmware/tasmota32-core2.* ] || mv ./mv_firmware/firmware/tasmota32-core2.* ./firmware/tasmota32/
[ ! -f ./mv_firmware/firmware/tasmota32-bluetooth.* ] || mv ./mv_firmware/firmware/tasmota32-bluetooth.* ./firmware/tasmota32/
[ ! -f ./mv_firmware/firmware/tasmota32c3*.* ] || mv ./mv_firmware/firmware/tasmota32c3*.* ./firmware/tasmota32/
[ ! -f ./mv_firmware/firmware/tasmota32s2*.* ] || mv ./mv_firmware/firmware/tasmota32s2*.* ./firmware/tasmota32/
[ ! -f ./mv_firmware/firmware/tasmota32s3*.* ] || mv ./mv_firmware/firmware/tasmota32s3*.* ./firmware/tasmota32/
[ ! -f ./mv_firmware/firmware/tasmota32-safeboot* ] || mv ./mv_firmware/firmware/tasmota32-safeboot* ./firmware/tasmota32/
[ ! -f ./mv_firmware/firmware/tasmota32-* ] || mv ./mv_firmware/firmware/tasmota32-* ./firmware/tasmota32/languages/
[ ! -f ./mv_firmware/firmware/tasmota32* ] || mv ./mv_firmware/firmware/tasmota32* ./firmware/tasmota32/

View File

@ -38,13 +38,17 @@ jobs:
- tasmota32-lvgl
- tasmota32c3
- tasmota32c3usb
- tasmota32s2
- tasmota32s3
- tasmota32s3usb
- tasmota32solo1
- tasmota32solo1-safeboot
- tasmota32-safeboot
- tasmota32c3-safeboot
- tasmota32c3usb-safeboot
- tasmota32s2-safeboot
- tasmota32s3-safeboot
- tasmota32c3usb-safeboot
- tasmota32s3usb-safeboot
steps:
- uses: actions/checkout@v3
with:
@ -132,6 +136,8 @@ jobs:
[ ! -f ./mv_firmware/firmware/tasmota32-core2.* ] || mv ./mv_firmware/firmware/tasmota32-core2.* ./release-firmware/tasmota32/
[ ! -f ./mv_firmware/firmware/tasmota32-bluetooth.* ] || mv ./mv_firmware/firmware/tasmota32-bluetooth.* ./release-firmware/tasmota32/
[ ! -f ./mv_firmware/firmware/tasmota32c3*.* ] || mv ./mv_firmware/firmware/tasmota32c3*.* ./release-firmware/tasmota32/
[ ! -f ./mv_firmware/firmware/tasmota32s2*.* ] || mv ./mv_firmware/firmware/tasmota32s2*.* ./release-firmware/tasmota32/
[ ! -f ./mv_firmware/firmware/tasmota32s3*.* ] || mv ./mv_firmware/firmware/tasmota32s3*.* ./release-firmware/tasmota32/
[ ! -f ./mv_firmware/firmware/tasmota32-safeboot* ] || mv ./mv_firmware/firmware/tasmota32-safeboot* ./release-firmware/tasmota32/
[ ! -f ./mv_firmware/firmware/tasmota32-* ] || mv ./mv_firmware/firmware/tasmota32-* ./release-firmware/tasmota32/languages/
[ ! -f ./mv_firmware/firmware/tasmota32* ] || mv ./mv_firmware/firmware/tasmota32* ./release-firmware/tasmota32/languages/

View File

@ -40,9 +40,11 @@ jobs:
- tasmota32-display
- tasmota32-ir
- tasmota32-lvgl
- tasmota32s2
- tasmota32c3
- tasmota32c3usb
- tasmota32s2
- tasmota32s3
- tasmota32s3usb
- tasmota32solo1
- tasmota32solo1-safeboot
- tasmota32-safeboot
@ -50,6 +52,7 @@ jobs:
- tasmota32c3usb-safeboot
- tasmota32s2-safeboot
- tasmota32s3-safeboot
- tasmota32s3usb-safeboot
steps:
- uses: actions/checkout@v2
- name: Set up Python

View File

@ -48,7 +48,7 @@ public:
inline uint8_t *buf(size_t i = 0) const { return &_buf->buf[i]; }
inline char *charptr(size_t i = 0) const { return (char*) &_buf->buf[i]; }
virtual ~SBuffer(void) {
~SBuffer(void) {
delete[] _buf;
}
@ -258,6 +258,12 @@ public:
return buf2;
}
static SBuffer SBufferFromBytes(const uint8_t *bytes, size_t len2) {
SBuffer buf2(len2);
buf2.addBuffer(bytes, len2);
return buf2;
}
// nullptr accepted
static bool equalsSBuffer(const class SBuffer * buf1, const class SBuffer * buf2) {
if (buf1 == buf2) { return true; }
@ -290,18 +296,3 @@ protected:
SBuffer_impl * _buf;
} SBuffer;
typedef class PreAllocatedSBuffer : public SBuffer {
public:
PreAllocatedSBuffer(const size_t size, void * buffer) {
_buf = (SBuffer_impl*) buffer;
_buf->size = size - 4;
_buf->len = 0;
}
~PreAllocatedSBuffer(void) {
// don't deallocate
_buf = nullptr;
}
} PreAllocatedSBuffer;

View File

@ -48,13 +48,16 @@ be_extern_native_module(uuid);
be_extern_native_module(animate);
be_extern_native_module(partition_core);
be_extern_native_module(crc);
#ifdef USE_ZIGBEE
be_extern_native_module(zigbee);
#endif // USE_ZIGBEE
#ifdef USE_LVGL
be_extern_native_module(lv);
be_extern_native_module(lv_extra);
be_extern_native_module(lv_tasmota);
#ifdef USE_LVGL_OPENHASP
be_extern_native_module(openhasp);
#endif // USE_LVGL_OPENHASP
#ifdef USE_LVGL_HASPMOTA
be_extern_native_module(haspmota);
#endif // USE_LVGL_HASPMOTA
#endif // USE_LVGL
/* user-defined modules declare start */
@ -137,9 +140,9 @@ BERRY_LOCAL const bntvmodule* const be_module_table[] = {
&be_native_module(lv),
&be_native_module(lv_extra),
&be_native_module(lv_tasmota),
#ifdef USE_LVGL_OPENHASP
&be_native_module(openhasp),
#endif // USE_LVGL_OPENHASP
#ifdef USE_LVGL_HASPMOTA
&be_native_module(haspmota),
#endif // USE_LVGL_HASPMOTA
#endif // USE_LVGL
#ifdef USE_ENERGY_SENSOR
&be_native_module(energy),
@ -147,6 +150,9 @@ BERRY_LOCAL const bntvmodule* const be_module_table[] = {
#ifdef USE_WEBSERVER
&be_native_module(webserver),
#endif // USE_WEBSERVER
#ifdef USE_ZIGBEE
&be_native_module(zigbee),
#endif // USE_ZIGBEE
&be_native_module(flash),
&be_native_module(partition_core),
&be_native_module(crc),

View File

@ -1,2 +1,8 @@
#!/bin/bash
#
# generate all precompiled Berry structures from multiple modules
#
# Should be eventually included in the build process
#
rm generate/be_*.h
python3 tools/pycoc/main.py -o generate src default ../berry_tasmota/src ../berry_mapping/src ../berry_int64/src ../../libesp32_lvgl/lv_binding_berry/src ../../libesp32_lvgl/lv_binding_berry/generate -c default/berry_conf.h

View File

@ -1,5 +1,6 @@
extern const bcstring be_const_str_;
extern const bcstring be_const_str_00;
extern const bcstring be_const_str_0x_X2502X;
extern const bcstring be_const_str_AA50;
extern const bcstring be_const_str_AES_GCM;
extern const bcstring be_const_str_ALIGN_BOTTOM_MID;
@ -264,6 +265,7 @@ extern const bcstring be_const_str__timers;
extern const bcstring be_const_str__validate;
extern const bcstring be_const_str__write;
extern const bcstring be_const_str_a;
extern const bcstring be_const_str_abort;
extern const bcstring be_const_str_abs;
extern const bcstring be_const_str_acos;
extern const bcstring be_const_str_active_otadata;
@ -486,6 +488,7 @@ extern const bcstring be_const_str_format;
extern const bcstring be_const_str_from_to;
extern const bcstring be_const_str_fromb64;
extern const bcstring be_const_str_frombytes;
extern const bcstring be_const_str_fromhex;
extern const bcstring be_const_str_fromptr;
extern const bcstring be_const_str_fromstring;
extern const bcstring be_const_str_full_state;
@ -567,6 +570,7 @@ extern const bcstring be_const_str_imax;
extern const bcstring be_const_str_img;
extern const bcstring be_const_str_imin;
extern const bcstring be_const_str_import;
extern const bcstring be_const_str_info;
extern const bcstring be_const_str_init;
extern const bcstring be_const_str_init_draw_arc_dsc;
extern const bcstring be_const_str_init_draw_line_dsc;
@ -917,6 +921,7 @@ extern const bcstring be_const_str_subscribe;
extern const bcstring be_const_str_subtype;
extern const bcstring be_const_str_subtype_to_string;
extern const bcstring be_const_str_success;
extern const bcstring be_const_str_sum;
extern const bcstring be_const_str_super;
extern const bcstring be_const_str_switch_factory;
extern const bcstring be_const_str_sys;
@ -1029,5 +1034,9 @@ extern const bcstring be_const_str_y;
extern const bcstring be_const_str_y1;
extern const bcstring be_const_str_year;
extern const bcstring be_const_str_yield;
extern const bcstring be_const_str_zb_coord_ntv;
extern const bcstring be_const_str_zb_device;
extern const bcstring be_const_str_zcl_frame;
extern const bcstring be_const_str_zcl_frame_ntv;
extern const bcstring be_const_str_zero;
extern const bcstring be_const_str_zip;

File diff suppressed because it is too large Load Diff

View File

@ -1,42 +1,43 @@
#include "be_constobj.h"
static be_define_const_map_slots(be_class_bytes_map) {
{ be_const_key(deinit, -1), be_const_func(m_deinit) },
{ be_const_key(get, 5), be_const_func(m_getu) },
{ be_const_key(fromb64, 18), be_const_func(m_fromb64) },
{ be_const_key(copy, -1), be_const_func(m_copy) },
{ be_const_key(_buffer, -1), be_const_func(m_buffer) },
{ be_const_key(getfloat, -1), be_const_func(m_getfloat) },
{ be_const_key(getbits, -1), be_const_closure(getbits_closure) },
{ be_const_key(tob64, -1), be_const_func(m_tob64) },
{ be_const_key(item, -1), be_const_func(m_item) },
{ be_const_key(_X21_X3D, -1), be_const_func(m_nequal) },
{ be_const_key(clear, 28), be_const_func(m_clear) },
{ be_const_key(size, 4), be_const_func(m_size) },
{ be_const_key(fromstring, -1), be_const_func(m_fromstring) },
{ be_const_key(_X2Elen, 21), be_const_var(0) },
{ be_const_key(seti, -1), be_const_func(m_set) },
{ be_const_key(_X2B, 9), be_const_func(m_merge) },
{ be_const_key(_X2Esize, 13), be_const_var(1) },
{ be_const_key(setfloat, 6), be_const_func(m_setfloat) },
{ be_const_key(_X2Ep, -1), be_const_var(2) },
{ be_const_key(set, -1), be_const_func(m_set) },
{ be_const_key(asstring, 0), be_const_func(m_asstring) },
{ be_const_key(add, 24), be_const_func(m_add) },
{ be_const_key(setitem, -1), be_const_func(m_setitem) },
{ be_const_key(_change_buffer, -1), be_const_func(m_change_buffer) },
{ be_const_key(_X3D_X3D, 15), be_const_func(m_equal) },
{ be_const_key(resize, 2), be_const_func(m_resize) },
{ be_const_key(_X2Esize, 9), be_const_var(0) },
{ be_const_key(resize, -1), be_const_func(m_resize) },
{ be_const_key(clear, -1), be_const_func(m_clear) },
{ be_const_key(_X21_X3D, 14), be_const_func(m_nequal) },
{ be_const_key(copy, 11), be_const_func(m_copy) },
{ be_const_key(tostring, -1), be_const_func(m_tostring) },
{ be_const_key(setbits, -1), be_const_closure(setbits_closure) },
{ be_const_key(item, -1), be_const_func(m_item) },
{ be_const_key(setbits, 29), be_const_closure(setbits_closure) },
{ be_const_key(deinit, 12), be_const_func(m_deinit) },
{ be_const_key(asstring, -1), be_const_func(m_asstring) },
{ be_const_key(_X2B, -1), be_const_func(m_merge) },
{ be_const_key(setitem, -1), be_const_func(m_setitem) },
{ be_const_key(fromstring, 31), be_const_func(m_fromstring) },
{ be_const_key(_X2E_X2E, -1), be_const_func(m_connect) },
{ be_const_key(init, -1), be_const_func(m_init) },
{ be_const_key(geti, -1), be_const_func(m_geti) },
{ be_const_key(set, -1), be_const_func(m_set) },
{ be_const_key(_X3D_X3D, -1), be_const_func(m_equal) },
{ be_const_key(getbits, 18), be_const_closure(getbits_closure) },
{ be_const_key(fromhex, -1), be_const_func(m_fromhex) },
{ be_const_key(getfloat, 27), be_const_func(m_getfloat) },
{ be_const_key(init, 16), be_const_func(m_init) },
{ be_const_key(add, -1), be_const_func(m_add) },
{ be_const_key(_change_buffer, -1), be_const_func(m_change_buffer) },
{ be_const_key(_X2Elen, -1), be_const_var(1) },
{ be_const_key(get, 25), be_const_func(m_getu) },
{ be_const_key(_buffer, 22), be_const_func(m_buffer) },
{ be_const_key(fromb64, -1), be_const_func(m_fromb64) },
{ be_const_key(geti, 17), be_const_func(m_geti) },
{ be_const_key(_X2Ep, -1), be_const_var(2) },
{ be_const_key(size, -1), be_const_func(m_size) },
{ be_const_key(setfloat, -1), be_const_func(m_setfloat) },
{ be_const_key(seti, -1), be_const_func(m_set) },
{ be_const_key(tob64, -1), be_const_func(m_tob64) },
};
static be_define_const_map(
be_class_bytes_map,
31
32
);
BE_EXPORT_VARIABLE be_define_const_class(

View File

@ -0,0 +1,23 @@
#include "be_constobj.h"
static be_define_const_map_slots(be_class_zb_coord_ntv_map) {
{ be_const_key(iter, -1), be_const_func(zc_iter) },
{ be_const_key(zcl_frame, -1), be_const_class(be_class_zcl_frame) },
{ be_const_key(zb_device, 3), be_const_class(be_class_zb_device) },
{ be_const_key(info, -1), be_const_func(zc_info) },
{ be_const_key(size, 1), be_const_ctype_func(zc_size) },
{ be_const_key(item, -1), be_const_func(zc_item) },
{ be_const_key(abort, 4), be_const_ctype_func(zc_abort) },
};
static be_define_const_map(
be_class_zb_coord_ntv_map,
7
);
BE_EXPORT_VARIABLE be_define_const_class(
be_class_zb_coord_ntv,
0,
NULL,
zb_coord_ntv
);

View File

@ -0,0 +1,20 @@
#include "be_constobj.h"
static be_define_const_map_slots(be_class_zb_device_map) {
{ be_const_key(init, -1), be_const_ctype_func(zd_init) },
{ be_const_key(tostring, -1), be_const_closure(zb_device_tostring_closure) },
{ be_const_key(_p, -1), be_const_var(0) },
{ be_const_key(member, 0), be_const_func(zd_member) },
};
static be_define_const_map(
be_class_zb_device_map,
4
);
BE_EXPORT_VARIABLE be_define_const_class(
be_class_zb_device,
1,
NULL,
zb_device
);

View File

@ -0,0 +1,17 @@
#include "be_constobj.h"
static be_define_const_map_slots(be_class_zcl_frame_ntv_map) {
{ be_const_key(_def, -1), be_const_comptr(&be_zigbee_zcl_frame_struct) },
};
static be_define_const_map(
be_class_zcl_frame_ntv_map,
1
);
BE_EXPORT_VARIABLE be_define_const_class(
be_class_zcl_frame_ntv,
0,
(bclass *)&be_class_ctypes_bytes,
zcl_frame_ntv
);

View File

@ -2,13 +2,14 @@
static be_define_const_map_slots(m_libcrc_map) {
{ be_const_key(crc32, 1), be_const_ctype_func(c_crc32) },
{ be_const_key(crc8, 2), be_const_ctype_func(c_crc8) },
{ be_const_key(sum, -1), be_const_ctype_func(c_sum) },
{ be_const_key(crc16, -1), be_const_ctype_func(c_crc16) },
{ be_const_key(crc8, -1), be_const_ctype_func(c_crc8) },
};
static be_define_const_map(
m_libcrc_map,
3
4
);
static be_define_const_module(

View File

@ -0,0 +1,17 @@
#include "be_constobj.h"
static be_define_const_map_slots(m_libzigbee_map) {
{ be_const_key(init, -1), be_const_func(zigbee_init) },
};
static be_define_const_map(
m_libzigbee_map,
1
);
static be_define_const_module(
m_libzigbee,
"zigbee"
);
BE_EXPORT_VARIABLE be_define_const_native_module(zigbee);

View File

@ -1184,6 +1184,45 @@ static int m_fromb64(bvm *vm)
be_return_nil(vm);
}
/*
* Converts hex to bytes()
*
* `bytes().fromhexx() -> bytes()`
*/
static int m_fromhex(bvm *vm)
{
int argc = be_top(vm);
if (argc >= 2 && be_isstring(vm, 2)) {
int32_t from = 0; // skip x chars
if (argc >= 3 && be_isint(vm, 3)) {
from = be_toint(vm, 3);
}
const char *s = be_tostring(vm, 2);
size_t s_len = strlen(s);
if (from < 0) { from = 0; }
if (from > s_len) { from = s_len; }
int32_t bin_len = (s_len - from) / 2;
buf_impl attr = m_read_attributes(vm, 1);
check_ptr(vm, &attr);
if (attr.fixed && attr.len != bin_len) {
be_raise(vm, BYTES_RESIZE_ERROR, BYTES_RESIZE_MESSAGE);
}
bytes_resize(vm, &attr, bin_len); /* resize if needed */
if (bin_len > attr.size) { /* avoid overflow */
be_raise(vm, "memory_error", "cannot allocate buffer");
}
attr.len = 0;
buf_add_hex(&attr, s + from, s_len - from);
be_pop(vm, 1); /* remove arg to leave instance */
m_write_attributes(vm, 1, &attr); /* update instance */
be_pop(vm, be_top(vm) - 1); /* leave instance on stack */
be_return(vm);
}
be_raise(vm, "type_error", "operand must be a string");
be_return_nil(vm);
}
/*
* Advanced API
@ -1538,6 +1577,7 @@ class be_class_bytes (scope: global, name: bytes) {
fromstring, func(m_fromstring)
tob64, func(m_tob64)
fromb64, func(m_fromb64)
fromhex, func(m_fromhex)
add, func(m_add)
get, func(m_getu)
geti, func(m_geti)

View File

@ -3,7 +3,6 @@
"displayName": "Berry Script Language",
"description": "A small embedded script language.",
"version": "0.1.0",
"icon": "berry-icon.png",
"publisher": "skiars",
"engines": {
"vscode": "^1.15.1"

View File

@ -76,6 +76,7 @@ static bbool be_const_member_dual(bvm *vm, const be_const_member_t * definitions
case '>': // call to a ctype function
{
be_ctype_var_args_t* args = (be_ctype_var_args_t*) definitions[idx].value;
be_pop(vm, be_top(vm) - 1); // make sure we have only the instance left on the stack
int ret = be_call_c_func(vm, args->func, args->return_type, NULL);
if ((ret == BE_OK) && !be_isnil(vm, -1)) {
return btrue;

View File

@ -10,21 +10,30 @@
#include "rom/crc.h"
uint32_t c_crc32(uint32_t crc, const uint8_t* buf, size_t size) {
static uint32_t c_crc32(uint32_t crc, const uint8_t* buf, size_t size) {
return crc32_le(crc, buf, size);
}
BE_FUNC_CTYPE_DECLARE(c_crc32, "i", "i(bytes)~")
uint32_t c_crc16(uint32_t crc, const uint8_t* buf, size_t size) {
static uint32_t c_crc16(uint32_t crc, const uint8_t* buf, size_t size) {
return crc16_le(crc, buf, size);
}
BE_FUNC_CTYPE_DECLARE(c_crc16, "i", "i(bytes)~")
uint32_t c_crc8(uint32_t crc, const uint8_t* buf, size_t size) {
static uint32_t c_crc8(uint32_t crc, const uint8_t* buf, size_t size) {
return crc8_le(crc, buf, size);
}
BE_FUNC_CTYPE_DECLARE(c_crc8, "i", "i(bytes)~")
static uint32_t c_sum(const uint8_t* buf, size_t size) {
uint32_t sum = 0;
for (uint32_t i = 0; i < size; i++) {
sum = (sum + buf[i]) & 0xFF;
}
return sum;
}
BE_FUNC_CTYPE_DECLARE(c_sum, "i", "(bytes)~")
// const uint32_t crc32_tab[] = {
// 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
// 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
@ -83,6 +92,7 @@ module crc (scope: global) {
crc32, ctype_func(c_crc32)
crc16, ctype_func(c_crc16)
crc8, ctype_func(c_crc8)
sum, ctype_func(c_sum)
}
@const_object_info_end */
#include "be_fixed_crc.h"

View File

@ -1,10 +1,10 @@
/********************************************************************
* Tasmota OpenHASP solidified
* Tasmota HASPmota solidified
*******************************************************************/
#include "be_constobj.h"
#ifdef USE_LVGL
#ifdef USE_LVGL_OPENHASP
#ifdef USE_LVGL_HASPMOTA
extern const bclass be_class_lv_anim;
extern const bclass be_class_lv_arc;
@ -5847,39 +5847,10 @@ void be_load_lvh_qrcode_class(bvm *vm) {
be_pop(vm, 1);
}
/********************************************************************
** Solidified function: _anonymous_
********************************************************************/
be_local_closure(openhasp__anonymous_, /* name */
be_nested_proto(
3, /* nstack */
1, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 1]) { /* constants */
/* K0 */ be_nested_str_literal("OpenHASP"),
}),
be_str_literal("_anonymous_"),
&be_const_str_solidified,
( &(const binstruction[ 4]) { /* code */
0x88040100, // 0000 GETMBR R1 R0 K0
0x5C080200, // 0001 MOVE R2 R1
0x7C080000, // 0002 CALL R2 0
0x80040400, // 0003 RET 1 R2
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: do_action
********************************************************************/
be_local_closure(OpenHASP_do_action, /* name */
be_local_closure(HASPmota_do_action, /* name */
be_nested_proto(
10, /* nstack */
3, /* argc */
@ -5991,7 +5962,7 @@ be_local_closure(OpenHASP_do_action, /* name */
/********************************************************************
** Solidified function: pages_list_sorted
********************************************************************/
be_local_closure(OpenHASP_pages_list_sorted, /* name */
be_local_closure(HASPmota_pages_list_sorted, /* name */
be_nested_proto(
8, /* nstack */
2, /* argc */
@ -6071,7 +6042,7 @@ be_local_closure(OpenHASP_pages_list_sorted, /* name */
/********************************************************************
** Solidified function: get_page_cur
********************************************************************/
be_local_closure(OpenHASP_get_page_cur, /* name */
be_local_closure(HASPmota_get_page_cur, /* name */
be_nested_proto(
3, /* nstack */
1, /* argc */
@ -6101,7 +6072,7 @@ be_local_closure(OpenHASP_get_page_cur, /* name */
/********************************************************************
** Solidified function: start
********************************************************************/
be_local_closure(OpenHASP_start, /* name */
be_local_closure(HASPmota_start, /* name */
be_nested_proto(
11, /* nstack */
3, /* argc */
@ -6131,7 +6102,7 @@ be_local_closure(OpenHASP_start, /* name */
/* K16 */ be_nested_str_literal("font_embedded"),
/* K17 */ be_nested_str_literal("robotocondensed"),
/* K18 */ be_nested_str_literal("montserrat"),
/* K19 */ be_nested_str_literal("theme_openhasp_init"),
/* K19 */ be_nested_str_literal("theme_haspmota_init"),
/* K20 */ be_const_int(0),
/* K21 */ be_nested_str_literal("color"),
/* K22 */ be_const_int(16711935),
@ -6263,7 +6234,7 @@ be_local_closure(OpenHASP_start, /* name */
/********************************************************************
** Solidified function: init
********************************************************************/
be_local_closure(OpenHASP_init, /* name */
be_local_closure(HASPmota_init, /* name */
be_nested_proto(
5, /* nstack */
1, /* argc */
@ -6297,7 +6268,7 @@ be_local_closure(OpenHASP_init, /* name */
/********************************************************************
** Solidified function: register_event
********************************************************************/
be_local_closure(OpenHASP_register_event, /* name */
be_local_closure(HASPmota_register_event, /* name */
be_nested_proto(
13, /* nstack */
3, /* argc */
@ -6373,7 +6344,7 @@ be_local_closure(OpenHASP_register_event, /* name */
/********************************************************************
** Solidified function: parse_page
********************************************************************/
be_local_closure(OpenHASP_parse_page, /* name */
be_local_closure(HASPmota_parse_page, /* name */
be_nested_proto(
9, /* nstack */
2, /* argc */
@ -6465,7 +6436,7 @@ be_local_closure(OpenHASP_parse_page, /* name */
/********************************************************************
** Solidified function: deinit
********************************************************************/
be_local_closure(OpenHASP_deinit, /* name */
be_local_closure(HASPmota_deinit, /* name */
be_nested_proto(
5, /* nstack */
1, /* argc */
@ -6512,7 +6483,7 @@ be_local_closure(OpenHASP_deinit, /* name */
/********************************************************************
** Solidified function: page_dir_to
********************************************************************/
be_local_closure(OpenHASP_page_dir_to, /* name */
be_local_closure(HASPmota_page_dir_to, /* name */
be_nested_proto(
7, /* nstack */
2, /* argc */
@ -6573,7 +6544,7 @@ be_local_closure(OpenHASP_page_dir_to, /* name */
/********************************************************************
** Solidified function: _load
********************************************************************/
be_local_closure(OpenHASP__load, /* name */
be_local_closure(HASPmota__load, /* name */
be_nested_proto(
14, /* nstack */
2, /* argc */
@ -6668,7 +6639,7 @@ be_local_closure(OpenHASP__load, /* name */
/********************************************************************
** Solidified function: parse
********************************************************************/
be_local_closure(OpenHASP_parse, /* name */
be_local_closure(HASPmota_parse, /* name */
be_nested_proto(
9, /* nstack */
2, /* argc */
@ -6722,7 +6693,7 @@ be_local_closure(OpenHASP_parse, /* name */
/********************************************************************
** Solidified function: sort
********************************************************************/
be_local_closure(OpenHASP_sort, /* name */
be_local_closure(HASPmota_sort, /* name */
be_nested_proto(
6, /* nstack */
1, /* argc */
@ -6778,7 +6749,7 @@ be_local_closure(OpenHASP_sort, /* name */
/********************************************************************
** Solidified function: parse_obj
********************************************************************/
be_local_closure(OpenHASP_parse_obj, /* name */
be_local_closure(HASPmota_parse_obj, /* name */
be_nested_proto(
20, /* nstack */
3, /* argc */
@ -7022,7 +6993,7 @@ be_local_closure(OpenHASP_parse_obj, /* name */
/********************************************************************
** Solidified function: event_dispatch
********************************************************************/
be_local_closure(OpenHASP_event_dispatch, /* name */
be_local_closure(HASPmota_event_dispatch, /* name */
be_nested_proto(
9, /* nstack */
2, /* argc */
@ -7090,27 +7061,27 @@ be_local_closure(OpenHASP_event_dispatch, /* name */
/********************************************************************
** Solidified class: OpenHASP
** Solidified class: HASPmota
********************************************************************/
be_local_class(OpenHASP,
be_local_class(HASPmota,
10,
NULL,
be_nested_map(43,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_const_key_literal("lvh_textarea", 41), be_const_class(be_class_lvh_textarea) },
{ be_const_key_literal("scr", -1), be_const_var(3) },
{ be_const_key_literal("event_dispatch", 16), be_const_closure(OpenHASP_event_dispatch_closure) },
{ be_const_key_literal("event_dispatch", 16), be_const_closure(HASPmota_event_dispatch_closure) },
{ be_const_key_literal("lvh_bar", -1), be_const_class(be_class_lvh_bar) },
{ be_const_key_literal("lvh_img", -1), be_const_class(be_class_lvh_img) },
{ be_const_key_literal("event", -1), be_const_var(8) },
{ be_const_key_literal("do_action", 33), be_const_closure(OpenHASP_do_action_closure) },
{ be_const_key_literal("pages_list_sorted", -1), be_const_closure(OpenHASP_pages_list_sorted_closure) },
{ be_const_key_literal("do_action", 33), be_const_closure(HASPmota_do_action_closure) },
{ be_const_key_literal("pages_list_sorted", -1), be_const_closure(HASPmota_pages_list_sorted_closure) },
{ be_const_key_literal("lvh_btnmatrix", 42), be_const_class(be_class_lvh_btnmatrix) },
{ be_const_key_literal("start", -1), be_const_closure(OpenHASP_start_closure) },
{ be_const_key_literal("init", 5), be_const_closure(OpenHASP_init_closure) },
{ be_const_key_literal("start", -1), be_const_closure(HASPmota_start_closure) },
{ be_const_key_literal("init", 5), be_const_closure(HASPmota_init_closure) },
{ be_const_key_literal("lvh_scr", -1), be_const_class(be_class_lvh_scr) },
{ be_const_key_literal("parse_page", -1), be_const_closure(OpenHASP_parse_page_closure) },
{ be_const_key_literal("register_event", 24), be_const_closure(OpenHASP_register_event_closure) },
{ be_const_key_literal("parse_page", -1), be_const_closure(HASPmota_parse_page_closure) },
{ be_const_key_literal("register_event", 24), be_const_closure(HASPmota_register_event_closure) },
{ be_const_key_literal("lvh_roller", 34), be_const_class(be_class_lvh_roller) },
{ be_const_key_literal("lvh_page", 11), be_const_class(be_class_lvh_page) },
{ be_const_key_literal("lvh_page_cur_idx", -1), be_const_var(6) },
@ -7118,13 +7089,13 @@ be_local_class(OpenHASP,
{ be_const_key_literal("hres", 38), be_const_var(1) },
{ be_const_key_literal("dark", -1), be_const_var(0) },
{ be_const_key_literal("lvh_label", 37), be_const_class(be_class_lvh_label) },
{ be_const_key_literal("deinit", 14), be_const_closure(OpenHASP_deinit_closure) },
{ be_const_key_literal("page_dir_to", -1), be_const_closure(OpenHASP_page_dir_to_closure) },
{ be_const_key_literal("parse_obj", -1), be_const_closure(OpenHASP_parse_obj_closure) },
{ be_const_key_literal("deinit", 14), be_const_closure(HASPmota_deinit_closure) },
{ be_const_key_literal("page_dir_to", -1), be_const_closure(HASPmota_page_dir_to_closure) },
{ be_const_key_literal("parse_obj", -1), be_const_closure(HASPmota_parse_obj_closure) },
{ be_const_key_literal("lvh_spinner", -1), be_const_class(be_class_lvh_spinner) },
{ be_const_key_literal("_load", -1), be_const_closure(OpenHASP__load_closure) },
{ be_const_key_literal("_load", -1), be_const_closure(HASPmota__load_closure) },
{ be_const_key_literal("lvh_qrcode", -1), be_const_class(be_class_lvh_qrcode) },
{ be_const_key_literal("parse", -1), be_const_closure(OpenHASP_parse_closure) },
{ be_const_key_literal("parse", -1), be_const_closure(HASPmota_parse_closure) },
{ be_const_key_literal("lvh_pages", 2), be_const_var(5) },
{ be_const_key_literal("lvh_line", -1), be_const_class(be_class_lvh_line) },
{ be_const_key_literal("lvh_switch", -1), be_const_class(be_class_lvh_switch) },
@ -7132,32 +7103,61 @@ be_local_class(OpenHASP,
{ be_const_key_literal("r16", -1), be_const_var(4) },
{ be_const_key_literal("def_templ_name", -1), be_nested_str_literal("pages.jsonl") },
{ be_const_key_literal("lvh_obj", 19), be_const_class(be_class_lvh_obj) },
{ be_const_key_literal("sort", 23), be_const_static_closure(OpenHASP_sort_closure) },
{ be_const_key_literal("sort", 23), be_const_static_closure(HASPmota_sort_closure) },
{ be_const_key_literal("lvh_dropdown", -1), be_const_class(be_class_lvh_dropdown) },
{ be_const_key_literal("lvh_checkbox", -1), be_const_class(be_class_lvh_checkbox) },
{ be_const_key_literal("lvh_slider", -1), be_const_class(be_class_lvh_slider) },
{ be_const_key_literal("vres", -1), be_const_var(2) },
{ be_const_key_literal("lvh_btn", -1), be_const_class(be_class_lvh_btn) },
{ be_const_key_literal("event_cb", -1), be_const_var(9) },
{ be_const_key_literal("get_page_cur", -1), be_const_closure(OpenHASP_get_page_cur_closure) },
{ be_const_key_literal("get_page_cur", -1), be_const_closure(HASPmota_get_page_cur_closure) },
})),
be_str_literal("OpenHASP")
be_str_literal("HASPmota")
);
/********************************************************************
** Solidified module: openhasp
** Solidified function: _anonymous_
********************************************************************/
be_local_module(openhasp,
"openhasp",
be_local_closure(haspmota__anonymous_, /* name */
be_nested_proto(
3, /* nstack */
1, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 1]) { /* constants */
/* K0 */ be_nested_str_literal("HASPmota"),
}),
be_str_literal("_anonymous_"),
&be_const_str_solidified,
( &(const binstruction[ 4]) { /* code */
0x88040100, // 0000 GETMBR R1 R0 K0
0x5C080200, // 0001 MOVE R2 R1
0x7C080000, // 0002 CALL R2 0
0x80040400, // 0003 RET 1 R2
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified module: haspmota
********************************************************************/
be_local_module(haspmota,
"haspmota",
be_nested_map(2,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_const_key_literal("OpenHASP", -1), be_const_class(be_class_OpenHASP) },
{ be_const_key_literal("init", 0), be_const_closure(openhasp__anonymous__closure) },
{ be_const_key_literal("HASPmota", -1), be_const_class(be_class_HASPmota) },
{ be_const_key_literal("init", -1), be_const_closure(haspmota__anonymous__closure) },
}))
);
BE_EXPORT_VARIABLE be_define_const_native_module(openhasp);
BE_EXPORT_VARIABLE be_define_const_native_module(haspmota);
/********************************************************************/
#endif // USE_LVGL_OPENHASP
#endif // USE_LVGL_HASPMOTA
#endif // USE_LVGL

View File

@ -1311,7 +1311,7 @@ be_local_closure(Partition_info_is_factory, /* name */
********************************************************************/
be_local_closure(Partition_info_type_to_string, /* name */
be_nested_proto(
2, /* nstack */
6, /* nstack */
1, /* argc */
2, /* varg */
0, /* has upvals */
@ -1319,16 +1319,19 @@ be_local_closure(Partition_info_type_to_string, /* name */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 5]) { /* constants */
( &(const bvalue[ 8]) { /* constants */
/* K0 */ be_nested_str(type),
/* K1 */ be_const_int(0),
/* K2 */ be_nested_str(app),
/* K3 */ be_const_int(1),
/* K4 */ be_nested_str(data),
/* K5 */ be_nested_str(string),
/* K6 */ be_nested_str(format),
/* K7 */ be_nested_str(0x_X2502X),
}),
&be_const_str_type_to_string,
&be_const_str_solidified,
( &(const binstruction[10]) { /* code */
( &(const binstruction[15]) { /* code */
0x88040100, // 0000 GETMBR R1 R0 K0
0x1C040301, // 0001 EQ R1 R1 K1
0x78060001, // 0002 JMPF R1 #0005
@ -1338,7 +1341,12 @@ be_local_closure(Partition_info_type_to_string, /* name */
0x1C040303, // 0006 EQ R1 R1 K3
0x78060000, // 0007 JMPF R1 #0009
0x80060800, // 0008 RET 1 K4
0x80000000, // 0009 RET 0
0xA4060A00, // 0009 IMPORT R1 K5
0x8C080306, // 000A GETMET R2 R1 K6
0x58100007, // 000B LDCONST R4 K7
0x88140100, // 000C GETMBR R5 R0 K0
0x7C080600, // 000D CALL R2 3
0x80040400, // 000E RET 1 R2
})
)
);
@ -1453,7 +1461,7 @@ be_local_closure(Partition_info_init, /* name */
********************************************************************/
be_local_closure(Partition_info_subtype_to_string, /* name */
be_nested_proto(
4, /* nstack */
6, /* nstack */
1, /* argc */
2, /* varg */
0, /* has upvals */
@ -1461,7 +1469,7 @@ be_local_closure(Partition_info_subtype_to_string, /* name */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[18]) { /* constants */
( &(const bvalue[21]) { /* constants */
/* K0 */ be_nested_str(type),
/* K1 */ be_const_int(0),
/* K2 */ be_nested_str(subtype),
@ -1480,10 +1488,13 @@ be_local_closure(Partition_info_subtype_to_string, /* name */
/* K15 */ be_nested_str(esphttpd),
/* K16 */ be_nested_str(fat),
/* K17 */ be_nested_str(spiffs),
/* K18 */ be_nested_str(string),
/* K19 */ be_nested_str(format),
/* K20 */ be_nested_str(0x_X2502X),
}),
&be_const_str_subtype_to_string,
&be_const_str_solidified,
( &(const binstruction[83]) { /* code */
( &(const binstruction[88]) { /* code */
0x88040100, // 0000 GETMBR R1 R0 K0
0x1C040301, // 0001 EQ R1 R1 K1
0x7806001A, // 0002 JMPF R1 #001E
@ -1566,7 +1577,12 @@ be_local_closure(Partition_info_subtype_to_string, /* name */
0x1C040202, // 004F EQ R1 R1 R2
0x78060000, // 0050 JMPF R1 #0052
0x80062200, // 0051 RET 1 K17
0x80000000, // 0052 RET 0
0xA4062400, // 0052 IMPORT R1 K18
0x8C080313, // 0053 GETMET R2 R1 K19
0x58100014, // 0054 LDCONST R4 K20
0x88140102, // 0055 GETMBR R5 R0 K2
0x7C080600, // 0056 CALL R2 3
0x80040400, // 0057 RET 1 R2
})
)
);

View File

@ -0,0 +1,173 @@
/********************************************************************
* Zigbee
*
*******************************************************************/
#ifdef USE_ZIGBEE
#include "be_constobj.h"
#include "be_mapping.h"
#include "be_ctypes.h"
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#endif
extern const void * zd_init(void* d); BE_FUNC_CTYPE_DECLARE(zd_init, "+_p", "c")
extern int32_t zd_shortaddr(void* d); BE_VAR_CTYPE_DECLARE(zd_shortaddr, "i");
extern const void* zd_longaddr(void* d, size_t *size, void* p2); BE_VAR_CTYPE_DECLARE(zd_longaddr, "&");
extern const char* zd_manufacturer(void* d); BE_VAR_CTYPE_DECLARE(zd_manufacturer, "s");
extern const char* zd_model(void* d); BE_VAR_CTYPE_DECLARE(zd_model, "s");
extern const char* zd_name(void* d); BE_VAR_CTYPE_DECLARE(zd_name, "s");
extern bbool zd_router(void* d); BE_VAR_CTYPE_DECLARE(zd_router, "b");
extern bbool zd_hidden(void* d); BE_VAR_CTYPE_DECLARE(zd_hidden, "b");
extern bbool zd_reachable(void* d); BE_VAR_CTYPE_DECLARE(zd_reachable, "b");
extern int32_t zd_lastseen(void* d); BE_VAR_CTYPE_DECLARE(zd_lastseen, "i");
extern int32_t zd_lqi(void* d); BE_VAR_CTYPE_DECLARE(zd_lqi, "i");
extern int32_t zd_battery(void* d); BE_VAR_CTYPE_DECLARE(zd_battery, "i");
extern int32_t zd_battery_lastseen(void* d); BE_VAR_CTYPE_DECLARE(zd_battery_lastseen, "i");
// moved to constants array
// MUST BE STORED IN SORTED LIST
const be_const_member_t zd_members[] = {
{ ">battery", be_ctype(zd_battery) },
{ ">battery_lastseen", be_ctype(zd_battery_lastseen) },
{ ">hidden", be_ctype(zd_hidden) },
{ ">lastseen", be_ctype(zd_lastseen) },
{ ">longaddr", be_ctype(zd_longaddr) },
{ ">lqi", be_ctype(zd_lqi) },
{ ">manufacturer", be_ctype(zd_manufacturer) },
{ ">model", be_ctype(zd_model) },
{ ">name", be_ctype(zd_name) },
{ ">reachable", be_ctype(zd_reachable) },
{ ">router", be_ctype(zd_router) },
{ ">shortaddr", be_ctype(zd_shortaddr) },
};
static int zd_member(bvm *vm) {
if (be_const_class_member(vm, zd_members, ARRAY_SIZE(zd_members))) {
be_return(vm);
} else {
be_return_nil(vm);
}
}
extern int zc_info(struct bvm *vm);
extern int zc_item(struct bvm *vm);
extern int32_t zc_size(void* d); BE_FUNC_CTYPE_DECLARE(zc_size, "i", ".");
extern int zc_iter(bvm *vm);
extern void zc_abort(void); BE_FUNC_CTYPE_DECLARE(zc_abort, "", ".");
extern const bclass be_class_ctypes_bytes;
extern const be_ctypes_structure_t be_zigbee_zcl_frame_struct;
extern const bclass be_class_zcl_frame;
/********************************************************************
** Solidified function: tostring
********************************************************************/
be_local_closure(zb_device_tostring, /* name */
be_nested_proto(
14, /* nstack */
1, /* argc */
2, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[11]) { /* constants */
/* K0 */ be_nested_str_literal("json"),
/* K1 */ be_nested_str_literal("string"),
/* K2 */ be_nested_str_literal("longaddr"),
/* K3 */ be_nested_str_literal("format"),
/* K4 */ be_nested_str_literal("<instance: %s(0x%04X, 0x%08X%08X, name:'%s', model:'%s', manufacturer:'%s')>"),
/* K5 */ be_nested_str_literal("shortaddr"),
/* K6 */ be_nested_str_literal("get"),
/* K7 */ be_const_int(0),
/* K8 */ be_nested_str_literal("name"),
/* K9 */ be_nested_str_literal("model"),
/* K10 */ be_nested_str_literal("manufacturer"),
}),
be_str_literal("tostring"),
&be_const_str_solidified,
( &(const binstruction[22]) { /* code */
0xA4060000, // 0000 IMPORT R1 K0
0xA40A0200, // 0001 IMPORT R2 K1
0x880C0102, // 0002 GETMBR R3 R0 K2
0x8C100503, // 0003 GETMET R4 R2 K3
0x58180004, // 0004 LDCONST R6 K4
0x601C0005, // 0005 GETGBL R7 G5
0x5C200000, // 0006 MOVE R8 R0
0x7C1C0200, // 0007 CALL R7 1
0x88200105, // 0008 GETMBR R8 R0 K5
0x8C240706, // 0009 GETMET R9 R3 K6
0x542E0003, // 000A LDINT R11 4
0x54320003, // 000B LDINT R12 4
0x7C240600, // 000C CALL R9 3
0x8C280706, // 000D GETMET R10 R3 K6
0x58300007, // 000E LDCONST R12 K7
0x54360003, // 000F LDINT R13 4
0x7C280600, // 0010 CALL R10 3
0x882C0108, // 0011 GETMBR R11 R0 K8
0x88300109, // 0012 GETMBR R12 R0 K9
0x8834010A, // 0013 GETMBR R13 R0 K10
0x7C101200, // 0014 CALL R4 9
0x80040800, // 0015 RET 1 R4
})
)
);
/*******************************************************************/
// Module Zigbee
extern const bclass be_class_zb_coord;
static int zigbee_init(bvm *vm) {
be_pushntvclass(vm, &be_class_zb_coord);
be_call(vm, 0);
be_return(vm);
}
#include "be_fixed_be_class_zb_device.h"
#include "be_fixed_be_class_zb_coord_ntv.h"
#include "be_fixed_be_class_zcl_frame_ntv.h"
#include "be_fixed_zigbee.h"
/* @const_object_info_begin
class be_class_zb_device (scope: global, name: zb_device) {
_p, var
init, ctype_func(zd_init)
member, func(zd_member)
tostring, closure(zb_device_tostring_closure)
}
@const_object_info_end */
/* @const_object_info_begin
class be_class_zb_coord_ntv (scope: global, name: zb_coord_ntv) {
zcl_frame, class(be_class_zcl_frame)
zb_device, class(be_class_zb_device)
info, func(zc_info)
item, func(zc_item)
size, ctype_func(zc_size)
iter, func(zc_iter)
abort, ctype_func(zc_abort)
}
@const_object_info_end */
/* @const_object_info_begin
class be_class_zcl_frame_ntv (scope: global, name: zcl_frame_ntv, super: be_class_ctypes_bytes) {
_def, comptr(&be_zigbee_zcl_frame_struct)
}
@const_object_info_end */
/* @const_object_info_begin
module zigbee (scope: global) {
init, func(zigbee_init)
}
@const_object_info_end */
#endif // USE_LIGHT

View File

@ -0,0 +1,214 @@
/********************************************************************
* Zigbee
*
*******************************************************************/
#ifdef USE_ZIGBEE
#include "be_constobj.h"
extern const bclass be_class_zb_coord_ntv;
/********************************************************************
** Solidified function: init
********************************************************************/
be_local_closure(zb_coord_init, /* name */
be_nested_proto(
3, /* nstack */
1, /* argc */
2, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 1]) { /* constants */
/* K0 */ be_nested_str_literal("init"),
}),
be_str_literal("init"),
&be_const_str_solidified,
( &(const binstruction[ 6]) { /* code */
0x60040003, // 0000 GETGBL R1 G3
0x5C080000, // 0001 MOVE R2 R0
0x7C040200, // 0002 CALL R1 1
0x8C040300, // 0003 GETMET R1 R1 K0
0x7C040200, // 0004 CALL R1 1
0x80000000, // 0005 RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: add_handler
********************************************************************/
be_local_closure(zb_coord_add_handler, /* name */
be_nested_proto(
5, /* nstack */
2, /* argc */
2, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 5]) { /* constants */
/* K0 */ be_nested_str_literal("instance"),
/* K1 */ be_nested_str_literal("value_error"),
/* K2 */ be_nested_str_literal("instance required"),
/* K3 */ be_nested_str_literal("_handlers"),
/* K4 */ be_nested_str_literal("push"),
}),
be_str_literal("add_handler"),
&be_const_str_solidified,
( &(const binstruction[18]) { /* code */
0x60080004, // 0000 GETGBL R2 G4
0x5C0C0200, // 0001 MOVE R3 R1
0x7C080200, // 0002 CALL R2 1
0x20080500, // 0003 NE R2 R2 K0
0x780A0000, // 0004 JMPF R2 #0006
0xB0060302, // 0005 RAISE 1 K1 K2
0x88080103, // 0006 GETMBR R2 R0 K3
0x780A0004, // 0007 JMPF R2 #000D
0x88080103, // 0008 GETMBR R2 R0 K3
0x8C080504, // 0009 GETMET R2 R2 K4
0x5C100200, // 000A MOVE R4 R1
0x7C080400, // 000B CALL R2 2
0x70020003, // 000C JMP #0011
0x60080012, // 000D GETGBL R2 G18
0x7C080000, // 000E CALL R2 0
0x400C0401, // 000F CONNECT R3 R2 R1
0x90020602, // 0010 SETMBR R0 K3 R2
0x80000000, // 0011 RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: dispatch
********************************************************************/
be_local_closure(zb_coord_dispatch, /* name */
be_nested_proto(
19, /* nstack */
5, /* argc */
2, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[14]) { /* constants */
/* K0 */ be_nested_str_literal("_handlers"),
/* K1 */ be_nested_str_literal("introspect"),
/* K2 */ be_nested_str_literal("string"),
/* K3 */ be_nested_str_literal("zcl_frame"),
/* K4 */ be_const_int(0),
/* K5 */ be_nested_str_literal("get"),
/* K6 */ be_nested_str_literal("function"),
/* K7 */ be_nested_str_literal("format"),
/* K8 */ be_nested_str_literal("BRY: Exception> '%s' - %s"),
/* K9 */ be_nested_str_literal("tasmota"),
/* K10 */ be_nested_str_literal("_debug_present"),
/* K11 */ be_nested_str_literal("debug"),
/* K12 */ be_nested_str_literal("traceback"),
/* K13 */ be_const_int(1),
}),
be_str_literal("dispatch"),
&be_const_str_solidified,
( &(const binstruction[61]) { /* code */
0x88140100, // 0000 GETMBR R5 R0 K0
0x4C180000, // 0001 LDNIL R6
0x1C140A06, // 0002 EQ R5 R5 R6
0x78160000, // 0003 JMPF R5 #0005
0x80000A00, // 0004 RET 0
0xA4160200, // 0005 IMPORT R5 K1
0xA41A0400, // 0006 IMPORT R6 K2
0x5C1C0600, // 0007 MOVE R7 R3
0x1C200503, // 0008 EQ R8 R2 K3
0x78220003, // 0009 JMPF R8 #000E
0x8C200103, // 000A GETMET R8 R0 K3
0x5C280600, // 000B MOVE R10 R3
0x7C200400, // 000C CALL R8 2
0x5C1C1000, // 000D MOVE R7 R8
0x58200004, // 000E LDCONST R8 K4
0x6024000C, // 000F GETGBL R9 G12
0x88280100, // 0010 GETMBR R10 R0 K0
0x7C240200, // 0011 CALL R9 1
0x14241009, // 0012 LT R9 R8 R9
0x78260027, // 0013 JMPF R9 #003C
0x88240100, // 0014 GETMBR R9 R0 K0
0x94241208, // 0015 GETIDX R9 R9 R8
0x8C280B05, // 0016 GETMET R10 R5 K5
0x5C301200, // 0017 MOVE R12 R9
0x5C340200, // 0018 MOVE R13 R1
0x7C280600, // 0019 CALL R10 3
0x602C0004, // 001A GETGBL R11 G4
0x5C301400, // 001B MOVE R12 R10
0x7C2C0200, // 001C CALL R11 1
0x1C2C1706, // 001D EQ R11 R11 K6
0x782E001A, // 001E JMPF R11 #003A
0xA8020008, // 001F EXBLK 0 #0029
0x5C2C1400, // 0020 MOVE R11 R10
0x5C301200, // 0021 MOVE R12 R9
0x5C340200, // 0022 MOVE R13 R1
0x5C380400, // 0023 MOVE R14 R2
0x5C3C0E00, // 0024 MOVE R15 R7
0x5C400800, // 0025 MOVE R16 R4
0x7C2C0A00, // 0026 CALL R11 5
0xA8040001, // 0027 EXBLK 1 1
0x70020010, // 0028 JMP #003A
0xAC2C0002, // 0029 CATCH R11 0 2
0x7002000D, // 002A JMP #0039
0x60340001, // 002B GETGBL R13 G1
0x8C380D07, // 002C GETMET R14 R6 K7
0x58400008, // 002D LDCONST R16 K8
0x5C441600, // 002E MOVE R17 R11
0x5C481800, // 002F MOVE R18 R12
0x7C380800, // 0030 CALL R14 4
0x7C340200, // 0031 CALL R13 1
0xB8361200, // 0032 GETNGBL R13 K9
0x88341B0A, // 0033 GETMBR R13 R13 K10
0x78360002, // 0034 JMPF R13 #0038
0xA4361600, // 0035 IMPORT R13 K11
0x8C381B0C, // 0036 GETMET R14 R13 K12
0x7C380200, // 0037 CALL R14 1
0x70020000, // 0038 JMP #003A
0xB0080000, // 0039 RAISE 2 R0 R0
0x0020110D, // 003A ADD R8 R8 K13
0x7001FFD2, // 003B JMP #000F
0x80000000, // 003C RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified class: zb_coord
********************************************************************/
extern const bclass be_class_zb_coord_ntv;
be_local_class(zb_coord,
1,
&be_class_zb_coord_ntv,
be_nested_map(4,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_const_key_literal("dispatch", 1), be_const_closure(zb_coord_dispatch_closure) },
{ be_const_key_literal("add_handler", 2), be_const_closure(zb_coord_add_handler_closure) },
{ be_const_key_literal("_handlers", -1), be_const_var(0) },
{ be_const_key_literal("init", 0), be_const_closure(zb_coord_init_closure) },
})),
be_str_literal("zb_coord")
);
/*******************************************************************/
void be_load_zb_coord_class(bvm *vm) {
be_pushntvclass(vm, &be_class_zb_coord);
be_setglobal(vm, "zb_coord");
be_pop(vm, 1);
}
#endif // USE_LIGHT

View File

@ -0,0 +1,255 @@
/********************************************************************
* Zigbee
*
*******************************************************************/
#ifdef USE_ZIGBEE
#include "be_constobj.h"
extern const bclass be_class_zcl_frame_ntv;
/********************************************************************
** Solidified function: member
********************************************************************/
be_local_closure(zcl_frame_member, /* name */
be_nested_proto(
5, /* nstack */
2, /* argc */
2, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 3]) { /* constants */
/* K0 */ be_nested_str_literal("payload"),
/* K1 */ be_nested_str_literal("_get_bytes"),
/* K2 */ be_nested_str_literal("member"),
}),
be_str_literal("member"),
&be_const_str_solidified,
( &(const binstruction[14]) { /* code */
0x1C080300, // 0000 EQ R2 R1 K0
0x780A0003, // 0001 JMPF R2 #0006
0x8C080101, // 0002 GETMET R2 R0 K1
0x7C080200, // 0003 CALL R2 1
0x80040400, // 0004 RET 1 R2
0x70020006, // 0005 JMP #000D
0x60080003, // 0006 GETGBL R2 G3
0x5C0C0000, // 0007 MOVE R3 R0
0x7C080200, // 0008 CALL R2 1
0x8C080502, // 0009 GETMET R2 R2 K2
0x5C100200, // 000A MOVE R4 R1
0x7C080400, // 000B CALL R2 2
0x80040400, // 000C RET 1 R2
0x80000000, // 000D RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: tomap
********************************************************************/
be_local_closure(zcl_frame_tomap, /* name */
be_nested_proto(
7, /* nstack */
1, /* argc */
2, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 7]) { /* constants */
/* K0 */ be_nested_str_literal("string"),
/* K1 */ be_nested_str_literal("tomap"),
/* K2 */ be_nested_str_literal("shortaddr_hex"),
/* K3 */ be_nested_str_literal("format"),
/* K4 */ be_nested_str_literal("0x%04X"),
/* K5 */ be_nested_str_literal("shortaddr"),
/* K6 */ be_nested_str_literal("payload"),
}),
be_str_literal("tomap"),
&be_const_str_solidified,
( &(const binstruction[14]) { /* code */
0xA4060000, // 0000 IMPORT R1 K0
0x60080003, // 0001 GETGBL R2 G3
0x5C0C0000, // 0002 MOVE R3 R0
0x7C080200, // 0003 CALL R2 1
0x8C080501, // 0004 GETMET R2 R2 K1
0x7C080200, // 0005 CALL R2 1
0x8C0C0303, // 0006 GETMET R3 R1 K3
0x58140004, // 0007 LDCONST R5 K4
0x88180105, // 0008 GETMBR R6 R0 K5
0x7C0C0600, // 0009 CALL R3 3
0x980A0403, // 000A SETIDX R2 K2 R3
0x880C0106, // 000B GETMBR R3 R0 K6
0x980A0C03, // 000C SETIDX R2 K6 R3
0x80040400, // 000D RET 1 R2
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: init
********************************************************************/
be_local_closure(zcl_frame_init, /* name */
be_nested_proto(
5, /* nstack */
2, /* argc */
2, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 2]) { /* constants */
/* K0 */ be_nested_str_literal("init"),
/* K1 */ be_nested_str_literal("no_bytes"),
}),
be_str_literal("init"),
&be_const_str_solidified,
( &(const binstruction[10]) { /* code */
0x60080003, // 0000 GETGBL R2 G3
0x5C0C0000, // 0001 MOVE R3 R0
0x7C080200, // 0002 CALL R2 1
0x8C080500, // 0003 GETMET R2 R2 K0
0x5C100200, // 0004 MOVE R4 R1
0x7C080400, // 0005 CALL R2 2
0x60080015, // 0006 GETGBL R2 G21
0x7C080000, // 0007 CALL R2 0
0x90020202, // 0008 SETMBR R0 K1 R2
0x80000000, // 0009 RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: _get_bytes
********************************************************************/
be_local_closure(zcl_frame__get_bytes, /* name */
be_nested_proto(
10, /* nstack */
1, /* argc */
2, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 7]) { /* constants */
/* K0 */ be_nested_str_literal("introspect"),
/* K1 */ be_nested_str_literal("toptr"),
/* K2 */ be_nested_str_literal("payload_ptr"),
/* K3 */ be_const_int(0),
/* K4 */ be_nested_str_literal("get"),
/* K5 */ be_const_int(2),
/* K6 */ be_nested_str_literal("no_bytes"),
}),
be_str_literal("_get_bytes"),
&be_const_str_solidified,
( &(const binstruction[32]) { /* code */
0xA4060000, // 0000 IMPORT R1 K0
0x8C080301, // 0001 GETMET R2 R1 K1
0x88100102, // 0002 GETMBR R4 R0 K2
0x7C080400, // 0003 CALL R2 2
0x600C0009, // 0004 GETGBL R3 G9
0x5C100400, // 0005 MOVE R4 R2
0x7C0C0200, // 0006 CALL R3 1
0x200C0703, // 0007 NE R3 R3 K3
0x780E0013, // 0008 JMPF R3 #001D
0x600C0015, // 0009 GETGBL R3 G21
0x5C100400, // 000A MOVE R4 R2
0x5415FFFB, // 000B LDINT R5 -4
0x7C0C0400, // 000C CALL R3 2
0x8C100704, // 000D GETMET R4 R3 K4
0x58180005, // 000E LDCONST R6 K5
0x581C0005, // 000F LDCONST R7 K5
0x7C100600, // 0010 CALL R4 3
0x60140015, // 0011 GETGBL R5 G21
0x8C180301, // 0012 GETMET R6 R1 K1
0x60200009, // 0013 GETGBL R8 G9
0x5C240400, // 0014 MOVE R9 R2
0x7C200200, // 0015 CALL R8 1
0x54260003, // 0016 LDINT R9 4
0x00201009, // 0017 ADD R8 R8 R9
0x7C180400, // 0018 CALL R6 2
0x5C1C0800, // 0019 MOVE R7 R4
0x7C140400, // 001A CALL R5 2
0x80040A00, // 001B RET 1 R5
0x70020001, // 001C JMP #001F
0x880C0106, // 001D GETMBR R3 R0 K6
0x80040600, // 001E RET 1 R3
0x80000000, // 001F RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: tostring
********************************************************************/
be_local_closure(zcl_frame_tostring, /* name */
be_nested_proto(
4, /* nstack */
1, /* argc */
2, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 1]) { /* constants */
/* K0 */ be_nested_str_literal("tomap"),
}),
be_str_literal("tostring"),
&be_const_str_solidified,
( &(const binstruction[ 6]) { /* code */
0x8C040100, // 0000 GETMET R1 R0 K0
0x7C040200, // 0001 CALL R1 1
0x60080008, // 0002 GETGBL R2 G8
0x5C0C0200, // 0003 MOVE R3 R1
0x7C080200, // 0004 CALL R2 1
0x80040400, // 0005 RET 1 R2
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified class: zcl_frame
********************************************************************/
extern const bclass be_class_zcl_frame_ntv;
be_local_class(zcl_frame,
1,
&be_class_zcl_frame_ntv,
be_nested_map(6,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_const_key_literal("no_bytes", -1), be_const_var(0) },
{ be_const_key_literal("member", 2), be_const_closure(zcl_frame_member_closure) },
{ be_const_key_literal("tostring", -1), be_const_closure(zcl_frame_tostring_closure) },
{ be_const_key_literal("init", -1), be_const_closure(zcl_frame_init_closure) },
{ be_const_key_literal("tomap", 5), be_const_closure(zcl_frame_tomap_closure) },
{ be_const_key_literal("_get_bytes", -1), be_const_closure(zcl_frame__get_bytes_closure) },
})),
be_str_literal("zcl_frame")
);
/*******************************************************************/
void be_load_zcl_frame_class(bvm *vm) {
be_pushntvclass(vm, &be_class_zcl_frame);
be_setglobal(vm, "zcl_frame");
be_pop(vm, 1);
}
#endif // USE_LIGHT

View File

@ -146,6 +146,8 @@ class Partition_info
if self.type == 0 return "app"
elif self.type == 1 return "data"
end
import string
return string.format("0x%02X", self.type)
end
def subtype_to_string()
@ -166,6 +168,8 @@ class Partition_info
elif self.subtype == 0x82 return "spiffs"
end
end
import string
return string.format("0x%02X", self.subtype)
end
# Human readable version of Partition information

View File

@ -0,0 +1,17 @@
# zigbee code
class zb_device
def tostring()
import json
import string
var la = self.longaddr # bytes() of size 8, little-endian
return string.format("<instance: %s(0x%04X, 0x%08X%08X, name:'%s', model:'%s', manufacturer:'%s')>",
classname(self), self.shortaddr,
la.get(4,4), la.get(0,4),
self.name, self.model, self.manufacturer)
return
end
end

View File

@ -0,0 +1,59 @@
# zigbee zcl_frame class
# solidify.dump(zb_coord,true)
class zb_coord_ntv end # fake class replaced with native one
#zb_coord_ntv = classof(super(zigbee))
class zb_coord : zb_coord_ntv
var _handlers
def init()
super(self).init()
end
def add_handler(h)
if type(h) != 'instance'
raise "value_error", "instance required"
end
if self._handlers
self._handlers.push(h)
else
self._handlers = [h]
end
end
def dispatch(event_type, data_type, data_ptr, idx)
if self._handlers == nil return end
import introspect
import string
var data = data_ptr
if data_type == "zcl_frame"
data = self.zcl_frame(data_ptr)
end
#print(string.format(">ZIG: cmd=%s data_type=%s data=%s idx=%i", event_type, data_type, str(data), idx))
var i = 0
while i < size(self._handlers)
var h = self._handlers[i]
var f = introspect.get(h, event_type) # try to match a function or method with the same name
if type(f) == 'function'
try
f(h, event_type, data_type, data, idx)
except .. as e,m
print(string.format("BRY: Exception> '%s' - %s", e, m))
if tasmota._debug_present
import debug
debug.traceback()
end
end
end
i += 1
end
end
end

View File

@ -0,0 +1,50 @@
# zigbee zcl_frame class
#
# solidify.dump(zcl_frame,true)
var zcl_frame_ntv = super(zcl_frame)
class zcl_frame : zcl_frame_ntv
var no_bytes
def init(p)
super(self).init(p)
self.no_bytes = bytes()
end
def member(name)
if name == "payload"
return self._get_bytes()
else
return super(self).member(name)
end
end
# return a bytes() object from a pre-populated zcl_frame payload
def _get_bytes()
import introspect
var payload_ptr = introspect.toptr(self.payload_ptr)
if int(payload_ptr) != 0
var sbuffer = bytes(payload_ptr, -4)
var sbuffer_len = sbuffer.get(2,2)
return bytes(introspect.toptr(int(payload_ptr) + 4), sbuffer_len)
else
return self.no_bytes
end
end
def tomap()
import string
var m = super(self).tomap()
m["shortaddr_hex"] = string.format("0x%04X", self.shortaddr)
m["payload"] = self.payload # add payload object which is a synthetic attribute not included in tomap()
return m
end
def tostring()
var m = self.tomap()
return str(m)
end
end

View File

@ -8,7 +8,7 @@
*********************/
#include "../lvgl.h" /*To see all the widgets*/
#include "lv_theme_openhasp.h"
#include "lv_theme_haspmota.h"
#include "misc/lv_gc.h"
/*********************
@ -625,7 +625,7 @@ static void style_init(void)
* GLOBAL FUNCTIONS
**********************/
lv_theme_t * lv_theme_openhasp_init(lv_disp_t * disp, lv_color_t color_primary, lv_color_t color_secondary, bool dark, const lv_font_t * font)
lv_theme_t * lv_theme_haspmota_init(lv_disp_t * disp, lv_color_t color_primary, lv_color_t color_secondary, bool dark, const lv_font_t * font)
{
/*This trick is required only to avoid the garbage collection of
@ -658,7 +658,7 @@ lv_theme_t * lv_theme_openhasp_init(lv_disp_t * disp, lv_color_t color_primary,
return (lv_theme_t *)&theme;
}
bool lv_theme_openhasp_is_inited(void)
bool lv_theme_haspmota_is_inited(void)
{
return inited;
}

View File

@ -1,5 +1,5 @@
/**
* @file lv_theme_openhasp.h
* @file lv_theme_haspmota.h
*
*/
@ -40,9 +40,9 @@ typedef enum {
* @param font pointer to a font to use.
* @return a pointer to reference this theme later
*/
lv_theme_t * lv_theme_openhasp_init(lv_disp_t * disp, lv_color_t color_primary, lv_color_t color_secondary, bool dark, const lv_font_t * font);
lv_theme_t * lv_theme_haspmota_init(lv_disp_t * disp, lv_color_t color_primary, lv_color_t color_secondary, bool dark, const lv_font_t * font);
bool lv_theme_openhasp_is_inited(void);
bool lv_theme_haspmota_is_inited(void);
/**********************
* MACROS

View File

@ -9,7 +9,7 @@
#include "lvgl.h"
#include "be_mapping.h"
#include "lv_berry.h"
#include "lv_theme_openhasp.h"
#include "lv_theme_haspmota.h"
extern int lv0_member(bvm *vm); // resolve virtual members
extern int lv0_load_font(bvm *vm);
@ -163,9 +163,9 @@ const be_ntv_func_def_t lv_func[] = {
{ "theme_get_font_normal", { (const void*) &lv_theme_get_font_normal, "lv.lv_font", "(lv.lv_obj)" } },
{ "theme_get_font_small", { (const void*) &lv_theme_get_font_small, "lv.lv_font", "(lv.lv_obj)" } },
{ "theme_get_from_obj", { (const void*) &lv_theme_get_from_obj, "lv.lv_theme", "(lv.lv_obj)" } },
{ "theme_haspmota_init", { (const void*) &lv_theme_haspmota_init, "lv.lv_theme", "(lv.lv_disp)(lv.lv_color)(lv.lv_color)b(lv.lv_font)" } },
{ "theme_haspmota_is_inited", { (const void*) &lv_theme_haspmota_is_inited, "b", "" } },
{ "theme_mono_init", { (const void*) &lv_theme_mono_init, "lv.lv_theme", "(lv.lv_disp)b(lv.lv_font)" } },
{ "theme_openhasp_init", { (const void*) &lv_theme_openhasp_init, "lv.lv_theme", "(lv.lv_disp)(lv.lv_color)(lv.lv_color)b(lv.lv_font)" } },
{ "theme_openhasp_is_inited", { (const void*) &lv_theme_openhasp_is_inited, "b", "" } },
{ "theme_set_apply_cb", { (const void*) &lv_theme_set_apply_cb, "", "(lv.lv_theme)^lv_theme_apply_cb^" } },
{ "theme_set_parent", { (const void*) &lv_theme_set_parent, "", "(lv.lv_theme)(lv.lv_theme)" } },
{ "timer_create", { (const void*) &lv_timer_create, "lv.lv_timer", "^lv_timer_cb^i." } },

View File

@ -1151,7 +1151,7 @@ void lv_textarea_cursor_left(lv_obj_t * obj)
void lv_textarea_cursor_down(lv_obj_t * obj)
void lv_textarea_cursor_up(lv_obj_t * obj)
// ../../LVGL_assets/src/lv_theme_openhasp.h
lv_theme_t * lv_theme_openhasp_init(lv_disp_t * disp, lv_color_t color_primary, lv_color_t color_secondary, bool dark, const lv_font_t * font)
bool lv_theme_openhasp_is_inited(void)
// ../../LVGL_assets/src/lv_theme_haspmota.h
lv_theme_t * lv_theme_haspmota_init(lv_disp_t * disp, lv_color_t color_primary, lv_color_t color_secondary, bool dark, const lv_font_t * font)
bool lv_theme_haspmota_is_inited(void)

View File

@ -741,7 +741,7 @@ print("""/********************************************************************
#include "lvgl.h"
#include "be_mapping.h"
#include "lv_berry.h"
#include "lv_theme_openhasp.h"
#include "lv_theme_haspmota.h"
extern int lv0_member(bvm *vm); // resolve virtual members
extern int lv0_load_font(bvm *vm);

View File

@ -78,7 +78,7 @@ lv_fun_globs = [
#"**/*.h",
]
headers_names = list_files(lv_src_prefix, lv_fun_globs)
headers_names += list_files("../../LVGL_assets/src/", ["lv_theme_openhasp.h"])
headers_names += list_files("../../LVGL_assets/src/", ["lv_theme_haspmota.h"])
# headers_names += ["lv_pre_style.h"] # for LVGL v7, add pre-generated style functions from C preprocessor
# unit test

View File

@ -39,7 +39,7 @@ FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoespressif32")
variants_dir = join(FRAMEWORK_DIR, "variants", "tasmota")
def esp32_create_chip_string(chip):
tasmota_platform = env.subst("$BUILD_DIR").split('/')[-1]
tasmota_platform = env.subst("$BUILD_DIR").split(os.path.sep)[-1]
tasmota_platform = tasmota_platform.split('-')[0]
if 'tasmota' and chip[3:] not in tasmota_platform: # quick check for a valid name like 'tasmota' + '32c3'
print('Unexpected naming conventions in this build environment -> Undefined behavior for further build process!!')
@ -106,7 +106,7 @@ def esp32_create_combined_bin(source, target, env):
app_offset = int(row[3],base=16)
# elif(row[0] == 'factory'):
# factory_offset = int(row[3],base=16)
elif(row[0] == 'spiffs'):
elif(row[0] == 'spiffs'):
if esp32_build_filesystem(row[4]):
fs_offset = int(row[3],base=16)
@ -152,7 +152,7 @@ def esp32_create_combined_bin(source, target, env):
if exists(fs_bin):
print(f" - {hex(fs_offset)}| {fs_bin}")
cmd += [hex(fs_offset), fs_bin]
env.Replace(
env.Replace(
UPLOADERFLAGS=[
"--chip", chip,
"--port", '"$UPLOAD_PORT"',

View File

@ -12,7 +12,7 @@ build_flags = ${env:tasmota32_base.build_flags}
-D USE_WIFI_RANGE_EXTENDER
-D USE_WIFI_RANGE_EXTENDER_NAPT
[env:tasmota32s3]
[env:tasmota32s3-file]
extends = env:tasmota32_base
board = esp32s3
build_flags = ${env:tasmota32_base.build_flags} -D FIRMWARE_TASMOTA32

View File

@ -40,6 +40,16 @@ lib_ignore =
; tasmota/berry/modules/Partition_Manager.tapp
custom_files_upload = no_files
[env:tasmota32-safeboot]
extends = env:tasmota32_base
build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_SAFEBOOT
lib_extra_dirs = lib/lib_ssl, lib/libesp32
lib_ignore =
TTGO TWatch Library
NimBLE-Arduino
Micro-RTSP
epdiy
[env:tasmota32]
extends = env:tasmota32_base
build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_TASMOTA32
@ -54,13 +64,6 @@ extends = env:tasmota32_base
board = esp32_16M
build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_TASMOTA32
[env:tasmota32solo1]
extends = env:tasmota32_base
board = esp32_solo1_4M
platform = ${core32solo1.platform}
platform_packages = ${core32solo1.platform_packages}
build_flags = ${core32solo1.build_flags} -DFIRMWARE_TASMOTA32
[env:tasmota32-webcam]
extends = env:tasmota32_base
board = esp32-cam
@ -98,42 +101,6 @@ extends = env:tasmota32_base
build_flags = ${env:tasmota32_base.build_flags} -DUSE_IR_REMOTE_FULL -DFIRMWARE_IR
lib_extra_dirs = lib/libesp32, lib/lib_basic, lib/lib_ssl
[env:tasmota32c3]
extends = env:tasmota32_base
board = esp32c3
build_unflags = ${env:tasmota32_base.build_unflags}
-flto
-mtarget-align
build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_TASMOTA32
-fno-lto
lib_ignore =
TTGO TWatch Library
Micro-RTSP
epdiy
[env:tasmota32c3usb]
extends = env:tasmota32c3
board = esp32c3usb
[env:tasmota32s2]
extends = env:tasmota32_base
board = esp32s2
build_flags = ${env:tasmota32_base.build_flags} -D FIRMWARE_TASMOTA32
lib_ignore =
TTGO TWatch Library
NimBLE-Arduino
Micro-RTSP
epdiy
[env:tasmota32-safeboot]
extends = env:tasmota32_base
build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_SAFEBOOT
lib_extra_dirs = lib/lib_ssl, lib/libesp32
lib_ignore =
TTGO TWatch Library
NimBLE-Arduino
Micro-RTSP
epdiy
[env:tasmota32solo1-safeboot]
extends = env:tasmota32_base
board = esp32_solo1_4M
@ -147,6 +114,49 @@ lib_ignore =
Micro-RTSP
epdiy
[env:tasmota32solo1]
extends = env:tasmota32_base
board = esp32_solo1_4M
platform = ${core32solo1.platform}
platform_packages = ${core32solo1.platform_packages}
build_flags = ${core32solo1.build_flags} -DFIRMWARE_TASMOTA32
[env:tasmota32c3-safeboot]
extends = env:tasmota32_base
board = esp32c3
build_unflags = ${env:tasmota32_base.build_unflags}
-flto
-mtarget-align
build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_SAFEBOOT
-fno-lto
lib_extra_dirs = lib/lib_ssl, lib/libesp32
lib_ignore =
TTGO TWatch Library
NimBLE-Arduino
Micro-RTSP
epdiy
[env:tasmota32c3]
extends = env:tasmota32_base
board = esp32c3
build_unflags = ${env:tasmota32_base.build_unflags}
-flto
-mtarget-align
build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_TASMOTA32
-fno-lto
lib_ignore =
TTGO TWatch Library
Micro-RTSP
epdiy
[env:tasmota32c3usb-safeboot]
extends = env:tasmota32c3-safeboot
board = esp32c3usb
[env:tasmota32c3usb]
extends = env:tasmota32c3
board = esp32c3usb
[env:tasmota32s2-safeboot]
extends = env:tasmota32_base
board = esp32s2
@ -158,6 +168,16 @@ lib_ignore =
Micro-RTSP
epdiy
[env:tasmota32s2]
extends = env:tasmota32_base
board = esp32s2
build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_TASMOTA32
lib_ignore =
TTGO TWatch Library
NimBLE-Arduino
Micro-RTSP
epdiy
[env:tasmota32s3-safeboot]
extends = env:tasmota32_base
board = esp32s3
@ -169,35 +189,22 @@ lib_ignore =
Micro-RTSP
epdiy
[env:tasmota32c3-safeboot]
[env:tasmota32s3]
extends = env:tasmota32_base
board = esp32c3
build_unflags = ${env:tasmota32_base.build_unflags}
-flto
-mtarget-align
build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_SAFEBOOT
-fno-lto
lib_extra_dirs = lib/lib_ssl, lib/libesp32
board = esp32s3
build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_TASMOTA32
lib_ignore =
TTGO TWatch Library
NimBLE-Arduino
Micro-RTSP
epdiy
[env:tasmota32c3usb-safeboot]
extends = env:tasmota32_base
board = esp32c3usb
build_unflags = ${env:tasmota32_base.build_unflags}
-flto
-mtarget-align
build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_SAFEBOOT
-fno-lto
lib_extra_dirs = lib/lib_ssl, lib/libesp32
lib_ignore =
TTGO TWatch Library
NimBLE-Arduino
Micro-RTSP
epdiy
[env:tasmota32s3usb-safeboot]
extends = env:tasmota32s3-safeboot
board = esp32s3usb
[env:tasmota32s3usb]
extends = env:tasmota32s3
board = esp32s3usb
[env:tasmota32-AF]
extends = env:tasmota32_base

View File

@ -0,0 +1,5 @@
# generate all haspmota tapp files
rm haspmota.tapp; zip -j -0 haspmota.tapp haspmota_core/*
rm haspmota_demo.tapp ; zip -j -0 haspmota_demo.tapp haspmota_demo/* haspmota_core/haspmota.be
cp haspmota.tapp ../haspmota
cp haspmota_demo.tapp ../haspmota

View File

@ -0,0 +1,7 @@
# start haspmota
# package with
# rm haspmota.tapp; zip -j -0 haspmota.tapp haspmota_core/*
import haspmota
# defer start to make sure all modules and tapp applications were loaded first
tasmota.set_timer(1000, /-> haspmota.start())

View File

@ -1,19 +1,19 @@
# OpenHASP compatibility module
# HASPMota - OpenHASP compatibility module
#
# use `import openhasp` and set the JSONL definitions in `pages.jsonl`
# use `import haspmota` and set the JSONL definitions in `pages.jsonl`
#
# As an optimization `0 #- lv.PART_MAIN | lv.STATE_DEFAULT -#` is replaced with `0`
#
# rm openhasp.tapp; zip -j -0 openhasp.tapp openhasp_core/*
# rm haspmota.tapp; zip -j -0 haspmota.tapp haspmota_core/*
#################################################################################
# How to solidify (needs an ESP32 with PSRAM)
#-
import path
path.remove("openhasp.bec")
path.remove("haspmota.bec")
import solidify
var openhasp
load('openhasp.be')
var haspmota
load('haspmota.be')
var classes = [
"page", "obj", "scr",
@ -23,12 +23,12 @@ var classes = [
"qrcode"
]
for c:classes
solidify.dump(openhasp.OpenHASP.("lvh_"+c), true)
solidify.dump(haspmota.HASPmota.("lvh_"+c), true)
end
solidify.dump(openhasp, true)
solidify.dump(haspmota, true)
-#
var openhasp = module("openhasp")
var haspmota = module("haspmota")
#################################################################################
#################################################################################
@ -37,7 +37,7 @@ var openhasp = module("openhasp")
# Provide a mapping for virtual members
# Stores the associated page and object id
#
# Adds specific virtual members used by OpenHASP
# Adds specific virtual members used by HASPmota
#################################################################################
#################################################################################
class lvh_obj
@ -62,7 +62,7 @@ class lvh_obj
# and the Berry or LVGL attribute to set
#
# We try to map directly an attribute to the LVGL
# Ex: OpenHASP attribute `w` is mapped to LVGL `width`
# Ex: HASPmota attribute `w` is mapped to LVGL `width`
#
# If mapping is null, we use set_X and get_X from our own class
static _attr_map = {
@ -150,7 +150,7 @@ class lvh_obj
var _lv_obj # native lvgl object
var _lv_label # sub-label if exists
var _page # parent page object
var _action # value of the OpenHASP `action` attribute, shouldn't be called `self.action` since we want to trigger the set/member functions
var _action # value of the HASPmota `action` attribute, shouldn't be called `self.action` since we want to trigger the set/member functions
#====================================================================
# Rule engine to map value and text to rules
@ -242,10 +242,10 @@ class lvh_obj
end
#====================================================================
# init OpenHASP object from its jsonl definition
# init HASPmota object from its jsonl definition
#
# arg1: LVGL parent object (used to create a sub-object)
# arg2: `jline` JSONL definition of the object from OpenHASP template (used in sub-classes)
# arg2: `jline` JSONL definition of the object from HASPmota template (used in sub-classes)
# arg3: (opt) LVGL object if it already exists and was created prior to init()
#====================================================================
def init(parent, page, jline, obj)
@ -323,7 +323,7 @@ class lvh_obj
# the callback avoids doing anything sophisticated in the cb
# defer the actual action to the Tasmota event loop
# print("-> CB fired","self",self,"obj",obj,"event",event.tomap(),"code",event.code)
var oh = self._page._oh # openhasp global object
var oh = self._page._oh # haspmota global object
var code = event.code # materialize to a local variable, otherwise the value can change (and don't capture event object)
if self.action != "" && code == lv.EVENT_CLICKED
# if clicked and action is declared, do the page change event
@ -507,7 +507,7 @@ class lvh_obj
#====================================================================
# `text_font`
#
# For OpenHASP compatiblity, default to "robotocondensed-latin1"
# For HASPmota compatiblity, default to "robotocondensed-latin1"
# However we propose an extension to allow for other font names
#
# Arg1: (int) font size for `robotocondensed-latin1`
@ -1104,7 +1104,7 @@ class lvh_dropdown : lvh_obj
end
end
# direction needs a conversion from OpenHASP numbers and LVGL's
# direction needs a conversion from HASPmota numbers and LVGL's
def set_direction(t)
# 0 = down, 1 = up, 2 = left, 3 = right
self._lv_obj.set_dir(self._dir[int(t)])
@ -1119,7 +1119,7 @@ class lvh_dropdown : lvh_obj
return -1
end
# show_selected (bool) is a OpenHASP addition
# show_selected (bool) is a HASPmota addition
# only meaningful if set to `true`, setting to false requires a call to `set_text`
def set_show_selected(t)
if t
@ -1159,22 +1159,22 @@ class lvh_page
var _obj_id # (map) of `lvh_obj` objects by id numbers
var _page_id # (int) id number of this page
var _lv_scr # (lv_obj) lvgl screen object
var _oh # OpenHASP global object
# openhasp attributes for page are on item `#0`
var _oh # HASPmota global object
# haspmota attributes for page are on item `#0`
var prev, next, back # (int) id values for `prev`, `next`, `back` buttons
#====================================================================
# `init`
#
# arg1: `page_number` (int) OpenHASP page id
# arg1: `page_number` (int) HASPmota page id
# defaults to `1` if not specified
# page 0 is special, visible on all pages. Internally uses `layer_top`
# arg2: `oh` global OpenHASP monad object
# page_number: openhasp page number, defaults to `1` if not specified
# arg2: `oh` global HASPmota monad object
# page_number: haspmota page number, defaults to `1` if not specified
#====================================================================
def init(page_number, oh)
import global
self._oh = oh # memorize OpenHASP parent object
self._oh = oh # memorize HASPmota parent object
# if no parameter, default to page #1
page_number = int(page_number)
@ -1283,17 +1283,17 @@ end
#################################################################################
#
# class `OpenHASP` to initialize the OpenHASP parsing
# class `HASPmota` to initialize the HASPmota parsing
#
#################################################################################
# main class controller, meant to be a singleton and the only externally used class
class OpenHASP
class HASPmota
var dark # (bool) use dark theme?
var hres, vres # (int) resolution
var scr # (lv_obj) default LVGL screen
var r16 # (lv_font) robotocondensed fonts size 16
# openhasp objects
# haspmota objects
var lvh_pages # (list of lvg_page) list of pages
var lvh_page_cur_idx # (int) current page index number
# regex patterns
@ -1376,8 +1376,8 @@ class OpenHASP
self.r16 = lv.font_embedded("montserrat", 14) # TODO what if does not exist
end
# set the theme for OpenHASP
var th2 = lv.theme_openhasp_init(0, lv.color(0xFF00FF), lv.color(0x303030), self.dark, self.r16)
# set the theme for HASPmota
var th2 = lv.theme_haspmota_init(0, lv.color(0xFF00FF), lv.color(0x303030), self.dark, self.r16)
self.scr.get_disp().set_theme(th2)
self.scr.set_style_bg_color(self.dark ? lv.color(0x000000) : lv.color(0xFFFFFF),0) # set background to white
# apply theme to layer_top, but keep it transparent
@ -1675,7 +1675,7 @@ class OpenHASP
return
end
# extract openhasp class, prefix with `lvh_`. Ex: `btn` becomes `lvh_btn`
# extract haspmota class, prefix with `lvh_`. Ex: `btn` becomes `lvh_btn`
# extract parent
var parent_lvgl
var parent_id = int(jline.find("parentid"))
@ -1746,20 +1746,20 @@ class OpenHASP
end
end
end
openhasp.OpenHASP = OpenHASP
haspmota.HASPmota = HASPmota
#################################################################################
# General module initilization
#################################################################################
# automatically instanciate the OpenHASP() monad
# automatically instanciate the HASPmota() monad
# note: value is cached in the module cache
# and is returned whenever you call `import openhasp` again
# and is returned whenever you call `import haspmota` again
# This means that the object is never garbage collected
#
openhasp.init = def (m) # `init(m)` is called during first `import openhasp`
var oh = m.OpenHASP
haspmota.init = def (m) # `init(m)` is called during first `import haspmota`
var oh = m.HASPmota
return oh()
end
return openhasp
return haspmota

View File

@ -1,5 +1,5 @@
# OpenHASP demo
# rm openhasp_demo.tapp ; zip -j -0 openhasp_demo.tapp openhasp_demo/* openhasp_core/openhasp.be
# rm haspmota_demo.tapp ; zip -j -0 haspmota_demo.tapp haspmota_demo/* haspmota_core/haspmota.be
if !tasmota.memory().contains("psram")
print("HSP: Error: OpenHASP demo requires PSRAM")
@ -10,8 +10,8 @@ import lv_tasmota_log
import lv_tasmota_info
import lv_wifi_graph
import openhasp
openhasp.start(false, "openhasp_demo.tapp#pages.jsonl")
import haspmota
haspmota.start(false, "haspmota_demo.tapp#pages.jsonl")
var prev_day = -1
def set_watch()

View File

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

View File

@ -36,16 +36,16 @@
{"page":4,"comment":"---------- Page 4 - fan animation ----------"}
{"id":0,"bg_color":"#0000A0","bg_grad_color":"#000000","bg_grad_dir":1,"text_color":"#FFFFFF"}
{"id":11,"obj":"img","src":"A:/openhasp_demo.tapp#noun_Fan_35097_140.png","auto_size":1,"w":140,"h":140,"x":50,"y":50,"image_recolor":"#0080FF","image_recolor_opa":150}
{"id":11,"obj":"img","src":"A:/haspmota_demo.tapp#noun_Fan_35097_140.png","auto_size":1,"w":140,"h":140,"x":50,"y":50,"image_recolor":"#0080FF","image_recolor_opa":150}
{"id":12,"obj":"spinner","parentid":11,"x":7,"y":6,"w":126,"h":126,"bg_opa":0,"border_width":0,"line_width":7,"line_width1":7,"type":2,"angle":120,"speed":1000,"value_str":3,"value_font":24}
{"page":5,"comment":"---------- Page 5 - fancy watch ----------"}
{"id":0,"bg_color":"#000000","bg_grad_color":"#000000","bg_grad_dir":1,"text_color":"#000000"}
{"id":10,"obj":"img","src":"A:/openhasp_demo.tapp#watch_ren_back_240.png","x":40,"y":0,"w":240,"h":240}
{"id":11,"obj":"img","parentid":10,"src":"A:/openhasp_demo.tapp#watch_ren_hour_240.png","auto_size":1,"x":110,"y":45}
{"id":12,"obj":"img","parentid":10,"src":"A:/openhasp_demo.tapp#watch_ren_min_240.png","auto_size":1}
{"id":13,"obj":"img","parentid":10,"src":"A:/openhasp_demo.tapp#watch_ren_sec_240.png","auto_size":1,"x":110,"y":10}
{"id":10,"obj":"img","src":"A:/haspmota_demo.tapp#watch_ren_back_240.png","x":40,"y":0,"w":240,"h":240}
{"id":11,"obj":"img","parentid":10,"src":"A:/haspmota_demo.tapp#watch_ren_hour_240.png","auto_size":1,"x":110,"y":45}
{"id":12,"obj":"img","parentid":10,"src":"A:/haspmota_demo.tapp#watch_ren_min_240.png","auto_size":1}
{"id":13,"obj":"img","parentid":10,"src":"A:/haspmota_demo.tapp#watch_ren_sec_240.png","auto_size":1,"x":110,"y":10}
{"id":15,"obj":"label","parentid":10,"x":184,"y":112,"w":18,"h":16,"text":"","align":1,"text_font":"montserrat-14"}

View File

Before

Width:  |  Height:  |  Size: 95 KiB

After

Width:  |  Height:  |  Size: 95 KiB

View File

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

@ -1,6 +1,6 @@
# pre-load widgets so future `import` will be already in memory
# create tapp file with:
# rm rm openhasp_widgets.tapp; zip -j -0 openhasp_widgets.tapp openhasp_widgets/*
# rm rm haspmota_widgets.tapp; zip -j -0 haspmota_widgets.tapp haspmota_widgets/*
import lv_tasmota_log
import lv_tasmota_info
import lv_wifi_graph

View File

@ -1,5 +0,0 @@
# generate all openhasp tapp files
rm openhasp.tapp; zip -j -0 openhasp.tapp openhasp_core/*
rm openhasp_demo.tapp ; zip -j -0 openhasp_demo.tapp openhasp_demo/* openhasp_core/openhasp.be
cp openhasp.tapp ../openhasp
cp openhasp_demo.tapp ../openhasp

View File

@ -1,7 +0,0 @@
# start openhasp
# package with
# rm openhasp.tapp; zip -j -0 openhasp.tapp openhasp_core/*
import openhasp
# defer start to make sure all modules and tapp applications were loaded first
tasmota.set_timer(1000, /-> openhasp.start())

View File

@ -1048,7 +1048,7 @@
// -- LVGL Graphics Library ---------------------------------
//#define USE_LVGL // LVGL Engine, requires Berry (+382KB)
#define USE_LVGL_PSRAM // Allocate LVGL memory in PSRAM if PSRAM is connected - this might be slightly slower but leaves main memory intact
// #define USE_LVGL_OPENHASP // Enable OpenHASP compatiblity and Robotocondensed fonts (+90KB flash)
// #define USE_LVGL_HASPMOTA // Enable OpenHASP compatiblity and Robotocondensed fonts (+90KB flash)
#define USE_LVGL_MAX_SLEEP 10 // max sleep in ms when LVGL is enabled, more than 10ms will make display less responsive
#define USE_LVGL_PNG_DECODER // include a PNG image decoder from file system (+16KB)
//#define USE_LVGL_TOUCHSCREEN // Use virtual touch screen with Berry driver

View File

@ -260,7 +260,7 @@
#ifdef FIRMWARE_LVGL
#undef CODE_IMAGE_STR
#define CODE_IMAGE_STR "lvgl-openhasp"
#define CODE_IMAGE_STR "lvgl-haspmota"
#undef MODULE
#define MODULE WEMOS // [Module] Select default module from tasmota_template.h
@ -276,7 +276,7 @@
#define USE_I2S
#define USE_SPI
#define USE_LVGL
#define USE_LVGL_OPENHASP
#define USE_LVGL_HASPMOTA
#define USE_LVGL_FREETYPE
#undef SET_ESP32_STACK_SIZE
#define SET_ESP32_STACK_SIZE (24 * 1024)

View File

@ -2514,8 +2514,11 @@ void HandleInformation(void)
}
char running[2] = { 0 };
if (part->subtype == cur_part) { running[0] = '*'; }
uint32_t part_used = ((prog_size / 1024) * 100) / part_size;
WSContentSend_PD(PSTR("}1" D_PARTITION " %s%s}2%d KB (" D_USED " %d%%)"), part->label, running, part_size, part_used);
WSContentSend_PD(PSTR("}1" D_PARTITION " %s%s}2%d KB"), part->label, running, part_size);
if (prog_size) {
uint32_t part_used = ((prog_size / 1024) * 100) / part_size;
WSContentSend_PD(PSTR(" (" D_USED " %d%%)"), part_used);
}
}
if ((ESP_PARTITION_TYPE_DATA == part->type) && (ESP_PARTITION_SUBTYPE_DATA_SPIFFS == part->subtype)) {
WSContentSend_PD(PSTR("}1" D_PARTITION " fs}2%d KB"), part_size);

View File

@ -73,7 +73,6 @@ public:
bool state_machine = false; // the state machine is running
bool state_waiting = false; // the state machine is waiting for external event or timeout
bool state_no_timeout = false; // the current wait loop does not generate a timeout but only continues running
bool ready = false; // cc2530 initialization is complet, ready to operate
bool init_phase = true; // initialization phase, before accepting zigbee traffic
bool recv_until = false; // ignore all messages until the received frame fully matches
bool eeprom_present = false; // is the ZBBridge EEPROM present?

View File

@ -995,7 +995,7 @@ private:
* Berry support
\*********************************************************************************************/
#ifdef USE_BERRY
extern "C" void callBerryZigbeeDispatcher(const char* type, ZCLFrame* zcl_received);
extern "C" int32_t callBerryZigbeeDispatcher(const char* cmd, const char* type, void* data, int32_t idx);
#endif // USE_BERRY
/*********************************************************************************************\

View File

@ -849,16 +849,16 @@ public:
uint8_t transactseq = 0; // transaction sequence number
uint8_t cmd = 0;
SBuffer payload;
uint16_t cluster = 0;
uint16_t cluster = 0xFFFF; // invalid cluster by default
uint16_t groupaddr = 0;
// information from decoded ZCL frame
uint16_t shortaddr = BAD_SHORTADDR; // BAD_SHORTADDR is broadcast, so considered invalid
uint8_t dstendpoint = 0x00; // 0x00 is invalid for the dst endpoint
// attributes used in send-only mode
bool clusterSpecific = false;
bool needResponse = true;
bool direct = false; // true if direct, false if discover router
bool transacSet = false; // is transac already set
bool clusterSpecific = false;
bool needResponse = true;
bool direct = false; // true if direct, false if discover router
bool transacSet = false; // is transac already set
// below private attributes are not used when sending a message
private:

View File

@ -1641,7 +1641,7 @@ void Z_IncomingMessage(class ZCLFrame &zcl_received) {
#ifdef USE_BERRY
// Berry pre-process messages
// callBerryZigbeeDispatcher("pre", &zcl_received);
callBerryZigbeeDispatcher("incoming", "zcl_frame", &zcl_received, 0);
#endif // USE_BERRY
// create the device entry if it does not exist and if it's not the local device

View File

@ -300,11 +300,8 @@ void ZigbeeInitSerial(void)
ZigbeeSerial->begin(115200);
if (ZigbeeSerial->hardwareSerial()) {
ClaimSerial();
uint32_t aligned_buffer = ((uint32_t)TasmotaGlobal.serial_in_buffer + 3) & ~3;
zigbee_buffer = new PreAllocatedSBuffer(sizeof(TasmotaGlobal.serial_in_buffer) - 3, (char*) aligned_buffer);
} else {
zigbee_buffer = new SBuffer(ZIGBEE_BUFFER_SIZE);
}
zigbee_buffer = new SBuffer(ZIGBEE_BUFFER_SIZE);
zigbee.active = true;
zigbee.init_phase = true; // start the state machine

View File

@ -306,7 +306,7 @@ extern "C" {
{ "montserrat", lv_montserrat_fonts },
{ "seg7", lv_seg7_fonts },
{ "unscii", lv_unscii_fonts},
#ifdef USE_LVGL_OPENHASP
#ifdef USE_LVGL_HASPMOTA
{ "robotocondensed", lv_robotocondensed_fonts },
#endif
{ nullptr, nullptr}
@ -355,9 +355,9 @@ extern "C" {
}
int lv0_load_robotocondensed_latin1_font(bvm *vm) {
#ifdef USE_LVGL_OPENHASP
#ifdef USE_LVGL_HASPMOTA
return lv_load_embedded_font(vm, "robotocondensed", 0);
#endif // USE_LVGL_OPENHASP
#endif // USE_LVGL_HASPMOTA
be_raise(vm, kTypeError, nullptr);
}

View File

@ -0,0 +1,239 @@
/*
xdrv_52_3_berry_zigbee.ino - Berry scripting language, native fucnctions
Copyright (C) 2021 Stephan Hadinger, Berry language by Guan Wenliang https://github.com/Skiars/berry
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// Mappgin from internal light and a generic `light_state` Berry class
#ifdef USE_BERRY
#ifdef USE_ZIGBEE
#include "berry.h"
#include "be_func.h"
extern "C" {
extern const bclass be_class_zb_device;
// Zigbee Device `zd`
const void* zd_init(const class Z_Device* device) {
return device;
}
int32_t zd_shortaddr(const class Z_Device* d) {
return d->shortaddr;
}
const void* zd_longaddr(const class Z_Device* d, size_t *size, void* p2) {
*size = 8; // 64 bits
return &d->longaddr;
}
const char* zd_manufacturer(const class Z_Device* d) {
return d->manufacturerId ? d->manufacturerId : "";
}
extern const char* zd_model(const class Z_Device* d) {
return d->modelId ? d->modelId : "";
}
extern const char* zd_name(const class Z_Device* d) {
return d->friendlyName ? d->friendlyName : "";
}
bool zd_router(const class Z_Device* d) {
return d->is_router;
}
bool zd_hidden(const class Z_Device* d) {
return d->hidden;
}
bool zd_reachable(const class Z_Device* d) {
return d->reachable;
}
int32_t zd_lastseen(const class Z_Device* d) {
return d->last_seen;
}
int32_t zd_lqi(const class Z_Device* d) {
return d->lqi == 255 ? -1 : d->lqi;
}
int32_t zd_battery(const class Z_Device* d) {
return d->batterypercent == 255 ? -1 : d->batterypercent;
}
int32_t zd_battery_lastseen(const class Z_Device* d) {
return 0; // TODO not yet known
}
}
extern "C" {
// Zigbee Coordinator `zc`
int zc_info(struct bvm *vm);
int zc_info(struct bvm *vm) {
int32_t top = be_top(vm); // Get the number of arguments
if (top == 1) { // no argument (instance only)
be_newobject(vm, "map");
be_map_insert_int(vm, "channel", Settings->zb_channel);
be_map_insert_int(vm, "tx_radio", Settings->zb_txradio_dbm);
char tmp[24];
ext_snprintf_P(tmp, sizeof(tmp), "0x%04X", Settings->zb_pan_id);
be_map_insert_str(vm, "pan_id_hex", tmp);
be_map_insert_int(vm, "pan_id", Settings->zb_pan_id);
ext_snprintf_P(tmp, sizeof(tmp), "0x%_X", &Settings->zb_ext_panid);
be_map_insert_str(vm, "ext_pan_id", tmp);
ext_snprintf_P(tmp, sizeof(tmp), "0x%04X", localShortAddr);
be_map_insert_str(vm, "shortaddr_hex", tmp);
be_map_insert_int(vm, "shortaddr", localShortAddr);
ext_snprintf_P(tmp, sizeof(tmp), "0x%_X", &localIEEEAddr);
be_map_insert_str(vm, "longaddr", tmp);
be_pop(vm, 1);
be_return(vm);
}
be_raise(vm, kTypeError, nullptr);
}
int zc_item(struct bvm *vm);
int zc_item(struct bvm *vm) {
int32_t top = be_top(vm); // Get the number of arguments
if (zigbee.init_phase) {
be_raise(vm, "internal_error", "zigbee not started");
}
if (top >= 2 && (be_isint(vm, 2) || be_isstring(vm, 2))) {
const Z_Device & device = be_isint(vm, 2) ? zigbee_devices.findShortAddr(be_toint(vm, 2))
: zigbee_devices.parseDeviceFromName(be_tostring(vm, 2));
if (!device.valid()) {
be_raise(vm, "value_error", "unknown device");
}
be_pushntvclass(vm, &be_class_zb_device);
be_pushcomptr(vm, (void*) &device);
be_call(vm, 1);
be_pop(vm, 1);
be_return(vm);
}
be_raise(vm, kTypeError, nullptr);
}
int32_t zc_size(void*) {
return zigbee_devices.devicesSize();
}
// stop zigbee, abort
// The abort state corresponds to state machine stopped but init not finished
void zc_abort(void) {
zigbee.active = false;
zigbee.state_machine = false; // not ready
zigbee.init_phase = false;
}
// iterator for devices in the coordinator's list of devices
// upval 0: index from 0 to size-1
static int zc_iter_closure(bvm *vm)
{
/* for better performance, we operate the upvalues
* directly without using by the stack. */
bntvclos *func = (bntvclos*) var_toobj(vm->cf->func);
bvalue *uv0 = be_ntvclos_upval(func, 0)->value;
bint idx = var_toint(uv0); /* upvalue[0] => lower */
if (idx >= zigbee_devices.devicesSize()) {
be_stop_iteration(vm);
}
var_toint(uv0) = idx + 1; /* set upvale[0] */
be_pushntvclass(vm, &be_class_zb_device);
const Z_Device & device = zigbee_devices.isKnownIndexDevice(idx);
be_pushcomptr(vm, (void*) &device);
be_call(vm, 1);
be_pop(vm, 1);
be_return(vm);
}
int zc_iter(bvm *vm);
int zc_iter(bvm *vm) {
if (zigbee.init_phase) {
be_raise(vm, "internal_error", "zigbee not started");
}
be_pushntvclosure(vm, zc_iter_closure, 1);
be_pushint(vm, 0);
be_setupval(vm, -2, 0);
be_pop(vm, 1);
be_return(vm);
}
int32_t callBerryZigbeeDispatcher(const char* cmd, const char* type, void* data, int32_t idx);
int32_t callBerryZigbeeDispatcher(const char* cmd, const char* type, void* data, int32_t idx) {
int32_t ret = 0;
bvm *vm = berry.vm;
if (nullptr == vm) { return ret; }
checkBeTop();
be_getglobal(vm, PSTR("zigbee")); // global object of type zb_coord()
if (!be_isnil(vm, -1)) {
be_getmethod(vm, -1, PSTR("dispatch")); // method dispatch
if (!be_isnil(vm, -1)) {
be_pushvalue(vm, -2); // add instance as first arg
be_pushstring(vm, cmd != nullptr ? cmd : "");
be_pushstring(vm, type != nullptr ? type : "");
be_pushcomptr(vm, data);
be_pushint(vm, idx);
BrTimeoutStart();
ret = be_pcall(vm, 5); // 5 arguments
BrTimeoutReset();
if (ret != 0) {
be_error_pop_all(berry.vm); // clear Berry stack
return ret;
}
be_pop(vm, 5);
if (be_isint(vm, -1) || be_isbool(vm, -1)) {
if (be_isint(vm, -1)) { ret = be_toint(vm, -1); }
if (be_isbool(vm, -1)) { ret = be_tobool(vm, -1); }
}
}
be_pop(vm, 1); // remove method
}
be_pop(vm, 1); // remove instance object
checkBeTop();
return ret;
}
}
/*********************************************************************************************\
* Mapping for zcl_message
*
\*********************************************************************************************/
extern "C" {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Winvalid-offsetof" // avoid warnings since we're using offsetof() in a risky way
extern const be_ctypes_structure_t be_zigbee_zcl_frame_struct = {
sizeof(ZCLFrame), /* size in bytes */
12, /* number of elements */
nullptr,
(const be_ctypes_structure_item_t[12]) {
{ "cluster", offsetof(ZCLFrame, cluster), 0, 0, ctypes_u16, 0 },
{ "cluster_specific", offsetof(ZCLFrame, clusterSpecific), 0, 0, ctypes_u8, 0 },
{ "cmd", offsetof(ZCLFrame, cmd), 0, 0, ctypes_u8, 0 },
{ "direct", offsetof(ZCLFrame, direct), 0, 0, ctypes_u8, 0 },
{ "dstendpoint", offsetof(ZCLFrame, dstendpoint), 0, 0, ctypes_u8, 0 },
{ "groupaddr", offsetof(ZCLFrame, groupaddr), 0, 0, ctypes_u16, 0 },
{ "manuf", offsetof(ZCLFrame, manuf), 0, 0, ctypes_u16, 0 },
{ "need_response", offsetof(ZCLFrame, needResponse), 0, 0, ctypes_u8, 0 },
{ "payload_ptr", offsetof(ZCLFrame, payload), 0, 0, ctypes_ptr32, 0 },
{ "shortaddr", offsetof(ZCLFrame, shortaddr), 0, 0, ctypes_u16, 0 },
{ "transactseq", offsetof(ZCLFrame, transactseq), 0, 0, ctypes_u8, 0 },
{ "transactseq_set", offsetof(ZCLFrame, transacSet), 0, 0, ctypes_u8, 0 },
}};
#pragma GCC diagnostic pop
}
#endif // USE_ZIGBEE
#endif // USE_BERRY

View File

@ -476,12 +476,21 @@ void Ade7880Cycle(void) {
#endif // ADE7880_PROFILING
uint32_t status0 = Ade7880ReadVerify(ADE7880_STATUS0); // 0xE502 - 0x000FEFE0
/*
if (!bitRead(status0, 5)) { // LENERGY
AddLog(LOG_LEVEL_DEBUG, PSTR("A78: Unexpected ISR0 0x%08X"), status0);
return;
} else {
Ade7880WriteVerify(ADE7880_STATUS0, 0x00000020); // 0xE502 - Acknowledge LENERGY - Reset IRQ0 line
status0 = Ade7880ReadVerify(ADE7880_STATUS0); // 0xE502 - 0x000FEFC0
}
*/
if (!bitRead(status0, 5)) { // LENERGY
AddLog(LOG_LEVEL_DEBUG, PSTR("A78: Unexpected ISR0 0x%08X"), status0);
}
Ade7880WriteVerify(ADE7880_STATUS0, 0x00000020); // 0xE502 - Acknowledge LENERGY - Reset IRQ0 line
status0 = Ade7880ReadVerify(ADE7880_STATUS0); // 0xE502 - 0x000FEFC0
if (Ade7880.cycle_count) { // Allow calibration stabilization
Ade7880.cycle_count--;
return; // Skip first cycles