Skip to content

Commit 3d6b8c4

Browse files
committed
Add ZDO converter for Mgmt_Bind_req; update return format to match zigpy expectations
The field names in the existing ZDO command definition didn't match the expected names at https://github.com/zigpy/zigpy/blob/77dec68ab51a9205535a0b47ae2f6f27f27ec73f/zigpy/zdo/types.py#L664-L669
1 parent d779a3d commit 3d6b8c4

File tree

2 files changed

+26
-13
lines changed

2 files changed

+26
-13
lines changed

zigpy_znp/commands/zdo.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,7 @@ class GroupIdList(t.LVList, item_type=t.GroupId, length_type=t.uint8_t):
100100
pass
101101

102102

103-
class BindEntry(t.Struct):
104-
"""Bind table entry."""
105-
106-
Src: t.EUI64
107-
SrcEp: t.uint8_t
108-
ClusterId: t.ClusterId
109-
DstAddr: zigpy.zdo.types.MultiAddress
110-
111-
112-
class BindEntryList(t.LVList, item_type=BindEntry, length_type=t.uint8_t):
103+
class BindEntryList(t.LVList, item_type=zigpy.zdo.types.Binding, length_type=t.uint8_t):
113104
pass
114105

115106

@@ -1205,12 +1196,12 @@ class ZDO(t.CommandsBase, subsystem=t.Subsystem.ZDO):
12051196
"Status", t.ZDOStatus, "Status is either Success (0) or Failure (1)"
12061197
),
12071198
t.Param(
1208-
"BindTableEntries",
1199+
"BindingTableEntries",
12091200
t.uint8_t,
12101201
"Total number of entries available on the device",
12111202
),
1212-
t.Param("Index", t.uint8_t, "Index where the response starts"),
1213-
t.Param("BindTable", BindEntryList, "list of BindEntries"),
1203+
t.Param("StartIndex", t.uint8_t, "Index where the response starts"),
1204+
t.Param("BindingTableList", BindEntryList, "list of BindEntries"),
12141205
),
12151206
)
12161207

zigpy_znp/zigbee/zdo_converters.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,4 +191,26 @@
191191
(lambda addr: c.ZDO.MgmtRtgRsp.Callback(partial=True, Src=addr.address)),
192192
(lambda rsp: (ZDOCmd.Mgmt_Rtg_rsp, {"Status": rsp.Status})),
193193
),
194+
ZDOCmd.Mgmt_Bind_req: (
195+
(
196+
lambda addr, StartIndex: (
197+
c.ZDO.MgmtBindReq.Req(
198+
Dst=addr.address,
199+
StartIndex=StartIndex,
200+
)
201+
)
202+
),
203+
(lambda addr: c.ZDO.MgmtBindRsp.Callback(partial=True, Src=addr.address)),
204+
(
205+
lambda rsp: (
206+
ZDOCmd.Mgmt_Bind_rsp,
207+
{
208+
"Status": rsp.Status,
209+
"BindingTableEntries": rsp.BindingTableEntries,
210+
"StartIndex": rsp.StartIndex,
211+
"BindingTableList": rsp.BindingTableList,
212+
},
213+
)
214+
),
215+
),
194216
}

0 commit comments

Comments
 (0)