# "sensor_setting_property_id" / Int16ul, # *FastCadencePeriodDivisorAndTriggerType, # Embedded(TriggerDelta), # "status_min_interval" / ExprAdapter(Int16ul, lambda obj, ctx: pow(2, obj), lambda obj, ctx: log(obj, 2)), # "fast_cadence_low" / PropertyValue, # "fast_cadence_high" / PropertyValue # ) SensorMessage = SwitchStruct( "opcode" / Opcode(SensorOpcode), "params" / Switch( this.opcode, { SensorOpcode.SENSOR_DESCRIPTOR_GET: SensorGet, SensorOpcode.SENSOR_DESCRIPTOR_STATUS: SensorDescriptorStatus, SensorOpcode.SENSOR_GET: SensorGet, SensorOpcode.SENSOR_STATUS: SensorStatus, # SensorOpcode.SENSOR_COLUMN_GET: SensorColumnGet, # SensorOpcode.SENSOR_COLUMN_STATUS: 0x00, # SensorOpcode.SENSOR_SERIES_GET: SensorSeriesGet, # SensorOpcode.SENSOR_SERIES_STATUS: 0x00, } ) ) SensorSetupMessage = SwitchStruct( "opcode" / Opcode(SensorSetupOpcode), "params" / Switch( this.opcode, { SensorSetupOpcode.SENSOR_CADENCE_GET: SensorGetOptional, # SensorSetupOpcode.SENSOR_CADENCE_SET: SensorCadence,
"connection_state" / ConnectionState, ) GatewayConfigParams = SwitchStruct( "subopcode" / EnumAdapter(Int8ul, GatewayConfigServerSubOpcode), "payload" / Switch( this.subopcode, { GatewayConfigServerSubOpcode.GATEWAY_CONFIGURATION_SET: ConfigurationSet, GatewayConfigServerSubOpcode.MTU_SIZE_SET: ConfigurationSetMtu, GatewayConfigServerSubOpcode.ETHERNET_MAC_ADDRESS_SET: ConfigurationSetMacAddr, GatewayConfigServerSubOpcode.SERVER_ADDRESS_AND_PORT_NUMBER_SET: ConfigurationSetServerAddrAndPortNr, GatewayConfigServerSubOpcode.RECONNECT_INTERVAL_SET: ConfigurationSetReconnectInterval, GatewayConfigServerSubOpcode.DNS_IP_ADDRESS_SET: ConfigurationSetDnsIpAddr, GatewayConfigServerSubOpcode.IP_ADDRESS_SET: ConfigurationSetIpAddr, GatewayConfigServerSubOpcode.GATEWAY_IP_ADDRESS_SET: ConfigurationSetGatewayIpAddr, GatewayConfigServerSubOpcode.NETMASK_SET: ConfigurationSetNetmask, GatewayConfigServerSubOpcode.GATEWAY_CONFIGURATION_STATUS: ConfigurationStatus, GatewayConfigServerSubOpcode.GATEWAY_PACKETS_STATUS: PacketsStatus, }, )) GatewayConfigMessage = SwitchStruct( "opcode" / Opcode(GatewayConfigServerOpcode), "params" /
) LightCTLRangeStatus = Struct("status" / StatusCodeAdapter, Embedded(LightCTLRange)) LightCTLMessage = SwitchStruct( "opcode" / Opcode(LightCTLOpcode), "params" / Switch( this.opcode, { LightCTLOpcode.LIGHT_CTL_GET: LightCTLGet, LightCTLOpcode.LIGHT_CTL_SET: LightCTLSet, LightCTLOpcode.LIGHT_CTL_SET_UNACKNOWLEDGED: LightCTLSet, LightCTLOpcode.LIGHT_CTL_STATUS: LightCTLStatus, LightCTLOpcode.LIGHT_CTL_TEMPERATURE_GET: LightCTLGet, LightCTLOpcode.LIGHT_CTL_TEMPERATURE_RANGE_GET: LightCTLGet, LightCTLOpcode.LIGHT_CTL_TEMPERATURE_RANGE_STATUS: LightCTLRangeStatus, LightCTLOpcode.LIGHT_CTL_TEMPERATURE_SET: LightCTLTemperatureSet, LightCTLOpcode.LIGHT_CTL_TEMPERATURE_SET_UNACKNOWLEDGED: LightCTLTemperatureSet, LightCTLOpcode.LIGHT_CTL_TEMPERATURE_STATUS: LightCTLTemperatureStatus, LightCTLOpcode.LIGHT_CTL_TEMPERATURE_DEFAULT_GET: LightCTLGet, LightCTLOpcode.LIGHT_CTL_TEMPERATURE_DEFAULT_STATUS: LightCTLDefault, }, )) LightCTLSetupMessage = SwitchStruct( "opcode" / Opcode(LightCTLSetupOpcode), "params" / Switch( this.opcode, {
TWO_HUNDRED_AND_FIFTY_FIFTH = 255 CompositionDataPageAdapter = EnumAdapter(Int8ul, CompositionDataPage) ConfigCompositionDataGet = Struct("page" / CompositionDataPageAdapter, ) ConfigCompositionData = Switch( this.page, { CompositionDataPage.ZERO: CompositionData, CompositionDataPage.FIRST: GreedyBytes, CompositionDataPage.TWO_HUNDRED_AND_FIFTY_FIFTH: GreedyBytes, }) ConfigCompositionDataStatus = SwitchStruct( "page" / CompositionDataPageAdapter, "data" / ConfigCompositionData, ) ConfigDefaultTTLGet = Struct() ConfigDefaultTTLSet = Struct("ttl" / TTL, ) ConfigDefaultTTLStatus = ConfigDefaultTTLSet ConfigGATTProxyGet = Struct() ConfigGATTProxySet = Struct("GATT_proxy" / GATTProxyAdapter, ) ConfigGATTProxyStatus = ConfigGATTProxySet ConfigRelayGet = Struct()
ENUM = 0x0A STRING = 0x0B ARRAY = 0x0C INVALID = 0xFF # fmt: off DebugV2Parameter = SwitchStruct( "data_type" / EnumAdapter(Int8ul, DebugV2DataTypes), "parameter" / Switch( this.data_type, { DebugV2DataTypes.UINT8: Int8ul, DebugV2DataTypes.UINT16: Int16ul, DebugV2DataTypes.UINT32: Int32ul, DebugV2DataTypes.UINT64: Int64ul, DebugV2DataTypes.INT8: Int8sl, DebugV2DataTypes.INT16: Int16sl, DebugV2DataTypes.INT32: Int32sl, DebugV2DataTypes.INT64: Int64sl, DebugV2DataTypes.FLOAT: Float32l, DebugV2DataTypes.DOUBLE: Float64l, DebugV2DataTypes.ENUM: Int8ul, DebugV2DataTypes.STRING: PascalString(Int8ul, "utf-8"), DebugV2DataTypes.ARRAY: PrefixedArray(Int8ul, Int8ul), DebugV2DataTypes.INVALID: Struct() })) DebugV2SubMessage = Struct("subopcode" / EnumAdapter(Int8ul, DebugV2SubOpcode), "parameter_type" / Int8ul, "page_number" / Int8ul, "payload" / GreedyRange(DebugV2Parameter)) DebugV2Message = SwitchStruct( "opcode" / Opcode(DebugV2Opcode),
# fmt: off BatteryFlags = BitStruct( "battery_serviceability_flags" / EnumAdapter(BitsInteger(2), GenericBatteryFlagsServiceability), "battery_charging_flags" / EnumAdapter(BitsInteger(2), GenericBatteryFlagsCharging), "battery_indicator_flags" / EnumAdapter(BitsInteger(2), GenericBatteryFlagsIndicator), "battery_presence_flags" / EnumAdapter(BitsInteger(2), GenericBatteryFlagsPresence), ) GenericBatteryGet = Struct() GenericBatteryStatus = Struct( "battery_level" / DefaultCountValidator(Int8ul), "time_to_discharge" / DefaultCountValidator(Int24ul), "time_to_charge" / DefaultCountValidator(Int24ul), "flags" / BatteryFlags) GenericBatteryMessage = SwitchStruct( "opcode" / Opcode(GenericBatteryOpcode), "params" / Switch( this.opcode, { GenericBatteryOpcode.GENERIC_BATTERY_GET: GenericBatteryGet, GenericBatteryOpcode.GENERIC_BATTERY_STATUS: GenericBatteryStatus, }, )) # fmt: on
SceneStatus = NamedSelect(optional=SceneStatusWithTargetScene, minimal=SceneStatusMinimal) SceneRegisterGet = Struct() SceneRegisterStatus = Struct( "status_code" / EnumAdapter(Int8ul, SceneStatusCode), "current_scene" / Int16ul, "scenes" / GreedyRange(Int16ul)) SceneSetupWithValidation = Struct( "scene_number" / ExprValidator(Int16ul, obj_ > 0), ) SceneSetup = Struct("scene_number" / Int16ul) SceneMessage = SwitchStruct( "opcode" / Opcode(SceneOpcode), "params" / Switch( this.opcode, { SceneOpcode.SCENE_GET: SceneGet, SceneOpcode.SCENE_RECALL: SceneRecall, SceneOpcode.SCENE_RECALL_UNACKNOWLEDGED: SceneRecall, SceneOpcode.SCENE_STATUS: SceneStatus, SceneOpcode.SCENE_REGISTER_GET: SceneRegisterGet, SceneOpcode.SCENE_REGISTER_STATUS: SceneRegisterStatus, SceneOpcode.SCENE_STORE: SceneSetupWithValidation, SceneOpcode.SCENE_STORE_UNACKNOWLEDGED: SceneSetupWithValidation, SceneOpcode.SCENE_DELETE: SceneSetup, SceneOpcode.SCENE_DELETE_UNACKNOWLEDGED: SceneSetup, })) # fmt: on
LightExtendedControllerPropertyStatus = Struct( "id" / EnumAdapter(Int16ul, LightExtendedControllerProperty), "value" / LightExtendedControllerPropertyValue, ) LightExtendedControllerSyncIntegralStatus = Struct("sync_integral" / Int16ul, ) LightExtendedControllerParams = SwitchStruct( "subopcode" / EnumAdapter(Int8ul, LightExtendedControllerSubOpcode), "payload" / Switch( this.subopcode, { LightExtendedControllerSubOpcode.PROPERTY_GET: LightExtendedControllerPropertyGet, LightExtendedControllerSubOpcode.PROPERTY_SET: LightExtendedControllerPropertySet, LightExtendedControllerSubOpcode.PROPERTY_SET_UNACKNOWLEDGED: LightExtendedControllerPropertySet, LightExtendedControllerSubOpcode.PROPERTY_STATUS: LightExtendedControllerPropertyStatus, LightExtendedControllerSubOpcode.SYNC_INTEGRAL_STATUS: LightExtendedControllerSyncIntegralStatus, })) LightExtendedControllerMessage = SwitchStruct( "opcode" / Opcode(LightExtendedControllerOpcode), "params" / Switch(this.opcode, { LightExtendedControllerOpcode.SILVAIR_LEC: LightExtendedControllerParams, })) # fmt: on
TIME_STATUS = 0x005D TIME_ROLE_GET = 0x8238 TIME_ROLE_SET = 0x8239 TIME_ROLE_STATUS = 0x823A TIME_ZONE_GET = 0x823B TIME_ZONE_SET = 0x823C TIME_ZONE_STATUS = 0x823D TAI_UTC_DELTA_GET = 0x823E TAI_UTC_DELTA_SET = 0x823F TAI_UTC_DELTA_STATUS = 0x8240 # fmt: off TimeMessage = SwitchStruct( "opcode" / Opcode(TimeOpcode), "params" / Switch( this.opcode, { TimeOpcode.TIME_GET: TimeGet, TimeOpcode.TIME_SET: TimeSet, TimeOpcode.TIME_STATUS: TimeStatus, TimeOpcode.TIME_ZONE_GET: TimeZoneGet, TimeOpcode.TIME_ZONE_SET: TimeZoneSet, TimeOpcode.TIME_ZONE_STATUS: TimeZoneStatus, TimeOpcode.TAI_UTC_DELTA_GET: TAIUTCDeltaGet, TimeOpcode.TAI_UTC_DELTA_SET: TAIUTCDeltaSet, TimeOpcode.TAI_UTC_DELTA_STATUS: TAIUTCDeltaStatus, TimeOpcode.TIME_ROLE_GET: TimeRoleGet, TimeOpcode.TIME_ROLE_SET: TimeRoleSet, TimeOpcode.TIME_ROLE_STATUS: TimeRoleStatus })) # fmt: on
HEALTH_FAULT_TEST = 0x8032 HEALTH_FAULT_TEST_UNACKNOWLEDGED = 0x8033 HEALTH_PERIOD_GET = 0x8034 HEALTH_PERIOD_SET = 0x8035 HEALTH_PERIOD_SET_UNACKNOWLEDGED = 0x8036 HEALTH_PERIOD_STATUS = 0x8037 # fmt: off HealthMessage = SwitchStruct( "opcode" / Opcode(HealthOpcode), "params" / Switch( this.opcode, { HealthOpcode.HEALTH_ATTENTION_GET: HealthAttentionGet, HealthOpcode.HEALTH_ATTENTION_SET: HealthAttentionSet, HealthOpcode.HEALTH_ATTENTION_SET_UNACKNOWLEDGED: HealthAttentionSet, HealthOpcode.HEALTH_ATTENTION_STATUS: HealthAttentionStatus, HealthOpcode.HEALTH_CURRENT_STATUS: HealthCurrentStatus, HealthOpcode.HEALTH_FAULT_CLEAR: HealthFaultClear, HealthOpcode.HEALTH_FAULT_CLEAR_UNACKNOWLEDGED: HealthFaultClear, HealthOpcode.HEALTH_FAULT_GET: HealthFaultGet, HealthOpcode.HEALTH_FAULT_STATUS: HealthCurrentStatus, HealthOpcode.HEALTH_FAULT_TEST: HealthFaultTest, HealthOpcode.HEALTH_FAULT_TEST_UNACKNOWLEDGED: HealthFaultTest, HealthOpcode.HEALTH_PERIOD_GET: HealthPeriodGet, HealthOpcode.HEALTH_PERIOD_SET: HealthPeriodSet, HealthOpcode.HEALTH_PERIOD_SET_UNACKNOWLEDGED: HealthPeriodSet, HealthOpcode.HEALTH_PERIOD_STATUS: HealthPeriodStatus, })) # fmt: on
LightLightnessSet = NamedSelect( optional=LightLightnessSetOptional, minimal=LightLightnessSetMinimal ) LightLightnessMessage = SwitchStruct( "opcode" / Opcode(LightLightnessOpcode), "params" / Switch( this.opcode, { LightLightnessOpcode.LIGHT_LIGHTNESS_GET: LightLightnessGet, LightLightnessOpcode.LIGHT_LIGHTNESS_SET: LightLightnessSet, LightLightnessOpcode.LIGHT_LIGHTNESS_SET_UNACKNOWLEDGED: LightLightnessSet, LightLightnessOpcode.LIGHT_LIGHTNESS_STATUS: LightLightnessStatus, LightLightnessOpcode.LIGHT_LIGHTNESS_LINEAR_GET: LightLightnessGet, LightLightnessOpcode.LIGHT_LIGHTNESS_LINEAR_SET: LightLightnessSet, LightLightnessOpcode.LIGHT_LIGHTNESS_LINEAR_SET_UNACKNOWLEDGED: LightLightnessSet, LightLightnessOpcode.LIGHT_LIGHTNESS_LINEAR_STATUS: LightLightnessStatus, LightLightnessOpcode.LIGHT_LIGHTNESS_LAST_GET: LightLightnessGet, LightLightnessOpcode.LIGHT_LIGHTNESS_LAST_STATUS: LightLightnessDefault, LightLightnessOpcode.LIGHT_LIGHTNESS_DEFAULT_GET: LightLightnessGet, LightLightnessOpcode.LIGHT_LIGHTNESS_DEFAULT_STATUS: LightLightnessDefault, LightLightnessOpcode.LIGHT_LIGHTNESS_RANGE_GET: LightLightnessGet, LightLightnessOpcode.LIGHT_LIGHTNESS_RANGE_STATUS: LightLightnessRangeStatus, } ) ) LightLightnessSetupMessage = SwitchStruct( "opcode" / Opcode(LightLightnessSetupOpcode), "params" / Switch( this.opcode,
"destination" / UnicastUnassignedGroupAddress, "period" / Int16ul) NetworkDiagnosticServerSubscriptionStatus = Struct( "destination" / UnicastUnassignedGroupAddress, "period" / Int16ul, "max_record_count" / Int8ul, "record" / GreedyRange(RegistryRecord)) NetworkDiagnosticServerRadioStatGet = Struct() NetworkDiagnosticServerParams = SwitchStruct( "subopcode" / EnumAdapter(Int8ul, NetworkDiagnosticServerSubOpcode), "payload" / Switch( this.subopcode, { NetworkDiagnosticServerSubOpcode.SUBSCRIPTION_GET: NetworkDiagnosticServerSubscriptionGet, NetworkDiagnosticServerSubOpcode.SUBSCRIPTION_SET: NetworkDiagnosticServerSubscriptionSet, NetworkDiagnosticServerSubOpcode.SUBSCRIPTION_SET_UNACKNOWLEDGED: NetworkDiagnosticServerSubscriptionSet, NetworkDiagnosticServerSubOpcode.SUBSCRIPTION_STATUS: NetworkDiagnosticServerSubscriptionStatus, NetworkDiagnosticServerSubOpcode.RADIO_STAT_GET: NetworkDiagnosticServerRadioStatGet })) NetworkDiagnosticSetupServerParams = SwitchStruct( "subopcode" / EnumAdapter(Int8ul, NetworkDiagnosticSetupServerSubOpcode), "payload" / Switch( this.subopcode, { NetworkDiagnosticSetupServerSubOpcode.PUBLICATION_GET: NetworkDiagnosticSetupServerPublicationGet, NetworkDiagnosticSetupServerSubOpcode.PUBLICATION_SET:
DebugParams = SwitchStruct( "subopcode" / EnumAdapter(Int8ul, DebugSubOpcode), "payload" / Switch( this.subopcode, { DebugSubOpcode.RSSI_THRESHOLD_GET: RssiThresholdGet, DebugSubOpcode.RSSI_THRESHOLD_SET: RssiThreshold, DebugSubOpcode.RSSI_THRESHOLD_STATUS: RssiThreshold, DebugSubOpcode.RADIO_TEST: RadioTest, DebugSubOpcode.TIMESLOT_TX_POWER_GET: TimeslotTxPowerGet, DebugSubOpcode.TIMESLOT_TX_POWER_SET: TimeslotTxPowerStatus, DebugSubOpcode.TIMESLOT_TX_POWER_STATUS: TimeslotTxPowerStatus, DebugSubOpcode.SOFTDEVICE_TX_POWER_GET: SoftdeviceTxPowerGet, DebugSubOpcode.SOFTDEVICE_TX_POWER_SET: SoftdeviceTxPowerStatus, DebugSubOpcode.SOFTDEVICE_TX_POWER_STATUS: SoftdeviceTxPowerStatus, DebugSubOpcode.UPTIME_GET: UptimeGet, DebugSubOpcode.UPTIME_STATUS: UptimeStatus, DebugSubOpcode.LAST_SW_FAULT_GET: LastSwFaultGet, DebugSubOpcode.LAST_SW_FAULT_CLEAR: LastSwFaultClear, DebugSubOpcode.LAST_SW_FAULT_STATUS: LastSwFaultStatus, DebugSubOpcode.SYSTEM_STATS_GET: SystemStatsGet, DebugSubOpcode.SYSTEM_STATS_STATUS: SystemStatsStatus, DebugSubOpcode.LAST_MALLOC_FAULT_GET: LastMallocFaultGet, DebugSubOpcode.LAST_MALLOC_FAULT_CLEAR: LastMallocFaultClear, DebugSubOpcode.LAST_MALLOC_FAULT_STATUS: LastMallocFaultStatus, DebugSubOpcode.LAST_FDS_FAULT_GET: LastFdsFaultGet, DebugSubOpcode.LAST_FDS_FAULT_CLEAR: LastFdsFaultClear, DebugSubOpcode.LAST_FDS_FAULT_STATUS: LastFdsFaultStatus, DebugSubOpcode.BYTES_BEFORE_GARBAGE_COLLECTOR_GET: BytesBeforeGarbageCollectorGet, DebugSubOpcode.BYTES_BEFORE_GARBAGE_COLLECTOR_STATUS: BytesBeforeGarbageCollectorStatus, DebugSubOpcode.PROVISIONED_APP_VERSION_GET: ProvisionedAppVersionGet, DebugSubOpcode.PROVISIONED_APP_VERSION_STATUS: ProvisionedAppVersionStatus, DebugSubOpcode.FULL_FIRMWARE_VERSION_GET: FullFirmwareVersionGet, DebugSubOpcode.FULL_FIRMWARE_VERSION_STATUS: FullFirmwareVersionStatus, DebugSubOpcode.IV_INDEX_GET: IvIndexGet, DebugSubOpcode.IV_INDEX_STATUS: IvIndexStatus, DebugSubOpcode.GARBAGE_COLLECTOR_COUNTER_GET: GarbageCollectorCounterGet, DebugSubOpcode.GARBAGE_COLLECTOR_COUNTER_STATUS: GarbageCollectorCounterStatus, DebugSubOpcode.ARAP_LIST_SIZE_GET: ArapListSizeGet, DebugSubOpcode.ARAP_LIST_SIZE_STATUS: ArapListSizeStatus, DebugSubOpcode.ARAP_LIST_CONTENT_GET: ArapListContentGet, DebugSubOpcode.ARAP_LIST_CONTENT_STATUS: ArapListContentStatus, }))
GenericOnOffSet = NamedSelect(optional=GenericOnOffSetOptional, minimal=GenericOnOffSetMinimal) GenericOnOffStatusMinimal = Struct("present_onoff" / Int8ul) GenericOnOffStatusOptional = Struct( "present_onoff" / Int8ul, "target_onoff" / Int8ul, "remaining_time" / TransitionTimeAdapter(TransitionTime, allow_unknown=True), ) GenericOnOffStatus = NamedSelect(optional=GenericOnOffStatusOptional, minimal=GenericOnOffStatusMinimal) GenericOnOffMessage = SwitchStruct( "opcode" / Opcode(GenericOnOffOpcode), "params" / Switch( this.opcode, { GenericOnOffOpcode.GENERIC_ONOFF_GET: GenericOnOffGet, GenericOnOffOpcode.GENERIC_ONOFF_SET: GenericOnOffSet, GenericOnOffOpcode.GENERIC_ONOFF_SET_UNACKNOWLEDGED: GenericOnOffSet, GenericOnOffOpcode.GENERIC_ONOFF_STATUS: GenericOnOffStatus, }, ), ) # fmt: off
GenericMoveSet = NamedSelect(optional=GenericMoveSetOptional, minimal=GenericMoveSetMinimal) GenericLevelStatusMinimal = Struct("present_level" / Int16sl) GenericLevelStatusOptional = Struct( Embedded(GenericLevelStatusMinimal), "target_level" / Int16sl, "remaining_time" / TransitionTimeAdapter(TransitionTime, allow_unknown=True)) GenericLevelStatus = NamedSelect(optional=GenericLevelStatusOptional, minimal=GenericLevelStatusMinimal) GenericLevelMessage = SwitchStruct( "opcode" / Opcode(GenericLevelOpcode), "params" / Switch( this.opcode, { GenericLevelOpcode.GENERIC_LEVEL_GET: GenericLevelGet, GenericLevelOpcode.GENERIC_LEVEL_SET: GenericLevelSet, GenericLevelOpcode.GENERIC_LEVEL_SET_UNACKNOWLEDGED: GenericLevelSet, GenericLevelOpcode.GENERIC_LEVEL_STATUS: GenericLevelStatus, GenericLevelOpcode.GENERIC_DELTA_SET: GenericDeltaSet, GenericLevelOpcode.GENERIC_DELTA_SET_UNACKNOWLEDGED: GenericDeltaSet, GenericLevelOpcode.GENERIC_MOVE_SET: GenericMoveSet, GenericLevelOpcode.GENERIC_MOVE_SET_UNACKNOWLEDGED: GenericMoveSet, }, )) # fmt: on