1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340
|
import zigpy_znp.types as t
class TransmitOptions(t.bitmap8):
NONE = 0
# Will force the message to use Wildcard ProfileID
WILDCARD_PROFILEID = 0x02
# Will force APS to callback to preprocess before calling NWK layer
APS_PREPROCESS = 0x04
LIMIT_CONCENTRATOR = 0x08
ACK_REQUEST = 0x10
# Suppress Route Discovery for intermediate routes (route discovery performed for
# initiating device)
SUPPRESS_ROUTE_DISC_NETWORK = 0x20
ENABLE_SECURITY = 0x40
SKIP_ROUTING = 0x80
class LatencyReq(t.enum8):
NoLatencyReqs = 0x00
FastBeacons = 0x01
SlowBeacons = 0x02
class AF(t.CommandsBase, subsystem=t.Subsystem.AF):
# This command enables the tester to register an application's endpoint description
Register = t.CommandDef(
t.CommandType.SREQ,
0x00,
req_schema=(
t.Param("Endpoint", t.uint8_t, "Endpoint Id of the device"),
t.Param("ProfileId", t.uint16_t, "Application Profile ID"),
t.Param("DeviceId", t.uint16_t, "Device Description ID"),
t.Param("DeviceVersion", t.uint8_t, "Device version number"),
t.Param(
"LatencyReq",
LatencyReq,
(
"Specifies latency reqs: 0x00 - None, "
"0x01 -- fast beacons, "
"0x02 -- slow beacons"
),
),
t.Param("InputClusters", t.ClusterIdList, "Input cluster list"),
t.Param("OutputClusters", t.ClusterIdList, "Output cluster list"),
),
rsp_schema=t.STATUS_SCHEMA,
)
# This command is used by the tester to build and send a message through AF layer
DataRequest = t.CommandDef(
t.CommandType.SREQ,
0x01,
req_schema=(
t.Param("DstAddr", t.NWK, "Short address of the destination device"),
t.Param("DstEndpoint", t.uint8_t, "Endpoint of the destination device"),
t.Param("SrcEndpoint", t.uint8_t, "Endpoint of the source device"),
t.Param("ClusterId", t.ClusterId, "Cluster ID"),
t.Param("TSN", t.uint8_t, "Transaction Sequence Number"),
t.Param(
"Options",
TransmitOptions,
(
"Transmit options bitmask: bit 4 -- APS Ack, "
"bit 5 -- Route Discovery, "
"bit 6 -- APS security, "
"bit 7 -- Skip routing"
),
),
t.Param(
"Radius",
t.uint8_t,
"Specifies the number of hops allowed delivering the message",
),
t.Param("Data", t.ShortBytes, "Data request"),
),
rsp_schema=t.STATUS_SCHEMA,
)
# This extended form of the AF_DATA_REQUEST must be used to send an
# inter-pan message
DataRequestExt = t.CommandDef(
t.CommandType.SREQ,
0x02,
req_schema=(
t.Param(
"DstAddrModeAddress",
t.AddrModeAddress,
"Destination address mode and address",
),
t.Param("DstEndpoint", t.uint8_t, "Endpoint of the destination device"),
t.Param(
"DstPanId",
t.PanId,
(
"PanId of the destination device: 0x0000==Intra-Pan, "
"otherwise Inter-Pan"
),
),
t.Param("SrcEndpoint", t.uint8_t, "Endpoint of the source device"),
t.Param("ClusterId", t.ClusterId, "Cluster ID"),
t.Param("TSN", t.uint8_t, "Transaction Sequence Number"),
t.Param(
"Options",
TransmitOptions,
(
"Transmit options bitmask: bit 4 -- APS Ack, "
"bit 5 -- Route Discovery, "
"bit 6 -- APS security, "
"bit 7 -- Skip routing"
),
),
t.Param(
"Radius",
t.uint8_t,
"Specifies the number of hops allowed delivering the message",
),
t.Param("Data", t.LongBytes, "Data request"),
),
rsp_schema=t.STATUS_SCHEMA,
)
# This command is used by the tester to build and send a message through AF layer
# using source routing
DataRequestSrcRtg = t.CommandDef(
t.CommandType.SREQ,
0x03,
req_schema=(
t.Param("DstAddr", t.NWK, "Short address of the destination device"),
t.Param("DstEndpoint", t.uint8_t, "Endpoint of the destination device"),
t.Param("SrcEndpoint", t.uint8_t, "Endpoint of the source device"),
t.Param("ClusterId", t.ClusterId, "Cluster ID"),
t.Param("TSN", t.uint8_t, "Transaction Sequence Number"),
t.Param(
"Options",
TransmitOptions,
(
"Transmit options bitmask: bit 4 -- APS Ack, "
"bit 5 -- Route Discovery, "
"bit 6 -- APS security, "
"bit 7 -- Skip routing"
),
),
t.Param(
"Radius",
t.uint8_t,
"Specifies the number of hops allowed delivering the message",
),
t.Param("SourceRoute", t.NWKList, "Relay list"),
t.Param("Data", t.ShortBytes, "Data request"),
),
rsp_schema=t.STATUS_SCHEMA,
)
# XXX: UNDOCUMENTED
Delete = t.CommandDef(
t.CommandType.SREQ,
0x04,
req_schema=(t.Param("Endpoint", t.uint8_t, "Application Endpoint to delete"),),
rsp_schema=t.STATUS_SCHEMA,
)
# Inter-Pan control command and data
InterPanCtl = t.CommandDef(
t.CommandType.SREQ,
0x10,
req_schema=(
t.Param(
"Command",
t.InterPanCommand,
(
"0x00 InterPanClr Proxy call to StubAPS_SetIntraPanChannel() to"
" switch channel back to the NIB-specified channel. "
"0x01 InterPanSet Proxy call to StubAPS_SetInterPanChannel() "
"with the 1-byte channel specified. "
"0x02 InterPanReg If the 1-byte Endpoint specified by the data "
"argument is found by invoking afFindEndPointDesc(), then proxy"
" a call to StubAPS_RegisterApp() with the pointer to the "
"endPointDesc_t found (i.e. the Endpoint must already be "
"registered with AF)"
),
),
t.Param("Data", t.Bytes, "Data"),
),
rsp_schema=t.STATUS_SCHEMA,
)
# Huge AF data request data buffer store command and data
DataStore = t.CommandDef(
t.CommandType.SREQ,
0x11,
req_schema=(
t.Param(
"Index",
t.uint16_t,
(
"Specifies the index into the outgoing data request data buffer"
"to start the storing of this chunk of data"
),
),
t.Param("Data", t.ShortBytes, "Data"),
),
rsp_schema=t.STATUS_SCHEMA,
)
# Huge AF incoming message data buffer retrieve command
DataRetrieve = t.CommandDef(
t.CommandType.SREQ,
0x12,
req_schema=(
t.Param("TimeStamp", t.uint32_t, "The timestamp of the message"),
t.Param(
"Index",
t.uint16_t,
(
"Specifies the index into the outgoing data request data buffer"
"to start the storing of this chunk of data"
),
),
t.Param(
"Length",
t.uint8_t,
(
"A length of zero is special and triggers the freeing of the "
"corresponding incoming message"
),
),
),
rsp_schema=(
t.Param("Status", t.Status, "Status is either Success (0) or Failure (1)"),
t.Param("Data", t.ShortBytes, "Data"),
),
)
# proxy for afAPSF_ConfigSet()
APSFConfigSet = t.CommandDef(
t.CommandType.SREQ,
0x13,
req_schema=(
t.Param("Endpoint", t.uint8_t, "Endpoint for which to set fragmentation"),
t.Param(
"FrameDelay",
t.uint8_t,
"APS Fragmentation inter-frame delay in milliseconds",
),
t.Param("WindowSize", t.uint8_t, "APS Fragmentation window size"),
),
rsp_schema=t.STATUS_SCHEMA,
)
# AF Callbacks
# This command is sent by the device to the user after it receives a data request
DataConfirm = t.CommandDef(
t.CommandType.AREQ,
0x80,
rsp_schema=(
t.Param("Status", t.Status, "Status is either Success (0) or Failure (1)"),
t.Param("Endpoint", t.uint8_t, "Endpoint of the device"),
t.Param("TSN", t.uint8_t, "Transaction Sequence Number"),
),
)
# This callback message is in response to incoming data to any of the registered
# endpoints on this device
IncomingMsg = t.CommandDef(
t.CommandType.AREQ,
0x81,
rsp_schema=(
t.Param("GroupId", t.GroupId, "The group ID of the device"),
t.Param("ClusterId", t.ClusterId, "Cluster ID"),
t.Param(
"SrcAddr", t.NWK, "Short address of the device sending the message"
),
t.Param("SrcEndpoint", t.uint8_t, "Endpoint of the source device"),
t.Param("DstEndpoint", t.uint8_t, "Endpoint of the destination device"),
t.Param(
"WasBroadcast", t.Bool, "Was the incoming message broadcast or not"
),
t.Param("LQI", t.uint8_t, "Link quality measured during reception"),
t.Param("SecurityUse", t.Bool, "Is security in use or not"),
t.Param("TimeStamp", t.uint32_t, "The timestamp of the message"),
t.Param("TSN", t.uint8_t, "Transaction Sequence Number"),
t.Param("Data", t.ShortBytes, "Data"),
# https://e2e.ti.com/support/wireless-connectivity/zigbee-and-thread/f/158/t/455787
t.Param("MacSrcAddr", t.NWK, "UNDOCUMENTED: MAC Source address"),
t.Param(
"MsgResultRadius", t.uint8_t, "UNDOCUMENTED: Messages result radius"
),
),
)
# This callback message is in response to incoming data to any of the registered
# endpoints on this device when the code is compiled with the INTER_PAN
# flag defined
IncomingMsgExt = t.CommandDef(
t.CommandType.AREQ,
0x82,
rsp_schema=(
t.Param("GroupId", t.GroupId, "The group ID of the device"),
t.Param("ClusterId", t.ClusterId, "Cluster ID"),
t.Param(
"SrcAddrModeAddress",
t.AddrModeAddress,
"Address of the device sending the message",
),
t.Param("SrcEndpoint", t.uint8_t, "Endpoint of the source device"),
t.Param("SrcPanId", t.PanId, "Source PanId of the message"),
t.Param("DstEndpoint", t.uint8_t, "Endpoint of the destination device"),
t.Param(
"WasBroadcast", t.Bool, "Was the incoming message broadcast or not"
),
t.Param("LQI", t.uint8_t, "Link quality measured during reception"),
t.Param("SecurityUse", t.uint8_t, "Is security in use or not"),
t.Param("TimeStamp", t.uint32_t, "The timestamp of the message"),
t.Param("TSN", t.uint8_t, "Transaction Sequence Number"),
t.Param("Data", t.LongBytes, "Data"),
# https://e2e.ti.com/support/wireless-connectivity/zigbee-and-thread/f/158/t/455787
t.Param("MacSrcAddr", t.NWK, "UNDOCUMENTED: MAC Source address"),
t.Param(
"MsgResultRadius", t.uint8_t, "UNDOCUMENTED: Messages result radius"
),
),
)
# sent by the device to the user when it determines that an error occurred during
# a reflected message
ReflectError = t.CommandDef(
t.CommandType.AREQ,
0x83,
rsp_schema=(
t.Param("Status", t.Status, "Status is either Success (0) or Failure (1)"),
t.Param("Endpoint", t.uint8_t, "Endpoint of the device"),
t.Param("TSN", t.uint8_t, "Transaction Sequence Number"),
t.Param("AddrMode", t.AddrMode, "Format of the address"),
t.Param("Dst", t.NWK, "Destination address -- depends on AddrMode"),
),
)
|