Skip to content

Commit 2c1f6b2

Browse files
authored
Matter add internal debug option (#21634)
1 parent 0c49262 commit 2c1f6b2

File tree

5 files changed

+4684
-4659
lines changed

5 files changed

+4684
-4659
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ All notable changes to this project will be documented in this file.
99
- Berry `classof` extended to class methods (#21615)
1010
- Extend command ``SetOption147 1`` to disable publish of IRReceived MQTT messages (#21574)
1111
- Matter support for Rain sensor (#21633)
12+
- Matter add internal debug option
1213

1314
### Breaking Changed
1415

lib/libesp32/berry_matter/src/embedded/Matter_IM.be

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ class Matter_IM
833833
log(f"MTR: >Subscribe ({msg.session.local_session_id:6i}) event_requests_size={size(query.event_requests)}", 3)
834834
end
835835

836-
var ret = self._inner_process_read_request(msg.session, query, msg, true #-no_log-#)
836+
var ret = self._inner_process_read_request(msg.session, query, msg, !self.device.debug #-log only if debug enabled-#)
837837
# ret is of type `Matter_ReportDataMessage`
838838
ret.subscription_id = sub.subscription_id # enrich with subscription id TODO
839839
self.send_subscribe_response(msg, ret, sub)

lib/libesp32/berry_matter/src/embedded/Matter_zz_Device.be

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class Matter_Device
6666
var ipv4only # advertize only IPv4 addresses (no IPv6)
6767
var disable_bridge_mode # default is bridge mode, this flag disables this mode for some non-compliant controllers
6868
var next_ep # next endpoint to be allocated for bridge, start at 1
69+
var debug # debug mode, output all values when responding to read request with wildcard
6970
# context for PBKDF
7071
var root_iterations # PBKDF number of iterations
7172
# PBKDF information used only during PASE (freed afterwards)
@@ -649,11 +650,14 @@ class Matter_Device
649650
self.update_remotes_info() # update self.plugins_config_remotes
650651

651652
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)
653+
if self.debug
654+
j += ',"debug":true'
655+
end
652656
if self.plugins_persist
653-
j += ',"config":'
657+
j += ',\n"config":'
654658
j += json.dump(self.plugins_config)
655659
if size(self.plugins_config_remotes) > 0
656-
j += ',"remotes":'
660+
j += ',\n"remotes":'
657661
j += json.dump(self.plugins_config_remotes)
658662
end
659663
end
@@ -717,6 +721,7 @@ class Matter_Device
717721
self.disable_bridge_mode = bool(j.find("disable_bridge_mode", false))
718722
self.next_ep = j.find("nextep", self.next_ep)
719723
self.plugins_config = j.find("config")
724+
self.debug = bool(j.find("debug")) # bool converts nil to false
720725
if self.plugins_config != nil
721726
log(f"MTR: Load_config = {self.plugins_config}", 3)
722727
self.adjust_next_ep()

lib/libesp32/berry_matter/src/solidify/solidified_Matter_IM.h

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3417,7 +3417,7 @@ be_local_closure(class_Matter_IM_subscribe_request, /* name */
34173417
0, /* has sup protos */
34183418
&be_class_Matter_IM,
34193419
1, /* has constants */
3420-
( &(const bvalue[32]) { /* constants */
3420+
( &(const bvalue[34]) { /* constants */
34213421
/* K0 */ be_nested_str_weak(matter),
34223422
/* K1 */ be_nested_str_weak(SubscribeRequestMessage),
34233423
/* K2 */ be_nested_str_weak(from_TLV),
@@ -3449,11 +3449,13 @@ be_local_closure(class_Matter_IM_subscribe_request, /* name */
34493449
/* K28 */ be_nested_str_weak(event_requests),
34503450
/* K29 */ be_nested_str_weak(MTR_X3A_X20_X3ESubscribe_X20_X28_X256i_X29_X20event_requests_size_X3D_X25s),
34513451
/* K30 */ be_nested_str_weak(_inner_process_read_request),
3452-
/* K31 */ be_nested_str_weak(send_subscribe_response),
3452+
/* K31 */ be_nested_str_weak(device),
3453+
/* K32 */ be_nested_str_weak(debug),
3454+
/* K33 */ be_nested_str_weak(send_subscribe_response),
34533455
}),
34543456
be_str_weak(subscribe_request),
34553457
&be_const_str_solidified,
3456-
( &(const binstruction[99]) { /* code */
3458+
( &(const binstruction[103]) { /* code */
34573459
0xB80E0000, // 0000 GETNGBL R3 K0
34583460
0x8C0C0701, // 0001 GETMET R3 R3 K1
34593461
0x7C0C0200, // 0002 CALL R3 1
@@ -3542,17 +3544,21 @@ be_local_closure(class_Matter_IM_subscribe_request, /* name */
35423544
0x88240306, // 0055 GETMBR R9 R1 K6
35433545
0x5C280600, // 0056 MOVE R10 R3
35443546
0x5C2C0200, // 0057 MOVE R11 R1
3545-
0x50300200, // 0058 LDBOOL R12 1 0
3546-
0x7C1C0A00, // 0059 CALL R7 5
3547-
0x88200919, // 005A GETMBR R8 R4 K25
3548-
0x901E3208, // 005B SETMBR R7 K25 R8
3549-
0x8C20011F, // 005C GETMET R8 R0 K31
3550-
0x5C280200, // 005D MOVE R10 R1
3551-
0x5C2C0E00, // 005E MOVE R11 R7
3552-
0x5C300800, // 005F MOVE R12 R4
3553-
0x7C200800, // 0060 CALL R8 4
3554-
0x50200200, // 0061 LDBOOL R8 1 0
3555-
0x80041000, // 0062 RET 1 R8
3547+
0x8830011F, // 0058 GETMBR R12 R0 K31
3548+
0x88301920, // 0059 GETMBR R12 R12 K32
3549+
0x78320000, // 005A JMPF R12 #005C
3550+
0x50300001, // 005B LDBOOL R12 0 1
3551+
0x50300200, // 005C LDBOOL R12 1 0
3552+
0x7C1C0A00, // 005D CALL R7 5
3553+
0x88200919, // 005E GETMBR R8 R4 K25
3554+
0x901E3208, // 005F SETMBR R7 K25 R8
3555+
0x8C200121, // 0060 GETMET R8 R0 K33
3556+
0x5C280200, // 0061 MOVE R10 R1
3557+
0x5C2C0E00, // 0062 MOVE R11 R7
3558+
0x5C300800, // 0063 MOVE R12 R4
3559+
0x7C200800, // 0064 CALL R8 4
3560+
0x50200200, // 0065 LDBOOL R8 1 0
3561+
0x80041000, // 0066 RET 1 R8
35563562
})
35573563
)
35583564
);

0 commit comments

Comments
 (0)