Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_list():
expected = list(map(ord, "\x0123"))
assert t.List(t.uint8_t).deserialize(b"\x0123") == (expected, b"")
_fields = [
('direction', t.uint8_t),
('attrid', t.uint16_t),
]
class DiscoverAttributesResponseRecord(t.EzspStruct):
_fields = [
('attrid', t.uint16_t),
('datatype', t.uint8_t),
]
COMMANDS = {
# id: (name, params, is_response)
0x00: ('Read attributes', (t.List(t.uint16_t), ), False),
0x01: ('Read attributes response', (t.List(ReadAttributeRecord), ), True),
0x02: ('Write attributes', (t.List(Attribute), ), False),
0x03: ('Write attributes undivided', (t.List(Attribute), ), False),
0x04: ('Write attributes response', (t.List(WriteAttributesStatusRecord), ), True),
0x05: ('Write attributes no response', (t.List(Attribute), ), False),
0x06: ('Configure reporting', (t.List(AttributeReportingConfig), ), False),
0x07: ('Configure reporting response', (t.List(ConfigureReportingResponseRecord), ), True),
0x08: ('Read reporting configuration', (t.List(ReadReportingConfigRecord), ), False),
0x09: ('Read reporting configuration response', (t.List(AttributeReportingConfig), ), True),
0x0a: ('Report attributes', (t.List(Attribute), ), False),
0x0b: ('Default response', (t.uint8_t, Status), True),
0x0c: ('Discover attributes', (t.uint16_t, t.uint8_t), False),
0x0d: ('Discover attributes response', (t.List(DiscoverAttributesResponseRecord), ), True),
# 0x0e: ('Read attributes structured', (, ), False),
('direction', t.uint8_t),
('attrid', t.uint16_t),
]
class DiscoverAttributesResponseRecord(t.EzspStruct):
_fields = [
('attrid', t.uint16_t),
('datatype', t.uint8_t),
]
COMMANDS = {
# id: (name, params, is_response)
0x00: ('Read attributes', (t.List(t.uint16_t), ), False),
0x01: ('Read attributes response', (t.List(ReadAttributeRecord), ), True),
0x02: ('Write attributes', (t.List(Attribute), ), False),
0x03: ('Write attributes undivided', (t.List(Attribute), ), False),
0x04: ('Write attributes response', (t.List(WriteAttributesStatusRecord), ), True),
0x05: ('Write attributes no response', (t.List(Attribute), ), False),
0x06: ('Configure reporting', (t.List(AttributeReportingConfig), ), False),
0x07: ('Configure reporting response', (t.List(ConfigureReportingResponseRecord), ), True),
0x08: ('Read reporting configuration', (t.List(ReadReportingConfigRecord), ), False),
0x09: ('Read reporting configuration response', (t.List(AttributeReportingConfig), ), True),
0x0a: ('Report attributes', (t.List(Attribute), ), False),
0x0b: ('Default response', (t.uint8_t, Status), True),
0x0c: ('Discover attributes', (t.uint16_t, t.uint8_t), False),
0x0d: ('Discover attributes response', (t.List(DiscoverAttributesResponseRecord), ), True),
# 0x0e: ('Read attributes structured', (, ), False),
_fields = [
('attrid', t.uint16_t),
('datatype', t.uint8_t),
]
COMMANDS = {
# id: (name, params, is_response)
0x00: ('Read attributes', (t.List(t.uint16_t), ), False),
0x01: ('Read attributes response', (t.List(ReadAttributeRecord), ), True),
0x02: ('Write attributes', (t.List(Attribute), ), False),
0x03: ('Write attributes undivided', (t.List(Attribute), ), False),
0x04: ('Write attributes response', (t.List(WriteAttributesStatusRecord), ), True),
0x05: ('Write attributes no response', (t.List(Attribute), ), False),
0x06: ('Configure reporting', (t.List(AttributeReportingConfig), ), False),
0x07: ('Configure reporting response', (t.List(ConfigureReportingResponseRecord), ), True),
0x08: ('Read reporting configuration', (t.List(ReadReportingConfigRecord), ), False),
0x09: ('Read reporting configuration response', (t.List(AttributeReportingConfig), ), True),
0x0a: ('Report attributes', (t.List(Attribute), ), False),
0x0b: ('Default response', (t.uint8_t, Status), True),
0x0c: ('Discover attributes', (t.uint16_t, t.uint8_t), False),
0x0d: ('Discover attributes response', (t.List(DiscoverAttributesResponseRecord), ), True),
# 0x0e: ('Read attributes structured', (, ), False),
COMMANDS = {
# id: (name, params, is_response)
0x00: ('Read attributes', (t.List(t.uint16_t), ), False),
0x01: ('Read attributes response', (t.List(ReadAttributeRecord), ), True),
0x02: ('Write attributes', (t.List(Attribute), ), False),
0x03: ('Write attributes undivided', (t.List(Attribute), ), False),
0x04: ('Write attributes response', (t.List(WriteAttributesStatusRecord), ), True),
0x05: ('Write attributes no response', (t.List(Attribute), ), False),
0x06: ('Configure reporting', (t.List(AttributeReportingConfig), ), False),
0x07: ('Configure reporting response', (t.List(ConfigureReportingResponseRecord), ), True),
0x08: ('Read reporting configuration', (t.List(ReadReportingConfigRecord), ), False),
0x09: ('Read reporting configuration response', (t.List(AttributeReportingConfig), ), True),
0x0a: ('Report attributes', (t.List(Attribute), ), False),
0x0b: ('Default response', (t.uint8_t, Status), True),
0x0c: ('Discover attributes', (t.uint16_t, t.uint8_t), False),
0x0d: ('Discover attributes response', (t.List(DiscoverAttributesResponseRecord), ), True),
# 0x0e: ('Read attributes structured', (, ), False),
0x0051: ('out_of_service', t.Bool),
0x0055: ('present_value', t.Single),
# 0x0057: ('priority_array', TODO.array), # Array of 16 structures of (boolean, single precision)
0x0067: ('reliability', t.uint8_t), # enum8
0x006f: ('status_flags', t.uint8_t), # bitmap8
0x0100: ('application_type', t.uint32_t),
}
server_commands = {}
client_commands = {}
class MultistateOutput(Cluster):
cluster_id = 0x0013
ep_attribute = 'multistate_output'
attributes = {
0x000e: ('state_text', t.List(t.LVBytes)),
0x001c: ('description', t.LVBytes),
0x004a: ('number_of_states', t.uint16_t),
0x0051: ('out_of_service', t.Bool),
0x0055: ('present_value', t.Single),
# 0x0057: ('priority_array', TODO.array), # Array of 16 structures of (boolean, single precision)
0x0067: ('reliability', t.uint8_t), # enum8
0x0068: ('relinquish_default', t.Single),
0x006f: ('status_flags', t.uint8_t), # bitmap8
0x0100: ('application_type', t.uint32_t),
}
server_commands = {}
client_commands = {}
class MultistateValue(Cluster):
cluster_id = 0x0014
]
COMMANDS = {
# id: (name, params, is_response)
0x00: ('Read attributes', (t.List(t.uint16_t), ), False),
0x01: ('Read attributes response', (t.List(ReadAttributeRecord), ), True),
0x02: ('Write attributes', (t.List(Attribute), ), False),
0x03: ('Write attributes undivided', (t.List(Attribute), ), False),
0x04: ('Write attributes response', (t.List(WriteAttributesStatusRecord), ), True),
0x05: ('Write attributes no response', (t.List(Attribute), ), False),
0x06: ('Configure reporting', (t.List(AttributeReportingConfig), ), False),
0x07: ('Configure reporting response', (t.List(ConfigureReportingResponseRecord), ), True),
0x08: ('Read reporting configuration', (t.List(ReadReportingConfigRecord), ), False),
0x09: ('Read reporting configuration response', (t.List(AttributeReportingConfig), ), True),
0x0a: ('Report attributes', (t.List(Attribute), ), False),
0x0b: ('Default response', (t.uint8_t, Status), True),
0x0c: ('Discover attributes', (t.uint16_t, t.uint8_t), False),
0x0d: ('Discover attributes response', (t.List(DiscoverAttributesResponseRecord), ), True),
# 0x0e: ('Read attributes structured', (, ), False),
0x8005: ('Active_EP_rsp', (STATUS, NWKI, ('ActiveEPList', t.LVList(t.uint8_t)))),
0x8006: ('Match_Desc_rsp', (STATUS, NWKI, ('MatchList', t.LVList(t.uint8_t)))),
# 0x8010: ('Complex_Desc_rsp', (STATUS, NWKI, ('Length', t.uint8_t), ('ComplexDescriptor', ComplexDescriptor))),
0x8011: ('User_Desc_rsp', (STATUS, NWKI, ('Length', t.uint8_t), ('UserDescriptor', t.fixed_list(16, t.uint8_t)))),
0x8012: ('Discovery_Cache_rsp', (STATUS, )),
0x8014: ('User_Desc_conf', (STATUS, NWKI)),
0x8015: ('System_Server_Discovery_rsp', (STATUS, ('ServerMask', t.uint16_t))),
0x8016: ('Discovery_Store_rsp', (STATUS, )),
0x8017: ('Node_Desc_store_rsp', (STATUS, )),
0x8018: ('Power_Desc_store_rsp', (STATUS, IEEE, ('PowerDescriptor', PowerDescriptor))),
0x8019: ('Active_EP_store_rsp', (STATUS, )),
0x801a: ('Simple_Desc_store_rsp', (STATUS, )),
0x801b: ('Remove_node_cache_rsp', (STATUS, )),
0x801c: ('Find_node_cache_rsp', (('CacheNWKAddr', t.EmberEUI64), NWK, IEEE)),
0x801d: ('Extended_Simple_Desc_rsp', (STATUS, NWK, ('Endpoint', t.uint8_t), ('AppInputClusterCount', t.uint8_t), ('AppOutputClusterCount', t.uint8_t), ('StartIndex', t.uint8_t), ('AppClusterList', t.List(t.uint16_t)))),
0x801e: ('Extended_Active_EP_rsp', (STATUS, NWKI, ('ActiveEPCount', t.uint8_t), ('StartIndex', t.uint8_t), ('ActiveEPList', t.List(t.uint8_t)))),
# Bind Management Server Services Responses
0x8020: ('End_Device_Bind_rsp', (STATUS, )),
0x8021: ('Bind_rsp', (STATUS, )),
0x8022: ('Unbind_rsp', (STATUS, )),
# ... TODO optional stuff ...
# Network Management Server Services Responses
# ... TODO optional stuff ...
0x8034: ('Mgmt_Leave_rsp', (STATUS, )),
0x8036: ('Mgmt_Permit_Joining_rsp', (STATUS, )),
# ... TODO optional stuff ...
}
# Rewrite to (name, param_names, param_types)
for command_id, c in CLUSTERS.items():
param_names = [p[0] for p in c[1]]
class DiscoverAttributesResponseRecord(t.EzspStruct):
_fields = [
('attrid', t.uint16_t),
('datatype', t.uint8_t),
]
COMMANDS = {
# id: (name, params, is_response)
0x00: ('Read attributes', (t.List(t.uint16_t), ), False),
0x01: ('Read attributes response', (t.List(ReadAttributeRecord), ), True),
0x02: ('Write attributes', (t.List(Attribute), ), False),
0x03: ('Write attributes undivided', (t.List(Attribute), ), False),
0x04: ('Write attributes response', (t.List(WriteAttributesStatusRecord), ), True),
0x05: ('Write attributes no response', (t.List(Attribute), ), False),
0x06: ('Configure reporting', (t.List(AttributeReportingConfig), ), False),
0x07: ('Configure reporting response', (t.List(ConfigureReportingResponseRecord), ), True),
0x08: ('Read reporting configuration', (t.List(ReadReportingConfigRecord), ), False),
0x09: ('Read reporting configuration response', (t.List(AttributeReportingConfig), ), True),
0x0a: ('Report attributes', (t.List(Attribute), ), False),
0x0b: ('Default response', (t.uint8_t, Status), True),
0x0c: ('Discover attributes', (t.uint16_t, t.uint8_t), False),
0x0d: ('Discover attributes response', (t.List(DiscoverAttributesResponseRecord), ), True),
# 0x0e: ('Read attributes structured', (, ), False),