Skip to content

Matter add option to disable bridge mode #18992

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file.
## [13.0.0.1]
### Added
- Command ``Delay -1`` to wait until next second (#18984)
- Matter add option to disable bridge mode

### Breaking Changed
- Berry `bool( [] )` and `bool( {} )` now evaluate as `false` (#18986)
Expand Down
5 changes: 4 additions & 1 deletion lib/libesp32/berry_matter/src/embedded/Matter_Device.be
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class Matter_Device
var root_discriminator # as `int`
var root_passcode # as `int`
var ipv4only # advertize only IPv4 addresses (no IPv6)
var disable_bridge_mode # default is bridge mode, this flag disables this mode for some non-compliant controllers
var next_ep # next endpoint to be allocated for bridge, start at 1
# context for PBKDF
var root_iterations # PBKDF number of iterations
Expand Down Expand Up @@ -92,6 +93,7 @@ class Matter_Device
self.next_ep = 1 # start at endpoint 1 for dynamically allocated endpoints
self.root_salt = crypto.random(16)
self.ipv4only = false
self.disable_bridge_mode = false
self.load_param()

self.sessions = matter.Session_Store(self)
Expand Down Expand Up @@ -628,7 +630,7 @@ class Matter_Device
import json
self.update_remotes_info() # update self.plugins_config_remotes

var j = format('{"distinguish":%i,"passcode":%i,"ipv4only":%s,"nextep":%i', self.root_discriminator, self.root_passcode, self.ipv4only ? 'true':'false', self.next_ep)
var j = format('{"distinguish":%i,"passcode":%i,"ipv4only":%s,"disable_bridge_mode":%s,"nextep":%i', self.root_discriminator, self.root_passcode, self.ipv4only ? 'true':'false', self.disable_bridge_mode ? 'true':'false', self.next_ep)
if self.plugins_persist
j += ',"config":'
j += json.dump(self.plugins_config)
Expand Down Expand Up @@ -693,6 +695,7 @@ class Matter_Device
self.root_discriminator = j.find("distinguish", self.root_discriminator)
self.root_passcode = j.find("passcode", self.root_passcode)
self.ipv4only = bool(j.find("ipv4only", false))
self.disable_bridge_mode = bool(j.find("disable_bridge_mode", false))
self.next_ep = j.find("nextep", self.next_ep)
self.plugins_config = j.find("config")
if self.plugins_config != nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class Matter_Plugin_Device : Matter_Plugin
d1.add_TLV(1, TLV.U2, types[dt]) # Revision
end
# if fabric is not Alexa
if self.NON_BRIDGE_VENDOR.find(session.get_admin_vendor()) == nil
if (self.NON_BRIDGE_VENDOR.find(session.get_admin_vendor()) == nil) && (!self.device.disable_bridge_mode)
var d1 = dtl.add_struct()
d1.add_TLV(0, TLV.U2, 0x0013) # DeviceType
d1.add_TLV(1, TLV.U2, 1) # Revision
Expand Down
3 changes: 3 additions & 0 deletions lib/libesp32/berry_matter/src/embedded/Matter_UI.be
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ class Matter_UI
webserver.content_send(f"<input type='number' min='0' max='4095' name='discriminator' value='{self.device.root_discriminator:i}'>")
var ipv4only_checked = self.device.ipv4only ? " checked" : ""
webserver.content_send(f"<p><input type='checkbox' name='ipv4'{ipv4only_checked}>IPv4 only</p>")
var disable_bridge_mode_checked = self.device.disable_bridge_mode ? " checked" : ""
webserver.content_send(f"<p><input type='checkbox' name='nobridge'{disable_bridge_mode_checked}>Disable bridge mode (not recommended)</p>")
webserver.content_send("<p></p><button name='passcode' class='button bgrn'>Change</button></form></p>"
"<p></p></fieldset><p></p>")

Expand Down Expand Up @@ -755,6 +757,7 @@ class Matter_UI
self.device.root_discriminator = int(webserver.arg("discriminator"))
end
self.device.ipv4only = webserver.arg("ipv4") == 'on'
self.device.disable_bridge_mode = webserver.arg("nobridge") == 'on'
self.device.save_param()

#- and force restart -#
Expand Down
Loading