@@ -29,47 +29,51 @@ async def test_permit_join(device, fixed_joining_bug, mocker, make_application):
29
29
30
30
app , znp_server = make_application (server_cls = device )
31
31
32
- # Handle us opening joins on the coordinator
33
32
permit_join_coordinator = znp_server .reply_once_to (
34
- request = zdo_request_matcher (
35
- dst_addr = t .AddrModeAddress (t .AddrMode .NWK , 0x0000 ),
36
- command_id = zdo_t .ZDOCmd .Mgmt_Permit_Joining_req ,
37
- TSN = 7 ,
38
- zdo_PermitDuration = 10 ,
39
- zdo_TC_Significant = 0 ,
33
+ request = c .ZDO .MgmtPermitJoinReq .Req (
34
+ AddrMode = t .AddrMode .NWK , Dst = 0x0000 , Duration = 10 , partial = True
40
35
),
41
36
responses = [
42
- c .AF . DataRequestExt .Rsp (Status = t .Status .SUCCESS ),
37
+ c .ZDO . MgmtPermitJoinReq .Rsp (Status = t .Status .SUCCESS ),
43
38
c .ZDO .MgmtPermitJoinRsp .Callback (Src = 0x0000 , Status = t .ZDOStatus .SUCCESS ),
44
39
],
45
40
)
46
41
47
42
# Handle the ZDO broadcast sent by Zigpy
48
- permit_join_broadcast = znp_server .reply_once_to (
43
+ permit_join_broadcast_raw = znp_server .reply_once_to (
49
44
request = zdo_request_matcher (
50
45
dst_addr = t .AddrModeAddress (t .AddrMode .Broadcast , 0xFFFC ),
51
46
command_id = zdo_t .ZDOCmd .Mgmt_Permit_Joining_req ,
52
- TSN = 8 if not fixed_joining_bug else 7 ,
47
+ TSN = 6 ,
53
48
zdo_PermitDuration = 10 ,
54
49
zdo_TC_Significant = 0 ,
55
50
),
56
51
responses = [
57
52
c .AF .DataRequestExt .Rsp (Status = t .Status .SUCCESS ),
53
+ ],
54
+ )
55
+
56
+ # And the duplicate one using the MT command
57
+ permit_join_broadcast = znp_server .reply_once_to (
58
+ request = c .ZDO .MgmtPermitJoinReq .Req (
59
+ AddrMode = t .AddrMode .Broadcast , Dst = 0xFFFC , Duration = 10 , partial = True
60
+ ),
61
+ responses = [
62
+ c .ZDO .MgmtPermitJoinReq .Rsp (Status = t .Status .SUCCESS ),
58
63
c .ZDO .MgmtPermitJoinRsp .Callback (Src = 0x0000 , Status = t .ZDOStatus .SUCCESS ),
59
64
],
60
65
)
61
66
62
67
await app .startup (auto_form = False )
63
68
await app .permit (time_s = 10 )
64
69
65
- if fixed_joining_bug :
66
- await permit_join_broadcast
70
+ await permit_join_broadcast
71
+ await permit_join_broadcast_raw
67
72
68
- # Joins should not have been opened on the coordinator
73
+ if fixed_joining_bug :
69
74
assert not permit_join_coordinator .done ()
70
75
else :
71
- await permit_join_coordinator
72
- await permit_join_broadcast
76
+ assert permit_join_coordinator .done ()
73
77
74
78
await app .shutdown ()
75
79
@@ -80,15 +84,11 @@ async def test_join_coordinator(device, make_application):
80
84
81
85
# Handle us opening joins on the coordinator
82
86
permit_join_coordinator = znp_server .reply_once_to (
83
- request = zdo_request_matcher (
84
- dst_addr = t .AddrModeAddress (t .AddrMode .NWK , 0x0000 ),
85
- command_id = zdo_t .ZDOCmd .Mgmt_Permit_Joining_req ,
86
- TSN = 7 ,
87
- zdo_PermitDuration = 60 ,
88
- zdo_TC_Significant = 0 ,
87
+ request = c .ZDO .MgmtPermitJoinReq .Req (
88
+ AddrMode = t .AddrMode .NWK , Dst = 0x0000 , Duration = 60 , partial = True
89
89
),
90
90
responses = [
91
- c .AF . DataRequestExt .Rsp (Status = t .Status .SUCCESS ),
91
+ c .ZDO . MgmtPermitJoinReq .Rsp (Status = t .Status .SUCCESS ),
92
92
c .ZDO .MgmtPermitJoinRsp .Callback (Src = 0x0000 , Status = t .ZDOStatus .SUCCESS ),
93
93
],
94
94
)
@@ -328,7 +328,7 @@ async def test_unknown_device_discovery(device, make_application, mocker):
328
328
request = zdo_request_matcher (
329
329
dst_addr = t .AddrModeAddress (t .AddrMode .NWK , existing_nwk + 1 ),
330
330
command_id = zdo_t .ZDOCmd .IEEE_addr_req ,
331
- TSN = 7 ,
331
+ TSN = 6 ,
332
332
zdo_NWKAddrOfInterest = existing_nwk + 1 ,
333
333
zdo_RequestType = c .zdo .AddrRequestType .SINGLE ,
334
334
zdo_StartIndex = 0 ,
@@ -340,7 +340,7 @@ async def test_unknown_device_discovery(device, make_application, mocker):
340
340
IsBroadcast = t .Bool .false ,
341
341
ClusterId = zdo_t .ZDOCmd .IEEE_addr_rsp ,
342
342
SecurityUse = 0 ,
343
- TSN = 7 ,
343
+ TSN = 6 ,
344
344
MacDst = 0x0000 ,
345
345
Data = serialize_zdo_command (
346
346
command_id = zdo_t .ZDOCmd .IEEE_addr_rsp ,
@@ -387,7 +387,7 @@ async def test_unknown_device_discovery(device, make_application, mocker):
387
387
request = zdo_request_matcher (
388
388
dst_addr = t .AddrModeAddress (t .AddrMode .NWK , new_nwk ),
389
389
command_id = zdo_t .ZDOCmd .IEEE_addr_req ,
390
- TSN = 8 ,
390
+ TSN = 7 ,
391
391
zdo_NWKAddrOfInterest = new_nwk ,
392
392
zdo_RequestType = c .zdo .AddrRequestType .SINGLE ,
393
393
zdo_StartIndex = 0 ,
@@ -399,7 +399,7 @@ async def test_unknown_device_discovery(device, make_application, mocker):
399
399
IsBroadcast = t .Bool .false ,
400
400
ClusterId = zdo_t .ZDOCmd .IEEE_addr_rsp ,
401
401
SecurityUse = 0 ,
402
- TSN = 8 ,
402
+ TSN = 7 ,
403
403
MacDst = 0x0000 ,
404
404
Data = serialize_zdo_command (
405
405
command_id = zdo_t .ZDOCmd .IEEE_addr_rsp ,
0 commit comments