@@ -1233,48 +1233,48 @@ async def _send_request_raw(
1233
1233
Data = data ,
1234
1234
)
1235
1235
1236
- # XXX: Joins *must* be sent via a ZDO command. Otherwise, Z-Stack will not
1237
- # actually permit the coordinator to send the network key.
1238
- if dst_ep == ZDO_ENDPOINT and cluster == zdo_t .ZDOCmd .Mgmt_Permit_Joining_req :
1239
- await self ._znp .request_callback_rsp (
1240
- request = c .ZDO .MgmtPermitJoinReq .Req (
1241
- AddrMode = dst_addr .mode ,
1242
- Dst = dst_addr .address ,
1243
- Duration = data [1 ],
1244
- TCSignificance = data [2 ],
1245
- ),
1246
- RspStatus = t .Status .SUCCESS ,
1247
- callback = c .ZDO .MgmtPermitJoinRsp .Callback (Src = 0x0000 , partial = True ),
1248
- )
1249
- # Internally forward ZDO requests destined for the coordinator back to zigpy so
1250
- # we can send Z-Stack internal requests when necessary
1251
- elif dst_ep == ZDO_ENDPOINT and (
1252
- # Broadcast that will reach the device
1253
- (
1236
+ # Z-Stack requires special treatment when sending ZDO requests
1237
+ if dst_ep == ZDO_ENDPOINT :
1238
+ # XXX: Joins *must* be sent via a ZDO command, even if they are directly
1239
+ # addressing another device. The router will receive the ZDO request and a
1240
+ # device will try to join, but Z-Stack will never send the network key.
1241
+ if cluster == zdo_t .ZDOCmd .Mgmt_Permit_Joining_req :
1242
+ await self ._znp .request_callback_rsp (
1243
+ request = c .ZDO .MgmtPermitJoinReq .Req (
1244
+ AddrMode = dst_addr .mode ,
1245
+ Dst = dst_addr .address ,
1246
+ Duration = data [1 ],
1247
+ TCSignificance = data [2 ],
1248
+ ),
1249
+ RspStatus = t .Status .SUCCESS ,
1250
+ callback = c .ZDO .MgmtPermitJoinRsp .Callback (Src = 0x0000 , partial = True ),
1251
+ )
1252
+ # Internally forward ZDO requests destined for the coordinator back to zigpy
1253
+ # so we can send internal Z-Stack requests when necessary
1254
+ elif (
1255
+ # Broadcast that will reach the device
1254
1256
dst_addr .mode == t .AddrMode .Broadcast
1255
1257
and dst_addr .address
1256
1258
in (
1257
1259
zigpy .types .BroadcastAddress .ALL_DEVICES ,
1258
1260
zigpy .types .BroadcastAddress .RX_ON_WHEN_IDLE ,
1259
1261
zigpy .types .BroadcastAddress .ALL_ROUTERS_AND_COORDINATOR ,
1260
1262
)
1261
- )
1262
- # Or a direct unicast request
1263
- or (
1263
+ ) or (
1264
+ # Or a direct unicast request
1264
1265
dst_addr .mode == t .AddrMode .NWK
1265
1266
and dst_addr .address == self .zigpy_device .nwk
1266
- )
1267
- ):
1268
- self .handle_message (
1269
- sender = self .zigpy_device ,
1270
- profile = ZDO_PROFILE ,
1271
- cluster = cluster ,
1272
- src_ep = ZDO_ENDPOINT ,
1273
- dst_ep = ZDO_ENDPOINT ,
1274
- message = data ,
1275
- )
1267
+ ):
1268
+ self .handle_message (
1269
+ sender = self .zigpy_device ,
1270
+ profile = profile ,
1271
+ cluster = cluster ,
1272
+ src_ep = src_ep ,
1273
+ dst_ep = dst_ep ,
1274
+ message = data ,
1275
+ )
1276
1276
1277
- if dst_addr .mode == t .AddrMode .Broadcast or dst_ep == ZDO_ENDPOINT :
1277
+ if dst_ep == ZDO_ENDPOINT or dst_addr .mode == t .AddrMode .Broadcast :
1278
1278
# Broadcasts and ZDO requests will not receive a confirmation
1279
1279
response = await self ._znp .request (
1280
1280
request = request , RspStatus = t .Status .SUCCESS
0 commit comments