Berry zigbee.started() (#21895)

This commit is contained in:
s-hadinger 2024-08-02 19:42:11 +02:00 committed by GitHub
parent d8cac9c811
commit 3c884118ed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 20 additions and 1 deletions

View File

@ -17,6 +17,7 @@ All notable changes to this project will be documented in this file.
- Berry `file.savecode()` (#21884)
- Berry `solidify.nocompact()` and reduce size of Matter UI (#21885)
- Berry `zigbee.find()`
- Berry `zigbee.started()`
### Breaking Changed
- Berry `energy` module support for 8 phases and move to pseudo-arrays (#21887)

View File

@ -49,6 +49,7 @@ static int zd_member(bvm *vm) {
be_return(vm);
}
extern int zc_started(struct bvm *vm);
extern int zc_info(struct bvm *vm);
extern int zc_item(struct bvm *vm);
extern int zc_find(struct bvm *vm);
@ -112,6 +113,8 @@ class be_class_zb_coord_ntv (scope: global, name: zb_coord_ntv, strings: weak) {
zcl_attribute_list, class(be_class_zcl_attribute_list)
zb_device, class(be_class_zb_device)
started, func(zc_started)
info, func(zc_info)
item, func(zc_item)
find, func(zc_find)

View File

@ -2426,7 +2426,7 @@ void ZigbeeShow(bool json)
zigbee.major_rel, zigbee.minor_rel,
zigbee.maint_rel, zigbee.revision);
WSContentSend_P(HTTP_BTN_ZB_BUTTONS);
} else {
} else if (zigbee.state_machine) { // show buttons only if the state machine is still running. If not running anymore, it means aborted
uint32_t grey = WebColor(COL_FORM);
WSContentSend_P(HTTP_BTN_ZB_BUTTONS_DISABLED, grey, grey);
}

View File

@ -75,6 +75,21 @@ extern "C" {
extern "C" {
// Zigbee Coordinator `zc`
// `zigbee.started() -> bool or nil`
// Returns `true` if Zigbee sucessfully started, `false` if not yet started
// or `nil` if not configured or aborted
int zc_started(struct bvm *vm);
int zc_started(struct bvm *vm) {
// return `nil` if `zigbee.active` is false (i.e. no GPIO configured)
// or aborted, `zigbee.init_phase` is `true` but `zigbee.state_machine` is `false`
if (!zigbee.active || (!zigbee.state_machine && zigbee.init_phase)) {
be_return_nil(vm);
}
be_pushbool(vm, !zigbee.init_phase);
be_return(vm);
}
int zc_info(struct bvm *vm);
int zc_info(struct bvm *vm) {
int32_t top = be_top(vm); // Get the number of arguments