NetworkDiagnosticSetupServerPublicationStatus = NetworkDiagnosticSetupServerPublicationSet

NetworkDiagnosticServerSubscriptionSet = Struct(
    "destination" / UnicastUnassignedGroupAddress,
    "period" / Int16ul
)

NetworkDiagnosticServerSubscriptionStatus = Struct(
    "destination" / UnicastUnassignedGroupAddress,
    "period" / Int16ul,
    "max_record_count" / Const(MAX_RECORD_COUNT, Int8ul),
    "record" / GreedyRange(RegistryRecord)
)

NetworkDiagnosticServerPayload = Struct(
    "subopcode" / EnumAdapter(Int8ul, NetworkDiagnosticServerSubOpcode),
    "payload" / Default(Switch(
        this.subopcode,
        {
            NetworkDiagnosticServerSubOpcode.SUBSCRIPTION_SET: NetworkDiagnosticServerSubscriptionSet,
            NetworkDiagnosticServerSubOpcode.SUBSCRIPTION_SET_UNACK: NetworkDiagnosticServerSubscriptionSet,
            NetworkDiagnosticServerSubOpcode.SUBSCRIPTION_STATUS: NetworkDiagnosticServerSubscriptionStatus
        }
    ), None)
)

NetworkDiagnosticSetupServerPayload = Struct(
    "subopcode" / EnumAdapter(Int8ul, NetworkDiagnosticSetupServerSubOpcode),
    "payload" / Default(Switch(
        this.subopcode,
        {
Пример #2
0
from bluetooth_mesh.messages.util import EnumAdapter


class FdMessageType(IntEnum):
    NETKEY = 0
    APPKEY = 1


# fmt: off
NetKeyMessageElements = Struct("net_index" / Int16ul, "remote" / Flag,
                               Padding(17))

AppKeyMessageElements = Struct("app_index" / Int16ul, "destination" / Int16ul,
                               "label" / Int8ul, Padding(15))

FdMessage = Struct(
    "element" / Int8ul,
    "source" / Int16ul,
    "type" / EnumAdapter(Int8ul, FdMessageType),
    "params" / Switch(
        this.type,
        {
            FdMessageType.NETKEY: NetKeyMessageElements,
            FdMessageType.APPKEY: AppKeyMessageElements,
        },
    ),
    "data" / GreedyBytes,
)
# fmt: on
    def _encode(self, obj, context, path):
        return int(obj.total_seconds() * 1000)


# fmt: off
LightExtendedControllerPropertyValue = Switch(
    this.id,
    {
        LightExtendedControllerProperty.AUTO_RESUME_MODE: Flag,
        LightExtendedControllerProperty.AUTO_RESUME_TIMER: AutoResumeTimerAdapter(Int24ul),
    }
)

LightExtendedControllerPropertyGet = Struct(
    "id" / EnumAdapter(Int16ul, LightExtendedControllerProperty),
)

LightExtendedControllerPropertySet = Struct(
    "id" / EnumAdapter(Int16ul, LightExtendedControllerProperty),
    "value" / LightExtendedControllerPropertyValue,
)

LightExtendedControllerPropertyStatus = Struct(
    "id" / EnumAdapter(Int16ul, LightExtendedControllerProperty),
    "value" / LightExtendedControllerPropertyValue,
)

LightExtendedControllerSyncIntegralStatus = Struct(
    "sync_integral" / Int16ul,
)
Пример #4
0
    SENSOR_CADENCE_STATUS = 0x57
    SENSOR_SETTINGS_GET = 0x8235
    SENSOR_SETTINGS_STATUS = 0x58
    SENSOR_SETTING_GET = 0x8236
    SENSOR_SETTING_SET = 0x59
    SENSOR_SETTING_SET_UNACKNOWLEDGED = 0x5A
    SENSOR_SETTING_STATUS = 0x5B

    def __repr__(self):
        return str(self.value)


# fmt: off
SensorPropertyId = FieldAdapter(
    Select(
        EnumAdapter(Int16ul, PropertyID),
        Int16ul),
    Int16ul
)

SensorGetMinimal = Struct()

SensorGetOptional = Struct(
    "property_id" / SensorPropertyId,
)

SensorGet = NamedSelect(
    optional=SensorGetOptional,
    minimal=SensorGetMinimal
)
Пример #5
0
LightCTLTemperatureSetOptional = Struct(
    Embedded(LightCTLTemperatureSetMinimal), Embedded(OptionalSetParameters))

LightCTLTemperatureSet = Select(LightCTLTemperatureSetOptional,
                                LightCTLTemperatureSetMinimal)

LightCTLRange = Struct(
    "range_min" / Int16ul,
    "range_max" / Int16ul,
)

LightCTLRangeStatus = Struct("status" / StatusCodeAdapter,
                             Embedded(LightCTLRange))

LightCTLMessage = Struct(
    "opcode" / EnumAdapter(Opcode, LightCTLOpcode), "params" / Switch(
        this.opcode,
        {
            LightCTLOpcode.CTL_GET: LightCTLGet,
            LightCTLOpcode.CTL_SET: LightCTLSet,
            LightCTLOpcode.CTL_SET_UNACKNOWLEDGED: LightCTLSet,
            LightCTLOpcode.CTL_STATUS: LightCTLStatus,
            LightCTLOpcode.CTL_TEMPERATURE_GET: LightCTLGet,
            LightCTLOpcode.CTL_TEMPERATURE_RANGE_GET: LightCTLGet,
            LightCTLOpcode.CTL_TEMPERATURE_RANGE_STATUS: LightCTLRangeStatus,
            LightCTLOpcode.CTL_TEMPERATURE_SET: LightCTLTemperatureSet,
            LightCTLOpcode.CTL_TEMPERATURE_SET_UNACKNOWLEDGED:
            LightCTLTemperatureSet,
            LightCTLOpcode.CTL_TEMPERATURE_STATUS: LightCTLTemperatureStatus,
            LightCTLOpcode.CTL_TEMPERATURE_DEFAULT_GET: LightCTLGet,
            LightCTLOpcode.CTL_TEMPERATURE_DEFAULT_STATUS: LightCTLDefault,
Пример #6
0
# fmt: off
ProvisioningInvite = Struct("attention" / Int8ub, )

ProvisioningCapabilities = Struct(
    "num_elements" / Int8ub,
    "algorithms" / BitList(2, reversed=True),
    "public_key_type" / BitList(1, reversed=True),
    "static_oob_type" / BitList(1, reversed=True),
    "output_oob_size" / Int8ub,
    "output_oob_action" / BitList(2, reversed=True),
    "input_oob_size" / Int8ub,
    "input_oob_action" / BitList(2, reversed=True),
)

ProvisioningStart = Struct(
    "algorithm" / EnumAdapter(Int8ub, ProvisioningAlgorithm),
    "public_key" / ExprAdapter(Int8ub, lambda obj, ctx: bool(obj),
                               lambda obj, ctx: 1 if obj else 0),
    "authentication_method" /
    EnumAdapter(Int8ub, ProvisioningAuthenticationMethod),
    "authentication_action" / Switch(
        this.authentication_method,
        {
            ProvisioningAuthenticationMethod.NONE:
            Const(0, Int8ub),
            ProvisioningAuthenticationMethod.STATIC:
            Const(0, Int8ub),
            ProvisioningAuthenticationMethod.OUTPUT:
            EnumAdapter(Int8ub, ProvisioningOutputOOBAction),
            ProvisioningAuthenticationMethod.INPUT:
            EnumAdapter(Int8ub, ProvisioningInputOOBAction),
    BATTERY_NOT_CHARGEABLE = 0b00
    BATTERY_CHARGEABLE_NOT_CHARGING = 0b01
    BATTERY_CHARGEABLE_CHARGING = 0b10
    BATTERY_CHARGING_STATE_UNKNOWN = 0b11


class GenericBatteryFlagsServiceability(IntEnum):
    RFU = 0b00
    BATTERY_NOT_REQUIRE_SERVICE = 0b01
    BATTERY_REQUIRE_SERVICE = 0b10
    BATTERY_SERVICEABILITY_UNKNOWN = 0b11


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)
Пример #8
0
GenericMoveSetOptional = Struct(Embedded(GenericMoveSetMinimal),
                                Embedded(OptionalSetParameters))

GenericMoveSet = Select(GenericMoveSetOptional, GenericMoveSetMinimal)

GenericLevelStatusMinimal = Struct("present_level" / Int16ul)

GenericLevelStatusOptional = Struct(
    Embedded(GenericLevelStatusMinimal), "target_level" / Int16ul,
    "remaining_time" /
    TransitionTimeAdapter(TransitionTime, allow_unknown=True))

GenericLevelStatus = Select(GenericLevelStatusOptional,
                            GenericLevelStatusMinimal)

GenericLevelMessage = Struct(
    "opcode" / EnumAdapter(Opcode, GenericLevelOpcode), "params" / Switch(
        this.opcode,
        {
            GenericLevelOpcode.LEVEL_GET: GenericLevelGet,
            GenericLevelOpcode.LEVEL_SET: GenericLevelSet,
            GenericLevelOpcode.LEVEL_SET_UNACKNOWLEDGED: GenericLevelSet,
            GenericLevelOpcode.LEVEL_STATUS: GenericLevelStatus,
            GenericLevelOpcode.DELTA_SET: GenericDeltaSet,
            GenericLevelOpcode.DELTA_SET_UNACKNOWLEDGED: GenericDeltaSet,
            GenericLevelOpcode.MOVE_SET: GenericMoveSet,
            GenericLevelOpcode.MOVE_SET_UNACKNOWLEDGED: GenericMoveSet,
        },
    ))
Пример #9
0
        passed_time: datetime = obj["date"]
        total_time = passed_time.timestamp(
        ) - MESH_UNIX_EPOCH_DIFF - passed_time.utcoffset().total_seconds()

        return Container(tai_seconds=int(total_time),
                         subsecond=seconds_to_subsecond(total_time),
                         uncertainty=int(
                             (obj["uncertainty"].total_seconds() * 100)),
                         tai_utc_delta=timedelta_to_mesh_tai_utc_delta(
                             obj["tai_utc_delta"]),
                         time_authority=bool(obj["time_authority"]),
                         time_zone_offset=timedelta_to_mesh_time_zone_offset(
                             passed_time.utcoffset()))


TimeRoleMsg = Struct("time_role" / EnumAdapter(Int8ul, TimeRole))

TimeGet = Struct()

TimeSet = TimeAdapter(Time)

TimeStatus = TimeAdapter(Time)

TimeZoneGet = Struct()

TimeZoneSet = Struct(
    "time_zone_offset_new" / Int8ul,
    "tai_of_zone_change" / BytesInteger(5, swapped=True),
)

TimeZoneStatus = Struct(
    "tid" / Int8ul
)

LightLightnessSetOptional = Struct(
    Embedded(LightLightnessSetMinimal),
    Embedded(OptionalSetParameters)
)

LightLightnessSet = Select(
    LightLightnessSetOptional,
    LightLightnessSetMinimal
)


LightLightnessMessage = Struct(
    "opcode" / EnumAdapter(Opcode, LightLightnessOpcode),
    "params" / Switch(
        this.opcode,
        {
            LightLightnessOpcode.LIGHTNESS_GET: LightLightnessGet,
            LightLightnessOpcode.LIGHTNESS_SET: LightLightnessSet,
            LightLightnessOpcode.LIGHTNESS_SET_UNACKNOWLEDGED: LightLightnessSet,
            LightLightnessOpcode.LIGHTNESS_STATUS: LightLightnessStatus,
            LightLightnessOpcode.LIGHTNESS_LINEAR_GET: LightLightnessGet,
            LightLightnessOpcode.LIGHTNESS_LINEAR_SET: LightLightnessSet,
            LightLightnessOpcode.LIGHTNESS_LINEAR_SET_UNACKNOWLEDGED: LightLightnessSet,
            LightLightnessOpcode.LIGHTNESS_LINEAR_STATUS: LightLightnessStatus,
            LightLightnessOpcode.LIGHTNESS_LAST_GET: LightLightnessGet,
            LightLightnessOpcode.LIGHTNESS_LAST_STATUS: LightLightnessDefault,
            LightLightnessOpcode.LIGHTNESS_DEFAULT_GET: LightLightnessGet,
            LightLightnessOpcode.LIGHTNESS_DEFAULT_STATUS: LightLightnessDefault,
GenericOnOffGet = Struct()

GenericOnOffSetMinimal = Struct("onoff" / Int8ul, "tid" / Int8ul)

GenericOnOffSetOptional = Struct(
    "onoff" / Int8ul, "tid" / Int8ul, "transition_time" /
    TransitionTimeAdapter(TransitionTime, allow_unknown=False),
    "delay" / Delay(Int8ul))

GenericOnOffSet = Select(GenericOnOffSetOptional, GenericOnOffSetMinimal)

GenericOnOffStatusMinimal = Struct("present_onoff" / Int8ul)

GenericOnOffStatusOptional = Struct(
    "present_onoff" / Int8ul, "target_onoff" / Int8ul, "remaining_time" /
    TransitionTimeAdapter(TransitionTime, allow_unknown=True))

GenericOnOffStatus = Select(GenericOnOffStatusOptional,
                            GenericOnOffStatusMinimal)

GenericOnOffMessage = Struct(
    "opcode" / EnumAdapter(Opcode, GenericOnOffOpcode), "params" / Switch(
        this.opcode,
        {
            GenericOnOffOpcode.ONOFF_GET: GenericOnOffGet,
            GenericOnOffOpcode.ONOFF_SET: GenericOnOffSet,
            GenericOnOffOpcode.ONOFF_SET_UNACKNOWLEDGED: GenericOnOffSet,
            GenericOnOffOpcode.ONOFF_STATUS: GenericOnOffStatus,
        },
    ))
Пример #12
0
    SENSOR_CADENCE_GET = 0x8234
    SENSOR_CADENCE_SET = 0x55
    SENSOR_CADENCE_SET_UNACKNOWLEDGED = 0x56
    SENSOR_CADENCE_STATUS = 0x57
    SENSOR_SETTINGS_GET = 0x8235
    SENSOR_SETTINGS_STATUS = 0x58
    SENSOR_SETTING_GET = 0x8236
    SENSOR_SETTING_SET = 0x59
    SENSOR_SETTING_SET_UNACKNOWLEDGED = 0x5A
    SENSOR_SETTING_STATUS = 0x5B

    def __repr__(self):
        return str(self.value)


SensorPropertyId = Select(EnumAdapter(Int16ul, PropertyID), Int16ul)

# fmt: off
SensorGetMinimal = Struct()

SensorGetOptional = Struct("property_id" / SensorPropertyId, )

SensorGet = Select(SensorGetOptional, SensorGetMinimal)

SensorSettingsGet = Struct("sensor_property_id" / SensorPropertyId, )

SensorSettingGet = Struct(
    Embedded(SensorSettingsGet),
    "sensor_setting_property_id" / SensorPropertyId,
)
Пример #13
0
    "scene_number" / ExprValidator(Int16ul, obj_ > 0),
    "tid" / Int8ul,
)

SceneRecallWithTransition = Struct(
    "scene_number" / ExprValidator(Int16ul, obj_ > 0),
    "tid" / Int8ul,
    "transition_time" /
    TransitionTimeAdapter(TransitionTime, allow_unknown=False),
    "delay" / Delay(Int8ul),
)

SceneRecall = Select(SceneRecallWithTransition, SceneRecallMinimal)

SceneStatusMinimal = Struct(
    "status_code" / EnumAdapter(Int8ul, SceneStatusCode),
    "current_scene" / Int16ul)

SceneStatusWithTargetScene = Struct(
    "status_code" / EnumAdapter(Int8ul, SceneStatusCode),
    "current_scene" / Int16ul,
    "target_scene" / Int16ul,
    "remaining_time" /
    TransitionTimeAdapter(TransitionTime, allow_unknown=False),
)

SceneStatus = Select(SceneStatusWithTargetScene, SceneStatusMinimal)

SceneRegisterGet = Struct()

SceneRegisterStatus = Struct(
Пример #14
0
    BATTERY_CHARGEABLE_NOT_CHARGING = 0b01
    BATTERY_CHARGEABLE_CHARGING = 0b10
    BATTERY_CHARGING_STATE_UNKNOWN = 0b11


class GenericBatteryFlagsServiceability(IntEnum):
    RFU = 0b00
    BATTERY_NOT_REQUIRE_SERVICE = 0b01
    BATTERY_REQUIRE_SERVICE = 0b10
    BATTERY_SERVICEABILITY_UNKNOWN = 0b11


# 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)
Пример #15
0
    UINT64 = 0x03
    INT8 = 0x04
    INT16 = 0x05
    INT32 = 0x06
    INT64 = 0x07
    FLOAT = 0x08
    DOUBLE = 0x09
    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()
Пример #16
0
        }
    )
)

# TODO: message not implemented due to somewhat complicated structure and lack of examples
# SensorCadence = Struct(
#     "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 = Struct(
    "opcode" / EnumAdapter(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,
        },
    )
)
Пример #17
0
)

SceneRecallWithTransition = Struct(
    "scene_number" / ExprValidator(Int16ul, obj_ > 0),
    "tid" / Int8ul,
    "transition_time" / TransitionTimeAdapter(TransitionTime, allow_unknown=False),
    "delay" / Delay(Int8ul),
)

SceneRecall = Select(
    SceneRecallWithTransition,
    SceneRecallMinimal
)

SceneStatusMinimal = Struct(
    "status_code" / EnumAdapter(Int8ul, SceneStatusCode),
    "current_scene" / Int16ul
)

SceneStatusWithTargetScene = Struct(
    "status_code" / EnumAdapter(Int8ul, SceneStatusCode),
    "current_scene" / Int16ul,
    "target_scene" / Int16ul,
    "remaining_time" / TransitionTimeAdapter(TransitionTime, allow_unknown=False),
)

SceneStatus = Select(
    SceneStatusWithTargetScene,
    SceneStatusMinimal
)
    Embedded(ConfigurationSetWithOptionalDhcpEnabledWithStaticDns),
    "ip_address" / IpAddressAdapter(Bytes(4)),
    "gateway_ip_address" / IpAddressAdapter(Bytes(4)),
    "netmask" / Int8ul,
)

ConfigurationSet = Select(
    static=ConfigurationSetWithOptionalDhcpDisabled,
    dns=ConfigurationSetWithOptionalDhcpEnabledWithStaticDns,
    minimal=ConfigurationSetWithoutOptionalAutoDhcpEnabled,
)

ConfigurationStatus = Struct(
    "chip_revision_id" / Int8ul,
    Embedded(ConfigurationSetWithOptionalDhcpDisabled),
    "flags" / EnumAdapter(Int8ul, DhcpFlag),
    "status_code" / EnumAdapter(Int8ul, StatusCode),
)

ConnectionState = BitStruct(
    "conn_state" / EnumAdapter(BitsInteger(3), ConnState),
    "link_status" / EnumAdapter(BitsInteger(1), LinkStatus),
    "last_error" / EnumAdapter(BitsInteger(4), LastError))

# GATEWAY PACKETS MSG
PacketsStatus = Struct(
    "total_eth_rx_errors" / Int16ul,
    "total_eth_tx_errors" / Int16ul,
    "bandwidth" / Int16ul,
    "connection_state" / ConnectionState,
)
Пример #19
0
    ENABLED = 0x01
    NOT_SUPPORTED = 0x02


class KeyRefreshPhase(enum.IntEnum):
    NORMAL = 0x00
    FIRST = 0x01
    SECOND = 0x02


class KeyRefreshTransition(enum.IntEnum):
    SECOND = 0x02
    THIRD = 0x03


SecureNetworkBeaconAdapter = EnumAdapter(Int8ul, SecureNetworkBeacon)

GATTProxyAdapter = EnumAdapter(Int8ul, GATTProxy)

RelayAdapter = EnumAdapter(Int8ul, Relay)

GATTNamespaceDescriptorAdapter = EnumAdapter(Int16ul, GATTNamespaceDescriptor)

PublishFriendshipCredentialsFlagAdapter = EnumAdapter(
    Flag, PublishFriendshipCredentialsFlag)

StatusCodeAdapter = EnumAdapter(Int8ul, StatusCode)

NodeIdentityAdapter = EnumAdapter(Int8ul, NodeIdentity)

FriendAdapter = EnumAdapter(Int8ul, Friend)
Пример #20
0
        GreedyRange(
            ByteSwapped(
                BitStruct(
                    "sequence" / Bytewise(Int24ub),
                    "ivi" / BitsInteger(1),
                    "address" / BitsInteger(15),
                )
            )
        ),
        key=this.address,
        value=[this.ivi, this.sequence]
    )
)

DebugPayload = Struct(
    "subopcode" / EnumAdapter(Int8ul, DebugSubOpcode),
    "data" / Default(Switch(
        this.subopcode,
        {
            DebugSubOpcode.RSSI_THRESHOLD_SET: RssiThreshold,
            DebugSubOpcode.RSSI_THRESHOLD_STATUS: RssiThreshold,
            DebugSubOpcode.RADIO_TEST: RadioTest,
            DebugSubOpcode.TIMESLOT_TX_POWER_SET: TxPower,
            DebugSubOpcode.TIMESLOT_TX_POWER_STATUS: TxPower,
            DebugSubOpcode.SOFTDEVICE_TX_POWER_SET: TxPower,
            DebugSubOpcode.SOFTDEVICE_TX_POWER_STATUS: TxPower,
            DebugSubOpcode.UPTIME_STATUS: UptimeStatus,
            DebugSubOpcode.LAST_SW_FAULT_STATUS: LastFault,
            DebugSubOpcode.SYSTEM_STATS_STATUS: SystemStats,
            DebugSubOpcode.LAST_MALLOC_FAULT_STATUS: LastFault,
            DebugSubOpcode.LAST_FDS_FAULT_STATUS: LastFault,
Пример #21
0
)

ArapListContentGet = Struct("page" / Int8ul)

ArapNode = ByteSwapped(
    BitStruct(
        "sequence" / Bytewise(Int24ub),
        "ivi" / BitsInteger(1),
        "address" / BitsInteger(15),
    ))

ArapListContentStatus = Struct("current_page" / Int8ul, "last_page" / Int8ul,
                               "nodes" / GreedyRange(ArapNode))

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,