Skip to content

Add ZDO converter for Mgmt_Bind_req; update return format to match zigpy expectations #110

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
Dec 13, 2021
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
15 changes: 3 additions & 12 deletions zigpy_znp/commands/zdo.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,7 @@ class GroupIdList(t.LVList, item_type=t.GroupId, length_type=t.uint8_t):
pass


class BindEntry(t.Struct):
"""Bind table entry."""

Src: t.EUI64
SrcEp: t.uint8_t
ClusterId: t.ClusterId
DstAddr: zigpy.zdo.types.MultiAddress


class BindEntryList(t.LVList, item_type=BindEntry, length_type=t.uint8_t):
class BindEntryList(t.LVList, item_type=zigpy.zdo.types.Binding, length_type=t.uint8_t):
pass


Expand Down Expand Up @@ -1209,8 +1200,8 @@ class ZDO(t.CommandsBase, subsystem=t.Subsystem.ZDO):
t.uint8_t,
"Total number of entries available on the device",
),
t.Param("Index", t.uint8_t, "Index where the response starts"),
t.Param("BindTable", BindEntryList, "list of BindEntries"),
t.Param("StartIndex", t.uint8_t, "Index where the response starts"),
t.Param("BindTableList", BindEntryList, "list of BindEntries"),
),
)

Expand Down
22 changes: 22 additions & 0 deletions zigpy_znp/zigbee/zdo_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,26 @@
(lambda addr: c.ZDO.MgmtRtgRsp.Callback(partial=True, Src=addr.address)),
(lambda rsp: (ZDOCmd.Mgmt_Rtg_rsp, {"Status": rsp.Status})),
),
ZDOCmd.Mgmt_Bind_req: (
(
lambda addr, StartIndex: (
c.ZDO.MgmtBindReq.Req(
Dst=addr.address,
StartIndex=StartIndex,
)
)
),
(lambda addr: c.ZDO.MgmtBindRsp.Callback(partial=True, Src=addr.address)),
(
lambda rsp: (
ZDOCmd.Mgmt_Bind_rsp,
{
"Status": rsp.Status,
"BindingTableEntries": rsp.BindTableEntries,
"StartIndex": rsp.StartIndex,
"BindingTableList": rsp.BindTableList,
},
)
),
),
}