How to use the bellows.types.fixed_list function in bellows

To help you get started, we’ve selected a few bellows examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zigpy / bellows / bellows / cli / network.py View on Github external
pan_id = network.panId
        extended_pan_id = network.extendedPanId
        channel = network.channel

        click.echo(
            "Found network %s %s on channel %s" % (pan_id, extended_pan_id, channel)
        )

    if pan_id is None:
        pan_id = t.uint16_t(0)
    else:
        pan_id = t.uint16_t(pan_id)
    if isinstance(extended_pan_id, str):
        extended_pan_id = util.parse_epan(extended_pan_id)
    if extended_pan_id is None:
        extended_pan_id = t.fixed_list(8, t.uint8_t)([t.uint8_t(0)] * 8)

    v = await util.network_init(s)

    if v[0] == t.EmberStatus.SUCCESS:
        LOGGER.debug("Network was up, leaving...")
        v = await s.leaveNetwork()
        util.check(v[0], "Failure leaving network: %s" % (v[0],))
        await asyncio.sleep(1)  # TODO

    initial_security_state = zutil.zha_security()
    v = await s.setInitialSecurityState(initial_security_state)
    util.check(v[0], "Setting security state failed: %s" % (v[0],))

    parameters = t.EmberNetworkParameters()
    parameters.extendedPanId = extended_pan_id
    parameters.panId = pan_id
github zigpy / bellows / bellows / cli / util.py View on Github external
def parse_epan(epan):
    """Parse a user specified extended PAN ID"""
    epan_list = [t.uint8_t(x, 16) for x in epan.split(":")]
    return t.fixed_list(8, t.uint8_t)(epan_list)
github zigpy / bellows / bellows / zigbee / zcl / foundation.py View on Github external
class Analog:
    pass


class Discrete:
    pass


DATA_TYPES = {
    0x00: ('No data', None, None),
    0x08: ('General', t.fixed_list(1, t.uint8_t), Discrete),
    0x09: ('General', t.fixed_list(2, t.uint8_t), Discrete),
    0x0a: ('General', t.fixed_list(3, t.uint8_t), Discrete),
    0x0b: ('General', t.fixed_list(4, t.uint8_t), Discrete),
    0x0c: ('General', t.fixed_list(5, t.uint8_t), Discrete),
    0x0d: ('General', t.fixed_list(6, t.uint8_t), Discrete),
    0x0e: ('General', t.fixed_list(7, t.uint8_t), Discrete),
    0x0f: ('General', t.fixed_list(8, t.uint8_t), Discrete),
    0x10: ('Boolean', t.Bool, Discrete),
    0x18: ('Bitmap', t.uint8_t, Discrete),
    0x19: ('Bitmap', t.uint16_t, Discrete),
    0x1a: ('Bitmap', t.uint24_t, Discrete),
    0x1b: ('Bitmap', t.uint32_t, Discrete),
    0x1c: ('Bitmap', t.uint40_t, Discrete),
    0x1d: ('Bitmap', t.uint48_t, Discrete),
    0x1e: ('Bitmap', t.uint56_t, Discrete),
    0x1f: ('Bitmap', t.uint64_t, Discrete),
    0x20: ('Unsigned Integer', t.uint8_t, Analog),
    0x21: ('Unsigned Integer', t.uint16_t, Analog),
    0x22: ('Unsigned Integer', t.uint24_t, Analog),
github zigpy / bellows / bellows / zigbee / zcl / clusters / protocol.py View on Github external
0x0023: ('event_enable', t.uint8_t),  # bitmap8
        0x0024: ('event_state', t.uint8_t),  # enum8
        0x0048: ('notify_type', t.uint8_t),  # enum8
        0x0071: ('time_delay', t.uint8_t),
        # 0x0082: ('event_time_stamps', TODO.array),  # Array[3] of (16-bit unsigned integer, time of day, or structure of (date, time of day))
    }
    server_commands = {}
    client_commands = {}


class MultistateInputRegular(Cluster):
    cluster_id = 0x060e
    ep_attribute = 'bacnet_regular_multistate_input'
    attributes = {
        0x001f: ('device_type', t.LVBytes),
        0x004b: ('object_id', t.fixed_list(4, t.uint8_t)),
        0x004d: ('object_name', t.LVBytes),
        0x004f: ('object_type', t.uint16_t),  # enum16
        0x00a8: ('profile_name', t.LVBytes),
    }
    server_commands = {}
    client_commands = {}


class MultistateInputExtended(Cluster):
    cluster_id = 0x060f
    ep_attribute = 'bacnet_extended_multistate_input'
    attributes = {
        0x0000: ('acked_transitions', t.uint8_t),  # bitmap8
        0x0006: ('alarm_value', t.uint16_t),
        0x0011: ('notification_class', t.uint16_t),
        0x0023: ('event_enable', t.uint8_t),  # bitmap8
github zigpy / bellows / bellows / zigbee / zcl / clusters / general.py View on Github external
"""Attributes and commands for commissioning and
    managing a ZigBee device."""
    cluster_id = 0x0015
    ep_attribute = 'commissioning'
    attributes = {
        # Startup Parameters
        0x0000: ('short_address', t.uint16_t),
        0x0001: ('extended_pan_id', t.EmberEUI64),
        0x0002: ('pan_id', t.uint16_t),
        0x0003: ('channelmask', t.uint32_t),  # bitmap32
        0x0004: ('protocol_version', t.uint8_t),
        0x0005: ('stack_profile', t.uint8_t),
        0x0006: ('startup_control', t.uint8_t),  # enum8
        0x0010: ('trust_center_address', t.EmberEUI64),
        0x0011: ('trust_center_master_key', t.fixed_list(16, t.uint8_t)),
        0x0012: ('network_key', t.fixed_list(16, t.uint8_t)),
        0x0013: ('use_insecure_join', t.Bool),
        0x0014: ('preconfigured_link_key', t.fixed_list(16, t.uint8_t)),
        0x0015: ('network_key_seq_num', t.uint8_t),
        0x0016: ('network_key_type', t.uint8_t),  # enum8
        0x0017: ('network_manager_address', t.uint16_t),
        # Join Parameters
        0x0020: ('scan_attempts', t.uint8_t),
        0x0021: ('time_between_scans', t.uint16_t),
        0x0022: ('rejoin_interval', t.uint16_t),
        0x0023: ('max_rejoin_interval', t.uint16_t),
        # End Device Parameters
        0x0030: ('indirect_poll_rate', t.uint16_t),
        0x0031: ('parent_retry_threshold', t.uint8_t),
        # Concentrator Parameters
        0x0040: ('concentrator_flag', t.Bool),
        0x0041: ('concentrator_radius', t.uint8_t),
github zigpy / bellows / bellows / zigbee / zcl / foundation.py View on Github external
CALIBRATION_ERROR = 0xc2  # An error occurred during calibratio
    UNSUPPORTED_CLUSTER = 0xc3  # The cluster is not supported


class Analog:
    pass


class Discrete:
    pass


DATA_TYPES = {
    0x00: ('No data', None, None),
    0x08: ('General', t.fixed_list(1, t.uint8_t), Discrete),
    0x09: ('General', t.fixed_list(2, t.uint8_t), Discrete),
    0x0a: ('General', t.fixed_list(3, t.uint8_t), Discrete),
    0x0b: ('General', t.fixed_list(4, t.uint8_t), Discrete),
    0x0c: ('General', t.fixed_list(5, t.uint8_t), Discrete),
    0x0d: ('General', t.fixed_list(6, t.uint8_t), Discrete),
    0x0e: ('General', t.fixed_list(7, t.uint8_t), Discrete),
    0x0f: ('General', t.fixed_list(8, t.uint8_t), Discrete),
    0x10: ('Boolean', t.Bool, Discrete),
    0x18: ('Bitmap', t.uint8_t, Discrete),
    0x19: ('Bitmap', t.uint16_t, Discrete),
    0x1a: ('Bitmap', t.uint24_t, Discrete),
    0x1b: ('Bitmap', t.uint32_t, Discrete),
    0x1c: ('Bitmap', t.uint40_t, Discrete),
    0x1d: ('Bitmap', t.uint48_t, Discrete),
    0x1e: ('Bitmap', t.uint56_t, Discrete),
    0x1f: ('Bitmap', t.uint64_t, Discrete),
    0x20: ('Unsigned Integer', t.uint8_t, Analog),
github zigpy / bellows / bellows / commands.py View on Github external
"launchStandaloneBootloader": (0x8F, (t.uint8_t,), (t.EmberStatus,)),
    "sendBootloadMessage": (0x90, (t.Bool, t.EmberEUI64, t.LVBytes), (t.EmberStatus,)),
    "getStandaloneBootloaderVersionPlatMicroPhy": (
        0x91,
        (),
        (t.uint16_t, t.uint8_t, t.uint8_t, t.uint8_t),
    ),
    "incomingBootloadMessageHandler": (
        0x92,
        (),
        (t.EmberEUI64, t.uint8_t, t.int8s, t.LVBytes),
    ),
    "bootloadTransmitCompleteHandler": (0x93, (), (t.EmberStatus, t.LVBytes)),
    "aesEncrypt": (
        0x94,
        (t.fixed_list(16, t.uint8_t), t.fixed_list(16, t.uint8_t)),
        (t.fixed_list(16, t.uint8_t),),
    ),
    "overrideCurrentChannel": (0x95, (t.uint8_t,), (t.EmberStatus,)),
    # 14. ZLL Frames
    "zllNetworkOps": (
        0xB2,
        (t.EmberZllNetwork, t.EzspZllNetworkOperation, t.int8s),
        (t.EmberStatus,),
    ),
    "zllSetInitialSecurityState": (
        0xB3,
        (t.EmberKeyData, t.EmberZllInitialSecurityState),
        (t.EmberStatus,),
    ),
    "zllStartScan": (0xB4, (t.uint32_t, t.int8s, t.EmberNodeType), (t.EmberStatus,)),
    "zllSetRxOnWhenIdle": (0xB5, (t.uint16_t,), (t.EmberStatus,)),
github zigpy / bellows / bellows / zigbee / util.py View on Github external
isc.bitmask = t.uint16_t(
        t.EmberInitialSecurityBitmask.HAVE_PRECONFIGURED_KEY
        | t.EmberInitialSecurityBitmask.REQUIRE_ENCRYPTED_KEY
    )
    isc.preconfiguredKey = zha_key
    isc.networkKey = empty_key_data
    isc.networkKeySequenceNumber = t.uint8_t(0)
    isc.preconfiguredTrustCenterEui64 = t.EmberEUI64([t.uint8_t(0)] * 8)

    if controller:
        isc.bitmask |= (
            t.EmberInitialSecurityBitmask.TRUST_CENTER_GLOBAL_LINK_KEY
            | t.EmberInitialSecurityBitmask.HAVE_NETWORK_KEY
        )
        isc.bitmask = t.uint16_t(isc.bitmask)
        random_key = t.fixed_list(16, t.uint8_t)([t.uint8_t(x) for x in os.urandom(16)])
        isc.networkKey = random_key
    return isc