Matter solidify map of plugins (#19917)

This commit is contained in:
s-hadinger 2023-11-03 21:50:55 +01:00 committed by GitHub
parent 11e9b7375d
commit 8e6a8b6cff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 4376 additions and 4468 deletions

View File

@ -204,7 +204,6 @@ extern const bclass be_class_Matter_TLV; // need to declare it upfront because
#include "solidify/solidified_Matter_Plugin_0.h"
#include "solidify/solidified_Matter_Base38.h"
#include "solidify/solidified_Matter_UI.h"
#include "solidify/solidified_Matter_Device.h"
#include "solidify/solidified_Matter_Profiler.h"
#include "../generate/be_matter_certs.h"
@ -254,6 +253,8 @@ extern const bclass be_class_Matter_TLV; // need to declare it upfront because
#include "solidify/solidified_Matter_Plugin_3_Bridge_Sensor_Occupancy.h"
#include "solidify/solidified_Matter_Plugin_3_Bridge_Sensor_Contact.h"
#include "solidify/solidified_Matter_Plugin_4_Bridge_Sensor_Flow.h"
#include "solidify/solidified_Matter_Plugin_z_All.h"
#include "solidify/solidified_Matter_zz_Device.h"
/*********************************************************************************************\
* Get a bytes() object of the certificate DAC/PAI_Cert
@ -433,52 +434,10 @@ module matter (scope: global, strings: weak) {
DAC_Priv_FFF1_8000, func(matter_DAC_Priv_FFF1_8000)
CD_FFF1_8000, func(matter_CD_FFF1_8000) // Certification Declaration
// Plugins
// Plugins - only the core classes, all others are taken from `matter_device.plugins_classes`
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_Virt_OnOff, class(be_class_Matter_Plugin_Virt_OnOff) // Relay/Light virtual (OnOff)
Plugin_Light0, class(be_class_Matter_Plugin_Light0) // OnOff Light
Plugin_Virt_Light0, class(be_class_Matter_Plugin_Virt_Light0) // OnOff Light Virtual
Plugin_Light1, class(be_class_Matter_Plugin_Light1) // Dimmable Light
Plugin_Virt_Light1, class(be_class_Matter_Plugin_Virt_Light1) // Dimmable Light Virtual
Plugin_Light2, class(be_class_Matter_Plugin_Light2) // Color Temperature Light
Plugin_Virt_Light2, class(be_class_Matter_Plugin_Virt_Light2) // Color Temperature Light Virtual
Plugin_Light3, class(be_class_Matter_Plugin_Light3) // Extended Color Light
Plugin_Virt_Light3, class(be_class_Matter_Plugin_Virt_Light3) // Extended Color Light Virtual
Plugin_Shutter, class(be_class_Matter_Plugin_Shutter) // Shutter
Plugin_ShutterTilt, class(be_class_Matter_Plugin_ShutterTilt) // Shutter + Tilt
Plugin_Sensor, class(be_class_Matter_Plugin_Sensor) // Generic Sensor
Plugin_Sensor_Pressure, class(be_class_Matter_Plugin_Sensor_Pressure) // Pressure Sensor
Plugin_Sensor_Flow, class(be_class_Matter_Plugin_Sensor_Flow) // Flow Sensor
Plugin_Sensor_Virt_Pressure, class(be_class_Matter_Plugin_Virt_Sensor_Pressure) // Pressure Virtual Sensor
Plugin_Sensor_Virt_Flow, class(be_class_Matter_Plugin_Virt_Sensor_Flow) // Flow Virtual Sensor
Plugin_Sensor_Temp, class(be_class_Matter_Plugin_Sensor_Temp) // Temperature Sensor
Plugin_Virt_Sensor_Temp, class(be_class_Matter_Plugin_Virt_Sensor_Temp) // Temperature Sensor
Plugin_Sensor_Illuminance, class(be_class_Matter_Plugin_Sensor_Illuminance) // Illuminance Sensor
Plugin_Virt_Sensor_Illuminance, class(be_class_Matter_Plugin_Virt_Sensor_Illuminance) // Illuminance Virtual Sensor
Plugin_Sensor_Humidity, class(be_class_Matter_Plugin_Sensor_Humidity) // Humidity Sensor
Plugin_Sensor_Virt_Humidity, class(be_class_Matter_Plugin_Virt_Sensor_Humidity) // Humidity Virtual Sensor
Plugin_Sensor_Occupancy, class(be_class_Matter_Plugin_Sensor_Occupancy) // Occupancy Sensor
Plugin_Sensor_OnOff, class(be_class_Matter_Plugin_Sensor_OnOff) // Simple OnOff Sensor
Plugin_Sensor_Contact, class(be_class_Matter_Plugin_Sensor_Contact) // Contact Sensor
Plugin_Virt_Sensor_Occupancy, class(be_class_Matter_Plugin_Virt_Sensor_Occupancy) // Virtual Occupancy Sensor
Plugin_Virt_Sensor_Contact, class(be_class_Matter_Plugin_Virt_Sensor_Contact) // Virtual Contact Sensor
Plugin_Bridge_HTTP, class(be_class_Matter_Plugin_Bridge_HTTP) // HTTP bridge superclass
Plugin_Bridge_OnOff, class(be_class_Matter_Plugin_Bridge_OnOff) // HTTP Relay/Light behavior (OnOff)
Plugin_Bridge_Light0, class(be_class_Matter_Plugin_Bridge_Light0) // HTTP OnOff Light
Plugin_Bridge_Light1, class(be_class_Matter_Plugin_Bridge_Light1) // HTTP Dimmer Light
Plugin_Bridge_Light2, class(be_class_Matter_Plugin_Bridge_Light2) // HTTP CT Light
Plugin_Bridge_Light3, class(be_class_Matter_Plugin_Bridge_Light3) // HTTP RGB Light
Plugin_Bridge_Sensor, class(be_class_Matter_Plugin_Bridge_Sensor) // HTTP generic sensor
Plugin_Bridge_Sensor_Pressure, class(be_class_Matter_Plugin_Bridge_Sensor_Pressure) // HTTP Pressure sensor
Plugin_Bridge_Sensor_Flow, class(be_class_Matter_Plugin_Bridge_Sensor_Flow) // HTTP Flow sensor
Plugin_Bridge_Sensor_Temp, class(be_class_Matter_Plugin_Bridge_Sensor_Temp) // HTTP Temperature sensor
Plugin_Bridge_Sensor_Illuminance, class(be_class_Matter_Plugin_Bridge_Sensor_Illuminance) // HTTP Illuminance sensor
Plugin_Bridge_Sensor_Humidity, class(be_class_Matter_Plugin_Bridge_Sensor_Humidity) // HTTP Humidity sensor
Plugin_Bridge_Sensor_Occupancy, class(be_class_Matter_Plugin_Bridge_Sensor_Occupancy) // HTTP Occupancy sensor
Plugin_Bridge_Sensor_Contact, class(be_class_Matter_Plugin_Bridge_Sensor_Contact) // HTTP Contact sensor
}
@const_object_info_end */

View File

@ -0,0 +1,43 @@
#
# Matter_Plugin_z_All.be - list all plugin classes in a solidified map
#
# 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
# this is used to solidify plugins list in Matter_Device
def register_native_classes()
var plugins_classes = {}
# try to register any class that starts with 'Plugin_'
import introspect
import string
for k: introspect.members(matter)
var v = introspect.get(matter, k)
if type(v) == 'class' && string.find(k, "Plugin_") == 0
var typ = introspect.get(v, 'TYPE') # make sure we don't crash if TYPE does not exist
if typ
plugins_classes[typ] = v
end
end
end
return plugins_classes
end
plugins_classes = register_native_classes()
matter.plugins_classes = plugins_classes

View File

@ -1,5 +1,5 @@
#
# Matter_Device.be - implements a generic Matter device (commissionee)
# Matter_zz_Device.be - implements a generic Matter device (commissionee)
#
# Copyright (C) 2023 Stephan Hadinger & Theo Arends
#
@ -31,7 +31,7 @@ class Matter_Device
var started # is the Matter Device started (configured, mDNS and UDPServer started)
var plugins # list of plugins instances
var plugins_persist # true if plugins configuration needs to be saved
var plugins_classes # map of registered classes by type name
static var plugins_classes = matter.plugins_classes # map of registered classes by type name
var plugins_config # map of JSON configuration for plugins
var plugins_config_remotes # map of information on each remote under "remotes" key, '{}' when empty
var udp_server # `matter.UDPServer()` object
@ -86,9 +86,7 @@ class Matter_Device
self.tick = 0
self.plugins = []
self.plugins_persist = false # plugins need to saved only when the first fabric is associated
self.plugins_classes = {}
self.plugins_config_remotes = {}
self.register_native_classes() # register all native classes
self.vendorid = self.VENDOR_ID
self.productid = self.PRODUCT_ID
self.root_iterations = self.PBKDF_ITERATIONS
@ -1270,18 +1268,6 @@ class Matter_Device
for i:1..size(l)-1 var k = l[i] var j = i while (j > 0) && (l[j-1] > k) l[j] = l[j-1] j -= 1 end l[j] = k end return l
end
#############################################################
# register_plugin_class
#
# Adds a class by name
def register_plugin_class(cl)
import introspect
var typ = introspect.get(cl, 'TYPE') # make sure we don't crash if TYPE does not exist
if typ
self.plugins_classes[typ] = cl
end
end
#############################################################
# get_plugin_class_displayname
#
@ -1300,23 +1286,6 @@ class Matter_Device
return cl ? cl.ARG : ""
end
#############################################################
# register_native_classes
#
# Adds a class by name
def register_native_classes(name, cl)
# try to register any class that starts with 'Plugin_'
import introspect
import string
for k: introspect.members(matter)
var v = introspect.get(matter, k)
if type(v) == 'class' && string.find(k, "Plugin_") == 0
self.register_plugin_class(v)
end
end
# tasmota.log("MTR: registered classes "+str(self.k2l(self.plugins_classes)), 3)
end
#############################################################
# Dynamic adding and removal of endpoints (bridge mode)
#############################################################

View File

@ -0,0 +1,7 @@
/* Solidification of Matter_Plugin_z_All.h */
/********************************************************************\
* Generated code, don't edit *
\********************************************************************/
#include "be_constobj.h"
/********************************************************************/
/* End of solidification */