Esempio n. 1
0
class CommandDef:
    command_type: CommandType = attr.ib()
    command_id: int = attr.ib()
    req_schema: typing.Optional[t.Schema] = attr.ib(
        factory=lambda *v: None if not v else t.Schema(*v))
    rsp_schema: typing.Optional[t.Schema] = attr.ib(
        factory=lambda *v: None if not v else t.Schema(*v))
Esempio n. 2
0
class APPCommands(t.CommandsBase, subsystem=t.Subsystem.APP):
    # This command is sent to the target in order to test the functions defined
    # for individual applications.
    # This command sends a raw data to an application
    Msg = t.CommandDef(
        t.CommandType.SREQ,
        0x00,
        req_schema=t.Schema((
            t.Param(
                "Endpoint",
                t.uint8_t,
                "Application endpoint of the outgoing message",
            ),
            t.Param("DstAddr", t.NWK,
                    "Destination address of the outgoing message"),
            t.Param(
                "DstEndpoint",
                t.uint8_t,
                "Destination endpoint of the outgoing message",
            ),
            t.Param("ClusterId", t.ClusterId, "Cluster ID"),
            t.Param("Data", t.ShortBytes, "Data request"),
        )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # This command is used by tester to issue user’s defined commands to the
    # application
    UserTest = t.CommandDef(
        t.CommandType.SREQ,
        0x01,
        req_schema=t.Schema((
            t.Param(
                "SrcEndpoint",
                t.uint8_t,
                "Source Endpoint of the user-defined command",
            ),
            t.Param("CommandId", t.uint16_t,
                    "Command Id of the user-defined command"),
            t.Param("Parameter1", t.uint16_t, "Parameter #1 of the command"),
            t.Param("Parameter2", t.uint16_t, "Parameter #2 of the command"),
        )),
        rsp_schema=t.STATUS_SCHEMA,
    )
Esempio n. 3
0
class RPCErrorCommands(t.CommandsBase, subsystem=t.Subsystem.RPCError):
    # When the ZNP cannot recognize an SREQ command from the host processor,
    # the following SRSP is returned
    CommandNotRecognized = t.CommandDef(
        t.CommandType.SRSP,
        0x00,
        req_schema=None,  # XXX: There is no REQ, only a RSP
        rsp_schema=t.Schema((
            t.Param(
                "ErrorCode",
                ErrorCode,
                "The error code maps to one of the following enumerated values.",
            ),
            t.Param("RequestHeader", t.CommandHeader,
                    "Header of the invalid request"),
        )),
    )
Esempio n. 4
0
class APPConfigCommands(t.CommandsBase, subsystem=t.Subsystem.APPConfig):
    # sets the network frame counter to the value specified in the Frame Counter Value.
    # For projects with multiple instances of frame counter, the message sets the
    # frame counter of the current network
    SetNwkFrameCounter = t.CommandDef(
        t.CommandType.SREQ,
        0xFF,
        req_schema=t.Schema((t.Param("FrameCounterValue", t.uint32_t,
                                     "network frame counter"),
                             )  # XXX: check source for actual size
                            ),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # Set the default value used by parent device to expire legacy child devices
    SetDefaultRemoteEndDeviceTimeout = t.CommandDef(
        t.CommandType.SREQ,
        0x01,
        req_schema=t.Schema((t.Param("TimeoutIndex", TimeoutIndex,
                                     "0x00 -- 10s otherwise 2^N minutes"), )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # Sets in ZED the timeout value to be send to parent device for child expiring
    SetEndDeviceTimeout = t.CommandDef(
        t.CommandType.SREQ,
        0x02,
        req_schema=t.Schema((t.Param("TimeoutIndex", TimeoutIndex,
                                     "0x00 -- 10s otherwise 2^N minutes"), )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # Set the AllowRejoin TC policy
    SetAllowRejoinTCPolicy = t.CommandDef(
        t.CommandType.SREQ,
        0x03,
        req_schema=t.Schema((t.Param(
            "AllowRejoin",
            t.Bool,
            "whether or not the Trust center allows rejoins",
        ), )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # Set the commissioning methods to be executed. Initialization of BDB is executed
    # with this call, regardless of its parameters
    BDBStartCommissioning = t.CommandDef(
        t.CommandType.SREQ,
        0x05,
        req_schema=t.Schema((t.Param("Mode", BDBCommissioningMode,
                                     "Commissioning mode"), )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # Set BDB primary or secondary channel masks
    BDBSetChannel = t.CommandDef(
        t.CommandType.SREQ,
        0x08,
        req_schema=t.Schema((
            t.Param("IsPrimary", t.Bool, "True -- is primary channel"),
            t.Param("Channel", t.Channels, "Channel set mask"),
        )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # Add a preconfigured key (plain key or IC) to Trust Center device
    BDBAddInstallCode = t.CommandDef(
        t.CommandType.SREQ,
        0x04,
        req_schema=t.Schema((
            t.Param(
                "InstallCodeFormat",
                t.uint8_t,
                ("0x01 -- Install code + CRC"
                 "0x02 -- Key derived from install code"),
            ),
            t.Param("IEEE", t.EUI64, "IEEE address of the joining device"),
            t.Param("InstallCode", t.Bytes,
                    "16 bytes for derived key, 18 for IC + CRC"),
        )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # Set the policy flag on Trust Center device to mandate or not the TCLK
    # exchange procedure
    BDBSetTcRequireKeyExchange = t.CommandDef(
        t.CommandType.SREQ,
        0x09,
        req_schema=t.Schema((t.Param("BdbTrustCenterRequireKeyExchange",
                                     t.Bool, "Require key exchange"), )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # Sets the policy to mandate or not the usage of an Install Code upon joining
    BDBSetJoinUsesInstallCodeKey = t.CommandDef(
        t.CommandType.SREQ,
        0x06,
        req_schema=t.Schema((t.Param("BdbJoinUsesInstallCodeKey", t.Bool,
                                     "Use install code"), )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # On joining devices, set the default key or an install code to attempt
    # to join the network
    BDBSetActiveDefaultCentralizedKey = t.CommandDef(
        t.CommandType.SREQ,
        0x07,
        req_schema=t.Schema((
            t.Param(
                "CentralizedLinkKeyModes",
                CentralizedLinkKeyMode,
                ("which key will be used when performing association "
                 "to a centralized network"),
            ),
            t.Param("InstallCode", t.Bytes, "key in any of its formats"),
        )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # Instruct the ZED to try to rejoin its previews network. Use only in ZED devices
    BDBZedAttemptRecoverNWK = t.CommandDef(t.CommandType.SREQ,
                                           0x0A,
                                           req_schema=t.Schema(),
                                           rsp_schema=t.STATUS_SCHEMA)

    # MT_APP_CONFIG Callbacks
    # Callback to receive notifications from BDB process
    BDBCommissioningNotification = t.CommandDef(
        t.CommandType.AREQ,
        0x80,
        rsp_schema=t.Schema((
            t.Param(
                "Status",
                BDBCommissioningStatus,
                "Status of the commissioning mode notified",
            ),
            t.Param(
                "Mode",
                BDBCommissioningMode,
                "Commissioning mode to which status is related",
            ),
            t.Param(
                "RemainingModes",
                BDBRemainingCommissioningModes,
                ("Bitmask of the remaining commissioning modes after "
                 "this notification"),
            ),
        )),
    )
Esempio n. 5
0
class Util(t.CommandsBase, subsystem=t.Subsystem.UTIL):
    # MAC Reset command to reset MAC state machine
    GetDeviceInfo = t.CommandDef(
        t.CommandType.SREQ,
        0x00,
        req_schema=t.Schema(),
        rsp_schema=t.Schema((
            t.Param("Status", t.Status,
                    "Status is either Success (0) or Failure (1)"),
            t.Param("IEEE", t.EUI64, "Extended address of the device"),
            t.Param("NWK", t.NWK, "Short address of the device"),
            t.Param("DeviceType", t.DeviceTypeCapabilities, "Device type"),
            t.Param("DeviceState", t.DeviceState,
                    "Indicated the state of the device"),
            t.Param(
                "AssociatedDevices",
                t.NWKList,
                ("Network addresses of Reduce Function Devices associated "
                 "to the local device."),
            ),
        )),
    )

    # read a block of parameters from Non-Volatile storage of the target device
    GetNVInfo = t.CommandDef(
        t.CommandType.SREQ,
        0x01,
        req_schema=t.Schema(),
        rsp_schema=t.Schema((
            t.Param("Status", t.Status,
                    "Status is either Success (0) or Failure (1)"),
            t.Param("IEEE", t.EUI64, "IEEE address of the device"),
            t.Param(
                "ScanChannels",
                t.Channels,
                "Channels to be scanned when starting the device",
            ),
            t.Param(
                "PanId",
                t.PanId,
                "The PAN Id to use. This parameter is ignored if Pan",
            ),
            # ToDo: Make this an enum
            t.Param("SecurityLevel", t.uint8_t,
                    "Security level of this data frame"),
            t.Param("PreConfigKey", t.KeyData, "Preconfigured network key"),
        )),
    )

    # Set PAN ID
    SetPanId = t.CommandDef(
        t.CommandType.SREQ,
        0x02,
        req_schema=t.Schema((t.Param("PanId", t.PanId,
                                     "The PAN Id to set"), )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # store a channel select bit-mask into Non-Volatile memory to be used the next
    # time the target device resets
    SetChannels = t.CommandDef(
        t.CommandType.SREQ,
        0x03,
        req_schema=t.Schema(
            (t.Param("Channels", t.Channels,
                     "Channels to scan when starting the device"), )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # store a security level value into Non-Volatile memory to be used the next time
    # the target device reset
    SetSecurityLevel = t.CommandDef(
        t.CommandType.SREQ,
        0x04,
        req_schema=t.Schema((
            # ToDo: Make this an enum
            t.Param(
                "SecurityLevel",
                t.uint8_t,
                "Specifies the messaging network security level",
            ), )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # store a pre-configured key array into Non-Volatile memory to be used the next
    # time the target device resets
    SetPreConfigKey = t.CommandDef(
        t.CommandType.SREQ,
        0x05,
        req_schema=t.Schema((t.Param("PreConfigKey", t.KeyData,
                                     "Preconfigured network key"), )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # subscribes/unsubscribes to layer callbacks. For particular subsystem callbacks
    # to work, the software must be compiled with a special flag that is unique to that
    # subsystem to enable the callback mechanism. For example to enable ZDO callbacks,
    # MT_ZDO_CB_FUNC flag must be compiled when the software is built
    CallbackSubCmd = t.CommandDef(
        t.CommandType.SREQ,
        0x06,
        req_schema=t.Schema((
            t.Param(
                "SubsystemId",
                t.CallbackSubsystem,
                "Subsystem id to subscribe/unsubscribe",
            ),
            t.Param("Action", t.Bool, "True -- enable, False -- Disable"),
        )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # Send a key event to the device registered application
    KeyEvent = t.CommandDef(
        t.CommandType.SREQ,
        0x07,
        req_schema=t.Schema((
            t.Param("Keys", t.uint8_t, "Key code bitmask"),
            t.Param("Shift", t.Bool, "True -- shift, False -- no shift"),
        )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # get the board’s time alive
    TimeAlive = t.CommandDef(
        t.CommandType.SREQ,
        0x09,
        req_schema=t.Schema(),
        rsp_schema=t.Schema(
            (t.Param("Seconds", t.uint32_t,
                     "The time of the board's uptime in seconds"), )),
    )

    # control the LEDs on the board
    LEDControl = t.CommandDef(
        t.CommandType.SREQ,
        0x0A,
        req_schema=t.Schema((
            t.Param("Laded", t.uint8_t, "The LED number"),
            t.Param("On", t.Bool, "True -- On, False -- Off"),
        )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # test data buffer loopback
    Loopback = t.CommandDef(
        t.CommandType.SREQ,
        0x10,
        req_schema=t.Schema((t.Param("Data", t.Bytes,
                                     "The data bytes to loop back"), )),
        rsp_schema=t.Schema((t.Param("Data", t.Bytes,
                                     "The looped back data"), )),
    )

    # effect a MAC MLME Poll Request
    DataReq = t.CommandDef(
        t.CommandType.SREQ,
        0x11,
        req_schema=t.Schema((t.Param(
            "SecurityUse",
            t.Bool,
            "True -- to request MAC security, bun not used for now",
        ), )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # enable AUTOPEND and source address matching
    SrcMatchEnable = t.CommandDef(t.CommandType.SREQ,
                                  0x20,
                                  req_schema=t.Schema(),
                                  rsp_schema=t.STATUS_SCHEMA)

    # add a short or extended address to source address table
    SrcMatchAddEntry = t.CommandDef(
        t.CommandType.SREQ,
        0x21,
        req_schema=t.Schema((
            t.Param("AddrModeAddress", t.AddrModeAddress,
                    "Address mode and address"),
            t.Param(
                "PanId",
                t.PanId,
                "PAN Id of the device. Only use with a short address",
            ),
        )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # delete a short or extended address to source address table
    SrcMatchDelEntry = t.CommandDef(
        t.CommandType.SREQ,
        0x22,
        req_schema=t.Schema((
            t.Param("AddrModeAddress", t.AddrModeAddress,
                    "Address mode and address"),
            t.Param(
                "PanId",
                t.PanId,
                "PAN Id of the device. Only use with a short address",
            ),
        )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # check if a short or extended address is in the source address table
    SrcMatchCheckSrcAddr = t.CommandDef(
        t.CommandType.SREQ,
        0x23,
        req_schema=t.Schema((
            t.Param("AddrModeAddress", t.AddrModeAddress,
                    "Address mode and address"),
            t.Param(
                "PanId",
                t.PanId,
                "PAN Id of the device. Only use with a short address",
            ),
        )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # enable/disable acknowledging all packets with pending bit set
    SrcMatchAckAllPending = t.CommandDef(
        t.CommandType.SREQ,
        0x24,
        req_schema=t.Schema((t.Param(
            "Enabled",
            t.Bool,
            ("True - acknowledging all packets with pending field set, "
             "False - Otherwise"),
        ), )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # check if acknowledging all packets with pending bit set is enabled
    SrcMatchCheckAllPending = t.CommandDef(
        t.CommandType.SREQ,
        0x25,
        req_schema=t.Schema(),
        rsp_schema=t.Schema((
            t.Param("Status", t.Status,
                    "Status is either Success (0) or Failure (1)"),
            t.Param(
                "Enabled",
                t.Bool,
                ("True - acknowledging all packets with pending field set, "
                 "False - Otherwise"),
            ),
        )),
    )

    # proxy call to the AddrMgrEntryLookupExt() function
    AddrMgrExtAddrLookup = t.CommandDef(
        t.CommandType.SREQ,
        0x40,
        req_schema=t.Schema(
            (t.Param("IEEE", t.EUI64,
                     "Extended address of the device to lookup the NWK"), )),
        rsp_schema=t.Schema((t.Param("NWK", t.NWK,
                                     "NWK address of the device fo"), )),
    )

    # a proxy call to the AddrMgrEntryLookupNwk() function
    AddrMgwNwkAddrLookUp = t.CommandDef(
        t.CommandType.SREQ,
        0x41,
        req_schema=t.Schema(
            (t.Param("NWK", t.NWK,
                     "Short address of the device to lookup IEEE"), )),
        rsp_schema=t.Schema((t.Param("IEEE", t.EUI64,
                                     "Extended address of the device"), )),
    )

    # retrieve APS link key data, Tx and Rx frame counters
    APSMELinkKeyDataGet = t.CommandDef(
        t.CommandType.SREQ,
        0x44,
        req_schema=t.Schema(
            (t.Param("IEEE", t.EUI64,
                     "Extended address of the device to get link data"), )),
        rsp_schema=t.Schema((
            t.Param("Status", t.Status,
                    "Status is either Success (0) or Failure (1)"),
            t.Param("SecKey", t.KeyData, "Security Key"),
            t.Param("TxFrmCntr", t.uint32_t,
                    "On success, the TX frame counter"),
            t.Param("RxFrmCntr", t.uint32_t,
                    "On success, the RX frame counter"),
        )),
    )

    # a proxy call to the APSME_LinkKeyNvIdGet() function
    APSMELinkKeyNvIdGet = t.CommandDef(
        t.CommandType.SREQ,
        0x45,
        req_schema=t.Schema(
            (t.Param("IEEE", t.EUI64,
                     "Extended address of the device to get link data"), )),
        rsp_schema=t.Schema((
            t.Param("Status", t.Status,
                    "Status is either Success (0) or Failure (1)"),
            t.Param(
                "LinkKeyNvId",
                t.uint16_t,
                "On success, link key NV ID, otherwise 0xFFFF",
            ),
        )),
    )

    # a proxy call to the AssocCount() function
    AssocCount = t.CommandDef(
        t.CommandType.SREQ,
        0x48,
        req_schema=t.Schema((
            t.Param("StartRelation", t.uint8_t,
                    "A valid node relation from AssocList.h"),
            t.Param(
                "EndRelation",
                t.uint8_t,
                "Same as StartRelation, but the node relation to stop counting",
            ),
        )),
        rsp_schema=t.Schema(
            (t.Param("Count", t.uint16_t,
                     "The count returned by the proxy call"), )),
    )

    # a proxy call to the AssocFindDevice() function
    AssocFindDevice = t.CommandDef(
        t.CommandType.SREQ,
        0x49,
        req_schema=t.Schema(
            (t.Param("Index", t.uint8_t,
                     "Nth active entry in the device list"), )),
        rsp_schema=t.Schema((t.Param("Device", Device,
                                     "associated_devices_t structure"), )),
    )

    # a proxy call to the AssocGetWithAddress() function
    AssocGetWithAddress = t.CommandDef(
        t.CommandType.SREQ,
        0x4A,
        req_schema=t.Schema((
            t.Param(
                "IEEE",
                t.EUI64,
                ("Extended address for the lookup or all zeroes to use the NWK "
                 "addr for the lookup"),
            ),
            t.Param("NWK", t.NWK,
                    "NWK address to use for lookup if IEEE is all zeroes"),
        )),
        rsp_schema=t.Schema((t.Param("Device", Device,
                                     "associated_devices_t structure"), )),
    )

    # send a request key to the Trust Center from an originator device who wants to
    # exchange messages with a partner device
    APSMEREquestKeyCmd = t.CommandDef(
        t.CommandType.SREQ,
        0x4B,
        req_schema=t.Schema((t.Param(
            "IEEE",
            t.EUI64,
            ("Specifies the extended address of the partner device the "
             "originator wants to exchange messages with"),
        ), )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # a proxy call to the bindAddEntry() function
    BindAddEntry = t.CommandDef(
        t.CommandType.SREQ,
        0x4D,
        req_schema=t.Schema((
            t.Param(
                "DstAddrModeAddr",
                t.AddrModeAddress,
                "Address mode address of the partner",
            ),
            t.Param("DstEndpoint", t.uint8_t,
                    "Binding entry destination endpoint"),
            t.Param("ClusterIdList", t.ClusterIdList,
                    "List of the cluster IDs"),
        )),
        rsp_schema=t.Schema((t.Param(
            "BindEntry",
            BindEntry,
            ("Bind Entry. The dstIdx in the BindEntry is set to "
             "INVALID_NODE_ADDR to indicate failure"),
        ), )),
    )

    # a proxy call to zclGeneral_KeyEstablish_InitiateKeyEstablishment()
    ZCLKeyEstInitEst = t.CommandDef(
        t.CommandType.SREQ,
        0x80,
        req_schema=t.Schema((
            t.Param("TaskId", t.uint8_t,
                    "The OSAL Task Id making the request"),
            t.Param("SeqNum", t.uint8_t, "The sequence number of the request"),
            t.Param("EndPoint", t.uint8_t, "The endpoint of the partner"),
            t.Param(
                "AddrModeAddr",
                t.AddrModeAddress,
                "Address mode address of the partner",
            ),
        )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # a proxy call to zclGeneral_KeyEstablishment_ECDSASign()
    ZCLKeyEstSign = t.CommandDef(
        t.CommandType.SREQ,
        0x81,
        req_schema=t.Schema((t.Param("Input", t.ShortBytes,
                                     "The input data"), )),
        rsp_schema=t.Schema((
            t.Param("Status", t.Status,
                    "Status is either Success (0) or Failure (1)"),
            t.Param("Key", Key, "The output key on success"),
        )),
    )

    #  generate Secure Random Number. It generates 1,000,000 bits in sets of 100 bytes.
    #  As in 100 bytes of secure random numbers are generated until 1,000,000 bits are
    #  generated. 100 bytes are generated 1250 times. So 1250 SRSPs are generated.
    #  MT_SRNG has to be defined to include this API
    SRngGen = t.CommandDef(
        t.CommandType.SREQ,
        0x4C,
        req_schema=t.Schema(),
        rsp_schema=t.Schema((t.Param("RandomNumbers", RandomNumbers,
                                     "Secure random numbers list"), )),
    )

    # UTIL Callbacks
    # asynchronous request/response handshake
    # XXX: This command is ambiguously defined.
    #      We see an example of how it behaves.
    # SyncReq = t.CommandDef(t.CommandType.AREQ, 0xE0)

    # RPC proxy indication for a ZCL_KEY_ESTABLISH_IND
    ZCLKeyEstInd = t.CommandDef(
        t.CommandType.AREQ,
        0xE1,
        rsp_schema=t.Schema((
            t.Param(
                "TaskId",
                t.uint8_t,
                "The OSAL Task id registered to receive the indication",
            ),
            t.Param("Event", t.uint8_t, "The OSAL message event"),
            t.Param("Status", t.Status, "The OSAL message status"),
            t.Param("WaitTime", t.uint8_t, "The wait time"),
            t.Param("Suite", t.uint16_t, "The key establishment suite"),
        )),
    )
Esempio n. 6
0
class MAC(t.CommandsBase, subsystem=t.Subsystem.MAC):
    # MAC Reset command to reset MAC state machine
    ResetReq = t.CommandDef(
        t.CommandType.SREQ,
        0x01,
        req_schema=t.Schema((t.Param(
            "SetDefault",
            t.Bool,
            "TRUE – Set the MAC pib values to default values",
        ), )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # initialize the MAC
    Init = t.CommandDef(t.CommandType.SREQ,
                        0x02,
                        req_schema=t.Schema(),
                        rsp_schema=t.STATUS_SCHEMA)

    # start the MAC as a coordinator or end device
    StartReq = t.CommandDef(
        t.CommandType.SREQ,
        0x03,
        req_schema=t.Schema((
            t.Param(
                "StartTime",
                t.uint32_t,
                ("The time to begin transmitting beacons relative to "
                 "the received beacon"),
            ),
            t.Param(
                "PanId",
                t.PanId,
                ("The PAN Id to use. This parameter is ignored if Pan "
                 "Coordinator is FALSE"),
            ),
            t.Param("LogicalChannel", t.uint8_t, "The logical channel to use"),
            t.Param("ChannelPage", t.uint8_t, "The channel page to use"),
            t.Param(
                "BeaconOrder",
                t.uint8_t,
                "The exponent used to calculate the beacon interval",
            ),
            t.Param(
                "SuperFrameOrder",
                t.uint8_t,
                "The exponent used to calculate the superframe duration",
            ),
            t.Param(
                "PanCoordinator",
                t.Bool,
                "Set to TRUE to start a network as PAN coordinator",
            ),
            t.Param(
                "BatteryLifeExt",
                t.uint8_t,
                "full backoff periods following the interframe spacing",
            ),
            t.Param("CoordRealignment", t.uint8_t, "Coordinator realignment"),
            t.Param("RealignKeySource", t.KeySource,
                    "Key Source of this data frame"),
            # ToDo: Enum for for RealignSecurityLevel
            t.Param(
                "RealignSecurityLevel",
                t.uint8_t,
                "Security level of this data frame",
            ),
            # ToDo: Make this an enum
            t.Param("RealignKeyIdMode", t.uint8_t,
                    "Key Id Mode of this frame"),
            t.Param("RealignKeyIndex", t.uint8_t, "Key index of this frame"),
            t.Param("BeaconKeySource", t.KeySource,
                    "Key source of this data frame"),
            # ToDo: Make this an enum
            t.Param(
                "BeaconSecurityLevel",
                t.uint8_t,
                "Security Level of this data frame",
            ),
            t.Param("BeaconKeyIdMode", t.uint8_t,
                    "Key Id Mode of this data frame"),
            t.Param("BeaconKeyIndex", t.uint8_t,
                    "Key index of this data frame"),
        )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # request synchronization to the current network beacon
    SyncReq = t.CommandDef(
        t.CommandType.SREQ,
        0x04,
        req_schema=t.Schema((
            t.Param("LogicalChannel", t.uint8_t, "The logical channel to use"),
            t.Param("ChannelPage", t.uint8_t, "The channel page to use"),
            t.Param(
                "TrackBeacon",
                t.Bool,
                ("Set to TRUE to continue tracking beacons after synchronizing "
                 "with the first beacon. Set to FALSE to only synchronize with "
                 "the first beacon"),
            ),
        )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # send (on behalf of the next higher layer) MAC Data Frame packet
    DataReq = t.CommandDef(
        t.CommandType.SREQ,
        0x05,
        req_schema=t.Schema((
            t.Param(
                "DstAddrModeAddress",
                t.AddrModeAddress,
                "Destination address mode and address",
            ),
            t.Param("DstPanId", t.PanId, "The PAN Id of destination"),
            t.Param("SrcAddrMode", t.AddrMode, "Format of the source address"),
            t.Param("Handle", t.uint8_t, "Handle of the packet"),
            # ToDo: Make this a proper Flags Enum
            t.Param("TxOption", t.uint8_t, "Transmitting options"),
            t.Param(
                "LogicalChannel",
                t.uint8_t,
                "Channel that data frame will be transmitted",
            ),
            t.Param("Power", t.uint8_t, "Power level to use for transmission"),
            t.Param("KeySource", t.KeySource, "Key Source of this data frame"),
            # ToDo: Make this an enum
            t.Param("SecurityLevel", t.uint8_t,
                    "Security level of this data frame"),
            # ToDo: Make this an enum
            t.Param("KeyIdMode", t.uint8_t, "Key Id Mode of this frame"),
            t.Param("KeyIndex", t.uint8_t, "Key index of this frame"),
            t.Param("MSDU", t.ShortBytes, "Actual data that will be sent"),
        )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # request (on behalf of the next higher layer) an association with a coordinator
    AssociateReq = t.CommandDef(
        t.CommandType.SREQ,
        0x06,
        req_schema=t.Schema((
            t.Param("LogicalChannel", t.uint8_t, "The logical channel to use"),
            t.Param("ChannelPage", t.uint8_t, "The channel page to use"),
            t.Param(
                "CoordAddrModeAddress",
                t.AddrModeAddress,
                "Coordinator address mode and address",
            ),
            t.Param("CoordPanId", t.PanId, "The PAN Id of the coordinator"),
            # ToDo: make this a bitflag enum
            t.Param("CapabilityInformation", t.uint8_t, "BitFlag Coordinator"),
            t.Param("KeySource", t.KeySource, "Key Source of this data frame"),
            # ToDo: Make this an enum
            t.Param("SecurityLevel", t.uint8_t,
                    "Security level of this data frame"),
            # ToDo: Make this an enum
            t.Param("KeyIdMode", t.uint8_t, "Key Id Mode of this frame"),
            t.Param("KeyIndex", t.uint8_t, "Key index of this frame"),
        )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # This command is sent by the host to response to the MAC_ASSOCIATE_IND
    AssociateRsp = t.CommandDef(
        t.CommandType.SREQ,
        0x50,
        req_schema=t.Schema((
            t.Param(
                "IEEE",
                t.EUI64,
                "Extended address of the device requesting association",
            ),
            t.Param("NWK", t.NWK, "Short address of the associated device"),
            # ToDo: make this an enum
            t.Param("AssocStatus", t.uint8_t, "Status of the associaiton"),
        )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    #  request (on behalf of the next higher layer) a disassociation of the device
    #  from the coordinator
    DisAssociateReq = t.CommandDef(
        t.CommandType.SREQ,
        0x07,
        req_schema=t.Schema((
            t.Param(
                "DeviceAddrModeAddress",
                t.AddrModeAddress,
                "Device address mode and address",
            ),
            t.Param("DevicePanId", t.PanId, "Device's PAN Id"),
            # ToDo: Make this an enum
            t.Param("DisassociateReason", t.uint8_t,
                    "Reason for disassociation"),
            t.Param("TxIndirect", t.Bool, "Indirect Transmission"),
            t.Param("KeySource", t.KeySource, "Key Source of this data frame"),
            # ToDo: Make this an enum
            t.Param("SecurityLevel", t.uint8_t,
                    "Security level of this data frame"),
            # ToDo: Make this an enum
            t.Param("KeyIdMode", t.uint8_t, "Key Id Mode of this frame"),
            t.Param("KeyIndex", t.uint8_t, "Key index of this frame"),
        )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # read (on behalf of the next higher layer) a MAC PIB attribute
    GetReq = t.CommandDef(
        t.CommandType.SREQ,
        0x08,
        req_schema=t.Schema((
            # ToDo: Make this an enum
            t.Param("Attribute", t.uint8_t, "MAC PIB Attribute to get"), )),
        rsp_schema=t.Schema((
            t.Param("Status", t.Status,
                    "Status is either Success (0) or Failure (1)"),
            t.Param("Value", AttributeValue, "Value of the attribute"),
        )),
    )

    # request the device to write a MAC PIB value
    SetReq = t.CommandDef(
        t.CommandType.SREQ,
        0x09,
        req_schema=t.Schema((
            # ToDo: Make this an enum
            t.Param("Attribute", t.uint8_t, "MAC PIB Attribute to set"),
            t.Param("Value", AttributeValue, "Value of the attribute"),
        )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # send a request to the device to perform a network scan
    ScanReq = t.CommandDef(
        t.CommandType.SREQ,
        0x0C,
        req_schema=t.Schema((
            t.Param(
                "ScanChannels",
                t.Channels,
                "Bitmask of channels to scan when starting the device",
            ),
            # ToDo: Make this an enum
            t.Param("ScanType", t.uint8_t, "Specifies the scan type"),
            t.Param("ScanDuration", t.uint8_t,
                    "The exponent used in the scan duration"),
            t.Param("ChannelPage", t.uint8_t, "The channel page to use"),
            t.Param("KeySource", t.KeySource, "Key Source of this data frame"),
            # ToDo: Make this an enum
            t.Param("SecurityLevel", t.uint8_t,
                    "Security level of this data frame"),
            # ToDo: Make this an enum
            t.Param("KeyIdMode", t.uint8_t, "Key Id Mode of this frame"),
            t.Param("KeyIndex", t.uint8_t, "Key index of this frame"),
        )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # This command is sent by the host to response to the ORPHAN_IND
    OrphanRsp = t.CommandDef(
        t.CommandType.SREQ,
        0x51,
        req_schema=t.Schema((
            t.Param(
                "IEEE",
                t.EUI64,
                "Extended address of the device requesting association",
            ),
            t.Param("NWK", t.NWK, "Short address of the associated device"),
            t.Param(
                "AssociatedMember",
                t.Bool,
                "True is the orphan is a associated member",
            ),
        )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # send a MAC data request poll
    PollReq = t.CommandDef(
        t.CommandType.SREQ,
        0x0D,
        req_schema=t.Schema((
            t.Param(
                "CoordAddrModeAddress",
                t.AddrModeAddress,
                "Coordinator address mode and address",
            ),
            t.Param("CoordPanId", t.PanId, "The PAN Id of the coordinator"),
            t.Param("KeySource", t.KeySource, "Key Source of this data frame"),
            # ToDo: Make this an enum
            t.Param("SecurityLevel", t.uint8_t,
                    "Security level of this data frame"),
            # ToDo: Make this an enum
            t.Param("KeyIdMode", t.uint8_t, "Key Id Mode of this frame"),
            t.Param("KeyIndex", t.uint8_t, "Key index of this frame"),
        )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # send a request to the device to purge a data frame
    PurgeReq = t.CommandDef(
        t.CommandType.SREQ,
        0x0E,
        req_schema=t.Schema((t.Param("MsduHandle", t.uint8_t,
                                     "MSDU handle"), )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # send a request to the device to set Rx gain
    SetRxGainReq = t.CommandDef(
        t.CommandType.SREQ,
        0x0F,
        req_schema=t.Schema((t.Param("Mode", t.Bool,
                                     "PA/PNA mode – True/False"), )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # MAC Callbacks

    # send (on behalf of the next higher layer) an indication of the synchronization
    # loss
    SyncLossInd = t.CommandDef(
        t.CommandType.AREQ,
        0x80,
        rsp_schema=t.Schema((
            t.Param("Status", t.Status,
                    "Status is either Success (0) or Failure (1)"),
            t.Param(
                "PanId",
                t.PanId,
                "The PAN Id to use. This parameter is ignored if Pan",
            ),
            t.Param("LogicalChannel", t.uint8_t, "The logical channel to use"),
            t.Param("ChannelPage", t.uint8_t, "The channel page to use"),
            t.Param("KeySource", t.KeySource, "Key Source of this data frame"),
            # ToDo: Make this an enum
            t.Param("SecurityLevel", t.uint8_t,
                    "Security level of this data frame"),
            # ToDo: Make this an enum
            t.Param("KeyIdMode", t.uint8_t, "Key Id Mode of this frame"),
            t.Param("KeyIndex", t.uint8_t, "Key index of this frame"),
        )),
    )

    # send (on behalf of the next higher layer) an association indication message
    AssociateInd = t.CommandDef(
        t.CommandType.AREQ,
        0x81,
        rsp_schema=t.Schema((
            t.Param("IEEE", t.EUI64, "Extended address of the device"),
            t.Param("Capabilities", t.uint8_t,
                    "Operating capabilities of the device"),
            t.Param("KeySource", t.KeySource, "Key Source of this data frame"),
            # ToDo: Make this an enum
            t.Param("SecurityLevel", t.uint8_t,
                    "Security level of this data frame"),
            # ToDo: Make this an enum
            t.Param("KeyIdMode", t.uint8_t, "Key Id Mode of this frame"),
            t.Param("KeyIndex", t.uint8_t, "Key index of this frame"),
        )),
    )

    # send (on behalf of the next higher layer) an association confirmation message
    AssociateCnf = t.CommandDef(
        t.CommandType.AREQ,
        0x82,
        rsp_schema=t.Schema((
            t.Param("Status", t.Status,
                    "Status is either Success (0) or Failure (1)"),
            t.Param("NWK", t.NWK, "Short address of the device"),
            t.Param("KeySource", t.KeySource, "Key Source of this data frame"),
            # ToDo: Make this an enum
            t.Param("SecurityLevel", t.uint8_t,
                    "Security level of this data frame"),
            # ToDo: Make this an enum
            t.Param("KeyIdMode", t.uint8_t, "Key Id Mode of this frame"),
            t.Param("KeyIndex", t.uint8_t, "Key index of this frame"),
        )),
    )

    # send (on behalf of the next higher layer) a MAC beacon notify indication
    BeaconNotifyInd = t.CommandDef(
        t.CommandType.AREQ,
        0x83,
        rsp_schema=t.Schema((
            t.Param("BSN", t.uint8_t, "BSN"),
            t.Param("TimeStamp", t.uint32_t, "The timestamp of the message"),
            t.Param(
                "CoordinatorExtendedAddress",
                t.AddrModeAddress,
                "Extended address of coordinator",
            ),
            t.Param(
                "PanId",
                t.PanId,
                "The PAN Id to use. This parameter is ignored if Pan",
            ),
            t.Param("Superframe", t.uint16_t, "Superframe specification"),
            t.Param("LogicalChannel", t.uint8_t, "The logical channel to use"),
            t.Param("GTSPermit", t.Bool, "True/False - Permit/Not permit GTS"),
            t.Param("LQI", t.uint8_t, "Link quality of the message"),
            t.Param("SecurityFailure", t.uint8_t, "Security failure???"),
            t.Param("KeySource", t.KeySource, "Key Source of this data frame"),
            # ToDo: Make this an enum
            t.Param("SecurityLevel", t.uint8_t,
                    "Security level of this data frame"),
            # ToDo: Make this an enum
            t.Param("KeyIdMode", t.uint8_t, "Key Id Mode of this frame"),
            t.Param("KeyIndex", t.uint8_t, "Key index of this frame"),
            t.Param("PendingAddrSpec", t.uint8_t, "Pending address spec"),
            t.Param(
                "AddressList",
                t.uint8_t,
                "List of address associate with the device",
            ),
            t.Param("NSDU", t.ShortBytes, "Beacon payload"),
        )),
    )

    # send (on behalf of the next higher layer) a MAC data confirmation
    DataCnf = t.CommandDef(
        t.CommandType.AREQ,
        0x84,
        rsp_schema=t.Schema((
            t.Param("Status", t.Status,
                    "Status is either Success (0) or Failure (1)"),
            t.Param("Handle", t.uint8_t, "Handle of the message"),
            t.Param("TimeStamp", t.uint32_t, "The timestamp of the message"),
            t.Param("TimeStamp2", t.uint16_t,
                    "16 bit timestamp of the message"),
        )),
    )

    # send (on behalf of the next higher layer) a MAC data indication
    DataInd = t.CommandDef(
        t.CommandType.AREQ,
        0x85,
        rsp_schema=t.Schema((
            t.Param("SrcAddrModeAddr", t.AddrModeAddress, "Source address"),
            t.Param("DstAddrModeAddr", t.AddrModeAddress,
                    "Destination address"),
            t.Param("TimeStamp", t.uint32_t, "The timestamp of the message"),
            t.Param("TimeStamp2", t.uint16_t,
                    "16 bit timestamp of the message"),
            t.Param("SrcPanId", t.PanId, "PAN Id ofo the source address"),
            t.Param("DstPanId", t.PanId, "PAN Id ofo the destination address"),
            t.Param("LQI", t.uint8_t, "Link quality of the message"),
            t.Param("Correlation", t.uint8_t, "Correlation"),
            t.Param("RSSI", t.int8s, "RSSI"),
            t.Param("DSN", t.uint8_t, "DSN"),
            t.Param("KeySource", t.KeySource, "Key Source of this data frame"),
            # ToDo: Make this an enum
            t.Param("SecurityLevel", t.uint8_t,
                    "Security level of this data frame"),
            # ToDo: Make this an enum
            t.Param("KeyIdMode", t.uint8_t, "Key Id Mode of this frame"),
            t.Param("KeyIndex", t.uint8_t, "Key index of this frame"),
            t.Param("Data", t.ShortBytes, "Actual data that will be sent"),
        )),
    )

    # send (on behalf of the next higher layer) a MAC disassociation indication
    DisassociateReq = t.CommandDef(
        t.CommandType.AREQ,
        0x86,
        rsp_schema=t.Schema((
            t.Param("IEEE", t.EUI64,
                    "EUI64 address of the device leaving the network"),
            # ToDo: Make this an enum
            t.Param("DisassociateReason", t.uint8_t,
                    "Reason for disassociation"),
            t.Param("KeySource", t.KeySource, "Key Source of this data frame"),
            # ToDo: Make this an enum
            t.Param("SecurityLevel", t.uint8_t,
                    "Security level of this data frame"),
            # ToDo: Make this an enum
            t.Param("KeyIdMode", t.uint8_t, "Key Id Mode of this frame"),
            t.Param("KeyIndex", t.uint8_t, "Key index of this frame"),
        )),
    )

    # send (on behalf of the next higher layer) a MAC disassociate confirm
    DisassociateCnf = t.CommandDef(
        t.CommandType.AREQ,
        0x87,
        rsp_schema=t.Schema((
            t.Param("Status", t.Status,
                    "Status is either Success (0) or Failure (1)"),
            t.Param(
                "DeviceAddrModeAddr",
                t.AddrModeAddress,
                "Address mode address of the device",
            ),
            t.Param("PanId", t.PanId, "The PAN Id of the device"),
        )),
    )

    # send (on behalf of the next higher layer) a MAC orphan indication
    OrphanInd = t.CommandDef(
        t.CommandType.AREQ,
        0x8A,
        rsp_schema=t.Schema((
            t.Param("IEEE", t.EUI64, "Extended address of the orphan device"),
            t.Param("KeySource", t.KeySource, "Key Source of this data frame"),
            # ToDo: Make this an enum
            t.Param("SecurityLevel", t.uint8_t,
                    "Security level of this data frame"),
            # ToDo: Make this an enum
            t.Param("KeyIdMode", t.uint8_t, "Key Id Mode of this frame"),
            t.Param("KeyIndex", t.uint8_t, "Key index of this frame"),
        )),
    )

    # send (on behalf of the next higher layer) a MAC poll confirmation
    PollCnf = t.CommandDef(t.CommandType.AREQ,
                           0x8B,
                           rsp_schema=t.STATUS_SCHEMA)

    # TODO: investigate the actual structure of this command. The source code indicates
    #       that the response type differs heavily based on the ScanType.
    #       Also, ResultListMaxLength does not appear to be present.
    """
    # send (on behalf of the next higher layer) a MAC scan confirmation
    ScanCnf = t.CommandDef(
        t.CommandType.AREQ,
        0x8C,
        rsp_schema=t.Schema(
            (
                t.Param(
                    "Status", t.Status, "Status is either Success (0) or Failure (1)"
                ),
                t.Param("ED", t.uint8_t, "ED max energy"),
                t.Param("ScanType", t.ScanType, "Specifies the scan type"),
                t.Param("ChannelPage", t.uint8_t, "The channel page to use"),
                t.Param(
                    "UnScannedChannelList",
                    t.Channels,
                    "List of the un-scanned channels",
                ),
                t.Param(
                    "ResultListCount", t.uint8_t, "Number of items in the result list"
                ),
                t.Param(
                    "ResultListMaxLength",
                    t.uint8_t,
                    "Max length of the result list in bytes"
                ),
                t.Param("ResultList", t.LVList(t.uint8_t), "Result list"),
            )
        ),
    )
    """

    # send (on behalf of the next higher layer) a MAC communication indicator
    CommStatusInd = t.CommandDef(
        t.CommandType.AREQ,
        0x8D,
        rsp_schema=t.Schema((
            t.Param("Status", t.Status,
                    "Status is either Success (0) or Failure (1)"),
            t.Param("DstAddrMode", t.AddrMode, "Destination address mode"),
            t.Param("SrcIEEE", t.EUI64, "Source address"),
            t.Param("DstIEEE", t.EUI64, "Destination address"),
            t.Param("TimeStamp", t.uint32_t, "The timestamp of the message"),
            t.Param("DevicePanId", t.PanId, "PAN Id of the device"),
            t.Param("Reason", t.uint8_t, "Reason of communication indication"),
            t.Param("KeySource", t.KeySource, "Key Source of this data frame"),
            # ToDo: Make this an enum
            t.Param("SecurityLevel", t.uint8_t,
                    "Security level of this data frame"),
            # ToDo: Make this an enum
            t.Param("KeyIdMode", t.uint8_t, "Key Id Mode of this frame"),
            t.Param("KeyIndex", t.uint8_t, "Key index of this frame"),
        )),
    )

    # send (on behalf of the next higher layer) a MAC start confirmation
    StartCnf = t.CommandDef(t.CommandType.AREQ,
                            0x8E,
                            rsp_schema=t.STATUS_SCHEMA)

    # send (on behalf of the next higher layer) a MAC Rx enable confirmation
    RxEnableCnf = t.CommandDef(t.CommandType.AREQ,
                               0x8F,
                               rsp_schema=t.STATUS_SCHEMA)

    # send (on behalf of the next higher layer) a MAC purge confirmation
    PurgeCnf = t.CommandDef(
        t.CommandType.AREQ,
        0x9A,
        rsp_schema=t.Schema((
            t.Param("Status", t.Status,
                    "Status is either Success (0) or Failure (1)"),
            t.Param("Handle", t.uint8_t, "Handle of the message"),
        )),
    )
Esempio n. 7
0
class UBL(t.CommandsBase, subsystem=t.Subsystem.UBL_FUNC):
    WriteReq = t.CommandDef(
        t.CommandType.AREQ,
        0x01,
        req_schema=t.Schema((
            t.Param("FlashWordAddr", t.uint16_t,
                    "Write address, in flash words"),
            t.Param("Data", t.TrailingBytes,
                    "HandshakeRsp.BufferSize bytes of data"),
        )),
    )

    WriteRsp = t.CommandDef(
        t.CommandType.AREQ,
        0x81,
        rsp_schema=t.Schema((t.Param("Status", BootloaderStatus,
                                     "Write status"), )),
    )

    ReadReq = t.CommandDef(
        t.CommandType.AREQ,
        0x02,
        req_schema=t.Schema((t.Param("FlashWordAddr", t.uint16_t,
                                     "Read address, in flash words"), )),
    )

    ReadRsp = t.CommandDef(
        t.CommandType.AREQ,
        0x82,
        rsp_schema=t.Schema((
            t.Param("Status", BootloaderStatus, "Read status"),
            # These are missing if the request is bad
            t.Param(
                "FlashWordAddr",
                t.uint16_t,
                "Address read from, in flash words",
                optional=True,
            ),
            t.Param(
                "Data",
                t.TrailingBytes,
                "HandshakeRsp.BufferSize bytes of data",
                optional=True,
            ),
        )),
    )

    EnableReq = t.CommandDef(t.CommandType.AREQ, 0x03, req_schema=t.Schema())

    EnableRsp = t.CommandDef(
        t.CommandType.AREQ,
        0x83,
        rsp_schema=t.Schema((t.Param("Status", BootloaderStatus,
                                     "Enable status"), )),
    )

    HandshakeReq = t.CommandDef(t.CommandType.AREQ,
                                0x04,
                                req_schema=t.Schema())

    HandshakeRsp = t.CommandDef(
        t.CommandType.AREQ,
        0x84,
        rsp_schema=t.Schema((
            t.Param("Status", BootloaderStatus, "Handshake status"),
            t.Param("BootloaderRevision", t.uint32_t, "Bootloader revision"),
            t.Param("DeviceType", BootloaderDeviceType, "Device type"),
            t.Param("BufferSize", t.uint32_t, "Read/write buffer size"),
            t.Param("PageSize", t.uint32_t, "Device page size"),
            t.Param("BootloaderCodeRevision", t.uint32_t,
                    "Bootloader code revision"),
        )),
    )
Esempio n. 8
0
class SAPI(t.CommandsBase, subsystem=t.Subsystem.SAPI):
    # reset the device by using a soft reset (i.e. a jump to the reset vector) vice a
    # hardware reset (i.e. watchdog reset.)
    ZBSystemReset = t.CommandDef(t.CommandType.AREQ,
                                 0x09,
                                 req_schema=t.Schema())

    # start the ZigBee stack
    ZBStartReq = t.CommandDef(t.CommandType.SREQ,
                              0x00,
                              req_schema=t.Schema(),
                              rsp_schema=t.Schema())

    # control the joining permissions and thus allows or disallows new devices
    # from joining the network
    ZBPermitJoiningReq = t.CommandDef(
        t.CommandType.SREQ,
        0x08,
        req_schema=t.Schema((
            t.Param(
                "NWK",
                t.NWK,
                ("Short address of the device for which the joining "
                 "permissions should be set"),
            ),
            t.Param(
                "duration",
                t.uint8_t,
                "amount of time in seconds to allow new device to join",
            ),
        )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # establishes or removes a ‘binding’ between two devices. Once bound, an
    # application can send messages to a device by referencing the commandId
    # for the binding
    ZBBindDevice = t.CommandDef(
        t.CommandType.SREQ,
        0x01,
        req_schema=t.Schema((
            t.Param("Create", t.Bool,
                    "True to create binding, False to remove"),
            t.Param("CommandId", t.uint16_t, "The identifier of the binding"),
            t.Param("IEEE", t.EUI64, "IEEE address of the device to bind to"),
        )),
        rsp_schema=t.Schema(),
    )

    # puts the device into the Allow Binding Mode for a given period of time. A peer
    # device can establish a binding to a device in the Allow Binding Mode by calling
    # zb_BindDevice with a destination address of NULL
    ZBAllowBind = t.CommandDef(
        t.CommandType.SREQ,
        0x02,
        req_schema=t.Schema((t.Param(
            "duration",
            t.uint8_t,
            "amount of time in seconds to allow new device to join",
        ), )),
        rsp_schema=t.Schema(),
    )

    # initiates transmission of data to a peer device
    ZBSendDataRequest = t.CommandDef(
        t.CommandType.SREQ,
        0x03,
        req_schema=t.Schema((
            t.Param("Destination", t.NWK, "Short address of the destination"),
            t.Param("CommandId", t.uint16_t,
                    "The command id to send with the message"),
            t.Param(
                "Handle",
                t.uint8_t,
                "A handle used to Identify the send data request",
            ),
            t.Param("Ack", t.Bool,
                    "True if requesting ACK from the destination"),
            t.Param("Radius", t.uint8_t,
                    "The max number of hops the packet can travel"),
            t.Param("Data", t.ShortBytes, "Data"),
        )),
        rsp_schema=t.Schema(),
    )

    # get a configuration property from nonvolatile memory
    ZBReadConfiguration = t.CommandDef(
        t.CommandType.SREQ,
        0x04,
        req_schema=t.Schema(
            (t.Param("ConfigId", t.uint8_t,
                     "ID of the configuration property to read"), )),
        rsp_schema=t.Schema((
            t.Param("Status", t.Status,
                    "Status is either Success (0) or Failure (1)"),
            t.Param("ConfigId", t.uint8_t,
                    "ID of the configuration property to read"),
            t.Param("Value", t.ShortBytes, "Value"),
        )),
    )

    # write a configuration property from nonvolatile memory
    ZBWriteConfiguration = t.CommandDef(
        t.CommandType.SREQ,
        0x05,
        req_schema=t.Schema((
            t.Param("Status", t.Status,
                    "Status is either Success (0) or Failure (1)"),
            t.Param("ConfigId", t.uint8_t,
                    "ID of the configuration property to read"),
            t.Param("Value", t.ShortBytes, "Value"),
        )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # retrieves a Device Information Property
    ZBGetDeviceInfo = t.CommandDef(
        t.CommandType.SREQ,
        0x06,
        req_schema=t.Schema(
            (t.Param("Param", t.uint8_t,
                     "The identifier for deice information"), )),
        rsp_schema=t.Schema((
            t.Param("Param", t.uint8_t,
                    "The identifier for deice information"),
            t.Param("Value", t.uint16_t, "Value"),
        )),
    )

    #  determine the short address for a device in the network. The device
    # initiating a call to zb_FindDeviceRequest and the device being discovered must
    # both be a member of the same network. When the search is complete,
    # the zv_FindDeviceConfirm callback function is called
    ZBFindDeviceReq = t.CommandDef(
        t.CommandType.SREQ,
        0x07,
        req_schema=t.Schema((t.Param("SearchKey", t.EUI64,
                                     "IEEE address of the device"), )),
        rsp_schema=t.Schema(),
    )

    # SAPI CallBacks
    # this callback is called by the ZigBee stack after a start request
    # operation completes
    ZBStartConfirm = t.CommandDef(t.CommandType.AREQ,
                                  0x80,
                                  req_schema=t.STATUS_SCHEMA)

    # This callback is called by the ZigBee stack after a bind operation completes
    ZBBindConfirm = t.CommandDef(
        t.CommandType.AREQ,
        0x81,
        rsp_schema=t.Schema((
            t.Param("CommandId", t.uint16_t,
                    "The command id to send with the message"),
            t.Param("Status", t.Status,
                    "Status is either Success (0) or Failure (1)"),
        )),
    )

    # This callback indicates another device attempted to bind to this device
    ZBAllowBindConfirm = t.CommandDef(
        t.CommandType.AREQ,
        0x82,
        rsp_schema=t.Schema(
            (t.Param("Source", t.NWK,
                     "Source Nwk of the device attempted to bind"), )),
    )

    # This callback indicates the data has been sent
    ZBSendConfirm = t.CommandDef(
        t.CommandType.AREQ,
        0x83,
        rsp_schema=t.Schema((
            t.Param(
                "Handle",
                t.uint8_t,
                "A handle used to Identify the send data request",
            ),
            t.Param("Status", t.Status,
                    "Status is either Success (0) or Failure (1)"),
        )),
    )

    # This callback is called asynchronously by the ZigBee stack to notify the
    # application when data is received from a peer device
    ZBRecieveDataInd = t.CommandDef(
        t.CommandType.AREQ,
        0x87,
        rsp_schema=t.Schema((
            t.Param("Source", t.NWK, "NWK address of the source device"),
            t.Param("CommandId", t.uint16_t,
                    "The command id associated with the data"),
            t.Param("Data", t.LongBytes, "Data"),
        )),
    )

    # This callback is called by the ZigBee stack when a find device operation
    # completes
    ZBFindDeviceConfirm = t.CommandDef(
        t.CommandType.AREQ,
        0x85,
        rsp_schema=t.Schema((
            t.Param("SearchType", t.uint8_t,
                    "The type of search that was performed"),
            t.Param("SearchKey", t.uint16_t,
                    "Value that the search was executed on"),
            t.Param("Result", t.EUI64, "The result of the search"),
        )),
    )
Esempio n. 9
0
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.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.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.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",
                    t.uint8_t,
                    (
                        "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.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",
                    t.uint8_t,
                    (
                        "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.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.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.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.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.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.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.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.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.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"),
            )
        ),
    )

    # 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.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"),
            )
        ),
    )
Esempio n. 10
0
class ZGPCommands(t.CommandsBase, subsystem=t.Subsystem.ZGP):
    DataReq = t.CommandDef(
        t.CommandType.SREQ,
        0x01,
        req_schema=t.Schema((
            t.Param("Action", t.Bool,
                    "True/False -- add/remove GPDF into the queue"),
            t.Param("TXOptions", t.uint8_t, "ZGP TX Options"),
            t.Param(
                "ApplicationId",
                t.uint8_t,
                ("ApplicationID of the GPD to which the ASDU will be sent; "
                 "ApplicationID 0x00 indicates the usage of the SrcID; "
                 "ApplicationID 0x02 indicates the usage of the GPD IEEE"),
            ),
            t.Param(
                "SrcId",
                t.uint32_t,
                "The identifier of the GPD entity to which the ASDU will be sent",
            ),
            t.Param("IEEE", t.EUI64, "IEEE address"),
            t.Param(
                "Endpoint",
                t.uint8_t,
                "GPD ep used in combination with GPD IEEE for APPid of 0b010",
            ),
            t.Param("CommandId", t.uint8_t, "GPD command id"),
            t.Param("ASDU", t.ShortBytes, "GPD ASDU"),
            t.Param("Handle", t.uint8_t,
                    "GPEP handle to match req to confirmation"),
            t.Param("LifeTime", t.uint24_t, "The lifetime of the packet"),
        )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # send security data into # the dGP stub
    SecRsp = t.CommandDef(
        t.CommandType.SREQ,
        0x02,
        req_schema=t.Schema((
            t.Param(
                "Status",
                t.uint8_t,
                "The status code as returned by the GP endpoint",
            ),
            t.Param("Handle", t.uint8_t,
                    "GPEP handle to match req to confirmation"),
            t.Param(
                "ApplicationId",
                t.uint8_t,
                ("ApplicationID of the GPD to which the ASDU will be sent; "
                 "ApplicationID 0x00 indicates the usage of the SrcID; "
                 "ApplicationID 0x02 indicates the usage of the GPD IEEE"),
            ),
            t.Param(
                "SrcId",
                t.uint32_t,
                "The identifier of the GPD entity to which the ASDU will be sent",
            ),
            t.Param("IEEE", t.EUI64, "IEEE address"),
            t.Param(
                "Endpoint",
                t.uint8_t,
                "GPD ep used in combination with GPD IEEE for APPid of 0b010",
            ),
            t.Param("SecurityLevel", t.uint8_t,
                    "Security level for GPDF processing"),
            t.Param("KeyType", t.uint8_t, "The security key type"),
            t.Param("KeyData", t.KeyData, "Security key"),
            t.Param("FrameCounter", t.uint32_t,
                    "The security frame counter value"),
        )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # ZGP Callbacks
    # Green power confirm is a message that provides a mechanism for the Green Power
    # EndPoint in the host processor to understand the status of a previous request
    # to send a GPDF
    DataCnf = t.CommandDef(
        t.CommandType.AREQ,
        0x05,
        req_schema=t.Schema((
            t.Param(
                "Status",
                t.uint8_t,
                "The status code as returned by the GP endpoint",
            ),
            t.Param("Handle", t.uint8_t,
                    "handle to match req to confirmation"),
        )),
    )

    # This message provides a mechanism for dGP stub to request security data from the
    # Green Power EndPoint in the host processor
    SecReq = t.CommandDef(
        t.CommandType.AREQ,
        0x03,
        req_schema=t.Schema((
            t.Param(
                "ApplicationId",
                t.uint8_t,
                ("ApplicationID of the GPD to which the ASDU will be sent; "
                 "ApplicationID 0x00 indicates the usage of the SrcID; "
                 "ApplicationID 0x02 indicates the usage of the GPD IEEE"),
            ),
            t.Param(
                "SrcId",
                t.uint32_t,
                "The identifier of the GPD entity to which the ASDU will be sent",
            ),
            t.Param("IEEE", t.EUI64, "IEEE address"),
            t.Param(
                "Endpoint",
                t.uint8_t,
                "GPD ep used in combination with GPD IEEE for APPid of 0b010",
            ),
            t.Param("SecurityLevel", t.uint8_t,
                    "Security level for GPDF processing"),
            t.Param("KeyType", t.uint8_t, "The security key type"),
            t.Param("FrameCounter", t.uint32_t,
                    "The security frame counter value"),
            t.Param("Handle", t.uint8_t,
                    "dGP stub handle to match req to confirmation"),
        )),
    )

    # This message provides a mechanism for identifying and conveying a received
    # GPDF to the Green Power EndPoint in the host processor
    DataInd = t.CommandDef(
        t.CommandType.AREQ,
        0x04,
        req_schema=t.Schema((
            t.Param("Status", t.uint8_t,
                    "The status code as returned by the dGP stub"),
            t.Param(
                "RSSI",
                t.int8s,
                "The RSSI delivered by the MAC on receipt of this frame",
            ),
            t.Param("LQI", t.uint8_t,
                    "Link quality measured during reception"),
            t.Param("SeqNum", t.uint8_t,
                    "The sequence number from MAC header of MPDU"),
            t.Param("SrcAddrMode", t.AddrMode,
                    "The source addressing mode of MPDU"),
            t.Param("SrcPanId", t.PanId, "The source PAN Id"),
            # ToDo: ugh, this could be ieee depending on addressing mode
            t.Param("SrcNWK", t.NWK, "The source address of the GPD entity"),
            t.Param("DstAddrMode", t.AddrMode,
                    "The destination addressing mode of MPDU"),
            t.Param("DstPanId", t.PanId, "The destination PAN Id"),
            # ToDo: ugh, this could be ieee depending on addressing mode
            t.Param("DstNWK", t.NWK,
                    "The destination address of the GPD entity"),
            t.Param("MPDU", t.ShortBytes, "GP MPDU"),
        )),
    )
Esempio n. 11
0
    CAP_SYS = 1 << 0
    CAP_MAC = 1 << 1
    CAP_NWK = 1 << 2
    CAP_AF = 1 << 3
    CAP_ZDO = 1 << 4
    CAP_SAPI = 1 << 5
    CAP_UTIL = 1 << 6
    CAP_DEBUG = 1 << 7
    CAP_APP = 1 << 8
    CAP_GP = 1 << 9
    CAP_APP_CNF = 1 << 10
    CAP_UNK12 = 1 << 11
    CAP_ZOAD = 1 << 12
    CAP_UNK14 = 1 << 13
    CAP_UNK15 = 1 << 14
    CAP_UNK16 = 1 << 15


@attr.s
class Network(t.Struct):
    PanId = attr.ib(type=t.PanId, converter=t.Struct.converter(t.PanId))
    Channel = attr.ib(type=t.uint8_t, converter=t.uint8_t)
    StackProfileVersion = attr.ib(type=t.uint8_t, converter=t.uint8_t)
    BeaconOrderSuperframe = attr.ib(type=t.uint8_t, converter=t.uint8_t)
    PermitJoining = attr.ib(type=t.uint8_t, converter=t.uint8_t)


STATUS_SCHEMA = t.Schema(
    (t.Param("Status", t.Status, "Status is either Success (0) or Failure (1)"),)
)
Esempio n. 12
0
class SysCommands(t.CommandsBase, subsystem=t.Subsystem.SYS):
    # reset the target device
    ResetReq = t.CommandDef(
        t.CommandType.AREQ,
        0x00,
        req_schema=t.Schema((t.Param(
            "Type",
            t.uint8_t,
            ("This command will reset the device by using a hardware reset "
             "(i.e. watchdog reset) if ‘Type’ is zero. Otherwise a soft "
             "reset (i.e. a jump to the reset vector) is done. This "
             "is especially useful in the CC2531, for instance, so that the "
             "USB host does not have to contend with the USB H/W resetting "
             "(and thus causing the USB host to reenumerate the device "
             "which can cause an open virtual serial port to hang.)"),
        ), )),
    )

    # issue PING requests to verify if a device is active and check the capability of
    # the device
    Ping = t.CommandDef(
        t.CommandType.SREQ,
        0x01,
        req_schema=t.Schema(),
        rsp_schema=t.Schema((t.Param(
            "Capabilities",
            t.MTCapabilities,
            "Represents the intefaces this device can handle",
        ), )),
    )

    # request for the device’s version string
    Version = t.CommandDef(
        t.CommandType.SREQ,
        0x02,
        req_schema=t.Schema(),
        rsp_schema=t.Schema((
            t.Param("TransportRev", t.uint8_t, "Transport protocol revision"),
            t.Param("ProductId", t.uint8_t, "Product ID"),
            t.Param("MajorRel", t.uint8_t, "Software major release number"),
            t.Param("MinorRel", t.uint8_t, "Software minor release number"),
            t.Param("MaintRel", t.uint8_t,
                    "Software maintenance release number"),
        )),
    )

    # set the extended address of the device
    SetExtAddr = t.CommandDef(
        t.CommandType.SREQ,
        0x03,
        req_schema=t.Schema((t.Param("ExtAddr", t.EUI64,
                                     "The device's extended address"), )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # get the extended address of the device
    GetExtAddr = t.CommandDef(
        t.CommandType.SREQ,
        0x04,
        req_schema=t.STATUS_SCHEMA,
        rsp_schema=t.Schema((t.Param("ExtAddr", t.EUI64,
                                     "The device's extended address"), )),
    )

    # read a single memory location in the target RAM. The command accepts an address
    # value and returns the memory value present in the target RAM at that address
    RamRead = t.CommandDef(
        t.CommandType.SREQ,
        0x05,
        req_schema=t.Schema((
            t.Param("Address", t.uint16_t, "Address of the memory to read"),
            t.Param("Len", t.uint8_t, "The number of bytes to read"),
        )),
        rsp_schema=t.Schema((
            t.Param("Status", t.Status,
                    "Status is either Success (0) or Failure (1)"),
            t.Param("Value", t.ShortBytes,
                    "The value read from memory address"),
        )),
    )

    # write to a particular location in the target RAM. The command accepts an
    # address location and a memory value. The memory value is written to the address
    # location in the target RAM
    RamWrite = t.CommandDef(
        t.CommandType.SREQ,
        0x06,
        req_schema=t.Schema((
            t.Param("Address", t.uint16_t, "Address of the memory to read"),
            t.Param("Value", t.ShortBytes,
                    "The value read from memory address"),
        )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # create and initialize an item in non-volatile memory. The NV item will be created
    # if it does not already exist. The data for the new NV item will be left
    # uninitialized if the InitLen parameter is zero. When InitLen is non-zero, the
    # data for the NV item will be initialized (starting at offset of zero) with the
    # values from InitData. Note that it is not necessary to initialize the entire NV
    # item (InitLen < ItemLen). It is also possible to create an NV item that is larger
    # than the maximum length InitData – use the SYS_OSAL_NV_WRITE command to finish
    # the initialization
    OSALNVItemInit = t.CommandDef(
        t.CommandType.SREQ,
        0x07,
        req_schema=t.Schema((
            t.Param("Id", nvids.NwkNvIds, "The Id of the NV Item"),
            t.Param("ItemLen", t.uint16_t, "Number of bytes in the NV item"),
            t.Param("Value", t.ShortBytes, "The value of the NV item"),
        )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # read a single memory item in the target non-volatile memory. The command accepts
    # an attribute Id value and returns the memory value present in the target for the
    # specified attribute Id
    OSALNVRead = t.CommandDef(
        t.CommandType.SREQ,
        0x08,
        req_schema=t.Schema((
            t.Param("Id", nvids.NwkNvIds, "The Id of the NV item"),
            t.Param(
                "Offset",
                t.uint8_t,
                "Number of bytes offset from the beginning of the NV value",
            ),
        )),
        rsp_schema=t.Schema((
            t.Param("Status", t.Status,
                    "Status is either Success (0) or Failure (1)"),
            t.Param("Value", t.ShortBytes, "The value of the NV item"),
        )),
    )

    # write to a particular item in non-volatile memory. The command accepts an
    # attribute Id and an attribute value. The attribute value is written to the
    # location specified for the attribute Id in the target
    OSALNVWrite = t.CommandDef(
        t.CommandType.SREQ,
        0x09,
        req_schema=t.Schema((
            t.Param("Id", nvids.NwkNvIds, "The Id of the NV item"),
            t.Param(
                "Offset",
                t.uint8_t,
                "Number of bytes offset from the beginning of the NV value",
            ),
            t.Param("Value", t.ShortBytes, "The value of the NV item"),
        )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # delete an item from the non-volatile memory. The ItemLen parameter must match
    # the length of the NV item or the command will fail
    OSALNVDelete = t.CommandDef(
        t.CommandType.SREQ,
        0x12,
        req_schema=t.Schema((
            t.Param("Id", nvids.NwkNvIds, "The Id of the NV item"),
            t.Param("ItemLen", t.uint16_t, "Number of bytes in the NV item"),
        )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # get the length of an item in non-volatile memory. A returned length of zero
    # indicates that the NV item does not exist
    OSALNVLength = t.CommandDef(
        t.CommandType.SREQ,
        0x13,
        req_schema=t.Schema((t.Param("Id", nvids.NwkNvIds,
                                     "The Id of the NV item"), )),
        rsp_schema=t.Schema((t.Param("ItemLen", t.uint16_t,
                                     "Number of bytes in the NV item"), )),
    )

    # start a timer event. The event will expired after the indicated amount of time
    # and a notification will be sent back to the tester
    OSALStartTimer = t.CommandDef(
        t.CommandType.SREQ,
        0x0A,
        req_schema=t.Schema((
            t.Param("Id", t.uint8_t, "The Id of the timer event (0-3)"),
            t.Param("Timeout", t.uint16_t, "Timer timeout in millliseconds"),
        )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # stop a timer event
    OSALStopTimer = t.CommandDef(
        t.CommandType.SREQ,
        0x0B,
        req_schema=t.Schema((t.Param("Id", t.uint8_t,
                                     "The Id of the timer event (0-3)"), )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    #  get a random 16-bit number
    Random = t.CommandDef(
        t.CommandType.SREQ,
        0x0C,
        req_schema=t.Schema(),
        rsp_schema=t.Schema((t.Param("Value", t.uint16_t,
                                     "The random value"), )),
    )

    # read a value from the ADC based on specified channel and resolution
    ADCRead = t.CommandDef(
        t.CommandType.SREQ,
        0x0D,
        req_schema=t.Schema((
            t.Param("Channel", t.ADCChannel, "The channel of ADC to read"),
            t.Param(
                "Resolution",
                t.ADCResolution,
                "Resolution of the reading: 8/10/12/14 bits",
            ),
        )),
        rsp_schema=t.Schema((t.Param("Value", t.uint16_t,
                                     "Value of ADC channel"), )),
    )

    # control the 4 GPIO pins on the CC2530-ZNP build
    GPIO = t.CommandDef(
        t.CommandType.SREQ,
        0x0E,
        req_schema=t.Schema((
            t.Param(
                "Operation",
                t.GpioOperation,
                "Specifies type of operation on GPIO pins",
            ),
            t.Param("Value", t.uint8_t, "GPIO value for specified operation"),
        )),
        rsp_schema=t.Schema((t.Param("Value", t.uint8_t, "GPIO value"), )),
    )

    # tune intricate or arcane settings at runtime
    StackTune = t.CommandDef(
        t.CommandType.SREQ,
        0x0F,
        req_schema=t.Schema((
            t.Param(
                "Operation",
                t.StackTuneOperation,
                "Specifies type of operation on GPIO pins",
            ),
            t.Param("Value", t.uint8_t, "Tuning value"),
        )),
        rsp_schema=t.Schema(
            (t.Param("Value", t.uint8_t,
                     "Applicable status of the tuning operation"), )),
    )

    # set the target system date and time. The time can be specified in
    # “seconds since 00:00:00 on January 1, 2000”
    # or in parsed date/time components
    SetTime = t.CommandDef(
        t.CommandType.SREQ,
        0x10,
        req_schema=t.Schema((
            t.Param(
                "UTCTime",
                t.uint32_t,
                "Number of seconds since 00:00:00 on Jan 2000",
            ),
            t.Param("Hour", t.uint8_t, "Hour of the day (0 -- 23)"),
            t.Param("Minute", t.uint8_t, "Minute of the hour (0 -- 59)"),
            t.Param("Second", t.uint8_t, "Seconds of the minute (0 -- 59)"),
            t.Param("Month", t.uint8_t, "Month of the year (1 -- 12)"),
            t.Param("Day", t.uint8_t, "Day of the month (1 -- 31)"),
            t.Param("Year", t.uint16_t, "Year (2000 -- )"),
        )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # get the target system date and time. The time is returned in
    # “seconds since 00:00:00 on January 1, 2000” and parsed date/time components
    GetTime = t.CommandDef(
        t.CommandType.SREQ,
        0x11,
        req_schema=t.Schema(),
        rsp_schema=t.Schema((
            t.Param(
                "UTCTime",
                t.uint32_t,
                "Number of seconds since 00:00:00 on Jan 2000",
            ),
            t.Param("Hour", t.uint8_t, "Hour of the day (0 -- 23)"),
            t.Param("Minute", t.uint8_t, "Minute of the hour (0 -- 59)"),
            t.Param("Second", t.uint8_t, "Seconds of the minute (0 -- 59)"),
            t.Param("Month", t.uint8_t, "Month of the year (1 -- 12)"),
            t.Param("Day", t.uint8_t, "Day of the month (1 -- 31)"),
            t.Param("Year", t.uint16_t, "Year (2000 -- )"),
        )),
    )

    # set the target system radio transmit power. The returned TX power is the actual
    # setting applied to the radio – nearest characterized value for the specific
    # radio
    SetTxPower = t.CommandDef(
        t.CommandType.SREQ,
        0x14,
        req_schema=t.Schema((t.Param("TXPower", t.int8s,
                                     "Requested TX power setting, in dBm"), )),
        # While the docs say "the returned TX power is the actual setting applied to
        # the radio – nearest characterized value for the specific radio.", the code
        # matches the documentation.
        rsp_schema=t.STATUS_SCHEMA,
    )

    # initialize the statistics table in NV memory
    ZDiagsInitStats = t.CommandDef(t.CommandType.SREQ,
                                   0x17,
                                   req_schema=t.Schema(),
                                   rsp_schema=t.STATUS_SCHEMA)

    # clear the statistics table. To clear data in NV (including the Boot
    # Counter) the clearNV flag shall be set to TRUE
    ZDiagsClearStats = t.CommandDef(
        t.CommandType.SREQ,
        0x018,
        req_schema=t.Schema(
            (t.Param("ClearNV", t.Bool,
                     "True -- clear statistics in NV memory"), )),
        rsp_schema=t.Schema((t.Param("SycClock", t.uint32_t,
                                     "Milliseconds since last reset"), )),
    )

    # read a specific system (attribute) ID statistics and/or metrics value
    ZDiagsGetStats = t.CommandDef(
        t.CommandType.SREQ,
        0x19,
        req_schema=t.Schema(
            # as defined in ZDiags.h
            (
                t.Param("AttributeId", t.uint16_t,
                        "System diagnostics attribute ID"), )),
        rsp_schema=t.Schema((t.Param("Value", t.uint32_t,
                                     "Value of the requested attribute"), )),
    )

    # restore the statistics table from NV into the RAM table
    ZDiagsRestoreStatsNV = t.CommandDef(t.CommandType.SREQ,
                                        0x1A,
                                        req_schema=t.Schema(),
                                        rsp_schema=t.STATUS_SCHEMA)

    # save the statistics table from RAM to NV
    ZDiagsSaveStatsToNV = t.CommandDef(
        t.CommandType.SREQ,
        0x1B,
        req_schema=t.Schema(),
        rsp_schema=t.Schema((t.Param("SycClock", t.uint32_t,
                                     "Milliseconds since last reset"), )),
    )

    # attempt to create an item in non-volatile memory
    NVCreate = t.CommandDef(
        t.CommandType.SREQ,
        0x30,
        req_schema=t.Schema((
            t.Param("SysId", t.uint8_t, "System ID of the NV item"),
            t.Param("ItemId", t.uint16_t, "Item ID of the NV item"),
            t.Param("SubId", t.uint16_t, "Sub ID of the NV item"),
            t.Param("Length", t.uint32_t, "Number of bytes in the NV item"),
        )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # attempt to delete an item in non-volatile memory
    NVDelete = t.CommandDef(
        t.CommandType.SREQ,
        0x31,
        req_schema=t.Schema((
            t.Param("SysId", t.uint8_t, "System ID of the NV item"),
            t.Param("ItemId", t.uint16_t, "Item ID of the NV item"),
            t.Param("SubId", t.uint16_t, "Sub ID of the NV item"),
        )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # get the length of an item in non-volatile memory
    NVLength = t.CommandDef(
        t.CommandType.SREQ,
        0x32,
        req_schema=t.Schema((
            t.Param("SysId", t.uint8_t, "System ID of the NV item"),
            t.Param("ItemId", t.uint16_t, "Item ID of the NV item"),
            t.Param("SubId", t.uint16_t, "Sub ID of the NV item"),
        )),
        rsp_schema=t.Schema((t.Param("Length", t.uint8_t,
                                     "Length of NV item"), )),
    )

    # read an item in non-volatile memory
    NVRead = t.CommandDef(
        t.CommandType.SREQ,
        0x33,
        req_schema=t.Schema((
            t.Param("SysId", t.uint8_t, "System ID of the NV item"),
            t.Param("ItemId", t.uint16_t, "Item ID of the NV item"),
            t.Param("SubId", t.uint16_t, "Sub ID of the NV item"),
            t.Param(
                "Offset",
                t.uint16_t,
                "Number of bytes offset from the beginning of the NV value",
            ),
            t.Param("Length", t.uint8_t, "Length of data to read"),
        )),
        rsp_schema=t.Schema((
            t.Param("Status", t.Status,
                    "Status is either Success (0) or Failure (1)"),
            t.Param("Value", t.ShortBytes, "Value of the NV item read"),
        )),
    )

    # write an item in non-volatile memory
    NVWrite = t.CommandDef(
        t.CommandType.SREQ,
        0x34,
        req_schema=t.Schema((
            t.Param("SysId", t.uint8_t, "System ID of the NV item"),
            t.Param("ItemId", t.uint16_t, "Item ID of the NV item"),
            t.Param("SubId", t.uint16_t, "Sub ID of the NV item"),
            t.Param(
                "Offset",
                t.uint16_t,
                "Number of bytes offset from the beginning of the NV value",
            ),
            # XXX: the spec has length as a a 16-bit integer but then shows it as
            # an 8-bit integer in the table below, which matches the code
            t.Param("Value", t.ShortBytes, "Value of the NV item to write"),
        )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # update an item in non-volatile memory
    NVUpdate = t.CommandDef(
        t.CommandType.SREQ,
        0x35,
        req_schema=t.Schema((
            t.Param("SysId", t.uint8_t, "System ID of the NV item"),
            t.Param("ItemId", t.uint16_t, "Item ID of the NV item"),
            t.Param("SubId", t.uint16_t, "Sub ID of the NV item"),
            t.Param("Value", t.ShortBytes, "Value of the NV item to update"),
        )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # compact the active page in non-volatile memory
    NVCompact = t.CommandDef(
        t.CommandType.SREQ,
        0x36,
        req_schema=t.Schema((t.Param(
            "Threshold",
            t.uint16_t,
            "Compaction occurs when NV bytes are less than this value",
        ), )),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # MT SYS Callbacks
    # This command is sent by the device to indicate the reset
    ResetInd = t.CommandDef(
        t.CommandType.AREQ,
        0x80,
        rsp_schema=t.Schema((
            t.Param("Reason", t.ResetReason, "Reason for the reset"),
            t.Param("TransportRev", t.uint8_t, "Transport protocol revision"),
            t.Param("ProductId", t.uint8_t, "Product ID"),
            t.Param("MajorRel", t.uint8_t, "Software major release number"),
            t.Param("MinorRel", t.uint8_t, "Software minor release number"),
            t.Param("MaintRel", t.uint8_t,
                    "Software maintenance release number"),
        )),
    )

    # This command is sent by the device to indicate a specific time has been expired
    OSALTimerExpired = t.CommandDef(
        t.CommandType.AREQ,
        0x81,
        rsp_schema=t.Schema((t.Param("Id", t.uint8_t,
                                     "The Id of the timer event (0-3)"), )),
    )
Esempio n. 13
0
class ZDO(t.CommandsBase, subsystem=t.Subsystem.ZDO):
    # send a “Network Address Request”. This message sends a broadcast message looking
    # for a 16 bit address with a known 64 bit IEEE address. You must subscribe to
    # “ZDO Network Address Response” to receive the response to this message
    NwkAddrReq = t.CommandDef(
        t.CommandType.SREQ,
        0x00,
        req_schema=t.Schema(
            (
                t.Param(
                    "IEEE",
                    t.EUI64,
                    "Extended address of the device requesting association",
                ),
                t.Param(
                    "RequestType",
                    t.uint8_t,
                    "0x00 -- single device request, 0x01 -- Extended",
                ),
                t.Param(
                    "StartIndex", t.uint8_t, "Starting index into the list of children"
                ),
            )
        ),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # request a device’s IEEE 64-bit address
    IEEEAddrReq = t.CommandDef(
        t.CommandType.SREQ,
        0x01,
        req_schema=t.Schema(
            (
                t.Param("NWK", t.NWK, "Short address of the device"),
                t.Param(
                    "RequestType",
                    t.uint8_t,
                    "0x00 -- single device request, 0x01 -- Extended",
                ),
                t.Param(
                    "StartIndex", t.uint8_t, "Starting index into the list of children"
                ),
            )
        ),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # inquire about the Node Descriptor information of the destination device
    NodeDescReq = t.CommandDef(
        t.CommandType.SREQ,
        0x02,
        req_schema=t.Schema(
            (
                t.Param(
                    "DstAddr",
                    t.NWK,
                    "Short address of the device generating the inquiry",
                ),
                t.Param(
                    "NWKAddrOfInterest",
                    t.NWK,
                    "Short address of the device being queried",
                ),
            )
        ),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # inquire about the Power Descriptor information of the destination device
    PowerDescReq = t.CommandDef(
        t.CommandType.SREQ,
        0x03,
        req_schema=t.Schema(
            (
                t.Param(
                    "DstAddr",
                    t.NWK,
                    "Short address of the device generating the inquiry",
                ),
                t.Param(
                    "NWKAddrOfInterest",
                    t.NWK,
                    "Short address of the device being queried",
                ),
            )
        ),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # inquire as to the Simple Descriptor of the destination device’s Endpoint
    SimpleDescReq = t.CommandDef(
        t.CommandType.SREQ,
        0x04,
        req_schema=t.Schema(
            (
                t.Param(
                    "DstAddr",
                    t.NWK,
                    "Short address of the device generating the inquiry",
                ),
                t.Param(
                    "NWKAddrOfInterest",
                    t.NWK,
                    "Short address of the device being queried",
                ),
                t.Param("Endpoint", t.uint8_t, "application endpoint the data is from"),
            )
        ),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # request a list of active endpoint from the destination device
    ActiveEpReq = t.CommandDef(
        t.CommandType.SREQ,
        0x05,
        req_schema=t.Schema(
            (
                t.Param(
                    "DstAddr",
                    t.NWK,
                    "Short address of the device generating the inquiry",
                ),
                t.Param(
                    "NWKAddrOfInterest",
                    t.NWK,
                    "Short address of the device being queried",
                ),
            )
        ),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # request the device match descriptor
    MatchDescReq = t.CommandDef(
        t.CommandType.SREQ,
        0x06,
        req_schema=t.Schema(
            (
                t.Param(
                    "DstAddr",
                    t.NWK,
                    "Short address of the device generating the inquiry",
                ),
                t.Param(
                    "NWKAddrOfInterest",
                    t.NWK,
                    "Short address of the device being queried",
                ),
                t.Param("ProfileId", t.uint16_t, "profile id of the device"),
                t.Param("InputClusters", t.ClusterIdList, "Input cluster id list"),
                t.Param("OutputClusters", t.ClusterIdList, "Output cluster id list"),
            )
        ),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # request for the destination device’s complex descriptor
    ComplexDescReq = t.CommandDef(
        t.CommandType.SREQ,
        0x07,
        req_schema=t.Schema(
            (
                t.Param(
                    "DstAddr",
                    t.NWK,
                    "Short address of the device generating the inquiry",
                ),
                t.Param(
                    "NWKAddrOfInterest",
                    t.NWK,
                    "Short address of the device being queried",
                ),
            )
        ),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # request for the destination device’s user descriptor
    UserDescReq = t.CommandDef(
        t.CommandType.SREQ,
        0x08,
        req_schema=t.Schema(
            (
                t.Param(
                    "DstAddr",
                    t.NWK,
                    "Short address of the device generating the inquiry",
                ),
                t.Param(
                    "NWKAddrOfInterest",
                    t.NWK,
                    "Short address of the device being queried",
                ),
            )
        ),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # This command will cause the CC2480 device to issue an “End device announce”
    # broadcast packet to the network. This is typically used by an end-device to
    # announce itself to the network
    EndDeviceAnnce = t.CommandDef(
        t.CommandType.SREQ,
        0x0A,
        req_schema=t.Schema(
            (
                t.Param("NWK", t.NWK, "Short address of the device"),
                t.Param(
                    "IEEE",
                    t.EUI64,
                    "Extended address of the device generating the request",
                ),
                t.Param("Capabilities", t.uint8_t, "MAC Capabilities"),
            )
        ),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # write a User Descriptor value to the targeted device
    UserDescSet = t.CommandDef(
        t.CommandType.SREQ,
        0x0B,
        req_schema=t.Schema(
            (
                t.Param(
                    "DstAddr",
                    t.NWK,
                    "network address of the device generating the set request",
                ),
                t.Param(
                    "NWK", t.NWK, "NWK address of the destination device being queried"
                ),
                t.Param("UserDescriptor", t.ShortBytes, "User descriptor array"),
            )
        ),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # discover the location of a particular system server or servers as indicated by
    # the ServerMask parameter. The destination addressing on this request is
    # ‘broadcast to all RxOnWhenIdle devices’
    ServerDiscReq = t.CommandDef(
        t.CommandType.SREQ,
        0x0C,
        req_schema=t.Schema(
            (
                t.Param(
                    "ServerMask", t.uint16_t, "system server capabilities of the device"
                ),
            )
        ),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # request an End Device Bind with the destination device
    EndDeviceBindReq = t.CommandDef(
        t.CommandType.SREQ,
        0x20,
        req_schema=t.Schema(
            (
                t.Param(
                    "DstAddr",
                    t.NWK,
                    "Short address of the device generating the request",
                ),
                t.Param(
                    "LocalCoordinator",
                    t.NWK,
                    (
                        "local coordinator’s short address. In the case of source "
                        "binding, it’s the short address of the source address"
                    ),
                ),
                t.Param("IEEE", t.EUI64, "Local coordinator's IEEE address"),
                t.Param("Endpoint", t.uint8_t, "device's endpoint"),
                t.Param("ProfileId", t.uint16_t, "profile id of the device"),
                t.Param("InputClusters", t.ClusterIdList, "Input cluster id list"),
                t.Param("OutputClusters", t.ClusterIdList, "Output cluster id list"),
            )
        ),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # request a Bind
    BindReq = t.CommandDef(
        t.CommandType.SREQ,
        0x21,
        req_schema=t.Schema(
            (
                t.Param("Dst", t.NWK, "Short address of the destination device"),
                t.Param("Src", t.EUI64, "Binding source IEEE address"),
                t.Param("SrcEndpoint", t.uint8_t, "binding source endpoint"),
                t.Param("ClusterId", t.ClusterId, "Cluster id to match in messages"),
                t.Param(
                    "Address", zigpy.zdo.types.MultiAddress, "Binding address/endpoint"
                ),
            )
        ),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # request a UnBind
    UnBindReq = t.CommandDef(
        t.CommandType.SREQ,
        0x22,
        req_schema=t.Schema(
            (
                t.Param("Dst", t.NWK, "Short address of the destination device"),
                t.Param("Src", t.EUI64, "Binding source IEEE address"),
                t.Param("SrcEndpoint", t.uint8_t, "binding source endpoint"),
                t.Param("ClusterId", t.ClusterId, "Cluster id to match in messages"),
                t.Param(
                    "Address",
                    t.AddrModeAddress,
                    "Binding address mode destination address",
                ),
                t.Param("DstEndpoint", t.uint8_t, "Binding destination endpoint"),
            )
        ),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # request the destination device to perform a network discovery
    MgmtNwkDiscReq = t.CommandDef(
        t.CommandType.SREQ,
        0x30,
        req_schema=t.Schema(
            (
                t.Param("Dst", t.NWK, "Short address of the destination device"),
                t.Param("Channels", t.Channels, "Bitmask of channels to scan"),
                t.Param("ScanDuration", t.uint8_t, "Scanning time"),
                t.Param(
                    "StartIndex",
                    t.uint8_t,
                    "Specifies where to start in the response array",
                ),
            )
        ),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # request the destination device to perform a LQI query of other devices
    # in the network
    MgmtLqiReq = t.CommandDef(
        t.CommandType.SREQ,
        0x31,
        req_schema=t.Schema(
            (
                t.Param("Dst", t.NWK, "Short address of the destination device"),
                t.Param(
                    "StartIndex",
                    t.uint8_t,
                    "Specifies where to start in the response array",
                ),
            )
        ),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # request the Routing Table of the destination device
    MgmtRtgReq = t.CommandDef(
        t.CommandType.SREQ,
        0x32,
        req_schema=t.Schema(
            (
                t.Param("Dst", t.NWK, "Short address of the destination device"),
                t.Param(
                    "StartIndex",
                    t.uint8_t,
                    "Specifies where to start in the response array",
                ),
            )
        ),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # request the Binding Table of the destination device
    MgmtBindReq = t.CommandDef(
        t.CommandType.SREQ,
        0x33,
        req_schema=t.Schema(
            (
                t.Param("Dst", t.NWK, "Short address of the destination device"),
                t.Param(
                    "StartIndex",
                    t.uint8_t,
                    "Specifies where to start in the response array",
                ),
            )
        ),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # request a Management Leave Request for the target device
    MgmtLeaveReq = t.CommandDef(
        t.CommandType.SREQ,
        0x34,
        req_schema=t.Schema(
            (
                t.Param(
                    "DstAddr",
                    t.NWK,
                    "Short address of the device that will process the "
                    "mgmt leave (remote or self)",
                ),
                t.Param(
                    "IEEE",
                    t.EUI64,
                    (
                        "The 64-bit IEEE address of the entity to be removed from the "
                        "network or 0x0000000000000000 if the device removes itself "
                        "from the network."
                    ),
                ),
                t.Param(
                    "RemoveChildren_Rejoin",
                    LeaveOptions,
                    "Specifies actions to be performed by "
                    "device when leaving the network.",
                ),
            )
        ),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # request the Management Direct Join Request of a designated device
    MgmtDirectJoinReq = t.CommandDef(
        t.CommandType.SREQ,
        0x35,
        req_schema=t.Schema(
            (
                t.Param("Dst", t.NWK, "Short address of the device to join"),
                t.Param("IEEE", t.EUI64, "IEEE address of the device to join"),
                t.Param("Capabilities", t.uint8_t, "MAC Capabilities"),
            )
        ),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # set the Permit Join for the destination device
    MgmtPermitJoinReq = t.CommandDef(
        t.CommandType.SREQ,
        0x36,
        req_schema=t.Schema(
            (
                t.Param(
                    "AddrMode", t.AddrMode, "Address mode of DST: short or broadcast"
                ),
                t.Param("Dst", t.NWK, "Short address of the device to join"),
                t.Param(
                    "Duration", t.uint8_t, "Specifies the duration to permit joining"
                ),
                t.Param(
                    "TCSignificance",
                    t.uint8_t,
                    "Trust Center Significance  -- unused in the code!",
                ),
            )
        ),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # allow updating of network configuration parameters or to request information
    # from devices on network conditions in the local operating environment
    MgmtNWKUpdateReq = t.CommandDef(
        t.CommandType.SREQ,
        0x37,
        req_schema=t.Schema(
            (
                t.Param("Dst", t.NWK, "Short address of the destination device"),
                t.Param("DstAddrMode", t.AddrMode, "Destination Address mode"),
                t.Param("Channels", t.Channels, "Bitmask of channels to scan"),
                t.Param("ScanDuration", t.uint8_t, "Scanning time"),
                t.Param(
                    "ScanCount",
                    t.uint8_t,
                    "The number of energy scans to be conducted and reported",
                ),
                t.Param(
                    "NwkManagerAddr",
                    t.NWK,
                    "NWK address for the device with the Network Manager bit set",
                ),
            )
        ),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # register for a ZDO callback
    MsgCallbackRegister = t.CommandDef(
        t.CommandType.SREQ,
        0x3E,
        req_schema=t.Schema(
            (
                t.Param(
                    "ClusterId",
                    t.ClusterId,
                    "Cluster id for which to receive ZDO callback",
                ),
            )
        ),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # de-register for a ZDO callback
    MsgCallbackRemove = t.CommandDef(
        t.CommandType.SREQ,
        0x3F,
        req_schema=t.Schema(
            (
                t.Param(
                    "ClusterId",
                    t.ClusterId,
                    "Cluster id for which to receive ZDO callback",
                ),
            )
        ),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # starts the device in the network
    StartupFromApp = t.CommandDef(
        t.CommandType.SREQ,
        0x40,
        req_schema=t.Schema((t.Param("StartDelay", t.uint16_t, "Startup delay"),)),
        rsp_schema=t.Schema((t.Param("State", StartupState, "State after startup"),)),
    )

    # Extended version of ZDO to indicate to router devices to create
    # a distributed network
    StartupFromAppExt = t.CommandDef(
        t.CommandType.SREQ,
        0x54,
        req_schema=t.Schema(
            (
                t.Param("StartDelay", t.uint16_t, "Startup delay"),
                t.Param(
                    "Mode", t.Bool, "True -- ZR devices to create a distributed network"
                ),
            )
        ),
        rsp_schema=t.Schema((t.Param("State", StartupState, "State after startup"),)),
    )

    # set the application link key for a given device
    SetLinkKey = t.CommandDef(
        t.CommandType.SREQ,
        0x23,
        req_schema=t.Schema(
            (
                t.Param("NWK", t.NWK, "Short address of the device"),
                t.Param("IEEE", t.EUI64, "Extended address of the device"),
                t.Param("LinkKeyData", t.KeyData, "128bit link key"),
            )
        ),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # remove the application link key for a given device
    RemoveLinkKey = t.CommandDef(
        t.CommandType.SREQ,
        0x24,
        req_schema=t.Schema(
            (t.Param("IEEE", t.EUI64, "Extended address of the device"),)
        ),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # get the application link key for a given device
    GetLinkKey = t.CommandDef(
        t.CommandType.SREQ,
        0x25,
        req_schema=t.Schema(
            (t.Param("IEEE", t.EUI64, "Extended address of the device"),)
        ),
        rsp_schema=t.Schema(
            (
                t.Param(
                    "Status", t.ZDOStatus, "Status is either Success (0) or Failure (1)"
                ),
                t.Param("IEEE", t.EUI64, "Extended address of the device"),
                t.Param("LinkKeyData", t.KeyData, "128bit link key"),
            )
        ),
    )

    # initiate a network discovery (active scan)
    NetworkDiscoveryReq = t.CommandDef(
        t.CommandType.SREQ,
        0x26,
        req_schema=t.Schema(
            (
                t.Param("Channels", t.Channels, "Bitmask of channels to scan"),
                t.Param("ScanDuration", t.uint8_t, "Scanning time"),
            )
        ),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # request the device to join itself to a parent device on a network
    JoinReq = t.CommandDef(
        t.CommandType.SREQ,
        0x27,
        req_schema=t.Schema(
            (
                t.Param(
                    "LogicalChannel", t.uint8_t, "Channel where the PAN is located"
                ),
                t.Param("PanId", t.PanId, "The PAN Id to join."),
                t.Param("ExtendedPanId", t.ExtendedPanId, "64-bit extended PAN ID"),
                t.Param(
                    "ChosenParent",
                    t.NWK,
                    "Short address of the parent device chosen to join",
                ),
                t.Param("Depth", t.uint8_t, "Depth of the parent"),
                t.Param(
                    "StackProfile", t.uint8_t, "Stack profile of the network to use"
                ),
            )
        ),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # set rejoin backoff duration and rejoin scan duration for an end device
    SetRejoinParams = t.CommandDef(
        t.CommandType.SREQ,
        # in documentation CmdId=0x26 which conflict with discover req
        0x28,
        req_schema=t.Schema(
            (
                t.Param(
                    "BackoffDuraation",
                    t.uint32_t,
                    "Rejoin backoff  duration for end device",
                ),
                t.Param(
                    "ScanDuration", t.uint32_t, "Rejoin scan duration for end device"
                ),
            )
        ),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # handles the ZDO security add link key extension message
    SecAddLinkKey = t.CommandDef(
        t.CommandType.SREQ,
        0x42,
        req_schema=t.Schema(
            (
                t.Param("NWK", t.NWK, "Short address of the device"),
                t.Param("IEEE", t.EUI64, "Extended address of the device"),
                t.Param("LinkKeyData", t.KeyData, "128bit link key"),
            )
        ),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # handle the ZDO security entry lookup extended extension message
    SecEntryLookupExt = t.CommandDef(
        t.CommandType.SREQ,
        0x43,
        req_schema=t.Schema(
            (
                t.Param("IEEE", t.EUI64, "Extended address of the device"),
                t.Param("Entry", SecurityEntry, "Valid entry"),
            )
        ),
        rsp_schema=t.Schema(
            (
                t.Param("AMI", t.uint16_t, "Address manager index"),
                t.Param("KeyNVID", t.uint16_t, "Index to link key table in NV"),
                t.Param("Option", t.uint8_t, "Authentication option for device"),
            )
        ),
    )

    # handle the ZDO security remove device extended extension message
    SecDeviceRemove = t.CommandDef(
        t.CommandType.SREQ,
        0x44,
        req_schema=t.Schema(
            (t.Param("IEEE", t.EUI64, "Extended address of the device"),)
        ),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # handle the ZDO route discovery extension message
    ExtRouteDisc = t.CommandDef(
        t.CommandType.SREQ,
        0x45,
        req_schema=t.Schema(
            (
                t.Param("Dst", t.NWK, "Short address of the destination"),
                t.Param("Options", RouteDiscoveryOptions, "Route options"),
                t.Param("Radius", t.uint8_t, "Broadcast radius"),
            )
        ),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # handle the ZDO route check extension messags
    ExtRouteChk = t.CommandDef(
        t.CommandType.SREQ,
        0x46,
        req_schema=t.Schema(
            (
                t.Param("Dst", t.NWK, "Short address of the destination"),
                t.Param("RtStatus", t.uint8_t, "Status value for routing entries"),
                t.Param("Options", t.uint8_t, "Route options"),
            )
        ),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # handle the ZDO extended remove group extension message
    ExtRemoveGroup = t.CommandDef(
        t.CommandType.SREQ,
        0x47,
        req_schema=t.Schema(
            (
                t.Param("Endpoint", t.uint8_t, "Endpoint to look for"),
                t.Param("GroupId", t.GroupId, "ID to look for group"),
            )
        ),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # handle the ZDO extended remove all group extension message
    ExtRemoveAllGroups = t.CommandDef(
        t.CommandType.SREQ,
        0x48,
        req_schema=t.Schema((t.Param("Endpoint", t.uint8_t, "Endpoint to look for"),)),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # handle the ZDO extension find all groups for endpoint message
    ExtFindAllGroupsEndpoint = t.CommandDef(
        t.CommandType.SREQ,
        0x49,
        req_schema=t.Schema(
            (
                t.Param("Endpoint", t.uint8_t, "Endpoint to look for"),
                # this parameter does not make sense
                t.Param("Groups", t.uint16_t, "List to hold group IDs"),
            )
        ),
        rsp_schema=t.Schema((t.Param("Groups", GroupIdList, "List of Group IDs"),)),
    )

    # handle the ZDO extension find group message
    ExtFindGroup = t.CommandDef(
        t.CommandType.SREQ,
        0x4A,
        req_schema=t.Schema(
            (
                t.Param("Endpoint", t.uint8_t, "Endpoint to look for"),
                t.Param("GroupId", t.GroupId, "ID to look for group"),
            )
        ),
        rsp_schema=t.Schema((t.Param("Group", t.Bytes, "Group information"),)),
    )

    # handle the ZDO extension add group message
    ExtAddGroup = t.CommandDef(
        t.CommandType.SREQ,
        0x4B,
        req_schema=t.Schema(
            (
                t.Param("Endpoint", t.uint8_t, "Endpoint to look for"),
                t.Param("GroupId", t.GroupId, "ID to look for group"),
                t.Param("GroupName", t.CharacterString, "Group name"),
            )
        ),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # handle the ZDO extension count all groups message
    ExtCountAllGroups = t.CommandDef(
        t.CommandType.SREQ,
        0x4C,
        req_schema=t.Schema(),
        rsp_schema=t.Schema(
            (t.Param("GroupCount", t.uint8_t, "Total number of groups"),)
        ),
    )

    # handle the ZDO extension Get/Set RxOnIdle to ZMac message
    ExtRxIdle = t.CommandDef(
        t.CommandType.SREQ,
        0x4D,
        req_schema=t.Schema(
            (
                t.Param("SetFlag", t.uint8_t, "Set or get value"),
                t.Param("SetValue", t.uint8_t, "Value to be set to ZMac message"),
            )
        ),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # handle the ZDO security update network key extension message
    ExtUpdateNwkKey = t.CommandDef(
        t.CommandType.SREQ,
        0x4E,
        req_schema=t.Schema(
            (
                t.Param("Dst", t.NWK, "Short address of the destination"),
                t.Param("KeySeqNum", t.uint8_t, "Key sequence number"),
                t.Param("Key", t.KeyData, "Network key"),
            )
        ),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # handle the ZDO security switch network key extension message
    ExtSwitchNwkKey = t.CommandDef(
        t.CommandType.SREQ,
        0x4F,
        req_schema=t.Schema(
            (
                t.Param("Dst", t.NWK, "Short address of the destination"),
                t.Param("KeySeqNum", t.uint8_t, "Key sequence number"),
            )
        ),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # handle the ZDO extension network message
    ExtNwkInfo = t.CommandDef(
        t.CommandType.SREQ,
        0x50,
        req_schema=t.Schema(),
        rsp_schema=t.Schema(
            (
                t.Param("Dst", t.NWK, "Short address of the destination"),
                t.Param("PanId", t.PanId, "The PAN Id to join."),
                t.Param("ParentNWK", t.NWK, "Short address of the parent"),
                t.Param("ExtendedPanId", t.ExtendedPanId, "64-bit extended PAN ID"),
                t.Param("ParentIEEE", t.EUI64, "IEEE address of the parent"),
                t.Param("Channel", t.Channels, "Current Channel"),
            )
        ),
    )

    # handle the ZDO extension Security Manager APS Remove Request message
    ExtSecApsRemoveReq = t.CommandDef(
        t.CommandType.SREQ,
        0x51,
        req_schema=t.Schema(
            (
                t.Param("NWK", t.NWK, "Short address of the device"),
                t.Param("IEEE", t.EUI64, "IEEE address of the device"),
                t.Param("ParentNWK", t.NWK, "Short address of the parent"),
            )
        ),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # forces a network concentrator change by resetting zgConcentratorEnable and
    # zgConcentratorDiscoveryTime from NV and set nwk event
    ForceConcentratorChange = t.CommandDef(
        t.CommandType.SREQ, 0x52, req_schema=t.Schema(), rsp_schema=t.Schema()
    )

    # set parameters not settable through NV
    ExtSetParams = t.CommandDef(
        t.CommandType.SREQ,
        0x53,
        req_schema=t.Schema(
            (t.Param("UseMulticast", t.Bool, "Set or reset of multicast"),)
        ),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # handle ZDO network address of interest request
    NwkAddrOfInterestReq = t.CommandDef(
        t.CommandType.SREQ,
        0x29,
        req_schema=t.Schema(
            (
                t.Param("NWK", t.NWK, "Short address of the destination"),
                t.Param(
                    "NWKAddrOfInterest",
                    t.NWK,
                    "Short address of the device being queried",
                ),
                t.Param(
                    "Cmd",
                    t.uint8_t,
                    "A valid Cluser ID command as specified by profile",
                ),
            )
        ),
        rsp_schema=t.STATUS_SCHEMA,
    )

    # ZDO Callbacks
    # return the results to the NwkAddrReq
    NwkAddrRsp = t.CommandDef(
        t.CommandType.AREQ,
        0x80,
        req_schema=t.Schema(),
        rsp_schema=t.Schema(
            (
                t.Param(
                    "Status", t.ZDOStatus, "Status is either Success (0) or Failure (1)"
                ),
                t.Param("IEEE", t.EUI64, "Extended address of the source device"),
                t.Param("NWK", t.NWK, "Short address of the source device"),
                t.Param(
                    "Index",
                    t.uint8_t,
                    "Starting index into the list of associated devices",
                ),
                t.Param("Devices", t.NWKList, "List of the associated devices"),
            )
        ),
    )

    # return the results to the IEEEAddrReq
    IEEEAddrRsp = t.CommandDef(
        t.CommandType.AREQ,
        0x81,
        rsp_schema=t.Schema(
            (
                t.Param(
                    "Status", t.ZDOStatus, "Status is either Success (0) or Failure (1)"
                ),
                t.Param("IEEE", t.EUI64, "Extended address of the source device"),
                t.Param("NWK", t.NWK, "Short address of the source device"),
                t.Param(
                    "Index",
                    t.uint8_t,
                    "Starting index into the list of associated devices",
                ),
                t.Param("Devices", t.NWKList, "List of the associated devices"),
            )
        ),
    )

    # return the results to the NodeDescReq
    NodeDescRsp = t.CommandDef(
        t.CommandType.AREQ,
        0x82,
        rsp_schema=t.Schema(
            (
                t.Param("Src", t.NWK, "The message’s source network address."),
                t.Param(
                    "Status",
                    t.ZDOStatus,
                    "This field indicates either SUCCESS or FAILURE.",
                ),
                t.Param("NWK", t.NWK, "Device’s short address of this Node descriptor"),
                t.Param("NodeDescriptor", NullableNodeDescriptor, "Node descriptor"),
            )
        ),
    )

    # return the results to the PowerDescReq
    PowerDescRsp = t.CommandDef(
        t.CommandType.AREQ,
        0x83,
        rsp_schema=t.Schema(
            (
                t.Param("Src", t.NWK, "message's source network address"),
                t.Param(
                    "Status", t.ZDOStatus, "Status is either Success (0) or Failure (1)"
                ),
                t.Param("NWK", t.NWK, "Short address of the device response describes"),
                t.Param(
                    "PowerDescriptor",
                    zigpy.zdo.types.PowerDescriptor,
                    "Power descriptor response",
                ),
            )
        ),
    )

    # return the results to the SimpleDescReq
    SimpleDescRsp = t.CommandDef(
        t.CommandType.AREQ,
        0x84,
        rsp_schema=t.Schema(
            (
                t.Param("Src", t.NWK, "message's source network address"),
                t.Param(
                    "Status", t.ZDOStatus, "Status is either Success (0) or Failure (1)"
                ),
                t.Param("NWK", t.NWK, "Short address of the device response describes"),
                t.Param(
                    "SimpleDescriptor",
                    zigpy.zdo.types.SizePrefixedSimpleDescriptor,
                    "Simple descriptor",
                ),
            )
        ),
    )

    # return the results to the ActiveEpReq
    ActiveEpRsp = t.CommandDef(
        t.CommandType.AREQ,
        0x85,
        rsp_schema=t.Schema(
            (
                t.Param("Src", t.NWK, "message's source network address"),
                t.Param(
                    "Status", t.ZDOStatus, "Status is either Success (0) or Failure (1)"
                ),
                t.Param("NWK", t.NWK, "Short address of the device response describes"),
                t.Param("ActiveEndpoints", EndpointList, "Active endpoints list"),
            )
        ),
    )

    # return the results to the MatchDescReq
    MatchDescRsp = t.CommandDef(
        t.CommandType.AREQ,
        0x86,
        rsp_schema=t.Schema(
            (
                t.Param("Src", t.NWK, "message's source network address"),
                t.Param(
                    "Status", t.ZDOStatus, "Status is either Success (0) or Failure (1)"
                ),
                t.Param("NWK", t.NWK, "Short address of the device response describes"),
                t.Param("MatchList", EndpointList, "Endpoints list"),
            )
        ),
    )

    # return the results to the ComplexDescReq
    ComplexDescRsp = t.CommandDef(
        t.CommandType.AREQ,
        0x87,
        rsp_schema=t.Schema(
            (
                t.Param("Src", t.NWK, "message's source network address"),
                t.Param(
                    "Status", t.ZDOStatus, "Status is either Success (0) or Failure (1)"
                ),
                t.Param("NWK", t.NWK, "Short address of the device response describes"),
                t.Param("ComplexDesc", t.ShortBytes, "Complex descriptor"),
            )
        ),
    )

    # return the results to the UserDescReq
    UserDescRsp = t.CommandDef(
        t.CommandType.AREQ,
        0x88,
        rsp_schema=t.Schema(
            (
                t.Param("Src", t.NWK, "message's source network address"),
                t.Param(
                    "Status", t.ZDOStatus, "Status is either Success (0) or Failure (1)"
                ),
                t.Param("NWK", t.NWK, "Short address of the device response describes"),
                t.Param("UserDesc", t.ShortBytes, "User descriptor"),
            )
        ),
    )

    # notify the user when the device receives a user descriptor
    UserDescCnf = t.CommandDef(
        t.CommandType.AREQ,
        0x89,
        rsp_schema=t.Schema(
            (
                t.Param("Src", t.NWK, "message's source network address"),
                t.Param(
                    "Status", t.ZDOStatus, "Status is either Success (0) or Failure (1)"
                ),
                t.Param("NWK", t.NWK, "Short address of the device response describes"),
            )
        ),
    )

    # return the results to the ServerDiscReq
    ServerDiscRsp = t.CommandDef(
        t.CommandType.AREQ,
        0x8A,
        rsp_schema=t.Schema(
            (
                t.Param("Src", t.NWK, "message's source network address"),
                t.Param(
                    "Status", t.ZDOStatus, "Status is either Success (0) or Failure (1)"
                ),
                t.Param("ServerMask", t.ZDOStatus, "Server mask response"),
            )
        ),
    )

    # return the results to the EndDeviceBindReq
    EndDeviceBindRsp = t.CommandDef(
        t.CommandType.AREQ,
        0xA0,
        rsp_schema=t.Schema(
            (
                t.Param("Src", t.NWK, "message's source network address"),
                t.Param(
                    "Status", t.ZDOStatus, "Status is either Success (0) or Failure (1)"
                ),
            )
        ),
    )

    # return the results to the BindReq
    BindRsp = t.CommandDef(
        t.CommandType.AREQ,
        0xA1,
        rsp_schema=t.Schema(
            (
                t.Param("Src", t.NWK, "message's source network address"),
                t.Param(
                    "Status", t.ZDOStatus, "Status is either Success (0) or Failure (1)"
                ),
            )
        ),
    )

    # return the results to the UnBindReq
    UnBindRsp = t.CommandDef(
        t.CommandType.AREQ,
        0xA2,
        rsp_schema=t.Schema(
            (
                t.Param("Src", t.NWK, "message's source network address"),
                t.Param(
                    "Status", t.ZDOStatus, "Status is either Success (0) or Failure (1)"
                ),
            )
        ),
    )

    # return the results to the MgmtNwkDiscReq
    MgmtNwkDiscRsp = t.CommandDef(
        t.CommandType.AREQ,
        0xB0,
        rsp_schema=t.Schema(
            (
                t.Param("Src", t.NWK, "message's source network address"),
                t.Param(
                    "Status", t.ZDOStatus, "Status is either Success (0) or Failure (1)"
                ),
                t.Param("NetworkCount", t.uint8_t, "Total number of entries available"),
                t.Param("Index", t.uint8_t, "Where the response starts"),
                t.Param("Networks", NetworkList, "Discovered networks list"),
            )
        ),
    )

    # return the results to the MgmtLqiReq
    MgmtLqiRsp = t.CommandDef(
        t.CommandType.AREQ,
        0xB1,
        rsp_schema=t.Schema(
            (
                t.Param("Src", t.NWK, "message's source network address"),
                t.Param(
                    "Status", t.ZDOStatus, "Status is either Success (0) or Failure (1)"
                ),
                t.Param("Neighbours", zigpy.zdo.types.Neighbors, "Neighbours"),
            )
        ),
    )

    # return the results to the MgmtRtgReq
    MgmtRtgRsp = t.CommandDef(
        t.CommandType.AREQ,
        0xB2,
        rsp_schema=t.Schema(
            (
                t.Param("Src", t.NWK, "message's source network address"),
                t.Param(
                    "Status", t.ZDOStatus, "Status is either Success (0) or Failure (1)"
                ),
                t.Param("Routes", zigpy.zdo.types.Routes, "Routes"),
            )
        ),
    )

    # return the results to the MgmtBingReq
    MgmtBindRsp = t.CommandDef(
        t.CommandType.AREQ,
        0xB3,
        rsp_schema=t.Schema(
            (
                t.Param("Src", t.NWK, "message's source network address"),
                t.Param(
                    "Status", t.ZDOStatus, "Status is either Success (0) or Failure (1)"
                ),
                t.Param(
                    "BindTableEntries",
                    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"),
            )
        ),
    )

    # return the results to the MgmtLeaveReq
    MgmtLeaveRsp = t.CommandDef(
        t.CommandType.AREQ,
        0xB4,
        rsp_schema=t.Schema(
            (
                t.Param("Src", t.NWK, "message's source network address"),
                t.Param(
                    "Status", t.ZDOStatus, "Status is either Success (0) or Failure (1)"
                ),
            )
        ),
    )

    # return the results to the MgmtDirectJoinReq
    MgmtDirectJoinRsp = t.CommandDef(
        t.CommandType.AREQ,
        0xB5,
        rsp_schema=t.Schema(
            (
                t.Param("Src", t.NWK, "message's source network address"),
                t.Param(
                    "Status", t.ZDOStatus, "Status is either Success (0) or Failure (1)"
                ),
            )
        ),
    )

    # return the results to the MgmtPermitJoinReq
    MgmtPermitJoinRsp = t.CommandDef(
        t.CommandType.AREQ,
        0xB6,
        rsp_schema=t.Schema(
            (
                t.Param("Src", t.NWK, "message's source network address"),
                t.Param(
                    "Status", t.ZDOStatus, "Status is either Success (0) or Failure (1)"
                ),
            )
        ),
    )

    # indicates ZDO state change
    StateChangeInd = t.CommandDef(
        t.CommandType.AREQ,
        0xC0,
        rsp_schema=t.Schema((t.Param("State", t.DeviceState, "New ZDO state"),)),
    )

    # indicates the ZDO End Device Announce
    EndDeviceAnnceInd = t.CommandDef(
        t.CommandType.AREQ,
        0xC1,
        rsp_schema=t.Schema(
            (
                t.Param("Src", t.NWK, "Source address of the message."),
                t.Param("NWK", t.NWK, "Specifies the device’s short address"),
                t.Param(
                    "IEEE",
                    t.EUI64,
                    "Extended address of the device generating the request",
                ),
                t.Param("Capabilities", MACCapabilities, "MAC Capabilities"),
            )
        ),
    )

    # indicates that Match Descriptor Response has been sent
    MatchDescRspSent = t.CommandDef(
        t.CommandType.AREQ,
        0xC2,
        rsp_schema=t.Schema(
            (
                t.Param("NWK", t.NWK, "Device's network address"),
                t.Param("InputClusters", t.ClusterIdList, "Input cluster id list"),
                t.Param("OutputClusters", t.ClusterIdList, "Output cluster id list"),
            )
        ),
    )

    # default message for error status
    StatusErrorRsp = t.CommandDef(
        t.CommandType.AREQ,
        0xC3,
        rsp_schema=t.Schema(
            (
                t.Param("Src", t.NWK, "message's source network address"),
                t.Param(
                    "Status", t.ZDOStatus, "Status is either Success (0) or Failure (1)"
                ),
            )
        ),
    )

    # indication to inform host device the receipt of a source route to a given device
    SrcRtgInd = t.CommandDef(
        t.CommandType.AREQ,
        0xC4,
        rsp_schema=t.Schema(
            (
                t.Param(
                    "DstAddr",
                    t.NWK,
                    "Network address of the destination of the source route",
                ),
                t.Param("Relays", t.NWKList, "List of relay devices"),
            )
        ),
    )

    # indication to inform host device the receipt of a beacon notification
    BeaconNotifyInd = t.CommandDef(
        t.CommandType.AREQ,
        0xC5,
        rsp_schema=t.Schema((t.Param("Beacons", BeaconList, "Beacons list"),)),
    )

    # inform the host device of a ZDO join request result
    JoinCnf = t.CommandDef(
        t.CommandType.AREQ,
        0xC6,
        rsp_schema=t.Schema(
            (
                t.Param(
                    "Status", t.ZDOStatus, "Status is either Success (0) or Failure (1)"
                ),
                t.Param("Nwk", t.NWK, "device's network address"),
                t.Param("ParentNwk", t.NWK, "Parent's network address"),
            )
        ),
    )

    # indication to inform host device the completion of network discovery scan
    NwkDiscoveryCnf = t.CommandDef(t.CommandType.AREQ, 0xC7, rsp_schema=t.STATUS_SCHEMA)

    # an indication to inform the host of a device leaving the network
    LeaveInd = t.CommandDef(
        t.CommandType.AREQ,
        0xC9,
        rsp_schema=t.Schema(
            (
                t.Param(
                    "NWK", t.NWK, "Short address of the source of the leave indication"
                ),
                t.Param(
                    "IEEE",
                    t.EUI64,
                    "IEEE address of the source of the leave indication",
                ),
                t.Param("Request", t.Bool, "True -- request, False -- indication"),
                t.Param("Remove", t.Bool, "True -- Remove children"),
                t.Param("Rejoin", t.Bool, "True -- Rejoin"),
            )
        ),
    )

    # ZDO callback for a Cluster Id that the host requested to receive
    # with a MsgCallbackRegister request
    MsgCbIncoming = t.CommandDef(
        t.CommandType.AREQ,
        0xFF,
        rsp_schema=t.Schema(
            (
                t.Param("Src", t.NWK, "Source address of the ZDO message"),
                t.Param(
                    "IsBroadcast",
                    t.Bool,
                    "Indicates whether the message was a broadcast",
                ),
                t.Param("ClusterId", t.ClusterId, "Cluster Id of this ZDO message"),
                t.Param("SecurityUse", t.uint8_t, "Not used"),
                t.Param("TSN", t.uint8_t, "Transaction sequence number"),
                t.Param(
                    "MacDst", t.NWK, "Mac destination short address of the ZDO message"
                ),
                t.Param(
                    "Data",
                    t.Bytes,
                    "Data that corresponds to the cluster ID of the message",
                ),
            )
        ),
    )

    # a ZDO callback for TC Device Indication
    TCDevInd = t.CommandDef(
        t.CommandType.AREQ,
        0xCA,
        rsp_schema=t.Schema(
            (
                t.Param("SrcNwk", t.NWK, "device's network address"),
                t.Param("SrcIEEE", t.EUI64, "IEEE address of the source"),
                t.Param("ParentNwk", t.NWK, "Parent's network address"),
            )
        ),
    )

    # a ZDO callback for Permit Join Indication
    PermitJoinInd = t.CommandDef(
        t.CommandType.AREQ,
        0xCB,
        rsp_schema=t.Schema((t.Param("Duration", t.uint8_t, "Permit join duration"),)),
    )