# Copyright (c) 2010 - 2020, Nordic Semiconductor ASA
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
#    list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
#
# 3. Neither the name of Nordic Semiconductor ASA nor the names of its
#    contributors may be used to endorse or promote products derived from this
#    software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

# This file was autogenerated by serial_doc_gen_pyaci.py at 2019-08-29 16:15:17.
from aci.aci_utils import CommandPacket, ResponsePacket, value_to_barray, iterable_to_barray, barray_pop
from aci.aci_evt import CmdRsp
import struct

class Echo(CommandPacket):
    """A simple loopback test command.

    Parameters
    ----------
        data : uint8_t[254]
            Data to echo back.
    """
    def __init__(self, data):
        __data = bytearray()
        __data += iterable_to_barray(data)
        super(Echo, self).__init__(0x02, __data)


class InternalEventsReport(CommandPacket):
    """Start reporting internal events, if supported."""
    def __init__(self):
        __data = bytearray()
        super(InternalEventsReport, self).__init__(0x03, __data)


class SerialVersionGet(CommandPacket):
    """Request the implemented version of the serial interface."""
    def __init__(self):
        __data = bytearray()
        super(SerialVersionGet, self).__init__(0x09, __data)


class FwInfoGet(CommandPacket):
    """Request the firmware version info structure for the firmware."""
    def __init__(self):
        __data = bytearray()
        super(FwInfoGet, self).__init__(0x0A, __data)


class RadioReset(CommandPacket):
    """Restart the device."""
    def __init__(self):
        __data = bytearray()
        super(RadioReset, self).__init__(0x0E, __data)


class BeaconStart(CommandPacket):
    """Start an application controlled beacon with the given payload.

    Parameters
    ----------
        beacon_slot : uint8_t
            Slot number of the beacon to set the payload for.
        data : uint8_t[31]
            Beacon payload.
    """
    def __init__(self, beacon_slot, data):
        __data = bytearray()
        __data += struct.pack("<B", beacon_slot)
        __data += iterable_to_barray(data)
        super(BeaconStart, self).__init__(0x10, __data)


class BeaconStop(CommandPacket):
    """Stop transmitting the current beacon.

    Parameters
    ----------
        beacon_slot : uint8_t
            Slot number of the beacon to stop.
    """
    def __init__(self, beacon_slot):
        __data = bytearray()
        __data += struct.pack("<B", beacon_slot)
        super(BeaconStop, self).__init__(0x11, __data)


class BeaconParamsGet(CommandPacket):
    """Set parameters for application controlled beacon.

    Parameters
    ----------
        beacon_slot : uint8_t
            Slot number of the beacon to get the parameters of.
    """
    def __init__(self, beacon_slot):
        __data = bytearray()
        __data += struct.pack("<B", beacon_slot)
        super(BeaconParamsGet, self).__init__(0x13, __data)


class BeaconParamsSet(CommandPacket):
    """Set parameters for application controlled beacon.

    Parameters
    ----------
        beacon_slot : uint8_t
            Slot number of the beacon to start.
        tx_power : uint8_t
            TX Power value, must be a value from @ref serial_cmd_tx_power_value_t.
        channel_map : uint8_t
            Channel map bitfield for beacon, starting at channel 37.
        interval_ms : uint32_t
            TX interval in milliseconds.
    """
    def __init__(self, beacon_slot, tx_power, channel_map, interval_ms):
        __data = bytearray()
        __data += struct.pack("<B", beacon_slot)
        __data += struct.pack("<B", tx_power)
        __data += struct.pack("<B", channel_map)
        __data += struct.pack("<I", interval_ms)
        super(BeaconParamsSet, self).__init__(0x12, __data)


class HousekeepingDataGet(CommandPacket):
    """Get the current housekeeping data values."""
    def __init__(self):
        __data = bytearray()
        super(HousekeepingDataGet, self).__init__(0x14, __data)


class HousekeepingDataClear(CommandPacket):
    """Clear the current housekeeping data values."""
    def __init__(self):
        __data = bytearray()
        super(HousekeepingDataClear, self).__init__(0x15, __data)


class Application(CommandPacket):
    """Application-specific command.

    Parameters
    ----------
        data : uint8_t[254]
            Application data.
    """
    def __init__(self, data):
        __data = bytearray()
        __data += iterable_to_barray(data)
        super(Application, self).__init__(0x20, __data)


class Start(CommandPacket):
    """Opening message of a Segmentation and Reassembly message."""
    def __init__(self):
        __data = bytearray()
        super(Start, self).__init__(0x21, __data)


class Continue(CommandPacket):
    """Continuation of a Segmentation and Reassembly message."""
    def __init__(self):
        __data = bytearray()
        super(Continue, self).__init__(0x22, __data)


class AdvAddrSet(CommandPacket):
    """Set the device's BLE advertisement address used for all BLE advertisment messages sent by
    the device.

    Parameters
    ----------
        addr_type : uint8_t
            BLE advertising address type.
        adv_addr : uint8_t[6]
            BLE advertising address.
    """
    def __init__(self, addr_type, adv_addr):
        __data = bytearray()
        __data += struct.pack("<B", addr_type)
        __data += iterable_to_barray(adv_addr)
        super(AdvAddrSet, self).__init__(0x40, __data)


class AdvAddrGet(CommandPacket):
    """Get the device's BLE advertisement address."""
    def __init__(self):
        __data = bytearray()
        super(AdvAddrGet, self).__init__(0x41, __data)


class ChannelMapSet(CommandPacket):
    """Set the channel map for advertisement packets.

    Parameters
    ----------
        channel_map : uint8_t
            Channel map bitfield for mesh to use, starting at channel 37.
    """
    def __init__(self, channel_map):
        __data = bytearray()
        __data += struct.pack("<B", channel_map)
        super(ChannelMapSet, self).__init__(0x42, __data)


class ChannelMapGet(CommandPacket):
    """Get the channel map used for advertisement packets."""
    def __init__(self):
        __data = bytearray()
        super(ChannelMapGet, self).__init__(0x43, __data)


class TxPowerSet(CommandPacket):
    """Set the transmission power of the radio.

    Parameters
    ----------
        tx_power : uint8_t
            Transmit power of radio, see @ref serial_cmd_tx_power_value_t for accepted values.
    """
    def __init__(self, tx_power):
        __data = bytearray()
        __data += struct.pack("<B", tx_power)
        super(TxPowerSet, self).__init__(0x44, __data)


class TxPowerGet(CommandPacket):
    """Get the transmission power of the radio."""
    def __init__(self):
        __data = bytearray()
        super(TxPowerGet, self).__init__(0x45, __data)


class UuidSet(CommandPacket):
    """Set the device UUID used for identifying the device during provisioning.

    Parameters
    ----------
        uuid : uint8_t[16]
            Device UUID.
    """
    def __init__(self, uuid):
        __data = bytearray()
        __data += iterable_to_barray(uuid)
        super(UuidSet, self).__init__(0x53, __data)


class UuidGet(CommandPacket):
    """Get the device UUID used for identifying the device during provisioning."""
    def __init__(self):
        __data = bytearray()
        super(UuidGet, self).__init__(0x54, __data)


class ScanStart(CommandPacket):
    """Start reporting of incoming unprovisioned beacons."""
    def __init__(self):
        __data = bytearray()
        super(ScanStart, self).__init__(0x61, __data)


class ScanStop(CommandPacket):
    """Stop reporting of incoming unprovisioned beacons."""
    def __init__(self):
        __data = bytearray()
        super(ScanStop, self).__init__(0x62, __data)


class Provision(CommandPacket):
    """Start provisioning of a device.

    Parameters
    ----------
        context_id : uint8_t
            Context ID to use for this provisioning session.
        target_uuid : uint8_t[16]
            UUID of the device to provision.
        network_key : uint8_t[16]
            Network key to give to the device.
        network_key_index : uint16_t
            Network key index.
        iv_index : uint32_t
            Initial IV index of the network.
        address : uint16_t
            Unicast address to assign to the device.
        iv_update_flag : uint8_t
            IV update in progress flag.
        key_refresh_flag : uint8_t
            Key refresh in progress flag.
        attention_duration_s : uint8_t
            Time in seconds during which the device will identify itself using any means it can.
    """
    def __init__(self, context_id, target_uuid, network_key, network_key_index, iv_index, address, iv_update_flag, key_refresh_flag, attention_duration_s):
        __data = bytearray()
        __data += struct.pack("<B", context_id)
        __data += iterable_to_barray(target_uuid)
        __data += iterable_to_barray(network_key)
        __data += struct.pack("<H", network_key_index)
        __data += struct.pack("<I", iv_index)
        __data += struct.pack("<H", address)
        __data += struct.pack("<B", iv_update_flag)
        __data += struct.pack("<B", key_refresh_flag)
        __data += struct.pack("<B", attention_duration_s)
        super(Provision, self).__init__(0x63, __data)


class Listen(CommandPacket):
    """As an uprovisioned device, listen for incoming provisioning requests."""
    def __init__(self):
        __data = bytearray()
        super(Listen, self).__init__(0x64, __data)


class OobUse(CommandPacket):
    """Used to respond to the _Provisioning Capabilities Received_ event.

    Parameters
    ----------
        context_id : uint8_t
            ID of context to set the oob method for.
        oob_method : uint8_t
            OOB method to use, see @ref nrf_mesh_prov_oob_method_t for accepted values.
        oob_action : uint8_t
            OOB action to use, see @ref nrf_mesh_prov_input_action_t or @ref
            nrf_mesh_prov_output_action_t for values.
        size : uint8_t
            Size of the OOB data.
    """
    def __init__(self, context_id, oob_method, oob_action, size):
        __data = bytearray()
        __data += struct.pack("<B", context_id)
        __data += struct.pack("<B", oob_method)
        __data += struct.pack("<B", oob_action)
        __data += struct.pack("<B", size)
        super(OobUse, self).__init__(0x66, __data)


class AuthData(CommandPacket):
    """Used to respond to a _Provisioning Auth Request_ event.

    Parameters
    ----------
        context_id : uint8_t
            ID of the context to set the authentication data for.
        data : uint8_t[16]
            Authentication data.
    """
    def __init__(self, context_id, data):
        __data = bytearray()
        __data += struct.pack("<B", context_id)
        __data += iterable_to_barray(data)
        super(AuthData, self).__init__(0x67, __data)


class EcdhSecret(CommandPacket):
    """Used to respond to a _Provisioning ECDH Request_ event.

    Parameters
    ----------
        context_id : uint8_t
            ID of the context to set the shared secret for.
        shared_secret : uint8_t[32]
            ECDH shared secret.
    """
    def __init__(self, context_id, shared_secret):
        __data = bytearray()
        __data += struct.pack("<B", context_id)
        __data += iterable_to_barray(shared_secret)
        super(EcdhSecret, self).__init__(0x68, __data)


class KeypairSet(CommandPacket):
    """Send a public/private keypair to the device.

    Parameters
    ----------
        private_key : uint8_t[32]
            Private key.
        public_key : uint8_t[64]
            Public key.
    """
    def __init__(self, private_key, public_key):
        __data = bytearray()
        __data += iterable_to_barray(private_key)
        __data += iterable_to_barray(public_key)
        super(KeypairSet, self).__init__(0x69, __data)


class CapabilitiesSet(CommandPacket):
    """Used to set the out-of-band authentication capabilities of a device.

    Parameters
    ----------
        num_elements : uint8_t
            The number of elements in the device
        public_key_type : uint8_t
            The type of public key used in the device.
        static_oob_types : uint8_t
            The types of static OOB authentication methods.
        output_oob_size : uint8_t
            Maximum size of the OOB authentication output.
        output_oob_actions : uint16_t
            Available output actions for OOB authentication.
        input_oob_size : uint8_t
            Maximum size of the OOB authentication input.
        input_oob_actions : uint16_t
            Available input actions for OOB authentication.
    """
    def __init__(self, num_elements, public_key_type, static_oob_types, output_oob_size, output_oob_actions, input_oob_size, input_oob_actions):
        __data = bytearray()
        __data += struct.pack("<B", num_elements)
        __data += struct.pack("<B", public_key_type)
        __data += struct.pack("<B", static_oob_types)
        __data += struct.pack("<B", output_oob_size)
        __data += struct.pack("<H", output_oob_actions)
        __data += struct.pack("<B", input_oob_size)
        __data += struct.pack("<H", input_oob_actions)
        super(CapabilitiesSet, self).__init__(0x6A, __data)


class Init(CommandPacket):
    """Not implemented."""
    def __init__(self):
        __data = bytearray()
        super(Init, self).__init__(0x70, __data)


class ValueSet(CommandPacket):
    """Not implemented."""
    def __init__(self):
        __data = bytearray()
        super(ValueSet, self).__init__(0x71, __data)


class ValueEnable(CommandPacket):
    """Not implemented."""
    def __init__(self):
        __data = bytearray()
        super(ValueEnable, self).__init__(0x72, __data)


class ValueDisable(CommandPacket):
    """Not implemented."""
    def __init__(self):
        __data = bytearray()
        super(ValueDisable, self).__init__(0x73, __data)


class Start(CommandPacket):
    """Not implemented."""
    def __init__(self):
        __data = bytearray()
        super(Start, self).__init__(0x74, __data)


class Stop(CommandPacket):
    """Not implemented."""
    def __init__(self):
        __data = bytearray()
        super(Stop, self).__init__(0x75, __data)


class FlagSet(CommandPacket):
    """Not implemented."""
    def __init__(self):
        __data = bytearray()
        super(FlagSet, self).__init__(0x76, __data)


class FlagGet(CommandPacket):
    """Not implemented."""
    def __init__(self):
        __data = bytearray()
        super(FlagGet, self).__init__(0x77, __data)


class DfuData(CommandPacket):
    """Send DFU data to the device.

    Parameters
    ----------
        dfu_packet : uint8_t[31]
            DFU packet data.
    """
    def __init__(self, dfu_packet):
        __data = bytearray()
        __data += iterable_to_barray(dfu_packet)
        super(DfuData, self).__init__(0x78, __data)


class ValueGet(CommandPacket):
    """Not implemented."""
    def __init__(self):
        __data = bytearray()
        super(ValueGet, self).__init__(0x7A, __data)


class BuildVersionGet(CommandPacket):
    """Not implemented."""
    def __init__(self):
        __data = bytearray()
        super(BuildVersionGet, self).__init__(0x7B, __data)


class AccessAddrGet(CommandPacket):
    """Not implemented."""
    def __init__(self):
        __data = bytearray()
        super(AccessAddrGet, self).__init__(0x7C, __data)


class ChannelGet(CommandPacket):
    """Not implemented."""
    def __init__(self):
        __data = bytearray()
        super(ChannelGet, self).__init__(0x7D, __data)


class IntervalMinMsGet(CommandPacket):
    """Not implemented."""
    def __init__(self):
        __data = bytearray()
        super(IntervalMinMsGet, self).__init__(0x7F, __data)


class Enable(CommandPacket):
    """Enable mesh operation."""
    def __init__(self):
        __data = bytearray()
        super(Enable, self).__init__(0x90, __data)


class Disable(CommandPacket):
    """Disable mesh operation."""
    def __init__(self):
        __data = bytearray()
        super(Disable, self).__init__(0x91, __data)


class SubnetAdd(CommandPacket):
    """Add a mesh subnetwork to the device.

    Parameters
    ----------
        net_key_index : uint16_t
            Mesh-global key index.
        key : uint8_t[16]
            Key to add.
    """
    def __init__(self, net_key_index, key):
        __data = bytearray()
        __data += struct.pack("<H", net_key_index)
        __data += iterable_to_barray(key)
        super(SubnetAdd, self).__init__(0x92, __data)


class SubnetUpdate(CommandPacket):
    """Update a mesh subnetwork's root key.

    Parameters
    ----------
        subnet_handle : uint16_t
            Handle of the subnet to change.
        key : uint8_t[16]
            Key to change to.
    """
    def __init__(self, subnet_handle, key):
        __data = bytearray()
        __data += struct.pack("<H", subnet_handle)
        __data += iterable_to_barray(key)
        super(SubnetUpdate, self).__init__(0x93, __data)


class SubnetDelete(CommandPacket):
    """Delete a subnetwork from the device.

    Parameters
    ----------
        subnet_handle : uint16_t
            Handle of the subnet to delete.
    """
    def __init__(self, subnet_handle):
        __data = bytearray()
        __data += struct.pack("<H", subnet_handle)
        super(SubnetDelete, self).__init__(0x94, __data)


class SubnetGetAll(CommandPacket):
    """Get all known subnetwork key indexes."""
    def __init__(self):
        __data = bytearray()
        super(SubnetGetAll, self).__init__(0x95, __data)


class SubnetCountMaxGet(CommandPacket):
    """Get the maximum number of subnetworks the device can fit."""
    def __init__(self):
        __data = bytearray()
        super(SubnetCountMaxGet, self).__init__(0x96, __data)


class AppkeyAdd(CommandPacket):
    """Add a mesh application key to the device.

    Parameters
    ----------
        app_key_index : uint16_t
            Mesh-global key index.
        subnet_handle : uint16_t
            Handle of the subnetwork to add the appkey to.
        key : uint8_t[16]
            Key to add.
    """
    def __init__(self, app_key_index, subnet_handle, key):
        __data = bytearray()
        __data += struct.pack("<H", app_key_index)
        __data += struct.pack("<H", subnet_handle)
        __data += iterable_to_barray(key)
        super(AppkeyAdd, self).__init__(0x97, __data)


class AppkeyUpdate(CommandPacket):
    """Update a mesh application key.

    Parameters
    ----------
        appkey_handle : uint16_t
            Handle of the appkey to change.
        key : uint8_t[16]
            Key to change to.
    """
    def __init__(self, appkey_handle, key):
        __data = bytearray()
        __data += struct.pack("<H", appkey_handle)
        __data += iterable_to_barray(key)
        super(AppkeyUpdate, self).__init__(0x98, __data)


class AppkeyDelete(CommandPacket):
    """Delete a application key from the device.

    Parameters
    ----------
        appkey_handle : uint16_t
            Handle of the appkey to delete.
    """
    def __init__(self, appkey_handle):
        __data = bytearray()
        __data += struct.pack("<H", appkey_handle)
        super(AppkeyDelete, self).__init__(0x99, __data)


class AppkeyGetAll(CommandPacket):
    """Get all the application key indices of the stored application keys associated with a
    specific subnetwork.

    Parameters
    ----------
        subnet_handle : uint16_t
            Handle of the subnet to get all appkeys of.
    """
    def __init__(self, subnet_handle):
        __data = bytearray()
        __data += struct.pack("<H", subnet_handle)
        super(AppkeyGetAll, self).__init__(0x9A, __data)


class AppkeyCountMaxGet(CommandPacket):
    """Get the maximum number of application keys the device can fit."""
    def __init__(self):
        __data = bytearray()
        super(AppkeyCountMaxGet, self).__init__(0x9B, __data)


class DevkeyAdd(CommandPacket):
    """Add a mesh device key to the device.

    Parameters
    ----------
        owner_addr : uint16_t
            Unicast address of the device that owns the given devkey.
        subnet_handle : uint16_t
            Handle of the subnetwork to bind the devkey to.
        key : uint8_t[16]
            Key to add.
    """
    def __init__(self, owner_addr, subnet_handle, key):
        __data = bytearray()
        __data += struct.pack("<H", owner_addr)
        __data += struct.pack("<H", subnet_handle)
        __data += iterable_to_barray(key)
        super(DevkeyAdd, self).__init__(0x9C, __data)


class DevkeyDelete(CommandPacket):
    """Delete a device key from the device.

    Parameters
    ----------
        devkey_handle : uint16_t
            Handle of the devkey to delete.
    """
    def __init__(self, devkey_handle):
        __data = bytearray()
        __data += struct.pack("<H", devkey_handle)
        super(DevkeyDelete, self).__init__(0x9D, __data)


class DevkeyCountMaxGet(CommandPacket):
    """Get the maximum number of device keys the device can fit."""
    def __init__(self):
        __data = bytearray()
        super(DevkeyCountMaxGet, self).__init__(0x9E, __data)


class AddrLocalUnicastSet(CommandPacket):
    """Set the start and count of the device's local unicast address.

    Parameters
    ----------
        start_address : uint16_t
            First address in the range of unicast addresses.
        count : uint16_t
            Number of addresses in the range of unicast addresses.
    """
    def __init__(self, start_address, count):
        __data = bytearray()
        __data += struct.pack("<H", start_address)
        __data += struct.pack("<H", count)
        super(AddrLocalUnicastSet, self).__init__(0x9F, __data)


class AddrLocalUnicastGet(CommandPacket):
    """Get the start and count of the device's local unicast addresses."""
    def __init__(self):
        __data = bytearray()
        super(AddrLocalUnicastGet, self).__init__(0xA0, __data)


class AddrGet(CommandPacket):
    """Get the raw representation of the address with the given handle.

    Parameters
    ----------
        address_handle : uint16_t
            Handle of address to get raw representation of.
    """
    def __init__(self, address_handle):
        __data = bytearray()
        __data += struct.pack("<H", address_handle)
        super(AddrGet, self).__init__(0xA7, __data)


class AddrGetAll(CommandPacket):
    """Get a list of all address handles in the address pool, not including local unicast
    addresses.
    """
    def __init__(self):
        __data = bytearray()
        super(AddrGetAll, self).__init__(0xA8, __data)


class AddrNonvirtualCountMaxGet(CommandPacket):
    """Get the maximum number of non-virtual addresses the device can fit."""
    def __init__(self):
        __data = bytearray()
        super(AddrNonvirtualCountMaxGet, self).__init__(0xA9, __data)


class AddrVirtualCountMaxGet(CommandPacket):
    """Get the maximum number of virtual addresses the device can fit."""
    def __init__(self):
        __data = bytearray()
        super(AddrVirtualCountMaxGet, self).__init__(0xAA, __data)


class AddrSubscriptionAdd(CommandPacket):
    """Add the specified address to the set of active address subscriptions.

    Parameters
    ----------
        address : uint16_t
            Address to add as a subscription address.
    """
    def __init__(self, address):
        __data = bytearray()
        __data += struct.pack("<H", address)
        super(AddrSubscriptionAdd, self).__init__(0xA1, __data)


class AddrSubscriptionAddVirtual(CommandPacket):
    """Add the virtual address with the specified UUID to the set of active address
    subscriptions.

    Parameters
    ----------
        uuid : uint8_t[16]
            Virtual address UUID.
    """
    def __init__(self, uuid):
        __data = bytearray()
        __data += iterable_to_barray(uuid)
        super(AddrSubscriptionAddVirtual, self).__init__(0xA2, __data)


class AddrSubscriptionRemove(CommandPacket):
    """Remove the address with the given handle from the set of active address subscriptions.

    Parameters
    ----------
        address_handle : uint16_t
            Handle of address to remove from address subscription list.
    """
    def __init__(self, address_handle):
        __data = bytearray()
        __data += struct.pack("<H", address_handle)
        super(AddrSubscriptionRemove, self).__init__(0xA3, __data)


class AddrPublicationAdd(CommandPacket):
    """Add the specified address to the set of active publish addresses.

    Parameters
    ----------
        address : uint16_t
            Address to add as a publication address.
    """
    def __init__(self, address):
        __data = bytearray()
        __data += struct.pack("<H", address)
        super(AddrPublicationAdd, self).__init__(0xA4, __data)


class AddrPublicationAddVirtual(CommandPacket):
    """Add the virtual address with the specified UUID to the set of active publish addresses.

    Parameters
    ----------
        uuid : uint8_t[16]
            Virtual address UUID.
    """
    def __init__(self, uuid):
        __data = bytearray()
        __data += iterable_to_barray(uuid)
        super(AddrPublicationAddVirtual, self).__init__(0xA5, __data)


class AddrPublicationRemove(CommandPacket):
    """Remove the address with the specified handle from the set of active publish addresses.

    Parameters
    ----------
        address_handle : uint16_t
            Handle of the address to remove from the publication address list.
    """
    def __init__(self, address_handle):
        __data = bytearray()
        __data += struct.pack("<H", address_handle)
        super(AddrPublicationRemove, self).__init__(0xA6, __data)


class PacketSend(CommandPacket):
    """Send a mesh packet.

    Parameters
    ----------
        appkey_handle : uint16_t
            Appkey or devkey handle to use for packet sending. Subnetwork will be picked
            automatically.
        src_addr : uint16_t
            Raw unicast address to use as source address. Must be in the range of local unicast
            addresses.
        dst_addr_handle : uint16_t
            Handle of destination address to use in packet.
        ttl : uint8_t
            Time To Live value to use in packet.
        force_segmented : uint8_t
            Whether or not to force use of segmented message type for the transmission.
        transmic_size : uint8_t
            Transport MIC size used enum. SMALL=0, LARGE=1, DEFAULT=2. LARGE may only be used with
            segmented packets.
        friendship_credential_flag : uint8_t
            Control parameter for credentials used to publish messages from a model. 0 for master, 1
            for friendship.
        data : uint8_t[244]
            Payload of the packet.
    """
    def __init__(self, appkey_handle, src_addr, dst_addr_handle, ttl, force_segmented, transmic_size, friendship_credential_flag, data):
        __data = bytearray()
        __data += struct.pack("<H", appkey_handle)
        __data += struct.pack("<H", src_addr)
        __data += struct.pack("<H", dst_addr_handle)
        __data += struct.pack("<B", ttl)
        __data += struct.pack("<B", force_segmented)
        __data += struct.pack("<B", transmic_size)
        __data += struct.pack("<B", friendship_credential_flag)
        __data += iterable_to_barray(data)
        super(PacketSend, self).__init__(0xAB, __data)


class StateClear(CommandPacket):
    """Reset the device and network state and erase the flash copies."""
    def __init__(self):
        __data = bytearray()
        super(StateClear, self).__init__(0xAC, __data)


class ConfigServerBind(CommandPacket):
    """Binds the config server model instance to given device key handle.

    Parameters
    ----------
        address_handle : uint16_t
            Handle of address to get raw representation of.
    """
    def __init__(self, address_handle):
        __data = bytearray()
        __data += struct.pack("<H", address_handle)
        super(ConfigServerBind, self).__init__(0xAD, __data)


class NetStateSet(CommandPacket):
    """Sets the network state

    Parameters
    ----------
        iv_index : uint32_t
            The IV index to set.
        iv_update_in_progress : uint8_t
            Value indicating the phase of the IV update process.
        iv_update_timeout_counter : uint16_t
            Timeout counter for IV update process.
        next_seqnum_block : uint32_t
            First sequence number block not yet allocated.
    """
    def __init__(self, iv_index, iv_update_in_progress, iv_update_timeout_counter, next_seqnum_block):
        __data = bytearray()
        __data += struct.pack("<I", iv_index)
        __data += struct.pack("<B", iv_update_in_progress)
        __data += struct.pack("<H", iv_update_timeout_counter)
        __data += struct.pack("<I", next_seqnum_block)
        super(NetStateSet, self).__init__(0xAE, __data)


class NetStateGet(CommandPacket):
    """Gets the network state"""
    def __init__(self):
        __data = bytearray()
        super(NetStateGet, self).__init__(0xAF, __data)


class JumpToBootloader(CommandPacket):
    """Immediately jump to bootloader mode."""
    def __init__(self):
        __data = bytearray()
        super(JumpToBootloader, self).__init__(0xD0, __data)


class Request(CommandPacket):
    """Request a DFU transfer.

    Parameters
    ----------
        dfu_type : uint8_t
            DFU Firmware type to request.
        fwid : nrf_mesh_fwid_t
            Firmware ID to request.
        bank_addr : uint32_t
            Address in which to bank firmware.
    """
    def __init__(self, dfu_type, fwid, bank_addr):
        __data = bytearray()
        __data += struct.pack("<B", dfu_type)
        __data += fwid
        __data += struct.pack("<I", bank_addr)
        super(Request, self).__init__(0xD1, __data)


class Relay(CommandPacket):
    """Relay a DFU transfer.

    Parameters
    ----------
        dfu_type : uint8_t
            DFU Firmware type to relay.
        fwid : nrf_mesh_fwid_t
            Firmware ID of firmware that should be relayed.
    """
    def __init__(self, dfu_type, fwid):
        __data = bytearray()
        __data += struct.pack("<B", dfu_type)
        __data += fwid
        super(Relay, self).__init__(0xD2, __data)


class Abort(CommandPacket):
    """Abort the ongoing DFU transfer."""
    def __init__(self):
        __data = bytearray()
        super(Abort, self).__init__(0xD3, __data)


class BankInfoGet(CommandPacket):
    """Get information about the firmware bank of the given type, if it exists.

    Parameters
    ----------
        dfu_type : uint8_t
            DFU Firmware type to get bank info about.
    """
    def __init__(self, dfu_type):
        __data = bytearray()
        __data += struct.pack("<B", dfu_type)
        super(BankInfoGet, self).__init__(0xD4, __data)


class BankFlash(CommandPacket):
    """Flash the bank with the given firmware type.

    Parameters
    ----------
        dfu_type : uint8_t
            DFU Firmware type to flash.
    """
    def __init__(self, dfu_type):
        __data = bytearray()
        __data += struct.pack("<B", dfu_type)
        super(BankFlash, self).__init__(0xD5, __data)


class StateGet(CommandPacket):
    """Get the current state of the DFU module."""
    def __init__(self):
        __data = bytearray()
        super(StateGet, self).__init__(0xD6, __data)


class ModelPubAddrSet(CommandPacket):
    """Set the publish address for a model instance.

    Parameters
    ----------
        model_handle : access_model_handle_t
            Handle for the model being modified.
        dsm_handle : dsm_handle_t
            Handle for a value (e.g. address) stored by the device state manager.
    """
    def __init__(self, model_handle, dsm_handle):
        __data = bytearray()
        __data += struct.pack("<H", model_handle)
        __data += struct.pack("<H", dsm_handle)
        super(ModelPubAddrSet, self).__init__(0xE0, __data)


class ModelPubAddrGet(CommandPacket):
    """Get the publish address for a model instance.

    Parameters
    ----------
        handle : access_model_handle_t
            Handle of the model that the access module should operate on.
    """
    def __init__(self, handle):
        __data = bytearray()
        __data += struct.pack("<H", handle)
        super(ModelPubAddrGet, self).__init__(0xE1, __data)


class ModelPubPeriodSet(CommandPacket):
    """Set the publish address for a model instance.

    Parameters
    ----------
        model_handle : access_model_handle_t
            Handle of the model that the access module should operate on.
        resolution : uint8_t
            see @ref access_publish_resolution_t for accepted values.
        step_number : uint8_t
            Must not be larger than @ref ACCESS_PUBLISH_PERIOD_STEP_MAX.
    """
    def __init__(self, model_handle, resolution, step_number):
        __data = bytearray()
        __data += struct.pack("<H", model_handle)
        __data += struct.pack("<B", resolution)
        __data += struct.pack("<B", step_number)
        super(ModelPubPeriodSet, self).__init__(0xE2, __data)


class ModelPubPeriodGet(CommandPacket):
    """Get the publish period for a model instance.

    Parameters
    ----------
        handle : access_model_handle_t
            Handle of the model that the access module should operate on.
    """
    def __init__(self, handle):
        __data = bytearray()
        __data += struct.pack("<H", handle)
        super(ModelPubPeriodGet, self).__init__(0xE3, __data)


class ModelSubsAdd(CommandPacket):
    """Add a subscription address to a model instance.

    Parameters
    ----------
        model_handle : access_model_handle_t
            Handle for the model being modified.
        dsm_handle : dsm_handle_t
            Handle for a value (e.g. address) stored by the device state manager.
    """
    def __init__(self, model_handle, dsm_handle):
        __data = bytearray()
        __data += struct.pack("<H", model_handle)
        __data += struct.pack("<H", dsm_handle)
        super(ModelSubsAdd, self).__init__(0xE4, __data)


class ModelSubsRemove(CommandPacket):
    """Remove a subscription address from a model instance.

    Parameters
    ----------
        model_handle : access_model_handle_t
            Handle for the model being modified.
        dsm_handle : dsm_handle_t
            Handle for a value (e.g. address) stored by the device state manager.
    """
    def __init__(self, model_handle, dsm_handle):
        __data = bytearray()
        __data += struct.pack("<H", model_handle)
        __data += struct.pack("<H", dsm_handle)
        super(ModelSubsRemove, self).__init__(0xE5, __data)


class ModelSubsGet(CommandPacket):
    """Get the list of subscription addresses from a model instance.

    Parameters
    ----------
        handle : access_model_handle_t
            Handle of the model that the access module should operate on.
    """
    def __init__(self, handle):
        __data = bytearray()
        __data += struct.pack("<H", handle)
        super(ModelSubsGet, self).__init__(0xE6, __data)


class ModelAppBind(CommandPacket):
    """Bind an application key to a model instance.

    Parameters
    ----------
        model_handle : access_model_handle_t
            Handle for the model being modified.
        dsm_handle : dsm_handle_t
            Handle for a value (e.g. address) stored by the device state manager.
    """
    def __init__(self, model_handle, dsm_handle):
        __data = bytearray()
        __data += struct.pack("<H", model_handle)
        __data += struct.pack("<H", dsm_handle)
        super(ModelAppBind, self).__init__(0xE7, __data)


class ModelAppUnbind(CommandPacket):
    """Unbind an application key from a model instance.

    Parameters
    ----------
        model_handle : access_model_handle_t
            Handle for the model being modified.
        dsm_handle : dsm_handle_t
            Handle for a value (e.g. address) stored by the device state manager.
    """
    def __init__(self, model_handle, dsm_handle):
        __data = bytearray()
        __data += struct.pack("<H", model_handle)
        __data += struct.pack("<H", dsm_handle)
        super(ModelAppUnbind, self).__init__(0xE8, __data)


class ModelAppGet(CommandPacket):
    """Get all the application keys bound to a model instance.

    Parameters
    ----------
        handle : access_model_handle_t
            Handle of the model that the access module should operate on.
    """
    def __init__(self, handle):
        __data = bytearray()
        __data += struct.pack("<H", handle)
        super(ModelAppGet, self).__init__(0xE9, __data)


class ModelPubAppSet(CommandPacket):
    """Set the application key to be used when publishing for a model instance.

    Parameters
    ----------
        model_handle : access_model_handle_t
            Handle for the model being modified.
        dsm_handle : dsm_handle_t
            Handle for a value (e.g. address) stored by the device state manager.
    """
    def __init__(self, model_handle, dsm_handle):
        __data = bytearray()
        __data += struct.pack("<H", model_handle)
        __data += struct.pack("<H", dsm_handle)
        super(ModelPubAppSet, self).__init__(0xEA, __data)


class ModelPubAppGet(CommandPacket):
    """Get the application key used when publishing for a model instance.

    Parameters
    ----------
        handle : access_model_handle_t
            Handle of the model that the access module should operate on.
    """
    def __init__(self, handle):
        __data = bytearray()
        __data += struct.pack("<H", handle)
        super(ModelPubAppGet, self).__init__(0xEB, __data)


class ModelPubTtlSet(CommandPacket):
    """Set the default TTL value used when publishing for a model instance.

    Parameters
    ----------
        model_handle : access_model_handle_t
            Handle of the model that the access module should operate on.
        ttl : uint8_t
            TTL for outgoing messages.
    """
    def __init__(self, model_handle, ttl):
        __data = bytearray()
        __data += struct.pack("<H", model_handle)
        __data += struct.pack("<B", ttl)
        super(ModelPubTtlSet, self).__init__(0xEC, __data)


class ModelPubTtlGet(CommandPacket):
    """Get the default TTL value used when publishing for a model instance.

    Parameters
    ----------
        handle : access_model_handle_t
            Handle of the model that the access module should operate on.
    """
    def __init__(self, handle):
        __data = bytearray()
        __data += struct.pack("<H", handle)
        super(ModelPubTtlGet, self).__init__(0xED, __data)


class ElemLocSet(CommandPacket):
    """Set the location descriptor for an element.

    Parameters
    ----------
        element_index : uint16_t
            Index of the addressed element.
        location : uint16_t
            Location value for the element.
    """
    def __init__(self, element_index, location):
        __data = bytearray()
        __data += struct.pack("<H", element_index)
        __data += struct.pack("<H", location)
        super(ElemLocSet, self).__init__(0xEE, __data)


class ElemLocGet(CommandPacket):
    """Get the location descriptor for an element.

    Parameters
    ----------
        element_index : uint16_t
            Index of the addressed element.
    """
    def __init__(self, element_index):
        __data = bytearray()
        __data += struct.pack("<H", element_index)
        super(ElemLocGet, self).__init__(0xEF, __data)


class ElemSigModelCountGet(CommandPacket):
    """Get the number of Bluetooth SIG models for an element.

    Parameters
    ----------
        element_index : uint16_t
            Index of the addressed element.
    """
    def __init__(self, element_index):
        __data = bytearray()
        __data += struct.pack("<H", element_index)
        super(ElemSigModelCountGet, self).__init__(0xF0, __data)


class ElemVendorModelCountGet(CommandPacket):
    """Get the number of vendor specific models for an element.

    Parameters
    ----------
        element_index : uint16_t
            Index of the addressed element.
    """
    def __init__(self, element_index):
        __data = bytearray()
        __data += struct.pack("<H", element_index)
        super(ElemVendorModelCountGet, self).__init__(0xF1, __data)


class ModelIdGet(CommandPacket):
    """Get the model ID of a model instance.

    Parameters
    ----------
        handle : access_model_handle_t
            Handle of the model that the access module should operate on.
    """
    def __init__(self, handle):
        __data = bytearray()
        __data += struct.pack("<H", handle)
        super(ModelIdGet, self).__init__(0xF2, __data)


class HandleGet(CommandPacket):
    """Get the handle assigned to the model instance of a model based on the element index and
    model ID.

    Parameters
    ----------
        element_index : uint16_t
            Index of the addressed element which owns the model.
        model_id : access_model_id_t
            Company and model IDs.
    """
    def __init__(self, element_index, model_id):
        __data = bytearray()
        __data += struct.pack("<H", element_index)
        __data += struct.pack("<I", model_id)
        super(HandleGet, self).__init__(0xF3, __data)


class ElemModelsGet(CommandPacket):
    """Get the array of handles corresponding to an element.

    Parameters
    ----------
        element_index : uint16_t
            Index of the addressed element.
    """
    def __init__(self, element_index):
        __data = bytearray()
        __data += struct.pack("<H", element_index)
        super(ElemModelsGet, self).__init__(0xF4, __data)


class ModelsGet(CommandPacket):
    """Get a list of all the models available on the device."""
    def __init__(self):
        __data = bytearray()
        super(ModelsGet, self).__init__(0xFC, __data)


class Init(CommandPacket):
    """Call the initializer of the addressed model to create a new instance.

    Parameters
    ----------
        model_init_info : serial_cmd_model_specific_init_header_t
            Basic information that is always needed to initialize a model
        data : uint8_t[248]
            Additional data provided to the initializer
    """
    def __init__(self, model_init_info, data):
        __data = bytearray()
        __data += model_init_info
        __data += iterable_to_barray(data)
        super(Init, self).__init__(0xFD, __data)


class Command(CommandPacket):
    """Forward a model specific command to a model instance.

    Parameters
    ----------
        model_cmd_info : serial_cmd_model_specific_command_header_t
            Contains the handle of the model being addressed.
        data : uint8_t[252]
            Additional data provided to the event
    """
    def __init__(self, model_cmd_info, data):
        __data = bytearray()
        __data += struct.pack("<H", model_cmd_info)
        __data += iterable_to_barray(data)
        super(Command, self).__init__(0xFE, __data)


class EchoRsp(ResponsePacket):
    """Response to a(n) Echo command."""
    def __init__(self, raw_data):
        __data = {}
        __data["data"] = raw_data[0:]
        super(EchoRsp, self).__init__("Echo", 0x02, __data)


class SerialVersionGetRsp(ResponsePacket):
    """Response to a(n) SerialVersionGet command."""
    def __init__(self, raw_data):
        __data = {}
        __data["serial_ver"], = struct.unpack("<H", raw_data[0:2])
        super(SerialVersionGetRsp, self).__init__("SerialVersionGet", 0x09, __data)


class FwInfoGetRsp(ResponsePacket):
    """Response to a(n) FwInfoGet command."""
    def __init__(self, raw_data):
        __data = {}
        __data["fwid"] = raw_data[0:10]
        super(FwInfoGetRsp, self).__init__("FwInfoGet", 0x0A, __data)


class BeaconParamsGetRsp(ResponsePacket):
    """Response to a(n) BeaconParamsGet command."""
    def __init__(self, raw_data):
        __data = {}
        __data["beacon_slot"], = struct.unpack("<B", raw_data[0:1])
        __data["tx_power"], = struct.unpack("<B", raw_data[1:2])
        __data["channel_map"], = struct.unpack("<B", raw_data[2:3])
        __data["interval_ms"], = struct.unpack("<I", raw_data[3:7])
        super(BeaconParamsGetRsp, self).__init__("BeaconParamsGet", 0x13, __data)


class HousekeepingDataGetRsp(ResponsePacket):
    """Response to a(n) HousekeepingDataGet command."""
    def __init__(self, raw_data):
        __data = {}
        __data["alloc_fail_count"], = struct.unpack("<I", raw_data[0:4])
        super(HousekeepingDataGetRsp, self).__init__("HousekeepingDataGet", 0x14, __data)


class AdvAddrGetRsp(ResponsePacket):
    """Response to a(n) AdvAddrGet command."""
    def __init__(self, raw_data):
        __data = {}
        __data["addr_type"], = struct.unpack("<B", raw_data[0:1])
        __data["addr"] = raw_data[1:7]
        super(AdvAddrGetRsp, self).__init__("AdvAddrGet", 0x41, __data)


class TxPowerGetRsp(ResponsePacket):
    """Response to a(n) TxPowerGet command."""
    def __init__(self, raw_data):
        __data = {}
        __data["tx_power"], = struct.unpack("<B", raw_data[0:1])
        super(TxPowerGetRsp, self).__init__("TxPowerGet", 0x45, __data)


class UuidGetRsp(ResponsePacket):
    """Response to a(n) UuidGet command."""
    def __init__(self, raw_data):
        __data = {}
        __data["device_uuid"] = raw_data[0:16]
        super(UuidGetRsp, self).__init__("UuidGet", 0x54, __data)


class ProvisionRsp(ResponsePacket):
    """Response to a(n) Provision command."""
    def __init__(self, raw_data):
        __data = {}
        __data["context"], = struct.unpack("<B", raw_data[0:1])
        super(ProvisionRsp, self).__init__("Provision", 0x63, __data)


class OobUseRsp(ResponsePacket):
    """Response to a(n) OobUse command."""
    def __init__(self, raw_data):
        __data = {}
        __data["context"], = struct.unpack("<B", raw_data[0:1])
        super(OobUseRsp, self).__init__("OobUse", 0x66, __data)


class AuthDataRsp(ResponsePacket):
    """Response to a(n) AuthData command."""
    def __init__(self, raw_data):
        __data = {}
        __data["context"], = struct.unpack("<B", raw_data[0:1])
        super(AuthDataRsp, self).__init__("AuthData", 0x67, __data)


class EcdhSecretRsp(ResponsePacket):
    """Response to a(n) EcdhSecret command."""
    def __init__(self, raw_data):
        __data = {}
        __data["context"], = struct.unpack("<B", raw_data[0:1])
        super(EcdhSecretRsp, self).__init__("EcdhSecret", 0x68, __data)


class SubnetAddRsp(ResponsePacket):
    """Response to a(n) SubnetAdd command."""
    def __init__(self, raw_data):
        __data = {}
        __data["subnet_handle"], = struct.unpack("<H", raw_data[0:2])
        super(SubnetAddRsp, self).__init__("SubnetAdd", 0x92, __data)


class SubnetUpdateRsp(ResponsePacket):
    """Response to a(n) SubnetUpdate command."""
    def __init__(self, raw_data):
        __data = {}
        __data["subnet_handle"], = struct.unpack("<H", raw_data[0:2])
        super(SubnetUpdateRsp, self).__init__("SubnetUpdate", 0x93, __data)


class SubnetDeleteRsp(ResponsePacket):
    """Response to a(n) SubnetDelete command."""
    def __init__(self, raw_data):
        __data = {}
        __data["subnet_handle"], = struct.unpack("<H", raw_data[0:2])
        super(SubnetDeleteRsp, self).__init__("SubnetDelete", 0x94, __data)


class SubnetGetAllRsp(ResponsePacket):
    """Response to a(n) SubnetGetAll command."""
    def __init__(self, raw_data):
        __data = {}
        __data["subnet_key_index"] = raw_data[0:252]
        super(SubnetGetAllRsp, self).__init__("SubnetGetAll", 0x95, __data)


class SubnetCountMaxGetRsp(ResponsePacket):
    """Response to a(n) SubnetCountMaxGet command."""
    def __init__(self, raw_data):
        __data = {}
        __data["list_size"], = struct.unpack("<H", raw_data[0:2])
        super(SubnetCountMaxGetRsp, self).__init__("SubnetCountMaxGet", 0x96, __data)


class AppkeyAddRsp(ResponsePacket):
    """Response to a(n) AppkeyAdd command."""
    def __init__(self, raw_data):
        __data = {}
        __data["appkey_handle"], = struct.unpack("<H", raw_data[0:2])
        super(AppkeyAddRsp, self).__init__("AppkeyAdd", 0x97, __data)


class AppkeyUpdateRsp(ResponsePacket):
    """Response to a(n) AppkeyUpdate command."""
    def __init__(self, raw_data):
        __data = {}
        __data["appkey_handle"], = struct.unpack("<H", raw_data[0:2])
        super(AppkeyUpdateRsp, self).__init__("AppkeyUpdate", 0x98, __data)


class AppkeyDeleteRsp(ResponsePacket):
    """Response to a(n) AppkeyDelete command."""
    def __init__(self, raw_data):
        __data = {}
        __data["appkey_handle"], = struct.unpack("<H", raw_data[0:2])
        super(AppkeyDeleteRsp, self).__init__("AppkeyDelete", 0x99, __data)


class AppkeyGetAllRsp(ResponsePacket):
    """Response to a(n) AppkeyGetAll command."""
    def __init__(self, raw_data):
        __data = {}
        __data["subnet_handle"], = struct.unpack("<H", raw_data[0:2])
        __data["appkey_key_index"] = raw_data[2:252]
        super(AppkeyGetAllRsp, self).__init__("AppkeyGetAll", 0x9A, __data)


class AppkeyCountMaxGetRsp(ResponsePacket):
    """Response to a(n) AppkeyCountMaxGet command."""
    def __init__(self, raw_data):
        __data = {}
        __data["list_size"], = struct.unpack("<H", raw_data[0:2])
        super(AppkeyCountMaxGetRsp, self).__init__("AppkeyCountMaxGet", 0x9B, __data)


class DevkeyAddRsp(ResponsePacket):
    """Response to a(n) DevkeyAdd command."""
    def __init__(self, raw_data):
        __data = {}
        __data["devkey_handle"], = struct.unpack("<H", raw_data[0:2])
        super(DevkeyAddRsp, self).__init__("DevkeyAdd", 0x9C, __data)


class DevkeyDeleteRsp(ResponsePacket):
    """Response to a(n) DevkeyDelete command."""
    def __init__(self, raw_data):
        __data = {}
        __data["devkey_handle"], = struct.unpack("<H", raw_data[0:2])
        super(DevkeyDeleteRsp, self).__init__("DevkeyDelete", 0x9D, __data)


class DevkeyCountMaxGetRsp(ResponsePacket):
    """Response to a(n) DevkeyCountMaxGet command."""
    def __init__(self, raw_data):
        __data = {}
        __data["list_size"], = struct.unpack("<H", raw_data[0:2])
        super(DevkeyCountMaxGetRsp, self).__init__("DevkeyCountMaxGet", 0x9E, __data)


class AddrLocalUnicastGetRsp(ResponsePacket):
    """Response to a(n) AddrLocalUnicastGet command."""
    def __init__(self, raw_data):
        __data = {}
        __data["address_start"], = struct.unpack("<H", raw_data[0:2])
        __data["count"], = struct.unpack("<H", raw_data[2:4])
        super(AddrLocalUnicastGetRsp, self).__init__("AddrLocalUnicastGet", 0xA0, __data)


class AddrGetRsp(ResponsePacket):
    """Response to a(n) AddrGet command."""
    def __init__(self, raw_data):
        __data = {}
        __data["address_handle"], = struct.unpack("<H", raw_data[0:2])
        __data["addr_type"], = struct.unpack("<B", raw_data[2:3])
        __data["subscribed"], = struct.unpack("<B", raw_data[3:4])
        __data["raw_short_addr"], = struct.unpack("<H", raw_data[4:6])
        __data["virtual_uuid"] = raw_data[6:22]
        super(AddrGetRsp, self).__init__("AddrGet", 0xA7, __data)


class AddrGetAllRsp(ResponsePacket):
    """Response to a(n) AddrGetAll command."""
    def __init__(self, raw_data):
        __data = {}
        __data["address_handles"] = raw_data[0:252]
        super(AddrGetAllRsp, self).__init__("AddrGetAll", 0xA8, __data)


class AddrNonvirtualCountMaxGetRsp(ResponsePacket):
    """Response to a(n) AddrNonvirtualCountMaxGet command."""
    def __init__(self, raw_data):
        __data = {}
        __data["list_size"], = struct.unpack("<H", raw_data[0:2])
        super(AddrNonvirtualCountMaxGetRsp, self).__init__("AddrNonvirtualCountMaxGet", 0xA9, __data)


class AddrVirtualCountMaxGetRsp(ResponsePacket):
    """Response to a(n) AddrVirtualCountMaxGet command."""
    def __init__(self, raw_data):
        __data = {}
        __data["list_size"], = struct.unpack("<H", raw_data[0:2])
        super(AddrVirtualCountMaxGetRsp, self).__init__("AddrVirtualCountMaxGet", 0xAA, __data)


class AddrSubscriptionAddRsp(ResponsePacket):
    """Response to a(n) AddrSubscriptionAdd command."""
    def __init__(self, raw_data):
        __data = {}
        __data["address_handle"], = struct.unpack("<H", raw_data[0:2])
        super(AddrSubscriptionAddRsp, self).__init__("AddrSubscriptionAdd", 0xA1, __data)


class AddrSubscriptionAddVirtualRsp(ResponsePacket):
    """Response to a(n) AddrSubscriptionAddVirtual command."""
    def __init__(self, raw_data):
        __data = {}
        __data["address_handle"], = struct.unpack("<H", raw_data[0:2])
        super(AddrSubscriptionAddVirtualRsp, self).__init__("AddrSubscriptionAddVirtual", 0xA2, __data)


class AddrSubscriptionRemoveRsp(ResponsePacket):
    """Response to a(n) AddrSubscriptionRemove command."""
    def __init__(self, raw_data):
        __data = {}
        __data["address_handle"], = struct.unpack("<H", raw_data[0:2])
        super(AddrSubscriptionRemoveRsp, self).__init__("AddrSubscriptionRemove", 0xA3, __data)


class AddrPublicationAddRsp(ResponsePacket):
    """Response to a(n) AddrPublicationAdd command."""
    def __init__(self, raw_data):
        __data = {}
        __data["address_handle"], = struct.unpack("<H", raw_data[0:2])
        super(AddrPublicationAddRsp, self).__init__("AddrPublicationAdd", 0xA4, __data)


class AddrPublicationAddVirtualRsp(ResponsePacket):
    """Response to a(n) AddrPublicationAddVirtual command."""
    def __init__(self, raw_data):
        __data = {}
        __data["address_handle"], = struct.unpack("<H", raw_data[0:2])
        super(AddrPublicationAddVirtualRsp, self).__init__("AddrPublicationAddVirtual", 0xA5, __data)


class AddrPublicationRemoveRsp(ResponsePacket):
    """Response to a(n) AddrPublicationRemove command."""
    def __init__(self, raw_data):
        __data = {}
        __data["address_handle"], = struct.unpack("<H", raw_data[0:2])
        super(AddrPublicationRemoveRsp, self).__init__("AddrPublicationRemove", 0xA6, __data)


class PacketSendRsp(ResponsePacket):
    """Response to a(n) PacketSend command."""
    def __init__(self, raw_data):
        __data = {}
        __data["token"], = struct.unpack("<I", raw_data[0:4])
        super(PacketSendRsp, self).__init__("PacketSend", 0xAB, __data)


class NetStateGetRsp(ResponsePacket):
    """Response to a(n) NetStateGet command."""
    def __init__(self, raw_data):
        __data = {}
        __data["iv_index"], = struct.unpack("<I", raw_data[0:4])
        __data["iv_update_in_progress"], = struct.unpack("<B", raw_data[4:5])
        __data["iv_update_timout_counter"], = struct.unpack("<H", raw_data[5:7])
        __data["next_seqnum_block"], = struct.unpack("<I", raw_data[7:11])
        super(NetStateGetRsp, self).__init__("NetStateGet", 0xAF, __data)


class BankInfoGetRsp(ResponsePacket):
    """Response to a(n) BankInfoGet command."""
    def __init__(self, raw_data):
        __data = {}
        __data["dfu_type"], = struct.unpack("<B", raw_data[0:1])
        __data["fwid"] = raw_data[1:11]
        __data["is_signed"], = struct.unpack("<B", raw_data[11:12])
        __data["start_addr"], = struct.unpack("<I", raw_data[12:16])
        __data["length"], = struct.unpack("<I", raw_data[16:20])
        super(BankInfoGetRsp, self).__init__("BankInfoGet", 0xD4, __data)


class StateGetRsp(ResponsePacket):
    """Response to a(n) StateGet command."""
    def __init__(self, raw_data):
        __data = {}
        __data["role"], = struct.unpack("<B", raw_data[0:1])
        __data["type"], = struct.unpack("<B", raw_data[1:2])
        __data["fwid"] = raw_data[2:12]
        __data["state"], = struct.unpack("<B", raw_data[12:13])
        __data["data_progress"], = struct.unpack("<B", raw_data[13:14])
        super(StateGetRsp, self).__init__("StateGet", 0xD6, __data)


class ModelPubAddrGetRsp(ResponsePacket):
    """Response to a(n) ModelPubAddrGet command."""
    def __init__(self, raw_data):
        __data = {}
        __data["addr_handle"], = struct.unpack("<H", raw_data[0:2])
        super(ModelPubAddrGetRsp, self).__init__("ModelPubAddrGet", 0xE1, __data)


class ModelPubPeriodGetRsp(ResponsePacket):
    """Response to a(n) ModelPubPeriodGet command."""
    def __init__(self, raw_data):
        __data = {}
        __data["resolution"], = struct.unpack("<B", raw_data[0:1])
        __data["step_number"], = struct.unpack("<B", raw_data[1:2])
        super(ModelPubPeriodGetRsp, self).__init__("ModelPubPeriodGet", 0xE3, __data)


class ModelSubsGetRsp(ResponsePacket):
    """Response to a(n) ModelSubsGet command."""
    def __init__(self, raw_data):
        __data = {}
        __data["count"], = struct.unpack("<H", raw_data[0:2])
        __data["address_handles"] = raw_data[2:252]
        super(ModelSubsGetRsp, self).__init__("ModelSubsGet", 0xE6, __data)


class ModelAppGetRsp(ResponsePacket):
    """Response to a(n) ModelAppGet command."""
    def __init__(self, raw_data):
        __data = {}
        __data["count"], = struct.unpack("<H", raw_data[0:2])
        __data["appkey_handles"] = raw_data[2:252]
        super(ModelAppGetRsp, self).__init__("ModelAppGet", 0xE9, __data)


class ModelPubAppGetRsp(ResponsePacket):
    """Response to a(n) ModelPubAppGet command."""
    def __init__(self, raw_data):
        __data = {}
        __data["appkey_handle"], = struct.unpack("<H", raw_data[0:2])
        super(ModelPubAppGetRsp, self).__init__("ModelPubAppGet", 0xEB, __data)


class ModelPubTtlGetRsp(ResponsePacket):
    """Response to a(n) ModelPubTtlGet command."""
    def __init__(self, raw_data):
        __data = {}
        __data["ttl"], = struct.unpack("<B", raw_data[0:1])
        super(ModelPubTtlGetRsp, self).__init__("ModelPubTtlGet", 0xED, __data)


class ElemLocGetRsp(ResponsePacket):
    """Response to a(n) ElemLocGet command."""
    def __init__(self, raw_data):
        __data = {}
        __data["location"], = struct.unpack("<H", raw_data[0:2])
        super(ElemLocGetRsp, self).__init__("ElemLocGet", 0xEF, __data)


class ElemSigModelCountGetRsp(ResponsePacket):
    """Response to a(n) ElemSigModelCountGet command."""
    def __init__(self, raw_data):
        __data = {}
        __data["model_count"], = struct.unpack("<B", raw_data[0:1])
        super(ElemSigModelCountGetRsp, self).__init__("ElemSigModelCountGet", 0xF0, __data)


class ElemVendorModelCountGetRsp(ResponsePacket):
    """Response to a(n) ElemVendorModelCountGet command."""
    def __init__(self, raw_data):
        __data = {}
        __data["model_count"], = struct.unpack("<B", raw_data[0:1])
        super(ElemVendorModelCountGetRsp, self).__init__("ElemVendorModelCountGet", 0xF1, __data)


class ModelIdGetRsp(ResponsePacket):
    """Response to a(n) ModelIdGet command."""
    def __init__(self, raw_data):
        __data = {}
        __data["model_id"], = struct.unpack("<I", raw_data[0:4])
        super(ModelIdGetRsp, self).__init__("ModelIdGet", 0xF2, __data)


class HandleGetRsp(ResponsePacket):
    """Response to a(n) HandleGet command."""
    def __init__(self, raw_data):
        __data = {}
        __data["model_handle"], = struct.unpack("<H", raw_data[0:2])
        super(HandleGetRsp, self).__init__("HandleGet", 0xF3, __data)


class ElemModelsGetRsp(ResponsePacket):
    """Response to a(n) ElemModelsGet command."""
    def __init__(self, raw_data):
        __data = {}
        __data["count"], = struct.unpack("<H", raw_data[0:2])
        __data["model_handles"] = raw_data[2:252]
        super(ElemModelsGetRsp, self).__init__("ElemModelsGet", 0xF4, __data)


class ModelsGetRsp(ResponsePacket):
    """Response to a(n) ModelsGet command."""
    def __init__(self, raw_data):
        __data = {}
        __data["count"], = struct.unpack("<H", raw_data[0:2])
        __data["model_ids"] = raw_data[2:250]
        super(ModelsGetRsp, self).__init__("ModelsGet", 0xFC, __data)


class InitRsp(ResponsePacket):
    """Response to a(n) Init command."""
    def __init__(self, raw_data):
        __data = {}
        __data["model_handle"], = struct.unpack("<H", raw_data[0:2])
        super(InitRsp, self).__init__("Init", 0xFD, __data)


class CommandRsp(ResponsePacket):
    """Response to a(n) Command command."""
    def __init__(self, raw_data):
        __data = {}
        __data["data_len"], = struct.unpack("<B", raw_data[0:1])
        __data["data"] = raw_data[1:]
        super(CommandRsp, self).__init__("Command", 0xFE, __data)


RESPONSE_LUT = {
    0x02: {"object": EchoRsp, "name": "Echo"},
    0x09: {"object": SerialVersionGetRsp, "name": "SerialVersionGet"},
    0x0A: {"object": FwInfoGetRsp, "name": "FwInfoGet"},
    0x13: {"object": BeaconParamsGetRsp, "name": "BeaconParamsGet"},
    0x14: {"object": HousekeepingDataGetRsp, "name": "HousekeepingDataGet"},
    0x41: {"object": AdvAddrGetRsp, "name": "AdvAddrGet"},
    0x45: {"object": TxPowerGetRsp, "name": "TxPowerGet"},
    0x54: {"object": UuidGetRsp, "name": "UuidGet"},
    0x63: {"object": ProvisionRsp, "name": "Provision"},
    0x66: {"object": OobUseRsp, "name": "OobUse"},
    0x67: {"object": AuthDataRsp, "name": "AuthData"},
    0x68: {"object": EcdhSecretRsp, "name": "EcdhSecret"},
    0x92: {"object": SubnetAddRsp, "name": "SubnetAdd"},
    0x93: {"object": SubnetUpdateRsp, "name": "SubnetUpdate"},
    0x94: {"object": SubnetDeleteRsp, "name": "SubnetDelete"},
    0x95: {"object": SubnetGetAllRsp, "name": "SubnetGetAll"},
    0x96: {"object": SubnetCountMaxGetRsp, "name": "SubnetCountMaxGet"},
    0x97: {"object": AppkeyAddRsp, "name": "AppkeyAdd"},
    0x98: {"object": AppkeyUpdateRsp, "name": "AppkeyUpdate"},
    0x99: {"object": AppkeyDeleteRsp, "name": "AppkeyDelete"},
    0x9A: {"object": AppkeyGetAllRsp, "name": "AppkeyGetAll"},
    0x9B: {"object": AppkeyCountMaxGetRsp, "name": "AppkeyCountMaxGet"},
    0x9C: {"object": DevkeyAddRsp, "name": "DevkeyAdd"},
    0x9D: {"object": DevkeyDeleteRsp, "name": "DevkeyDelete"},
    0x9E: {"object": DevkeyCountMaxGetRsp, "name": "DevkeyCountMaxGet"},
    0xA0: {"object": AddrLocalUnicastGetRsp, "name": "AddrLocalUnicastGet"},
    0xA7: {"object": AddrGetRsp, "name": "AddrGet"},
    0xA8: {"object": AddrGetAllRsp, "name": "AddrGetAll"},
    0xA9: {"object": AddrNonvirtualCountMaxGetRsp, "name": "AddrNonvirtualCountMaxGet"},
    0xAA: {"object": AddrVirtualCountMaxGetRsp, "name": "AddrVirtualCountMaxGet"},
    0xA1: {"object": AddrSubscriptionAddRsp, "name": "AddrSubscriptionAdd"},
    0xA2: {"object": AddrSubscriptionAddVirtualRsp, "name": "AddrSubscriptionAddVirtual"},
    0xA3: {"object": AddrSubscriptionRemoveRsp, "name": "AddrSubscriptionRemove"},
    0xA4: {"object": AddrPublicationAddRsp, "name": "AddrPublicationAdd"},
    0xA5: {"object": AddrPublicationAddVirtualRsp, "name": "AddrPublicationAddVirtual"},
    0xA6: {"object": AddrPublicationRemoveRsp, "name": "AddrPublicationRemove"},
    0xAB: {"object": PacketSendRsp, "name": "PacketSend"},
    0xAF: {"object": NetStateGetRsp, "name": "NetStateGet"},
    0xD4: {"object": BankInfoGetRsp, "name": "BankInfoGet"},
    0xD6: {"object": StateGetRsp, "name": "StateGet"},
    0xE1: {"object": ModelPubAddrGetRsp, "name": "ModelPubAddrGet"},
    0xE3: {"object": ModelPubPeriodGetRsp, "name": "ModelPubPeriodGet"},
    0xE6: {"object": ModelSubsGetRsp, "name": "ModelSubsGet"},
    0xE9: {"object": ModelAppGetRsp, "name": "ModelAppGet"},
    0xEB: {"object": ModelPubAppGetRsp, "name": "ModelPubAppGet"},
    0xED: {"object": ModelPubTtlGetRsp, "name": "ModelPubTtlGet"},
    0xEF: {"object": ElemLocGetRsp, "name": "ElemLocGet"},
    0xF0: {"object": ElemSigModelCountGetRsp, "name": "ElemSigModelCountGet"},
    0xF1: {"object": ElemVendorModelCountGetRsp, "name": "ElemVendorModelCountGet"},
    0xF2: {"object": ModelIdGetRsp, "name": "ModelIdGet"},
    0xF3: {"object": HandleGetRsp, "name": "HandleGet"},
    0xF4: {"object": ElemModelsGetRsp, "name": "ElemModelsGet"},
    0xFC: {"object": ModelsGetRsp, "name": "ModelsGet"},
    0xFD: {"object": InitRsp, "name": "Init"},
    0xFE: {"object": CommandRsp, "name": "Command"}
}


def response_deserialize(rsp):
    if not isinstance(rsp, CmdRsp):
        raise TypeError("Expected a CmdRsp object.")
    elif not rsp._data["opcode"] in RESPONSE_LUT:
        return None

    response = RESPONSE_LUT[rsp._data["opcode"]]
    # Response is always {opcode, status, [...]}
    if len(rsp._data["data"]) > 0:
        return response["object"](rsp._data["data"])
    else:
        return response["name"]
