Matter Bridge mode always on (#18785)

This commit is contained in:
s-hadinger 2023-06-03 19:01:36 +02:00 committed by GitHub
parent 61f17221d0
commit 6fdfdb8475
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 2555 additions and 1848 deletions

View File

@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file.
### Changed
- Berry `webclient.url_encode()` is now a static class method, no change required to existing code (#18775)
- Matter Bridge mode always on
### Fixed
- Interaction of ``SetOption92``, ``VirtualCT``, and ``RGBWWTable`` (#18768)

View File

@ -189,6 +189,7 @@ extern const bclass be_class_Matter_TLV; // need to declare it upfront because
#include "../generate/be_matter_certs.h"
#include "solidify/solidified_Matter_Plugin_Root.h"
#include "solidify/solidified_Matter_Plugin_Aggregator.h"
#include "solidify/solidified_Matter_Plugin_Device.h"
#include "solidify/solidified_Matter_Plugin_OnOff.h"
#include "solidify/solidified_Matter_Plugin_Light0.h"
@ -388,6 +389,7 @@ module matter (scope: global, strings: weak) {
// Plugins
Plugin_Root, class(be_class_Matter_Plugin_Root) // Generic behavior common to all devices
Plugin_Aggregator, class(be_class_Matter_Plugin_Aggregator) // Aggregator
Plugin_Device, class(be_class_Matter_Plugin_Device) // Generic device (abstract)
Plugin_OnOff, class(be_class_Matter_Plugin_OnOff) // Relay/Light behavior (OnOff)
Plugin_Light0, class(be_class_Matter_Plugin_Light0) // OnOff Light

View File

@ -680,13 +680,23 @@ class Matter_Device
var endpoints = self.k2l_num(config)
tasmota.log("MTR: endpoints to be configured "+str(endpoints), 3)
# start with mandatory endpoint 0 for root node
self.plugins.push(matter.Plugin_Root(self, 0, {}))
tasmota.log(string.format("MTR: endpoint:%i type:%s%s", 0, 'root', ''), 2)
# always include an aggregator for dynamic endpoints
self.plugins.push(matter.Plugin_Aggregator(self, 0xFF00, {}))
tasmota.log(string.format("MTR: endpoint:%i type:%s%s", 0xFF00, 'aggregator', ''), 2)
for ep: endpoints
if ep == 0 continue end # skip endpoint 0
try
var plugin_conf = config[str(ep)]
tasmota.log(string.format("MTR: endpoint %i config %s", ep, plugin_conf), 3)
var pi_class_name = plugin_conf.find('type')
if pi_class_name == nil tasmota.log("MTR: no class name, skipping", 3) continue end
if pi_class_name == 'root' tasmota.log("MTR: only one root node allowed", 3) continue end
var pi_class = self.plugins_classes.find(pi_class_name)
if pi_class == nil tasmota.log("MTR: unknown class name '"+str(pi_class_name)+"' skipping", 2) continue end
@ -1004,9 +1014,6 @@ class Matter_Device
import json
var m = {}
# add the default plugin
m["0"] = {'type':'root'}
# check if we have a light
var endpoint = 1
var light_present = false

View File

@ -36,6 +36,7 @@ class Matter_Plugin
# Configuration of the plugin: clusters and type
static var CLUSTERS = {
0x001D: [0,1,2,3,0xFFFC,0xFFFD], # Descriptor Cluster 9.5 p.453
0x0039: [0x11], # Bridged Device Basic Information 9.13 p.485
}
var device # reference to the `device` global object
var endpoint # current endpoint
@ -180,6 +181,12 @@ class Matter_Plugin
return TLV.create_TLV(TLV.U4, 1) # "Initial Release"
end
# ====================================================================================================
elif cluster == 0x0039 # ========== Bridged Device Basic Information 9.13 p.485 ==========
if attribute == 0x0011 # ---------- Reachable / bool ----------
return TLV.create_TLV(TLV.BOOL, 1) # by default we are reachable
end
else
return nil
end

View File

@ -0,0 +1,71 @@
#
# Matter_Plugin_Aggregator.be - implements the Aggregator endpoint
#
# Copyright (C) 2023 Stephan Hadinger & Theo Arends
#
# 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/>.
#
import matter
# Matter plug-in for root behavior
# dummy declaration for solidification
class Matter_Plugin end
#@ solidify:Matter_Plugin_Aggregator,weak
class Matter_Plugin_Aggregator : Matter_Plugin
static var TYPE = "aggregator" # name of the plug-in in json
static var NAME = "Aggregator" # display name of the plug-in
# static var CLUSTERS = {
# # 0x001D: inherited # Descriptor Cluster 9.5 p.453
# }
static var TYPES = { 0x000E: 1 } # Aggregator
#############################################################
# read an attribute
#
def read_attribute(session, ctx)
import string
var TLV = matter.TLV
var cluster = ctx.cluster
var attribute = ctx.attribute
if cluster == 0x001D # ========== Descriptor Cluster 9.5 p.453 ==========
# overwrite PartsList
if attribute == 0x0003 # ---------- PartsList / list[endpoint-no]----------
var pl = TLV.Matter_TLV_array()
var eps = self.device.get_active_endpoints(true)
for ep: eps
if ep != 0xFF00
pl.add_TLV(nil, TLV.U2, ep) # add each endpoint
end
end
return pl
else
return super(self).read_attribute(session, ctx)
end
else
return super(self).read_attribute(session, ctx)
end
# no match found, return that the attribute is unsupported
end
end
matter.Plugin_Aggregator = Matter_Plugin_Aggregator

View File

@ -43,7 +43,7 @@ class Matter_Plugin_Bridge_HTTP : Matter_Plugin_Device
# 0x0006: [0,0xFFFC,0xFFFD], # On/Off 1.5 p.48
# 0x0028: [0,1,2,3,4,5,6,7,8,9,0x0A,0x0F,0x12,0x13],# Basic Information Cluster cluster 11.1 p.565
0x0039: [0x11] # Bridged Device Basic Information 9.13 p.485
# 0x0039: [0x11] # Bridged Device Basic Information 9.13 p.485
}
# static var TYPES = { 0x010A: 2 } # On/Off Light
@ -176,9 +176,7 @@ class Matter_Plugin_Bridge_HTTP : Matter_Plugin_Device
# ====================================================================================================
if cluster == 0x0039 # ========== Bridged Device Basic Information 9.13 p.485 ==========
if attribute == 0x0000 # ---------- DataModelRevision / CommissioningWindowStatus ----------
# return TLV.create_TLV(TLV.U2, 1)
elif attribute == 0x0011 # ---------- Reachable / bool ----------
if attribute == 0x0011 # ---------- Reachable / bool ----------
# self.is_reachable_lazy_sync() # Not needed anymore
return TLV.create_TLV(TLV.BOOL, self.http_remote.reachable) # TODO find a way to do a ping
end

View File

@ -0,0 +1,97 @@
#
# Matter_Plugin_Sensor_OnOff.be - implements the behavior for a Occupany Switch
#
# Copyright (C) 2023 Stephan Hadinger & Theo Arends
#
# 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/>.
#
# Matter plug-in for core behavior
# dummy declaration for solidification
class Matter_Plugin_Device end
#@ solidify:Matter_Plugin_Sensor_OnOff,weak
class Matter_Plugin_Sensor_OnOff : Matter_Plugin_Device
static var TYPE = "occupancy" # name of the plug-in in json
static var NAME = "OnOff" # display name of the plug-in
static var ARG = "switch" # additional argument name (or empty if none)
static var ARG_TYPE = / x -> int(x) # function to convert argument to the right type
static var UPDATE_TIME = 5000 # update every 250ms
static var CLUSTERS = {
0x0006: [0,0xFFFC,0xFFFD], # On/Off 1.5 p.48
}
static var TYPES = { 0x0850: 2 } # OnOff Sensor, rev 2
var tasmota_switch_index # Switch number in Tasmota (one based)
var shadow_onoff
#############################################################
# Constructor
def init(device, endpoint, arguments)
super(self).init(device, endpoint, arguments)
self.tasmota_switch_index = int(arguments.find(self.ARG #-'relay'-#, 1))
if self.tasmota_switch_index <= 0 self.tasmota_switch_index = 1 end
end
#############################################################
# Update shadow
#
def update_shadow()
super(self).update_shadow()
import json
var ret = tasmota.cmd("Status 8", true)
if ret != nil
var j = json.load(ret)
if j != nil
var state = false
state = (j.find("Switch" + str(self.tasmota_switch_index)) == "ON")
if self.shadow_onoff != nil && self.shadow_onoff != bool(state)
self.attribute_updated(0x0406, 0x0000)
end
self.shadow_onoff = state
end
end
end
#############################################################
# read an attribute
#
def read_attribute(session, ctx)
import string
var TLV = matter.TLV
var cluster = ctx.cluster
var attribute = ctx.attribute
# ====================================================================================================
if cluster == 0x0006 # ========== On/Off 1.5 p.48 ==========
self.update_shadow_lazy()
if attribute == 0x0000 # ---------- OnOff / bool ----------
return TLV.create_TLV(TLV.BOOL, self.shadow_onoff)
elif attribute == 0xFFFC # ---------- FeatureMap / map32 ----------
return TLV.create_TLV(TLV.U4, 0) # 0 = no Level Control for Lighting
elif attribute == 0xFFFD # ---------- ClusterRevision / u2 ----------
return TLV.create_TLV(TLV.U4, 4) # 0 = no Level Control for Lighting
end
else
return super(self).read_attribute(session, ctx)
end
end
end
matter.Plugin_Sensor_OnOff = Matter_Plugin_Sensor_OnOff

View File

@ -32,7 +32,6 @@ import matter
# WebUI for the partition manager
#################################################################################
class Matter_UI
static var _ROOT_TYPES = "root"
static var _CLASSES_TYPES = "|relay|light0|light1|light2|light3|shutter|shutter+tilt"
"|temperature|pressure|illuminance|humidity|occupancy"
static var _CLASSES_TYPES2= "-http|http_relay|http_light0|http_light1|http_light2|http_light3"
@ -164,6 +163,15 @@ class Matter_UI
import string
webserver.content_send("<fieldset><legend><b>&nbsp;Matter Passcode&nbsp;</b></legend><p></p>")
# button for open/close commissioning
webserver.content_send("<form action='/matterc' method='post'>")
if self.device.commissioning_open == nil
webserver.content_send(string.format("<p></p><button name='open_comm' class='button bgrn'>%s</button>", "Open Commissioning"))
else
webserver.content_send(string.format("<p></p><button name='clos_comm' class='button bgrn'>%s</button>", "Close Commissioning"))
end
webserver.content_send("</form></p>")
#
webserver.content_send("<form action='/matterc' method='post' onsubmit='return confirm(\"This will cause a restart.\");'>")
webserver.content_send("<p>Passcode:</p>")
webserver.content_send(string.format("<input type='number' min='1' max='99999998' name='passcode' value='%i'>", self.device.root_passcode))
@ -239,22 +247,16 @@ class Matter_UI
var i = 0
# special case for root node
if endpoints[0] == 0
var ep = endpoints[i]
var conf = self.device.plugins_config[str(ep)]
var typ = conf.find('type')
webserver.content_send(string.format("<tr><td><input type='text' name='ep%03i' maxlength='4' size='3' value='0' readonly></td>", i))
webserver.content_send(string.format("<td><select name='pi%03i'>", i))
self.plugin_option(conf.find('type', ''), self._ROOT_TYPES)
webserver.content_send(string.format("</select></td>"))
webserver.content_send("<td><font size='-1'>&nbsp;</font></td>")
i += 1
end
# display a fake configuration item (disabled)
webserver.content_send("<tr><td><input type='text' name='ep000' maxlength='4' size='3' value='0' readonly disabled></td>")
webserver.content_send("<td><select name='pi000'>")
webserver.content_send("<option value='' selected disabled>Root node</option>")
webserver.content_send("</select></td>")
webserver.content_send("<td><font size='-1'>&nbsp;</font></td>")
while i < size(endpoints)
var ep = endpoints[i]
if ep == 0 i += 1 continue end # skip endpoint 0 (leftover from previous versions)
var conf = self.device.plugins_config[str(ep)]
var typ = conf.find('type')
if !typ i += 1 continue end
@ -371,6 +373,16 @@ class Matter_UI
#- and force restart -#
webserver.redirect("/?rst=")
#---------------------------------------------------------------------#
# Enable or Disable Commissioning
#---------------------------------------------------------------------#
elif webserver.has_arg("open_comm")
self.device.start_root_basic_commissioning()
webserver.redirect("/")
elif webserver.has_arg("clos_comm")
self.device.stop_basic_commissioning()
webserver.redirect("/")
#---------------------------------------------------------------------#
# Enable Matter
#---------------------------------------------------------------------#
@ -421,72 +433,69 @@ class Matter_UI
#---------------------------------------------------------------------#
# Apply new configuration template
#---------------------------------------------------------------------#
elif webserver.has_arg("config")
var config = {}
elif webserver.has_arg("config")
var config = {}
tasmota.log(string.format("MTR: /matterc received '%s' command", 'config'), 3)
# iterate by id
var idx = 0
var idx_str = string.format("%03i", idx)
while webserver.has_arg('ep'+idx_str)
tasmota.log(string.format("MTR: /matterc received '%s' command", 'config'), 3)
# iterate by id
var idx = 1
var idx_str = string.format("%03i", idx)
while webserver.has_arg('ep'+idx_str)
var ep = webserver.arg('ep'+idx_str)
var ep_int = int(ep)
var typ = webserver.arg('pi'+idx_str)
var arg = webserver.arg('arg'+idx_str)
tasmota.log(string.format("MTR: ep=%i type=%s arg=%s", ep, typ, arg), 3)
var ep = webserver.arg('ep'+idx_str)
var ep_int = int(ep)
var typ = webserver.arg('pi'+idx_str)
var arg = webserver.arg('arg'+idx_str)
tasmota.log(string.format("MTR: ep=%i type=%s arg=%s", ep, typ, arg), 3)
if ep != '' && typ != ''
# check if type exists
var typ_class = self.device.plugins_classes.find(typ)
if typ_class != nil
var elt = {'type':typ}
typ_class.ui_string_to_conf(typ_class, elt, arg)
# var arg_name = typ_class.ARG
# var arg_type = typ_class.ARG_TYPE
# if arg && arg_name
# elt[arg_name] = arg_type(arg)
# end
config[ep] = elt
if ep != '' && typ != '' && ep != '0'
# check if type exists
var typ_class = self.device.plugins_classes.find(typ)
if typ_class != nil
var elt = {'type':typ}
typ_class.ui_string_to_conf(typ_class, elt, arg)
# var arg_name = typ_class.ARG
# var arg_type = typ_class.ARG_TYPE
# if arg && arg_name
# elt[arg_name] = arg_type(arg)
# end
config[ep] = elt
else
tasmota.log(string.format("MTR: unknown type = %s", typ), 2)
end
else
tasmota.log(string.format("MTR: unknown type = %s", typ), 2)
tasmota.log("MTR: skipping parameter", 2)
end
else
tasmota.log("MTR: skipping parameter", 2)
idx += 1
idx_str = string.format("%03i", idx)
end
tasmota.log(string.format("MTR: config = %s", str(config)), 3)
if error
tasmota.log(string.format("MTR: config error = %s", error), 3)
else
self.device.plugins_config = config
self.device.plugins_persist = true
self.device.save_param()
#- and force restart -#
webserver.redirect("/?rst=")
end
idx += 1
idx_str = string.format("%03i", idx)
end
tasmota.log(string.format("MTR: config = %s", str(config)), 3)
# sanity check
if !config.contains("0") error = "Missing endpoint 0" end
if error
tasmota.log(string.format("MTR: config error = %s", error), 3)
else
self.device.plugins_config = config
self.device.plugins_persist = true
self.device.save_param()
#- and force restart -#
webserver.redirect("/?rst=")
webserver.content_start("Parameter error") #- title of the web page -#
webserver.content_send_style() #- send standard Tasmota styles -#
webserver.content_send(string.format("<p style='width:340px;'><b>Error:</b>%s</p>", webserver.html_escape(error)))
webserver.content_button(webserver.BUTTON_CONFIGURATION) #- button back to configuration page -#
webserver.content_stop() #- end of web page -#
end
end
if error
webserver.content_start("Parameter error") #- title of the web page -#
webserver.content_send_style() #- send standard Tasmota styles -#
webserver.content_send(string.format("<p style='width:340px;'><b>Error:</b>%s</p>", webserver.html_escape(error)))
webserver.content_button(webserver.BUTTON_CONFIGURATION) #- button back to configuration page -#
webserver.content_stop() #- end of web page -#
end
except .. as e, m
tasmota.log(string.format("BRY: Exception> '%s' - %s", e, m), 2)
#- display error page -#

View File

@ -486,7 +486,7 @@ be_local_closure(Matter_Plugin_read_attribute, /* name */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[18]) { /* constants */
( &(const bvalue[19]) { /* constants */
/* K0 */ be_nested_str_weak(matter),
/* K1 */ be_nested_str_weak(TLV),
/* K2 */ be_nested_str_weak(cluster),
@ -505,10 +505,11 @@ be_local_closure(Matter_Plugin_read_attribute, /* name */
/* K15 */ be_const_int(2),
/* K16 */ be_const_int(3),
/* K17 */ be_nested_str_weak(create_TLV),
/* K18 */ be_nested_str_weak(BOOL),
}),
be_str_weak(read_attribute),
&be_const_str_solidified,
( &(const binstruction[92]) { /* code */
( &(const binstruction[104]) { /* code */
0xB80E0000, // 0000 GETNGBL R3 K0
0x880C0701, // 0001 GETMBR R3 R3 K1
0x88100502, // 0002 GETMBR R4 R2 K2
@ -597,10 +598,22 @@ be_local_closure(Matter_Plugin_read_attribute, /* name */
0x5824000B, // 0055 LDCONST R9 K11
0x7C180600, // 0056 CALL R6 3
0x80040C00, // 0057 RET 1 R6
0x70020001, // 0058 JMP #005B
0x4C180000, // 0059 LDNIL R6
0x80040C00, // 005A RET 1 R6
0x80000000, // 005B RET 0
0x7002000D, // 0058 JMP #0067
0x541A0038, // 0059 LDINT R6 57
0x1C180806, // 005A EQ R6 R4 R6
0x781A0008, // 005B JMPF R6 #0065
0x541A0010, // 005C LDINT R6 17
0x1C180A06, // 005D EQ R6 R5 R6
0x781A0004, // 005E JMPF R6 #0064
0x8C180711, // 005F GETMET R6 R3 K17
0x88200712, // 0060 GETMBR R8 R3 K18
0x5824000B, // 0061 LDCONST R9 K11
0x7C180600, // 0062 CALL R6 3
0x80040C00, // 0063 RET 1 R6
0x70020001, // 0064 JMP #0067
0x4C180000, // 0065 LDNIL R6
0x80040C00, // 0066 RET 1 R6
0x80000000, // 0067 RET 0
})
)
);
@ -886,7 +899,7 @@ be_local_class(Matter_Plugin,
{ be_const_key_weak(ARG_TYPE, 4), be_const_static_closure(Matter_Plugin__X3Clambda_X3E_closure) },
{ be_const_key_weak(update_shadow_lazy, 28), be_const_closure(Matter_Plugin_update_shadow_lazy_closure) },
{ be_const_key_weak(CLUSTERS, -1), be_const_simple_instance(be_nested_simple_instance(&be_class_map, {
be_const_map( * be_nested_map(1,
be_const_map( * be_nested_map(2,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_const_key_int(29, -1), be_const_simple_instance(be_nested_simple_instance(&be_class_list, {
be_const_list( * be_nested_list(6,
@ -897,6 +910,11 @@ be_local_class(Matter_Plugin,
be_const_int(3),
be_const_int(65532),
be_const_int(65533),
})) ) } )) },
{ be_const_key_int(57, 0), be_const_simple_instance(be_nested_simple_instance(&be_class_list, {
be_const_list( * be_nested_list(1,
( (struct bvalue*) &(const bvalue[]) {
be_const_int(17),
})) ) } )) },
})) ) } )) },
{ be_const_key_weak(subscribe_event, -1), be_const_closure(Matter_Plugin_subscribe_event_closure) },

View File

@ -0,0 +1,128 @@
/* Solidification of Matter_Plugin_Aggregator.h */
/********************************************************************\
* Generated code, don't edit *
\********************************************************************/
#include "be_constobj.h"
extern const bclass be_class_Matter_Plugin_Aggregator;
/********************************************************************
** Solidified function: read_attribute
********************************************************************/
be_local_closure(Matter_Plugin_Aggregator_read_attribute, /* name */
be_nested_proto(
16, /* nstack */
3, /* argc */
2, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[13]) { /* constants */
/* K0 */ be_nested_str_weak(string),
/* K1 */ be_nested_str_weak(matter),
/* K2 */ be_nested_str_weak(TLV),
/* K3 */ be_nested_str_weak(cluster),
/* K4 */ be_nested_str_weak(attribute),
/* K5 */ be_const_int(3),
/* K6 */ be_nested_str_weak(Matter_TLV_array),
/* K7 */ be_nested_str_weak(device),
/* K8 */ be_nested_str_weak(get_active_endpoints),
/* K9 */ be_nested_str_weak(add_TLV),
/* K10 */ be_nested_str_weak(U2),
/* K11 */ be_nested_str_weak(stop_iteration),
/* K12 */ be_nested_str_weak(read_attribute),
}),
be_str_weak(read_attribute),
&be_const_str_solidified,
( &(const binstruction[54]) { /* code */
0xA40E0000, // 0000 IMPORT R3 K0
0xB8120200, // 0001 GETNGBL R4 K1
0x88100902, // 0002 GETMBR R4 R4 K2
0x88140503, // 0003 GETMBR R5 R2 K3
0x88180504, // 0004 GETMBR R6 R2 K4
0x541E001C, // 0005 LDINT R7 29
0x1C1C0A07, // 0006 EQ R7 R5 R7
0x781E0024, // 0007 JMPF R7 #002D
0x1C1C0D05, // 0008 EQ R7 R6 K5
0x781E0019, // 0009 JMPF R7 #0024
0x8C1C0906, // 000A GETMET R7 R4 K6
0x7C1C0200, // 000B CALL R7 1
0x88200107, // 000C GETMBR R8 R0 K7
0x8C201108, // 000D GETMET R8 R8 K8
0x50280200, // 000E LDBOOL R10 1 0
0x7C200400, // 000F CALL R8 2
0x60240010, // 0010 GETGBL R9 G16
0x5C281000, // 0011 MOVE R10 R8
0x7C240200, // 0012 CALL R9 1
0xA802000A, // 0013 EXBLK 0 #001F
0x5C281200, // 0014 MOVE R10 R9
0x7C280000, // 0015 CALL R10 0
0x542EFEFF, // 0016 LDINT R11 65280
0x202C140B, // 0017 NE R11 R10 R11
0x782E0004, // 0018 JMPF R11 #001E
0x8C2C0F09, // 0019 GETMET R11 R7 K9
0x4C340000, // 001A LDNIL R13
0x8838090A, // 001B GETMBR R14 R4 K10
0x5C3C1400, // 001C MOVE R15 R10
0x7C2C0800, // 001D CALL R11 4
0x7001FFF4, // 001E JMP #0014
0x5824000B, // 001F LDCONST R9 K11
0xAC240200, // 0020 CATCH R9 1 0
0xB0080000, // 0021 RAISE 2 R0 R0
0x80040E00, // 0022 RET 1 R7
0x70020007, // 0023 JMP #002C
0x601C0003, // 0024 GETGBL R7 G3
0x5C200000, // 0025 MOVE R8 R0
0x7C1C0200, // 0026 CALL R7 1
0x8C1C0F0C, // 0027 GETMET R7 R7 K12
0x5C240200, // 0028 MOVE R9 R1
0x5C280400, // 0029 MOVE R10 R2
0x7C1C0600, // 002A CALL R7 3
0x80040E00, // 002B RET 1 R7
0x70020007, // 002C JMP #0035
0x601C0003, // 002D GETGBL R7 G3
0x5C200000, // 002E MOVE R8 R0
0x7C1C0200, // 002F CALL R7 1
0x8C1C0F0C, // 0030 GETMET R7 R7 K12
0x5C240200, // 0031 MOVE R9 R1
0x5C280400, // 0032 MOVE R10 R2
0x7C1C0600, // 0033 CALL R7 3
0x80040E00, // 0034 RET 1 R7
0x80000000, // 0035 RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified class: Matter_Plugin_Aggregator
********************************************************************/
extern const bclass be_class_Matter_Plugin;
be_local_class(Matter_Plugin_Aggregator,
0,
&be_class_Matter_Plugin,
be_nested_map(4,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_const_key_weak(NAME, 3), be_nested_str_weak(Aggregator) },
{ be_const_key_weak(TYPE, -1), be_nested_str_weak(aggregator) },
{ be_const_key_weak(TYPES, 0), be_const_simple_instance(be_nested_simple_instance(&be_class_map, {
be_const_map( * be_nested_map(1,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_const_key_int(14, -1), be_const_int(1) },
})) ) } )) },
{ be_const_key_weak(read_attribute, -1), be_const_closure(Matter_Plugin_Aggregator_read_attribute_closure) },
})),
be_str_weak(Matter_Plugin_Aggregator)
);
/*******************************************************************/
void be_load_Matter_Plugin_Aggregator_class(bvm *vm) {
be_pushntvclass(vm, &be_class_Matter_Plugin_Aggregator);
be_setglobal(vm, "Matter_Plugin_Aggregator");
be_pop(vm, 1);
}
/********************************************************************/
/* End of solidification */

View File

@ -459,50 +459,46 @@ be_local_closure(Matter_Plugin_Bridge_HTTP_read_attribute, /* name */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[10]) { /* constants */
( &(const bvalue[ 9]) { /* constants */
/* K0 */ be_nested_str_weak(matter),
/* K1 */ be_nested_str_weak(TLV),
/* K2 */ be_nested_str_weak(cluster),
/* K3 */ be_nested_str_weak(attribute),
/* K4 */ be_const_int(0),
/* K5 */ be_nested_str_weak(create_TLV),
/* K6 */ be_nested_str_weak(BOOL),
/* K7 */ be_nested_str_weak(http_remote),
/* K8 */ be_nested_str_weak(reachable),
/* K9 */ be_nested_str_weak(read_attribute),
/* K4 */ be_nested_str_weak(create_TLV),
/* K5 */ be_nested_str_weak(BOOL),
/* K6 */ be_nested_str_weak(http_remote),
/* K7 */ be_nested_str_weak(reachable),
/* K8 */ be_nested_str_weak(read_attribute),
}),
be_str_weak(read_attribute),
&be_const_str_solidified,
( &(const binstruction[29]) { /* code */
( &(const binstruction[26]) { /* code */
0xB80E0000, // 0000 GETNGBL R3 K0
0x880C0701, // 0001 GETMBR R3 R3 K1
0x88100502, // 0002 GETMBR R4 R2 K2
0x88140503, // 0003 GETMBR R5 R2 K3
0x541A0038, // 0004 LDINT R6 57
0x1C180806, // 0005 EQ R6 R4 R6
0x781A000C, // 0006 JMPF R6 #0014
0x1C180B04, // 0007 EQ R6 R5 K4
0x781A0000, // 0008 JMPF R6 #000A
0x70020008, // 0009 JMP #0013
0x541A0010, // 000A LDINT R6 17
0x1C180A06, // 000B EQ R6 R5 R6
0x781A0005, // 000C JMPF R6 #0013
0x8C180705, // 000D GETMET R6 R3 K5
0x88200706, // 000E GETMBR R8 R3 K6
0x88240107, // 000F GETMBR R9 R0 K7
0x88241308, // 0010 GETMBR R9 R9 K8
0x7C180600, // 0011 CALL R6 3
0x80040C00, // 0012 RET 1 R6
0x70020007, // 0013 JMP #001C
0x60180003, // 0014 GETGBL R6 G3
0x5C1C0000, // 0015 MOVE R7 R0
0x7C180200, // 0016 CALL R6 1
0x8C180D09, // 0017 GETMET R6 R6 K9
0x5C200200, // 0018 MOVE R8 R1
0x5C240400, // 0019 MOVE R9 R2
0x7C180600, // 001A CALL R6 3
0x80040C00, // 001B RET 1 R6
0x80000000, // 001C RET 0
0x781A0009, // 0006 JMPF R6 #0011
0x541A0010, // 0007 LDINT R6 17
0x1C180A06, // 0008 EQ R6 R5 R6
0x781A0005, // 0009 JMPF R6 #0010
0x8C180704, // 000A GETMET R6 R3 K4
0x88200705, // 000B GETMBR R8 R3 K5
0x88240106, // 000C GETMBR R9 R0 K6
0x88241307, // 000D GETMBR R9 R9 K7
0x7C180600, // 000E CALL R6 3
0x80040C00, // 000F RET 1 R6
0x70020007, // 0010 JMP #0019
0x60180003, // 0011 GETGBL R6 G3
0x5C1C0000, // 0012 MOVE R7 R0
0x7C180200, // 0013 CALL R6 1
0x8C180D08, // 0014 GETMET R6 R6 K8
0x5C200200, // 0015 MOVE R8 R1
0x5C240400, // 0016 MOVE R9 R2
0x7C180600, // 0017 CALL R6 3
0x80040C00, // 0018 RET 1 R6
0x80000000, // 0019 RET 0
})
)
);
@ -628,13 +624,8 @@ be_local_class(Matter_Plugin_Bridge_HTTP,
{ be_const_key_weak(ui_conf_to_string, -1), be_const_static_closure(Matter_Plugin_Bridge_HTTP_ui_conf_to_string_closure) },
{ be_const_key_weak(http_remote, -1), be_const_var(0) },
{ be_const_key_weak(CLUSTERS, 0), be_const_simple_instance(be_nested_simple_instance(&be_class_map, {
be_const_map( * be_nested_map(1,
be_const_map( * be_nested_map(0,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_const_key_int(57, -1), be_const_simple_instance(be_nested_simple_instance(&be_class_list, {
be_const_list( * be_nested_list(1,
( (struct bvalue*) &(const bvalue[]) {
be_const_int(17),
})) ) } )) },
})) ) } )) },
{ be_const_key_weak(ARG, -1), be_nested_str_weak() },
{ be_const_key_weak(UPDATE_CMD, -1), be_nested_str_weak(Status_X2011) },

View File

@ -0,0 +1,295 @@
/* Solidification of Matter_Plugin_Sensor_OnOff.h */
/********************************************************************\
* Generated code, don't edit *
\********************************************************************/
#include "be_constobj.h"
extern const bclass be_class_Matter_Plugin_Sensor_OnOff;
/********************************************************************
** Solidified function: <lambda>
********************************************************************/
be_local_closure(Matter_Plugin_Sensor_OnOff__X3Clambda_X3E, /* name */
be_nested_proto(
3, /* nstack */
1, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
0, /* has constants */
NULL, /* no const */
be_str_weak(_X3Clambda_X3E),
&be_const_str_solidified,
( &(const binstruction[ 4]) { /* code */
0x60040009, // 0000 GETGBL R1 G9
0x5C080000, // 0001 MOVE R2 R0
0x7C040200, // 0002 CALL R1 1
0x80040200, // 0003 RET 1 R1
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: read_attribute
********************************************************************/
be_local_closure(Matter_Plugin_Sensor_OnOff_read_attribute, /* name */
be_nested_proto(
11, /* nstack */
3, /* argc */
2, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[12]) { /* constants */
/* K0 */ be_nested_str_weak(string),
/* K1 */ be_nested_str_weak(matter),
/* K2 */ be_nested_str_weak(TLV),
/* K3 */ be_nested_str_weak(cluster),
/* K4 */ be_nested_str_weak(attribute),
/* K5 */ be_nested_str_weak(update_shadow_lazy),
/* K6 */ be_const_int(0),
/* K7 */ be_nested_str_weak(create_TLV),
/* K8 */ be_nested_str_weak(BOOL),
/* K9 */ be_nested_str_weak(shadow_onoff),
/* K10 */ be_nested_str_weak(U4),
/* K11 */ be_nested_str_weak(read_attribute),
}),
be_str_weak(read_attribute),
&be_const_str_solidified,
( &(const binstruction[45]) { /* code */
0xA40E0000, // 0000 IMPORT R3 K0
0xB8120200, // 0001 GETNGBL R4 K1
0x88100902, // 0002 GETMBR R4 R4 K2
0x88140503, // 0003 GETMBR R5 R2 K3
0x88180504, // 0004 GETMBR R6 R2 K4
0x541E0005, // 0005 LDINT R7 6
0x1C1C0A07, // 0006 EQ R7 R5 R7
0x781E001B, // 0007 JMPF R7 #0024
0x8C1C0105, // 0008 GETMET R7 R0 K5
0x7C1C0200, // 0009 CALL R7 1
0x1C1C0D06, // 000A EQ R7 R6 K6
0x781E0005, // 000B JMPF R7 #0012
0x8C1C0907, // 000C GETMET R7 R4 K7
0x88240908, // 000D GETMBR R9 R4 K8
0x88280109, // 000E GETMBR R10 R0 K9
0x7C1C0600, // 000F CALL R7 3
0x80040E00, // 0010 RET 1 R7
0x70020010, // 0011 JMP #0023
0x541EFFFB, // 0012 LDINT R7 65532
0x1C1C0C07, // 0013 EQ R7 R6 R7
0x781E0005, // 0014 JMPF R7 #001B
0x8C1C0907, // 0015 GETMET R7 R4 K7
0x8824090A, // 0016 GETMBR R9 R4 K10
0x58280006, // 0017 LDCONST R10 K6
0x7C1C0600, // 0018 CALL R7 3
0x80040E00, // 0019 RET 1 R7
0x70020007, // 001A JMP #0023
0x541EFFFC, // 001B LDINT R7 65533
0x1C1C0C07, // 001C EQ R7 R6 R7
0x781E0004, // 001D JMPF R7 #0023
0x8C1C0907, // 001E GETMET R7 R4 K7
0x8824090A, // 001F GETMBR R9 R4 K10
0x542A0003, // 0020 LDINT R10 4
0x7C1C0600, // 0021 CALL R7 3
0x80040E00, // 0022 RET 1 R7
0x70020007, // 0023 JMP #002C
0x601C0003, // 0024 GETGBL R7 G3
0x5C200000, // 0025 MOVE R8 R0
0x7C1C0200, // 0026 CALL R7 1
0x8C1C0F0B, // 0027 GETMET R7 R7 K11
0x5C240200, // 0028 MOVE R9 R1
0x5C280400, // 0029 MOVE R10 R2
0x7C1C0600, // 002A CALL R7 3
0x80040E00, // 002B RET 1 R7
0x80000000, // 002C RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: update_shadow
********************************************************************/
be_local_closure(Matter_Plugin_Sensor_OnOff_update_shadow, /* name */
be_nested_proto(
9, /* nstack */
1, /* argc */
2, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[13]) { /* constants */
/* K0 */ be_nested_str_weak(update_shadow),
/* K1 */ be_nested_str_weak(json),
/* K2 */ be_nested_str_weak(tasmota),
/* K3 */ be_nested_str_weak(cmd),
/* K4 */ be_nested_str_weak(Status_X208),
/* K5 */ be_nested_str_weak(load),
/* K6 */ be_nested_str_weak(find),
/* K7 */ be_nested_str_weak(Switch),
/* K8 */ be_nested_str_weak(tasmota_switch_index),
/* K9 */ be_nested_str_weak(ON),
/* K10 */ be_nested_str_weak(shadow_onoff),
/* K11 */ be_nested_str_weak(attribute_updated),
/* K12 */ be_const_int(0),
}),
be_str_weak(update_shadow),
&be_const_str_solidified,
( &(const binstruction[45]) { /* 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
0xA4060200, // 0005 IMPORT R1 K1
0xB80A0400, // 0006 GETNGBL R2 K2
0x8C080503, // 0007 GETMET R2 R2 K3
0x58100004, // 0008 LDCONST R4 K4
0x50140200, // 0009 LDBOOL R5 1 0
0x7C080600, // 000A CALL R2 3
0x4C0C0000, // 000B LDNIL R3
0x200C0403, // 000C NE R3 R2 R3
0x780E001D, // 000D JMPF R3 #002C
0x8C0C0305, // 000E GETMET R3 R1 K5
0x5C140400, // 000F MOVE R5 R2
0x7C0C0400, // 0010 CALL R3 2
0x4C100000, // 0011 LDNIL R4
0x20100604, // 0012 NE R4 R3 R4
0x78120017, // 0013 JMPF R4 #002C
0x50100000, // 0014 LDBOOL R4 0 0
0x8C140706, // 0015 GETMET R5 R3 K6
0x601C0008, // 0016 GETGBL R7 G8
0x88200108, // 0017 GETMBR R8 R0 K8
0x7C1C0200, // 0018 CALL R7 1
0x001E0E07, // 0019 ADD R7 K7 R7
0x7C140400, // 001A CALL R5 2
0x1C140B09, // 001B EQ R5 R5 K9
0x5C100A00, // 001C MOVE R4 R5
0x8814010A, // 001D GETMBR R5 R0 K10
0x4C180000, // 001E LDNIL R6
0x20140A06, // 001F NE R5 R5 R6
0x78160009, // 0020 JMPF R5 #002B
0x8814010A, // 0021 GETMBR R5 R0 K10
0x60180017, // 0022 GETGBL R6 G23
0x5C1C0800, // 0023 MOVE R7 R4
0x7C180200, // 0024 CALL R6 1
0x20140A06, // 0025 NE R5 R5 R6
0x78160003, // 0026 JMPF R5 #002B
0x8C14010B, // 0027 GETMET R5 R0 K11
0x541E0405, // 0028 LDINT R7 1030
0x5820000C, // 0029 LDCONST R8 K12
0x7C140600, // 002A CALL R5 3
0x90021404, // 002B SETMBR R0 K10 R4
0x80000000, // 002C RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: init
********************************************************************/
be_local_closure(Matter_Plugin_Sensor_OnOff_init, /* name */
be_nested_proto(
9, /* nstack */
4, /* argc */
2, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 6]) { /* constants */
/* K0 */ be_nested_str_weak(init),
/* K1 */ be_nested_str_weak(tasmota_switch_index),
/* K2 */ be_nested_str_weak(find),
/* K3 */ be_nested_str_weak(ARG),
/* K4 */ be_const_int(1),
/* K5 */ be_const_int(0),
}),
be_str_weak(init),
&be_const_str_solidified,
( &(const binstruction[20]) { /* code */
0x60100003, // 0000 GETGBL R4 G3
0x5C140000, // 0001 MOVE R5 R0
0x7C100200, // 0002 CALL R4 1
0x8C100900, // 0003 GETMET R4 R4 K0
0x5C180200, // 0004 MOVE R6 R1
0x5C1C0400, // 0005 MOVE R7 R2
0x5C200600, // 0006 MOVE R8 R3
0x7C100800, // 0007 CALL R4 4
0x60100009, // 0008 GETGBL R4 G9
0x8C140702, // 0009 GETMET R5 R3 K2
0x881C0103, // 000A GETMBR R7 R0 K3
0x58200004, // 000B LDCONST R8 K4
0x7C140600, // 000C CALL R5 3
0x7C100200, // 000D CALL R4 1
0x90020204, // 000E SETMBR R0 K1 R4
0x88100101, // 000F GETMBR R4 R0 K1
0x18100905, // 0010 LE R4 R4 K5
0x78120000, // 0011 JMPF R4 #0013
0x90020304, // 0012 SETMBR R0 K1 K4
0x80000000, // 0013 RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified class: Matter_Plugin_Sensor_OnOff
********************************************************************/
extern const bclass be_class_Matter_Plugin_Device;
be_local_class(Matter_Plugin_Sensor_OnOff,
2,
&be_class_Matter_Plugin_Device,
be_nested_map(12,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_const_key_weak(UPDATE_TIME, -1), be_const_int(5000) },
{ be_const_key_weak(TYPE, 11), be_nested_str_weak(occupancy) },
{ be_const_key_weak(TYPES, -1), be_const_simple_instance(be_nested_simple_instance(&be_class_map, {
be_const_map( * be_nested_map(1,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_const_key_int(2128, -1), be_const_int(2) },
})) ) } )) },
{ be_const_key_weak(ARG, 9), be_nested_str_weak(switch) },
{ be_const_key_weak(ARG_TYPE, 8), be_const_static_closure(Matter_Plugin_Sensor_OnOff__X3Clambda_X3E_closure) },
{ be_const_key_weak(NAME, -1), be_nested_str_weak(OnOff) },
{ be_const_key_weak(read_attribute, 5), be_const_closure(Matter_Plugin_Sensor_OnOff_read_attribute_closure) },
{ be_const_key_weak(tasmota_switch_index, -1), be_const_var(0) },
{ be_const_key_weak(shadow_onoff, -1), be_const_var(1) },
{ be_const_key_weak(init, -1), be_const_closure(Matter_Plugin_Sensor_OnOff_init_closure) },
{ be_const_key_weak(CLUSTERS, 7), be_const_simple_instance(be_nested_simple_instance(&be_class_map, {
be_const_map( * be_nested_map(1,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_const_key_int(6, -1), be_const_simple_instance(be_nested_simple_instance(&be_class_list, {
be_const_list( * be_nested_list(3,
( (struct bvalue*) &(const bvalue[]) {
be_const_int(0),
be_const_int(65532),
be_const_int(65533),
})) ) } )) },
})) ) } )) },
{ be_const_key_weak(update_shadow, -1), be_const_closure(Matter_Plugin_Sensor_OnOff_update_shadow_closure) },
})),
be_str_weak(Matter_Plugin_Sensor_OnOff)
);
/*******************************************************************/
void be_load_Matter_Plugin_Sensor_OnOff_class(bvm *vm) {
be_pushntvclass(vm, &be_class_Matter_Plugin_Sensor_OnOff);
be_setglobal(vm, "Matter_Plugin_Sensor_OnOff");
be_pop(vm, 1);
}
/********************************************************************/
/* End of solidification */

File diff suppressed because it is too large Load Diff