iqrfpy.objects

 1from __future__ import annotations
 2
 3from .binaryoutput_state import BinaryOutputState
 4from .coordinator_authorize_bond_params import CoordinatorAuthorizeBondParams
 5from .coordinator_dpa_param import CoordinatorDpaParam
 6from .exploration_per_enum_data import ExplorationPerEnumData
 7from .exploration_per_info_data import ExplorationPerInfoData
 8from .frc_params import FrcParams
 9from .init_phy_data import InitPhyData
10from .io_triplet import IoTriplet
11from .node_read_data import NodeReadData
12from .node_validate_bonds_params import NodeValidateBondsParams
13from .os_batch_data import OsBatchData
14from .os_indicate_param import OsIndicateParam
15from .os_load_code_flags import OsLoadCodeFlags
16from .os_read_data import OsReadData
17from .os_security_type_param import OsSecurityTypeParam
18from .os_sleep_params import OsSleepParams
19from .os_tr_conf_byte import OsTrConfByte
20from .os_tr_conf_data import OsTrConfData
21from .sensor_data import SensorData
22from .sensor_written_data import SensorWrittenData
23from .tr_mcu_type_data import TrMcuTypeData
24
25__all__ = (
26    'BinaryOutputState',
27    'CoordinatorAuthorizeBondParams',
28    'CoordinatorDpaParam',
29    'ExplorationPerEnumData',
30    'ExplorationPerInfoData',
31    'FrcParams',
32    'InitPhyData',
33    'IoTriplet',
34    'NodeReadData',
35    'NodeValidateBondsParams',
36    'OsBatchData',
37    'OsIndicateParam',
38    'OsLoadCodeFlags',
39    'OsReadData',
40    'OsSecurityTypeParam',
41    'OsSleepParams',
42    'OsTrConfByte',
43    'OsTrConfData',
44    'SensorData',
45    'SensorWrittenData',
46    'TrMcuTypeData',
47)
class BinaryOutputState:
  7class BinaryOutputState:
  8    """Binary Output State class."""
  9
 10    __slots__ = '_index', '_state'
 11
 12    def __init__(self, index: int, state: int):
 13        """Binary Output State constructor.
 14
 15        Each binary output can be configured using the :obj:`state` value as follows:
 16        - 0 - sets output to OFF state
 17        - 1 - sets output to ON state
 18        - 2-127 - sets output to ON state for the next 2-127 minutes
 19        - 128 - reserved
 20        - 129-255 - sets output to ON state for the next 1-127 seconds
 21
 22        Args:
 23            index (int): Binary output index.
 24            state (int): State to set.
 25        """
 26        self._validate(index=index, state=state)
 27        self._index = index
 28        self._state = state
 29
 30    def _validate(self, index: int, state: int):
 31        """Validate binary output state parameters.
 32
 33        Args:
 34            index (int): Binary output index.
 35            state (int): State to set.
 36        """
 37        self._validate_index(index=index)
 38        self._validate_state(state=state)
 39
 40    @staticmethod
 41    def _validate_index(index: int):
 42        """Validate binary output index parameter.
 43
 44        Args:
 45            index (int): Binary output index.
 46
 47        Raises:
 48            RequestParameterInvalidValueError: If index is less than 0 or greater than 31.
 49        """
 50        if not dpa_constants.BINOUT_INDEX_MIN <= index <= dpa_constants.BINOUT_INDEX_MAX:
 51            raise RequestParameterInvalidValueError('Index value should be between 0 and 31.')
 52
 53    @property
 54    def index(self) -> int:
 55        """:obj:`int`: Binary output index.
 56
 57        Getter and setter.
 58        """
 59        return self._index
 60
 61    @index.setter
 62    def index(self, value: int):
 63        self._validate_index(index=value)
 64        self._index = value
 65
 66    @staticmethod
 67    def _validate_state(state: int):
 68        """Validate binary output state parameter.
 69
 70        Args:
 71            state (int): State to set.
 72
 73        Raises:
 74            RequestParameterInvalidValueError: If state is less than 0 or greater than 255.
 75        """
 76        if not dpa_constants.BYTE_MIN <= state <= dpa_constants.BYTE_MAX:
 77            raise RequestParameterInvalidValueError('State value should be between 0 and 255.')
 78
 79    @property
 80    def state(self) -> int:
 81        """:obj:`int`: Binary output state.
 82
 83        Getter and setter.
 84        """
 85        return self._state
 86
 87    @state.setter
 88    def state(self, value: int):
 89        self._validate_state(state=value)
 90        self._state = value
 91
 92    def to_json(self) -> dict:
 93        """Serialize Binary Output State to JSON API param.
 94
 95        Returns:
 96            dict: JSON-serialized Binary Output State
 97        """
 98        record = {
 99            'index': self.index,
100            'state': self.state > 0,
101        }
102        if 2 <= self.state <= 127:
103            record['time'] = self.state * 60
104        elif 128 <= self.state <= 255:
105            record['time'] = self.state - 128
106        return record

Binary Output State class.

BinaryOutputState(index: int, state: int)
12    def __init__(self, index: int, state: int):
13        """Binary Output State constructor.
14
15        Each binary output can be configured using the :obj:`state` value as follows:
16        - 0 - sets output to OFF state
17        - 1 - sets output to ON state
18        - 2-127 - sets output to ON state for the next 2-127 minutes
19        - 128 - reserved
20        - 129-255 - sets output to ON state for the next 1-127 seconds
21
22        Args:
23            index (int): Binary output index.
24            state (int): State to set.
25        """
26        self._validate(index=index, state=state)
27        self._index = index
28        self._state = state

Binary Output State constructor.

Each binary output can be configured using the state value as follows:

  • 0 - sets output to OFF state
  • 1 - sets output to ON state
  • 2-127 - sets output to ON state for the next 2-127 minutes
  • 128 - reserved
  • 129-255 - sets output to ON state for the next 1-127 seconds
Arguments:
  • index (int): Binary output index.
  • state (int): State to set.
index: int

int: Binary output index.

Getter and setter.

state: int

int: Binary output state.

Getter and setter.

def to_json(self) -> dict:
 92    def to_json(self) -> dict:
 93        """Serialize Binary Output State to JSON API param.
 94
 95        Returns:
 96            dict: JSON-serialized Binary Output State
 97        """
 98        record = {
 99            'index': self.index,
100            'state': self.state > 0,
101        }
102        if 2 <= self.state <= 127:
103            record['time'] = self.state * 60
104        elif 128 <= self.state <= 255:
105            record['time'] = self.state - 128
106        return record

Serialize Binary Output State to JSON API param.

Returns:

dict: JSON-serialized Binary Output State

class CoordinatorAuthorizeBondParams:
 7class CoordinatorAuthorizeBondParams:
 8    """AuthorizeBondParams class.
 9
10    Parameters for AuthorizeBond request. Each object represents a single
11    pair of device address and MID.
12    """
13
14    __slots__ = '_req_addr', '_mid'
15
16    def __init__(self, req_addr: int, mid: int):
17        """AuthorizeBondParams constructor.
18
19        Args:
20            req_addr (int): Device address
21            mid (int): Module ID
22        """
23        self._validate(req_addr=req_addr, mid=mid)
24        self._req_addr = req_addr
25        self._mid = mid
26
27    def _validate(self, req_addr: int, mid: int):
28        """Validates pair parameters.
29
30        Args:
31            req_addr (int): Requested node address.
32            mid (int): Module ID.
33        """
34        self._validate_req_addr(req_addr=req_addr)
35        self._validate_mid(mid=mid)
36
37    @staticmethod
38    def _validate_req_addr(req_addr: int):
39        """Validates requested node address.
40
41        Args:
42            req_addr (int): Requested node address.
43
44        Raises:
45            RequestParameterInvalidValueError: If req_addr is less than 0 or greater than 255.
46        """
47        if not dpa_constants.BYTE_MIN <= req_addr <= dpa_constants.BYTE_MAX:
48            raise RequestParameterInvalidValueError('Requested address value should be between 1 and 239.')
49
50    @property
51    def req_addr(self) -> int:
52        """:obj:`int`: Requested node address.
53
54        Getter and setter.
55        """
56        return self._req_addr
57
58    @req_addr.setter
59    def req_addr(self, value: int):
60        self._validate_req_addr(req_addr=value)
61        self._req_addr = value
62
63    @staticmethod
64    def _validate_mid(mid: int):
65        """Validates module ID.
66
67        Args:
68            mid (int): Module ID.
69
70        Raises:
71            RequestParameterInvalidValueError: If mid is less than 0 or greater than 4294967295.
72        """
73        if not dpa_constants.MID_MIN <= mid <= dpa_constants.MID_MAX:
74            raise RequestParameterInvalidValueError('MID value should be an unsigned 32bit integer.')
75
76    @property
77    def mid(self) -> int:
78        """:obj:`int`: Module ID.
79
80        Getter and setter.
81        """
82        return self._mid
83
84    @mid.setter
85    def mid(self, value: int):
86        self._validate_mid(mid=value)
87        self._mid = value

AuthorizeBondParams class.

Parameters for AuthorizeBond request. Each object represents a single pair of device address and MID.

CoordinatorAuthorizeBondParams(req_addr: int, mid: int)
16    def __init__(self, req_addr: int, mid: int):
17        """AuthorizeBondParams constructor.
18
19        Args:
20            req_addr (int): Device address
21            mid (int): Module ID
22        """
23        self._validate(req_addr=req_addr, mid=mid)
24        self._req_addr = req_addr
25        self._mid = mid

AuthorizeBondParams constructor.

Arguments:
  • req_addr (int): Device address
  • mid (int): Module ID
req_addr: int

int: Requested node address.

Getter and setter.

mid: int

int: Module ID.

Getter and setter.

class CoordinatorDpaParam(enum.IntEnum):
 6class CoordinatorDpaParam(IntEnum):
 7    """DpaParam class.
 8
 9    Parameters for SetDpaParams request.
10    """
11    LAST_RSSI = 0
12    VOLTAGE = 1
13    SYSTEM = 2
14    USER_SPECIFIED = 3

DpaParam class.

Parameters for SetDpaParams request.

USER_SPECIFIED = <CoordinatorDpaParam.USER_SPECIFIED: 3>
Inherited Members
enum.Enum
name
value
builtins.int
conjugate
bit_length
bit_count
to_bytes
from_bytes
as_integer_ratio
real
imag
numerator
denominator
@dataclass
class ExplorationPerEnumData:
 7@dataclass
 8class ExplorationPerEnumData:
 9    """Exploration Peripheral Enumeration Data class."""
10
11    __slots__ = 'dpa_version', 'user_per_nr', 'embedded_pers', 'hwpid', 'hwpid_ver', 'flags', 'user_per'
12
13    def __init__(self, result: dict, os_read: bool = False):
14        """Peripheral Enumeration Data constructor.
15
16        Args:
17            result (dict): Peripheral enumeration result.
18            os_read (boolean): Data parsed from OS Read response.
19        """
20        self.dpa_version: int = result['dpaVer']
21        """DPA version."""
22        self.user_per_nr: int = result['perNr']
23        """Number of non-embedded peripherals implemented by custom DPA handler."""
24        self.embedded_pers: List[int] = result['embeddedPers']
25        """List of embedded peripherals implemented by device."""
26        self.hwpid: int = result['hwpid']
27        """Hardware profile ID."""
28        self.hwpid_ver: int = result['hwpidVer']
29        """Hardware profile version."""
30        self.flags: int = result['flagsEnum' if os_read else 'flags']
31        """Device function flags."""
32        self.user_per: List[int] = result['userPer']
33        """List of non-embedded peripherals implemented by device."""

Exploration Peripheral Enumeration Data class.

ExplorationPerEnumData(result: dict, os_read: bool = False)
13    def __init__(self, result: dict, os_read: bool = False):
14        """Peripheral Enumeration Data constructor.
15
16        Args:
17            result (dict): Peripheral enumeration result.
18            os_read (boolean): Data parsed from OS Read response.
19        """
20        self.dpa_version: int = result['dpaVer']
21        """DPA version."""
22        self.user_per_nr: int = result['perNr']
23        """Number of non-embedded peripherals implemented by custom DPA handler."""
24        self.embedded_pers: List[int] = result['embeddedPers']
25        """List of embedded peripherals implemented by device."""
26        self.hwpid: int = result['hwpid']
27        """Hardware profile ID."""
28        self.hwpid_ver: int = result['hwpidVer']
29        """Hardware profile version."""
30        self.flags: int = result['flagsEnum' if os_read else 'flags']
31        """Device function flags."""
32        self.user_per: List[int] = result['userPer']
33        """List of non-embedded peripherals implemented by device."""

Peripheral Enumeration Data constructor.

Arguments:
  • result (dict): Peripheral enumeration result.
  • os_read (boolean): Data parsed from OS Read response.
dpa_version: int

DPA version.

user_per_nr: int

Number of non-embedded peripherals implemented by custom DPA handler.

embedded_pers: List[int]

List of embedded peripherals implemented by device.

hwpid: int

Hardware profile ID.

hwpid_ver: int

Hardware profile version.

flags: int

Device function flags.

user_per: List[int]

List of non-embedded peripherals implemented by device.

@dataclass
class ExplorationPerInfoData:
 8@dataclass
 9class ExplorationPerInfoData:
10    """Exploration Peripheral Information Data class."""
11
12    __slots__ = 'perte', 'pert', 'par1', 'par2'
13
14    def __init__(self, result: dict):
15        """Peripheral Information Data constructor.
16
17        Args:
18            result (dict): Peripheral enumeration result.
19        """
20        self.perte: int = result['perTe']
21        """Extended peripheral characteristic."""
22        self.pert: Union[PeripheralTypes, int] = result['perT']
23        """Peripheral type. If the peripheral is not supported or enabled, value is equal
24        to :obj:`PERIPHERAL_TYPE_DUMMY`."""
25        self.par1 = result['par1']
26        """Optional peripheral specific information."""
27        self.par2 = result['par2']
28        """Optional peripheral specific information."""

Exploration Peripheral Information Data class.

ExplorationPerInfoData(result: dict)
14    def __init__(self, result: dict):
15        """Peripheral Information Data constructor.
16
17        Args:
18            result (dict): Peripheral enumeration result.
19        """
20        self.perte: int = result['perTe']
21        """Extended peripheral characteristic."""
22        self.pert: Union[PeripheralTypes, int] = result['perT']
23        """Peripheral type. If the peripheral is not supported or enabled, value is equal
24        to :obj:`PERIPHERAL_TYPE_DUMMY`."""
25        self.par1 = result['par1']
26        """Optional peripheral specific information."""
27        self.par2 = result['par2']
28        """Optional peripheral specific information."""

Peripheral Information Data constructor.

Arguments:
  • result (dict): Peripheral enumeration result.
perte: int

Extended peripheral characteristic.

Peripheral type. If the peripheral is not supported or enabled, value is equal to PERIPHERAL_TYPE_DUMMY.

par1

Optional peripheral specific information.

par2

Optional peripheral specific information.

@dataclass
class FrcParams:
 7@dataclass
 8class FrcParams:
 9    """FRC Params class."""
10
11    __slots__ = 'offline_frc', 'frc_response_time'
12
13    def __init__(self, offline_frc: bool = False, frc_response_time: FrcResponseTimes = FrcResponseTimes.MS40):
14        """FRC Params constructor.
15
16        Args:
17            offline_frc (bool): Offline FRC.
18            frc_response_time (FrcResponseTimes): FRC response time.
19        """
20        self.offline_frc: bool = offline_frc
21        """Offline FRC."""
22        self.frc_response_time: FrcResponseTimes = frc_response_time
23        """FRC response time."""
24
25    @classmethod
26    def from_int(cls, value: int) -> 'FrcParams':
27        """Deserializes FRC Params integer value into FRC Params object.
28
29        Args:
30            value (int): FRC params integer value.
31        """
32        return cls(
33            offline_frc=bool(value & 0x08),
34            frc_response_time=FrcResponseTimes(value & 0x70)
35        )
36
37    def to_data(self) -> int:
38        """Serialize FRC Params object into an integer value.
39
40        Returns:
41            :obj:`int`: Serialized FRC params value.
42        """
43        return self.frc_response_time | int(self.offline_frc) << 3

FRC Params class.

FrcParams( offline_frc: bool = False, frc_response_time: iqrfpy.utils.dpa.FrcResponseTimes = <FrcResponseTimes.MS40: 0>)
13    def __init__(self, offline_frc: bool = False, frc_response_time: FrcResponseTimes = FrcResponseTimes.MS40):
14        """FRC Params constructor.
15
16        Args:
17            offline_frc (bool): Offline FRC.
18            frc_response_time (FrcResponseTimes): FRC response time.
19        """
20        self.offline_frc: bool = offline_frc
21        """Offline FRC."""
22        self.frc_response_time: FrcResponseTimes = frc_response_time
23        """FRC response time."""

FRC Params constructor.

Arguments:
  • offline_frc (bool): Offline FRC.
  • frc_response_time (FrcResponseTimes): FRC response time.
offline_frc: bool

Offline FRC.

FRC response time.

@classmethod
def from_int(cls, value: int) -> FrcParams:
25    @classmethod
26    def from_int(cls, value: int) -> 'FrcParams':
27        """Deserializes FRC Params integer value into FRC Params object.
28
29        Args:
30            value (int): FRC params integer value.
31        """
32        return cls(
33            offline_frc=bool(value & 0x08),
34            frc_response_time=FrcResponseTimes(value & 0x70)
35        )

Deserializes FRC Params integer value into FRC Params object.

Arguments:
  • value (int): FRC params integer value.
def to_data(self) -> int:
37    def to_data(self) -> int:
38        """Serialize FRC Params object into an integer value.
39
40        Returns:
41            :obj:`int`: Serialized FRC params value.
42        """
43        return self.frc_response_time | int(self.offline_frc) << 3

Serialize FRC Params object into an integer value.

Returns:

int: Serialized FRC params value.

@dataclass
class InitPhyData:
10@dataclass
11class InitPhyData:
12    """TR configuration InitPhy data class."""
13
14    __slots__ = 'rf_band', 'thermometer_present', 'serial_eeprom_present', 'il_type', 'value'
15
16    def __init__(self, val: int):
17        """TR configuration InitPhy data constructor.
18
19        Args:
20            val (int): InitPhy value.
21        """
22        rf_band = val & 0x03
23        self.rf_band: Optional[RfBands] = RfBands(rf_band) if rf_band in RfBands else None
24        """RF Band."""
25        self.thermometer_present = bool(val & 0x10)
26        """Thermometer chip is present."""
27        self.serial_eeprom_present = bool(val & 0x20)
28        """Serial EEPROM chip is present."""
29        self.il_type = bool(val & 0x40)
30        """Transceiver for Israel region."""
31        self.value: int = val
32        """Raw value."""

TR configuration InitPhy data class.

InitPhyData(val: int)
16    def __init__(self, val: int):
17        """TR configuration InitPhy data constructor.
18
19        Args:
20            val (int): InitPhy value.
21        """
22        rf_band = val & 0x03
23        self.rf_band: Optional[RfBands] = RfBands(rf_band) if rf_band in RfBands else None
24        """RF Band."""
25        self.thermometer_present = bool(val & 0x10)
26        """Thermometer chip is present."""
27        self.serial_eeprom_present = bool(val & 0x20)
28        """Serial EEPROM chip is present."""
29        self.il_type = bool(val & 0x40)
30        """Transceiver for Israel region."""
31        self.value: int = val
32        """Raw value."""

TR configuration InitPhy data constructor.

Arguments:
  • val (int): InitPhy value.
rf_band: Optional[iqrfpy.utils.dpa.RfBands]

RF Band.

thermometer_present

Thermometer chip is present.

serial_eeprom_present

Serial EEPROM chip is present.

il_type

Transceiver for Israel region.

value: int

Raw value.

class IoTriplet:
  8class IoTriplet:
  9    """IO Triplet parameter class."""
 10
 11    __slots__ = '_port', '_mask', '_value'
 12
 13    def __init__(self, port: Union[IoConstants, int], mask: int, value: int):
 14        """IO Triplet constructor.
 15
 16        Args:
 17            port (Union[IoConstants, int]): Port number.
 18            mask (int): Port pin mask.
 19            value (int): Value to write.
 20        """
 21        self._validate(port=port, mask=mask, value=value)
 22        self._port = port
 23        self._mask = mask
 24        self._value = value
 25
 26    def _validate(self, port: int, mask: int, value: int):
 27        """Validate IO triplet parameters.
 28
 29        Args:
 30            port (int): Port number.
 31            mask (int): Port pin mask.
 32            value (int): Value to write.
 33        """
 34        self._validate_port(port=port)
 35        self._validate_mask(mask=mask)
 36        self._validate_value(value=value)
 37
 38    @staticmethod
 39    def _validate_port(port: Union[IoConstants, int]):
 40        """Validate port number.
 41
 42        Args:
 43            port (Union[IoConstants, int]): Port number.
 44
 45        Raises:
 46            RequestParameterInvalidValueError: If port is less than 0 or greater than 255.
 47        """
 48        if not BYTE_MIN <= port <= BYTE_MAX:
 49            raise RequestParameterInvalidValueError('Port should be between 0 and 255.')
 50
 51    @property
 52    def port(self) -> Union[IoConstants, int]:
 53        """:obj:`int` or :obj:`IoConstants`: Port number.
 54
 55        Getter and setter.
 56        """
 57        return self._port
 58
 59    @port.setter
 60    def port(self, val: Union[IoConstants, int]):
 61        self._validate_port(port=val)
 62        self._value = val
 63
 64    @staticmethod
 65    def _validate_mask(mask: int):
 66        """Validate port pin mask.
 67
 68        Args:
 69            mask (int): Port pin mask.
 70
 71        Raises:
 72            RequestParameterInvalidValueError: If mask is less than 0 or greater than 255.
 73        """
 74        if not BYTE_MIN <= mask <= BYTE_MAX:
 75            raise RequestParameterInvalidValueError('Mask should be between 0 and 255.')
 76
 77    @property
 78    def mask(self) -> int:
 79        """:obj:`int`: Port pin mask.
 80
 81        Getter and setter.
 82        """
 83        return self._mask
 84
 85    @mask.setter
 86    def mask(self, val: int):
 87        self._validate_mask(mask=val)
 88        self._mask = val
 89
 90    @staticmethod
 91    def _validate_value(value: int):
 92        """Validate value to write.
 93
 94        Args:
 95            value (int): Value to write.
 96
 97        Raises:
 98            RequestParameterInvalidValueError: If value is less than 0 or greater than 255.
 99        """
100        if not BYTE_MIN <= value <= BYTE_MAX:
101            raise RequestParameterInvalidValueError('Value should be between 0 and 255.')
102
103    @property
104    def value(self) -> int:
105        """:obj:`int`: Value to write.
106
107        Getter and setter.
108        """
109        return self._value
110
111    @value.setter
112    def value(self, val: int):
113        self._validate_value(value=val)
114        self._value = val

IO Triplet parameter class.

IoTriplet( port: Union[iqrfpy.utils.dpa.IoConstants, int], mask: int, value: int)
13    def __init__(self, port: Union[IoConstants, int], mask: int, value: int):
14        """IO Triplet constructor.
15
16        Args:
17            port (Union[IoConstants, int]): Port number.
18            mask (int): Port pin mask.
19            value (int): Value to write.
20        """
21        self._validate(port=port, mask=mask, value=value)
22        self._port = port
23        self._mask = mask
24        self._value = value

IO Triplet constructor.

Arguments:
  • port (Union[IoConstants, int]): Port number.
  • mask (int): Port pin mask.
  • value (int): Value to write.
port: Union[iqrfpy.utils.dpa.IoConstants, int]

int or IoConstants: Port number.

Getter and setter.

mask: int

int: Port pin mask.

Getter and setter.

value: int

int: Value to write.

Getter and setter.

@dataclass
class NodeReadData:
 6@dataclass
 7class NodeReadData:
 8    """Node Read Data class."""
 9
10    __slots__ = 'ntw_addr', 'ntw_vrn', 'ntw_zin', 'ntw_did', 'ntw_pvrn', 'ntw_useraddr', 'ntw_id', 'ntw_vrnfnz', \
11        'ntw_cfg', 'flags'
12
13    def __init__(self, data: dict):
14        """Node Read Data constructor.
15
16        Args:
17            data (dict): Node read result.
18        """
19        self.ntw_addr: int = data['ntwADDR']
20        """Logical node address."""
21        self.ntw_vrn: int = data['ntwVRN']
22        """Virtual routing number."""
23        self.ntw_zin: int = data['ntwZIN']
24        """Zone index (zone number + 1)."""
25        self.ntw_did: int = data['ntwDID']
26        """Discovery ID."""
27        self.ntw_pvrn: int = data['ntwPVRN']
28        """Parent virtual routing number."""
29        self.ntw_useraddr: int = data['ntwUSERADDRESS']
30        """User address."""
31        self.ntw_id: int = data['ntwID']
32        """Network identification."""
33        self.ntw_vrnfnz: int = data['ntwVRNFNZ']
34        """Virtual routing number of first node in zone."""
35        self.ntw_cfg: int = data['ntwCFG']
36        """Network configuration."""
37        self.flags: int = data['flags']
38        """Node flags."""

Node Read Data class.

NodeReadData(data: dict)
13    def __init__(self, data: dict):
14        """Node Read Data constructor.
15
16        Args:
17            data (dict): Node read result.
18        """
19        self.ntw_addr: int = data['ntwADDR']
20        """Logical node address."""
21        self.ntw_vrn: int = data['ntwVRN']
22        """Virtual routing number."""
23        self.ntw_zin: int = data['ntwZIN']
24        """Zone index (zone number + 1)."""
25        self.ntw_did: int = data['ntwDID']
26        """Discovery ID."""
27        self.ntw_pvrn: int = data['ntwPVRN']
28        """Parent virtual routing number."""
29        self.ntw_useraddr: int = data['ntwUSERADDRESS']
30        """User address."""
31        self.ntw_id: int = data['ntwID']
32        """Network identification."""
33        self.ntw_vrnfnz: int = data['ntwVRNFNZ']
34        """Virtual routing number of first node in zone."""
35        self.ntw_cfg: int = data['ntwCFG']
36        """Network configuration."""
37        self.flags: int = data['flags']
38        """Node flags."""

Node Read Data constructor.

Arguments:
  • data (dict): Node read result.
ntw_addr: int

Logical node address.

ntw_vrn: int

Virtual routing number.

ntw_zin: int

Zone index (zone number + 1).

ntw_did: int

Discovery ID.

ntw_pvrn: int

Parent virtual routing number.

ntw_useraddr: int

User address.

ntw_id: int

Network identification.

ntw_vrnfnz: int

Virtual routing number of first node in zone.

ntw_cfg: int

Network configuration.

flags: int

Node flags.

class NodeValidateBondsParams:
 7class NodeValidateBondsParams:
 8    """Node Validate Bonds parameters class."""
 9
10    __slots__ = '_bond_addr', '_mid'
11
12    def __init__(self, bond_addr: int, mid: int):
13        """Validate Bonds parameters constructor.
14
15        Args:
16            bond_addr (int): Node device address.
17            mid (int): Node module ID.
18        """
19        self._validate(bond_addr=bond_addr, mid=mid)
20        self._bond_addr = bond_addr
21        self._mid = mid
22
23    def _validate(self, bond_addr: int, mid: int):
24        """Validate parameters.
25
26        Args:
27            bond_addr (int): Node device address.
28            mid (int): Node module ID.
29        """
30        self._validate_bond_addr(bond_addr)
31        self._validate_mid(mid)
32
33    @staticmethod
34    def _validate_bond_addr(bond_addr: int):
35        """Validate node device address parameter.
36
37        Args:
38            bond_addr (int): Node device address.
39
40        Raises:
41            RequestParameterInvalidValueError: If bond_addr is less than 0 or greater than 255.
42        """
43        if not dpa_constants.BYTE_MIN <= bond_addr <= dpa_constants.BYTE_MAX:
44            raise RequestParameterInvalidValueError('Bond address value should be between 0 and 255.')
45
46    @property
47    def bond_addr(self) -> int:
48        """:obj:`int`: Node device address.
49
50        Getter and setter.
51        """
52        return self._bond_addr
53
54    @bond_addr.setter
55    def bond_addr(self, value: int):
56        self._validate_bond_addr(value)
57        self._bond_addr = value
58
59    @staticmethod
60    def _validate_mid(mid: int):
61        """Validate module ID parameter.
62
63        Args:
64            mid (int): Node module ID.
65
66        Raises:
67            RequestParameterInvalidValueError: If mid is less than 0 or greater than 4294967295.
68        """
69        if not dpa_constants.MID_MIN <= mid <= dpa_constants.MID_MAX:
70            raise RequestParameterInvalidValueError('MID value should be an unsigned 32bit integer.')
71
72    @property
73    def mid(self):
74        """:obj:`int`: Module ID.
75
76        Getter and setter.
77        """
78        return self._mid
79
80    @mid.setter
81    def mid(self, value):
82        self._validate_mid(value)
83        self._mid = value

Node Validate Bonds parameters class.

NodeValidateBondsParams(bond_addr: int, mid: int)
12    def __init__(self, bond_addr: int, mid: int):
13        """Validate Bonds parameters constructor.
14
15        Args:
16            bond_addr (int): Node device address.
17            mid (int): Node module ID.
18        """
19        self._validate(bond_addr=bond_addr, mid=mid)
20        self._bond_addr = bond_addr
21        self._mid = mid

Validate Bonds parameters constructor.

Arguments:
  • bond_addr (int): Node device address.
  • mid (int): Node module ID.
bond_addr: int

int: Node device address.

Getter and setter.

mid

int: Module ID.

Getter and setter.

class OsBatchData:
 11class OsBatchData:
 12    """Batch Data class."""
 13
 14    __slots__ = '_pnum', '_pcmd', '_hwpid', '_pdata'
 15
 16    def __init__(self, pnum: Union[Peripheral, int], pcmd: Union[Command, int], hwpid: int = dpa_constants.HWPID_MAX,
 17                 pdata: Optional[List[int]] = None):
 18        """Batch Data constructor.
 19
 20        Args:
 21            pnum (Union[Peripheral, int]): Peripheral number.
 22            pcmd (Union[Command, int]): Peripheral command.
 23            hwpid (int): Hardware profile ID. Defaults to 65535, this value ignores HWPID check.
 24            pdata (List[int], optional): Request data.
 25        """
 26        self._validate(pnum=pnum, pcmd=pcmd, hwpid=hwpid, pdata=pdata)
 27        self._pnum = pnum
 28        self._pcmd = pcmd
 29        self._hwpid = hwpid
 30        self._pdata = pdata if pdata is not None else []
 31
 32    def _validate(self, pnum: Union[Peripheral, int], pcmd: Union[Command, int], hwpid: int,
 33                  pdata: Optional[List[int]] = None):
 34        """Validate batch parameters.
 35
 36        Args:
 37            pnum (Union[Peripheral, int]): Peripheral number.
 38            pcmd (Union[Command, int]): Peripheral command.
 39            hwpid (int): Hardware profile ID. Defaults to 65535, this value ignores HWPID check.
 40            pdata (List[int], optional): Request data.
 41        """
 42        self._validate_pnum(pnum)
 43        self._validate_pcmd(pcmd)
 44        self._validate_hwpid(hwpid)
 45        self._validate_pdata(pdata)
 46
 47    @staticmethod
 48    def _validate_pnum(pnum: Union[Peripheral, int]):
 49        """Validate peripheral number parameter.
 50
 51        Args:
 52            pnum (Union[Peripheral, int]): Peripheral number.
 53
 54        Raises:
 55            RequestParameterInvalidValueError: If pnum is less than 0 or greater than 255.
 56        """
 57        if not dpa_constants.BYTE_MIN <= pnum <= dpa_constants.BYTE_MAX:
 58            raise RequestParameterInvalidValueError('PNUM value should be between 0 and 255.')
 59
 60    @property
 61    def pnum(self) -> Union[Peripheral, int]:
 62        """:obj:`Peripheral` or :obj:`int`: Peripheral number.
 63
 64        Getter and setter.
 65        """
 66        return self._pnum
 67
 68    @pnum.setter
 69    def pnum(self, value: Union[Peripheral, int]):
 70        self._validate_pnum(value)
 71        self._pnum = value
 72
 73    @staticmethod
 74    def _validate_pcmd(pcmd: Union[Command, int]):
 75        """Validate peripheral command parameter.
 76
 77        Args:
 78            pcmd (Union[Command, int]): Peripheral command.
 79
 80        Raises:
 81            RequestParameterInvalidValueError: If pcmd is less than 0 or greater than 255.
 82        """
 83        if not dpa_constants.BYTE_MIN <= pcmd <= dpa_constants.BYTE_MAX:
 84            raise RequestParameterInvalidValueError('PCMD value should be between 0 and 255.')
 85
 86    @property
 87    def pcmd(self) -> Union[Command, int]:
 88        """:obj:`Command` or :obj:`int`: Peripheral command.
 89
 90        Getter and setter.
 91        """
 92        return self._pcmd
 93
 94    @pcmd.setter
 95    def pcmd(self, value: Union[Command, int]):
 96        self._validate_pcmd(value)
 97        self._pcmd = value
 98
 99    @staticmethod
100    def _validate_hwpid(hwpid: int):
101        """Validate hardware profile ID parameter.
102
103        Args:
104            hwpid (int): Hardware profile ID. Defaults to 65535, this value ignores HWPID check.
105
106        Raises:
107            RequestParameterInvalidValueError: If hwpid is less than 0 or greater than 65535.
108        """
109        if not dpa_constants.HWPID_MIN <= hwpid <= dpa_constants.HWPID_MAX:
110            raise RequestParameterInvalidValueError('HWPID value should be between 0 and 65535.')
111
112    @property
113    def hwpid(self) -> int:
114        """:obj:`int`: Hardware profile ID.
115
116        Getter and setter.
117        """
118        return self._hwpid
119
120    @hwpid.setter
121    def hwpid(self, value: int):
122        self._validate_hwpid(value)
123        self._hwpid = value
124
125    @staticmethod
126    def _validate_pdata(pdata: Optional[List[int]] = None):
127        """Validate pdata parameter.
128
129        Args:
130            pdata (List[int], optional): Request data.
131        """
132        if pdata is None:
133            return
134        if not Common.values_in_byte_range(pdata):
135            raise RequestParameterInvalidValueError('PDATA values should be between 0 and 255.')
136
137    @property
138    def pdata(self) -> Optional[List[int]]:
139        """:obj:`list` of :obj:`int` or :obj:`None`: Request data.
140
141        Getter and setter.
142        """
143        return self._pdata
144
145    @pdata.setter
146    def pdata(self, value: Optional[List[int]] = None):
147        self._validate_pdata(value)
148        self._pdata = value if value is not None else []
149
150    def to_pdata(self) -> List[int]:
151        """Serialize batch data into DPA request pdata.
152
153        Returns:
154            :obj:`list` of :obj:`int`: Serialized DPA request pdata.
155        """
156        data = [self._pnum, self._pcmd, self._hwpid & 0xFF, (self._hwpid >> 8) & 0xFF] + self._pdata
157        return [len(data) + 1] + data
158
159    def to_json(self) -> dict:
160        """Serialize batch data into JSON API request data.
161
162        Returns:
163            :obj:`dict`: Serialized JSON API request data.
164        """
165        data = {
166            'pnum': f'{self._pnum:02x}',
167            'pcmd': f'{self._pcmd:02x}',
168            'hwpid': f'{self._hwpid:04x}',
169        }
170        if self._pdata is not None and len(self._pdata) > 0:
171            data['rdata'] = '.'.join([f'{x:02x}' for x in self._pdata])
172        return data

Batch Data class.

OsBatchData( pnum: Union[iqrfpy.enums.peripherals.Peripheral, int], pcmd: Union[iqrfpy.enums.commands.Command, int], hwpid: int = 65535, pdata: Optional[List[int]] = None)
16    def __init__(self, pnum: Union[Peripheral, int], pcmd: Union[Command, int], hwpid: int = dpa_constants.HWPID_MAX,
17                 pdata: Optional[List[int]] = None):
18        """Batch Data constructor.
19
20        Args:
21            pnum (Union[Peripheral, int]): Peripheral number.
22            pcmd (Union[Command, int]): Peripheral command.
23            hwpid (int): Hardware profile ID. Defaults to 65535, this value ignores HWPID check.
24            pdata (List[int], optional): Request data.
25        """
26        self._validate(pnum=pnum, pcmd=pcmd, hwpid=hwpid, pdata=pdata)
27        self._pnum = pnum
28        self._pcmd = pcmd
29        self._hwpid = hwpid
30        self._pdata = pdata if pdata is not None else []

Batch Data constructor.

Arguments:
  • pnum (Union[Peripheral, int]): Peripheral number.
  • pcmd (Union[Command, int]): Peripheral command.
  • hwpid (int): Hardware profile ID. Defaults to 65535, this value ignores HWPID check.
  • pdata (List[int], optional): Request data.

Peripheral or int: Peripheral number.

Getter and setter.

pcmd: Union[iqrfpy.enums.commands.Command, int]

Command or int: Peripheral command.

Getter and setter.

hwpid: int

int: Hardware profile ID.

Getter and setter.

pdata: Optional[List[int]]

list of int or None: Request data.

Getter and setter.

def to_pdata(self) -> List[int]:
150    def to_pdata(self) -> List[int]:
151        """Serialize batch data into DPA request pdata.
152
153        Returns:
154            :obj:`list` of :obj:`int`: Serialized DPA request pdata.
155        """
156        data = [self._pnum, self._pcmd, self._hwpid & 0xFF, (self._hwpid >> 8) & 0xFF] + self._pdata
157        return [len(data) + 1] + data

Serialize batch data into DPA request pdata.

Returns:

list of int: Serialized DPA request pdata.

def to_json(self) -> dict:
159    def to_json(self) -> dict:
160        """Serialize batch data into JSON API request data.
161
162        Returns:
163            :obj:`dict`: Serialized JSON API request data.
164        """
165        data = {
166            'pnum': f'{self._pnum:02x}',
167            'pcmd': f'{self._pcmd:02x}',
168            'hwpid': f'{self._hwpid:04x}',
169        }
170        if self._pdata is not None and len(self._pdata) > 0:
171            data['rdata'] = '.'.join([f'{x:02x}' for x in self._pdata])
172        return data

Serialize batch data into JSON API request data.

Returns:

dict: Serialized JSON API request data.

class OsIndicateParam(iqrfpy.utils.enums.IntEnumMember):
 6class OsIndicateParam(IntEnumMember):
 7    """OS Indicate control params enum."""
 8
 9    OFF = 0
10    ON = 1
11    INDICATE_1S = 2
12    INDICATE_10S = 3

OS Indicate control params enum.

OFF = <OsIndicateParam.OFF: 0>
ON = <OsIndicateParam.ON: 1>
INDICATE_1S = <OsIndicateParam.INDICATE_1S: 2>
INDICATE_10S = <OsIndicateParam.INDICATE_10S: 3>
Inherited Members
enum.Enum
name
value
builtins.int
conjugate
bit_length
bit_count
to_bytes
from_bytes
as_integer_ratio
real
imag
numerator
denominator
class OsLoadCodeFlags:
 6class OsLoadCodeFlags:
 7    """OS Load Code flags class."""
 8    __slots__ = '_action', '_code_type'
 9
10    def __init__(self, action: OsLoadCodeAction, code_type: OsLoadCodeType):
11        """Load Code flags constructor.
12
13        Args:
14            action (OsLoadCodeAction): Load code action.
15            code_type (OsLoadCodeType): Load code code type.
16        """
17        self._action = action
18        self._code_type = code_type
19
20    @property
21    def action(self) -> OsLoadCodeAction:
22        """:obj:`OsLoadCodeAction`: Load Code action.
23
24        Getter and setter.
25        """
26        return self._action
27
28    @action.setter
29    def action(self, value: OsLoadCodeAction):
30        self._action = value
31
32    @property
33    def code_type(self) -> OsLoadCodeType:
34        """:obj:`OsLoadCodeType`: Load Code code type.
35
36        Getter and setter.
37        """
38        return self._code_type
39
40    @code_type.setter
41    def code_type(self, value: OsLoadCodeType):
42        self._code_type = value
43
44    def serialize(self) -> int:
45        """Serialize flags into an integer value.
46
47        Returns:
48            :obj:`int`: Flags value.
49        """
50        return self._action | (self._code_type << 1)

OS Load Code flags class.

OsLoadCodeFlags( action: iqrfpy.utils.dpa.OsLoadCodeAction, code_type: iqrfpy.utils.dpa.OsLoadCodeType)
10    def __init__(self, action: OsLoadCodeAction, code_type: OsLoadCodeType):
11        """Load Code flags constructor.
12
13        Args:
14            action (OsLoadCodeAction): Load code action.
15            code_type (OsLoadCodeType): Load code code type.
16        """
17        self._action = action
18        self._code_type = code_type

Load Code flags constructor.

Arguments:
  • action (OsLoadCodeAction): Load code action.
  • code_type (OsLoadCodeType): Load code code type.

OsLoadCodeAction: Load Code action.

Getter and setter.

OsLoadCodeType: Load Code code type.

Getter and setter.

def serialize(self) -> int:
44    def serialize(self) -> int:
45        """Serialize flags into an integer value.
46
47        Returns:
48            :obj:`int`: Flags value.
49        """
50        return self._action | (self._code_type << 1)

Serialize flags into an integer value.

Returns:

int: Flags value.

@dataclass
class OsReadData:
 8@dataclass
 9class OsReadData:
10    """OS Read Data class."""
11
12    __slots__ = 'mid', 'os_version', 'tr_mcu_type', 'os_build', 'rssi', 'supply_voltage', 'flags', 'slot_limits', 'ibk', \
13        'per_enum'
14
15    def __init__(self, data: dict):
16        """Read Data constructor.
17
18        Args:
19            data (dict): OS Read data.
20        """
21        self.mid: int = data['mid']
22        """Module ID."""
23        self.os_version: int = data['osVersion']
24        """OS version."""
25        self.tr_mcu_type: TrMcuTypeData = TrMcuTypeData(data['trMcuType'])
26        """MCU type and TR series."""
27        self.os_build: int = data['osBuild']
28        """OS build."""
29        self.rssi: int = data['rssi']
30        """RSSI."""
31        self.supply_voltage: int = data['supplyVoltage']
32        """Supply voltage."""
33        self.flags: int = data['flags']
34        """OS flags."""
35        self.slot_limits: int = data['slotLimits']
36        """Slot limits."""
37        self.ibk: int = data['ibk']
38        """Individual bonding key."""
39        self.per_enum: ExplorationPerEnumData = ExplorationPerEnumData(data, os_read=True)
40        """Peripheral enumeration data."""

OS Read Data class.

OsReadData(data: dict)
15    def __init__(self, data: dict):
16        """Read Data constructor.
17
18        Args:
19            data (dict): OS Read data.
20        """
21        self.mid: int = data['mid']
22        """Module ID."""
23        self.os_version: int = data['osVersion']
24        """OS version."""
25        self.tr_mcu_type: TrMcuTypeData = TrMcuTypeData(data['trMcuType'])
26        """MCU type and TR series."""
27        self.os_build: int = data['osBuild']
28        """OS build."""
29        self.rssi: int = data['rssi']
30        """RSSI."""
31        self.supply_voltage: int = data['supplyVoltage']
32        """Supply voltage."""
33        self.flags: int = data['flags']
34        """OS flags."""
35        self.slot_limits: int = data['slotLimits']
36        """Slot limits."""
37        self.ibk: int = data['ibk']
38        """Individual bonding key."""
39        self.per_enum: ExplorationPerEnumData = ExplorationPerEnumData(data, os_read=True)
40        """Peripheral enumeration data."""

Read Data constructor.

Arguments:
  • data (dict): OS Read data.
mid: int

Module ID.

os_version: int

OS version.

tr_mcu_type: TrMcuTypeData

MCU type and TR series.

os_build: int

OS build.

rssi: int

RSSI.

supply_voltage: int

Supply voltage.

flags: int

OS flags.

slot_limits: int

Slot limits.

ibk: int

Individual bonding key.

Peripheral enumeration data.

class OsSecurityTypeParam(iqrfpy.utils.enums.IntEnumMember):
 6class OsSecurityTypeParam(IntEnumMember):
 7    """OS Security type enum."""
 8
 9    ACCESS_PASSWORD = 0
10    USER_KEY = 1

OS Security type enum.

ACCESS_PASSWORD = <OsSecurityTypeParam.ACCESS_PASSWORD: 0>
Inherited Members
enum.Enum
name
value
builtins.int
conjugate
bit_length
bit_count
to_bytes
from_bytes
as_integer_ratio
real
imag
numerator
denominator
class OsSleepParams:
 8class OsSleepParams:
 9    """OS Sleep Params class."""
10
11    __slots__ = '_time', 'wake_up_on_negative_edge', 'calibrate_before_sleep', 'flash_led_after_sleep', \
12        'wake_up_on_positive_edge', 'use_milliseconds', 'use_deep_sleep'
13
14    def __init__(self, time: int = 0, wake_up_on_negative_edge: bool = False, calibrate_before_sleep: bool = False,
15                 flash_led_after_sleep: bool = False, wake_up_on_positive_edge: bool = False,
16                 use_milliseconds: bool = False, use_deep_sleep: bool = False):
17        """Sleep Params constructor.
18
19        Args:
20            time (int): Sleep time.
21            wake_up_on_negative_edge (bool): Wake up on PORT B, bit 4 negative edge change.
22            calibrate_before_sleep (bool): Run calibration process before sleep.
23            flash_led_after_sleep (bool): Flash green LED once after waking up.
24            wake_up_on_positive_edge (bool): Wake up on PORT B, bit 4 positive edge change.
25            use_milliseconds (bool): Use sleep time with unit of 32.768 ms instead of 2.097s.
26            use_deep_sleep (bool): The IC is shutdown during sleep.
27        """
28        self._validate_time(time)
29        self._time = time
30        self.wake_up_on_negative_edge = wake_up_on_negative_edge
31        """Wake up on PORT B, bit 4 negative edge change."""
32        self.calibrate_before_sleep = calibrate_before_sleep
33        """Run calibration process before sleep."""
34        self.flash_led_after_sleep = flash_led_after_sleep
35        """Flash green LED once after waking up."""
36        self.wake_up_on_positive_edge = wake_up_on_positive_edge
37        """Wake up on PORT B, bit 4 positive edge change."""
38        self.use_milliseconds = use_milliseconds
39        """Use sleep time with unit of 32.768 ms instead of 2.097s."""
40        self.use_deep_sleep = use_deep_sleep
41        """The IC is shutdown during sleep."""
42
43    @staticmethod
44    def _validate_time(time: int):
45        """Validate sleep time parameter.
46
47        Args:
48            time (int): Sleep time.
49
50        Raises:
51            RequestParameterInvalidValueError: If time is less than 0 or greater than 255.
52        """
53        if not dpa_constants.WORD_MIN <= time <= dpa_constants.WORD_MAX:
54            raise RequestParameterInvalidValueError('Time value should be between 0 and 65535.')
55
56    @property
57    def time(self) -> int:
58        """:obj:`int`: Sleep time.
59
60        Getter and setter.
61        """
62        return self._time
63
64    @time.setter
65    def time(self, value: int):
66        self._validate_time(value)
67        self._time = value
68
69    def _calculate_control(self) -> int:
70        """Convert flags into a single value.
71
72        Returns:
73            :obj:`int`: Flags value.
74        """
75        return self.wake_up_on_negative_edge | (self.calibrate_before_sleep << 1) | \
76            (self.flash_led_after_sleep << 2) | (self.wake_up_on_positive_edge << 3) | \
77            (self.use_milliseconds << 4) | (self.use_deep_sleep << 5)
78
79    def to_pdata(self) -> List[int]:
80        """Serialize sleep parameters into DPA request pdata.
81
82        Returns:
83            :obj:`list` of :obj:`int`: Serialized DPA request pdata.
84        """
85        return [self._time & 0xFF, (self.time >> 8) & 0xFF, self._calculate_control()]
86
87    def to_json(self) -> dict:
88        """Serializes sleep parameters into JSON API request data.
89
90        Returns:
91            :obj:`dict`: Serialized JSON API request data.
92        """
93        return {
94            'time': self._time,
95            'control': self._calculate_control()
96        }

OS Sleep Params class.

OsSleepParams( time: int = 0, wake_up_on_negative_edge: bool = False, calibrate_before_sleep: bool = False, flash_led_after_sleep: bool = False, wake_up_on_positive_edge: bool = False, use_milliseconds: bool = False, use_deep_sleep: bool = False)
14    def __init__(self, time: int = 0, wake_up_on_negative_edge: bool = False, calibrate_before_sleep: bool = False,
15                 flash_led_after_sleep: bool = False, wake_up_on_positive_edge: bool = False,
16                 use_milliseconds: bool = False, use_deep_sleep: bool = False):
17        """Sleep Params constructor.
18
19        Args:
20            time (int): Sleep time.
21            wake_up_on_negative_edge (bool): Wake up on PORT B, bit 4 negative edge change.
22            calibrate_before_sleep (bool): Run calibration process before sleep.
23            flash_led_after_sleep (bool): Flash green LED once after waking up.
24            wake_up_on_positive_edge (bool): Wake up on PORT B, bit 4 positive edge change.
25            use_milliseconds (bool): Use sleep time with unit of 32.768 ms instead of 2.097s.
26            use_deep_sleep (bool): The IC is shutdown during sleep.
27        """
28        self._validate_time(time)
29        self._time = time
30        self.wake_up_on_negative_edge = wake_up_on_negative_edge
31        """Wake up on PORT B, bit 4 negative edge change."""
32        self.calibrate_before_sleep = calibrate_before_sleep
33        """Run calibration process before sleep."""
34        self.flash_led_after_sleep = flash_led_after_sleep
35        """Flash green LED once after waking up."""
36        self.wake_up_on_positive_edge = wake_up_on_positive_edge
37        """Wake up on PORT B, bit 4 positive edge change."""
38        self.use_milliseconds = use_milliseconds
39        """Use sleep time with unit of 32.768 ms instead of 2.097s."""
40        self.use_deep_sleep = use_deep_sleep
41        """The IC is shutdown during sleep."""

Sleep Params constructor.

Arguments:
  • time (int): Sleep time.
  • wake_up_on_negative_edge (bool): Wake up on PORT B, bit 4 negative edge change.
  • calibrate_before_sleep (bool): Run calibration process before sleep.
  • flash_led_after_sleep (bool): Flash green LED once after waking up.
  • wake_up_on_positive_edge (bool): Wake up on PORT B, bit 4 positive edge change.
  • use_milliseconds (bool): Use sleep time with unit of 32.768 ms instead of 2.097s.
  • use_deep_sleep (bool): The IC is shutdown during sleep.
wake_up_on_negative_edge

Wake up on PORT B, bit 4 negative edge change.

calibrate_before_sleep

Run calibration process before sleep.

flash_led_after_sleep

Flash green LED once after waking up.

wake_up_on_positive_edge

Wake up on PORT B, bit 4 positive edge change.

use_milliseconds

Use sleep time with unit of 32.768 ms instead of 2.097s.

use_deep_sleep

The IC is shutdown during sleep.

time: int

int: Sleep time.

Getter and setter.

def to_pdata(self) -> List[int]:
79    def to_pdata(self) -> List[int]:
80        """Serialize sleep parameters into DPA request pdata.
81
82        Returns:
83            :obj:`list` of :obj:`int`: Serialized DPA request pdata.
84        """
85        return [self._time & 0xFF, (self.time >> 8) & 0xFF, self._calculate_control()]

Serialize sleep parameters into DPA request pdata.

Returns:

list of int: Serialized DPA request pdata.

def to_json(self) -> dict:
87    def to_json(self) -> dict:
88        """Serializes sleep parameters into JSON API request data.
89
90        Returns:
91            :obj:`dict`: Serialized JSON API request data.
92        """
93        return {
94            'time': self._time,
95            'control': self._calculate_control()
96        }

Serializes sleep parameters into JSON API request data.

Returns:

dict: Serialized JSON API request data.

class OsTrConfByte:
  8class OsTrConfByte:
  9    """TR Configuration Byte class."""
 10
 11    __slots__ = '_address', '_value', '_mask'
 12
 13    def __init__(self, address: int, value: int, mask: int):
 14        """TR Configuration Byte constructor.
 15
 16        Args:
 17            address (int): Configuration memory block address.
 18            value (int): Value to set.
 19            mask (int): Bits of configuration byte to modify.
 20        """
 21        self._validate(address=address, value=value, mask=mask)
 22        self._address = address
 23        self._value = value
 24        self._mask = mask
 25
 26    def __eq__(self, other: 'OsTrConfByte'):
 27        """Rich comparison method, comparing this and another object to determine equality based on properties.
 28
 29        Args:
 30            other (OsTrConfByte): Object to compare with.
 31
 32        Returns:
 33            bool: True if the objects are equivalent, False otherwise.
 34        """
 35        return self.address == other.address and \
 36            self.value == other.value and \
 37            self.mask == other.mask
 38
 39    def _validate(self, address: int, value: int, mask: int):
 40        """Validate TR Configuration Byte parameters.
 41
 42        Args:
 43            address (int): Configuration memory block address.
 44            value (int): Value to set.
 45            mask (int): Bits of configuration byte to modify.
 46        """
 47        self._validate_address(address=address)
 48        self._validate_value(value=value)
 49        self._validate_mask(mask=mask)
 50
 51    @staticmethod
 52    def _validate_address(address: int):
 53        """Validate address parameter.
 54
 55        Args:
 56            address (int): Configuration memory block address.
 57
 58        Raises:
 59            RequestParameterInvalidValueError: If address is less than 0 or greater than 255.
 60        """
 61        if not dpa_constants.BYTE_MIN <= address <= dpa_constants.BYTE_MAX:
 62            raise RequestParameterInvalidValueError('Address value should be between 0 and 255.')
 63
 64    @property
 65    def address(self) -> int:
 66        """:obj:`int`: Configuration memory block address.
 67
 68        Getter and setter.
 69        """
 70        return self._address
 71
 72    @address.setter
 73    def address(self, value: int):
 74        self._validate_address(address=value)
 75        self._address = value
 76
 77    @staticmethod
 78    def _validate_value(value: int):
 79        """Validate value parameter.
 80
 81        Args:
 82            value (int): Value to set.
 83
 84        Raises:
 85            RequestParameterInvalidValueError: If value is less than 0 or greater than 255.
 86        """
 87        if not dpa_constants.BYTE_MIN <= value <= dpa_constants.BYTE_MAX:
 88            raise RequestParameterInvalidValueError('Value should be between 0 and 255.')
 89
 90    @property
 91    def value(self) -> int:
 92        """:obj:`int`: Value to set.
 93
 94        Getter and setter.
 95        """
 96        return self._value
 97
 98    @value.setter
 99    def value(self, val: int):
100        self._validate_value(value=val)
101        self._value = val
102
103    @staticmethod
104    def _validate_mask(mask: int):
105        """Validate mask parameter.
106
107        Args:
108            mask (int): Bits of configuration byte to modify.
109
110        Raises:
111            RequestParameterInvalidValueError: If mask is less than 0 or greater than 255.
112        """
113        if not dpa_constants.BYTE_MIN <= mask <= dpa_constants.BYTE_MAX:
114            raise RequestParameterInvalidValueError('Mask value should be between 0 and 255.')
115
116    @property
117    def mask(self) -> int:
118        """:obj:`int`: Bits of configuration byte to modify.
119
120        Getter and setter.
121        """
122        return self._mask
123
124    @mask.setter
125    def mask(self, value: int):
126        self._validate_mask(mask=value)
127        self._mask = value
128
129    def to_pdata(self) -> List[int]:
130        """Serialize TR configuration byte members into pdata.
131
132        Returns:
133            :obj:`list` of :obj:`int`: Serialized TR configuration byte pdata.
134        """
135        return [self._address, self._value, self._mask]
136
137    def to_json(self) -> dict:
138        """Serialize TR configuration byte members into JSON.
139
140        Returns:
141            :obj:`dict`: Serialized TR configuration byte JSON request data.
142        """
143        return {
144            'address': self._address,
145            'value': self._value,
146            'mask': self._mask
147        }

TR Configuration Byte class.

OsTrConfByte(address: int, value: int, mask: int)
13    def __init__(self, address: int, value: int, mask: int):
14        """TR Configuration Byte constructor.
15
16        Args:
17            address (int): Configuration memory block address.
18            value (int): Value to set.
19            mask (int): Bits of configuration byte to modify.
20        """
21        self._validate(address=address, value=value, mask=mask)
22        self._address = address
23        self._value = value
24        self._mask = mask

TR Configuration Byte constructor.

Arguments:
  • address (int): Configuration memory block address.
  • value (int): Value to set.
  • mask (int): Bits of configuration byte to modify.
address: int

int: Configuration memory block address.

Getter and setter.

value: int

int: Value to set.

Getter and setter.

mask: int

int: Bits of configuration byte to modify.

Getter and setter.

def to_pdata(self) -> List[int]:
129    def to_pdata(self) -> List[int]:
130        """Serialize TR configuration byte members into pdata.
131
132        Returns:
133            :obj:`list` of :obj:`int`: Serialized TR configuration byte pdata.
134        """
135        return [self._address, self._value, self._mask]

Serialize TR configuration byte members into pdata.

Returns:

list of int: Serialized TR configuration byte pdata.

def to_json(self) -> dict:
137    def to_json(self) -> dict:
138        """Serialize TR configuration byte members into JSON.
139
140        Returns:
141            :obj:`dict`: Serialized TR configuration byte JSON request data.
142        """
143        return {
144            'address': self._address,
145            'value': self._value,
146            'mask': self._mask
147        }

Serialize TR configuration byte members into JSON.

Returns:

dict: Serialized TR configuration byte JSON request data.

class OsTrConfData:
 12class OsTrConfData:
 13    """OS TR Configuration data."""
 14
 15    __slots__ = '_embedded_peripherals', '_custom_dpa_handler', '_dpa_peer_to_peer', '_routing_off', '_io_setup', \
 16        '_user_peer_to_peer', '_stay_awake_when_not_bonded', '_std_and_lp_network', '_rf_output_power', \
 17        '_rf_signal_filter', '_lp_rf_timeout', '_uart_baud_rate', '_alternative_dsm_channel', '_local_frc', \
 18        '_rf_channel_a', '_rf_channel_b', '_reserved_block_0', '_reserved_block_1', '_reserved_block_2'
 19
 20    def __init__(self, embedded_peripherals: Optional[List[Union[EmbedPeripherals, int]]] = None,
 21                 custom_dpa_handler: bool = False, dpa_peer_to_peer: bool = False, routing_off: bool = False,
 22                 io_setup: bool = False, user_peer_to_peer: bool = False, stay_awake_when_not_bonded: bool = False,
 23                 std_and_lp_network: bool = False, rf_output_power: int = 7, rf_signal_filter: int = 5,
 24                 lp_rf_timeout: int = 6,
 25                 uart_baud_rate: Union[dpa_constants.BaudRates, int] = dpa_constants.BaudRates.B9600,
 26                 alternative_dsm_channel: int = 0, local_frc: bool = False, rf_channel_a: int = 52,
 27                 rf_channel_b: int = 2, reserved_block_0: Optional[List[int]] = None,
 28                 reserved_block_1: Optional[List[int]] = None, reserved_block_2: Optional[List[int]] = None):
 29        """TR Configuration data constructor.
 30
 31        Args:
 32            embedded_peripherals (List[int]): Enabled embedded peripherals.
 33            custom_dpa_handler (bool): Custom DPA handler in use.
 34            dpa_peer_to_peer (bool): DPA peer-to-peer enabled.
 35            routing_off (bool): Node does not route packets in background.
 36            io_setup (bool): Run IO Setup early during module boot time.
 37            user_peer_to_peer (bool): Receive peer-to-peer packets and raise PeerToPeer event.
 38            stay_awake_when_not_bonded (bool): Stay awake during bonding process.
 39            std_and_lp_network (bool): Control STD+LP network.
 40            rf_output_power (int): RF output power.
 41            rf_signal_filter (int): RF signal filter.
 42            lp_rf_timeout (int): LP RF timeout.
 43            uart_baud_rate (Union[dpa_constants.BaudRates, int]): UART baud rate.
 44            alternative_dsm_channel (int): Alternative DSM channel.
 45            local_frc (bool): Local FRC reception enabled.
 46            rf_channel_a (int): RF Channel A.
 47            rf_channel_b (int): RF Channel B.
 48            reserved_block_0 (List[int], optional): Reserved data block.
 49            reserved_block_1 (List[int], optional): Reserved data block.
 50            reserved_block_2 (List[int], optional): Reserved data block.
 51        """
 52        if embedded_peripherals is None:
 53            embedded_peripherals = []
 54        if reserved_block_0 is None:
 55            reserved_block_0 = [0] * 2
 56        if reserved_block_1 is None:
 57            reserved_block_1 = [0] * 3
 58        if reserved_block_2 is None:
 59            reserved_block_2 = [0] * 13
 60        self._validate(embedded_peripherals=embedded_peripherals, rf_output_power=rf_output_power,
 61                       rf_signal_filter=rf_signal_filter, lp_rf_timeout=lp_rf_timeout, baud_rate=uart_baud_rate,
 62                       alternative_dsm=alternative_dsm_channel, rf_channel_a=rf_channel_a, rf_channel_b=rf_channel_b,
 63                       reserved_block_0=reserved_block_0, reserved_block_1=reserved_block_1,
 64                       reserved_block_2=reserved_block_2)
 65        self._embedded_peripherals = embedded_peripherals
 66        self._custom_dpa_handler = custom_dpa_handler
 67        self._dpa_peer_to_peer = dpa_peer_to_peer
 68        self._routing_off = routing_off
 69        self._io_setup = io_setup
 70        self._user_peer_to_peer = user_peer_to_peer
 71        self._stay_awake_when_not_bonded = stay_awake_when_not_bonded
 72        self._std_and_lp_network = std_and_lp_network
 73        self._rf_output_power = rf_output_power
 74        self._rf_signal_filter = rf_signal_filter
 75        self._lp_rf_timeout = lp_rf_timeout
 76        self._uart_baud_rate = uart_baud_rate
 77        self._alternative_dsm_channel = alternative_dsm_channel
 78        self._local_frc = local_frc
 79        self._rf_channel_a = rf_channel_a
 80        self._rf_channel_b = rf_channel_b
 81        self._reserved_block_0 = reserved_block_0
 82        self._reserved_block_1 = reserved_block_1
 83        self._reserved_block_2 = reserved_block_2
 84
 85    def __eq__(self, other: 'OsTrConfData'):
 86        """Rich comparison method, comparing this and another object to determine equality based on properties.
 87
 88        Args:
 89            other (OsTrConfData): Object to compare with.
 90
 91        Returns:
 92            bool: True if the objects are equivalent, False otherwise.
 93        """
 94        return self._embedded_peripherals == other._embedded_peripherals and \
 95            self._custom_dpa_handler == other._custom_dpa_handler and \
 96            self._dpa_peer_to_peer == other._dpa_peer_to_peer and \
 97            self._routing_off == other.routing_off and \
 98            self._io_setup == other._io_setup and \
 99            self._user_peer_to_peer == other._user_peer_to_peer and \
100            self._stay_awake_when_not_bonded == other._stay_awake_when_not_bonded and \
101            self._std_and_lp_network == other._std_and_lp_network and \
102            self._rf_output_power == other._rf_output_power and \
103            self._rf_signal_filter == other._rf_signal_filter and \
104            self._lp_rf_timeout == other._lp_rf_timeout and \
105            self._uart_baud_rate == other._uart_baud_rate and \
106            self._alternative_dsm_channel == other._alternative_dsm_channel and \
107            self._local_frc == other._local_frc and \
108            self._rf_channel_a == other._rf_channel_a and \
109            self._rf_channel_b == other._rf_channel_b and \
110            self._reserved_block_0 == other._reserved_block_0 and \
111            self._reserved_block_1 == other._reserved_block_1 and \
112            self._reserved_block_2 == other._reserved_block_2
113
114    def _validate(self, embedded_peripherals: List[int], rf_output_power: int, rf_signal_filter: int,
115                  lp_rf_timeout: int, baud_rate: Union[dpa_constants.BaudRates, int], alternative_dsm: int,
116                  rf_channel_a: int, rf_channel_b: int, reserved_block_0: List[int],
117                  reserved_block_1: List[int], reserved_block_2: List[int]):
118        self._validate_embedded_peripherals(embedded_peripherals)
119        self._validate_rf_output_power(rf_output_power)
120        self._validate_rf_signal_filter(rf_signal_filter)
121        self._validate_lp_rf_timeout(lp_rf_timeout)
122        self._validate_uart_baud_rate(baud_rate)
123        self._validate_alternative_dsm_channel(alternative_dsm)
124        self._validate_rf_channel_a(rf_channel_a)
125        self._validate_rf_channel_b(rf_channel_b)
126        self._validate_reserved_block_0(reserved_block_0)
127        self._validate_reserved_block_1(reserved_block_1)
128        self._validate_reserved_block_2(reserved_block_2)
129
130    @staticmethod
131    def _validate_embedded_peripherals(embedded_peripherals: List[Union[EmbedPeripherals, int]]) -> None:
132        if len(embedded_peripherals) > 32:
133            raise RequestParameterInvalidValueError('Embedded peripherals should be at most 32 values.')
134        if min(embedded_peripherals, default=0) < 0 or max(embedded_peripherals, default=0) > 31:
135            raise RequestParameterInvalidValueError('Embedded peripherals values should be between 0 and 31.')
136
137    @property
138    def embedded_peripherals(self) -> List[Union[EmbedPeripherals, int]]:
139        """:obj:`list` of :obj:`EmbedPeripherals` or :obj:`int`: Enabled embedded peripherals.
140
141        Getter and setter.
142        """
143        return self._embedded_peripherals
144
145    @embedded_peripherals.setter
146    def embedded_peripherals(self, value: List[Union[EmbedPeripherals, int]]):
147        self._validate_embedded_peripherals(embedded_peripherals=value)
148        self._embedded_peripherals = value
149
150    def enable_embedded_peripheral(self, peripheral: Union[EmbedPeripherals, int]) -> None:
151        """Enables embedded peripheral.
152
153        Args:
154            peripheral (:obj:`EmbeddedPeripherals` or :obj:`int`): Embedded peripheral.
155
156        Raises:
157            ValueError: If peripheral value is less than 0 or greater than 31.
158        """
159        if not (0 <= peripheral <= 31):
160            raise ValueError('Peripheral value should be between 0 and 31')
161        if peripheral not in self._embedded_peripherals:
162            self._embedded_peripherals.append(peripheral)
163
164    def disable_embedded_peripheral(self, peripheral: Union[EmbedPeripherals, int]) -> None:
165        """Disables embedded peripheral.
166
167        Args:
168            peripheral (:obj:`EmbeddedPeripherals` or :obj:`int`): Embedded peripheral.
169
170        Raises:
171            ValueError: If peripheral value is less than 0 or greater than 31.
172        """
173        if not (0 <= peripheral <= 31):
174            raise ValueError('Peripheral value should be between 0 and 31')
175        if peripheral in self._embedded_peripherals:
176            self._embedded_peripherals.remove(peripheral)
177
178    def get_embedded_peripheral_byte(self, peripheral: Union[EmbedPeripherals, int]) -> OsTrConfByte:
179        """Returns embedded peripheral configuration byte.
180
181        Args:
182            peripheral (:obj:`EmbeddedPeripherals` or :obj:`int`): Embedded peripheral.
183
184        Raises:
185            ValueError: If peripheral value is less than 0 or greater than 31.
186
187        Returns:
188            :obj:`OsTrConfByte`: Embedded peripheral configuration byte.
189        """
190        if not (0 <= peripheral <= 31):
191            raise ValueError('Peripheral value should be between 0 and 31')
192        if 0 <= peripheral <= 7:
193            address = 1
194        elif 8 <= peripheral <= 15:
195            address = 2
196        elif 16 <= peripheral <= 23:
197            address = 3
198        else:
199            address = 4
200        value = 1 << (peripheral % 8) if peripheral in self._embedded_peripherals else 0
201        return OsTrConfByte(
202            address=address,
203            value=value,
204            mask=value
205        )
206
207    @property
208    def custom_dpa_handler(self) -> bool:
209        """:obj:`bool`: Custom DPA handler in use.
210
211        Getter and setter.
212        """
213        return self._custom_dpa_handler
214
215    @custom_dpa_handler.setter
216    def custom_dpa_handler(self, value: bool):
217        self._custom_dpa_handler = value
218
219    def get_custom_dpa_handler_byte(self) -> OsTrConfByte:
220        """Returns custom DPA handler configuration byte.
221
222        Returns:
223            :obj:`OsTrConfByte`: Custom DPA handler configuration byte.
224        """
225        return OsTrConfByte(
226            address=TrConfByteAddrs.DPA_CONFIG_BITS_0,
227            value=1 if self._custom_dpa_handler else 0,
228            mask=TrConfBitMasks.CUSTOM_DPA_HANDLER
229        )
230
231    @property
232    def dpa_peer_to_peer(self) -> bool:
233        """:obj:`bool`: DPA peer-to-peer enabled.
234
235        Getter and setter.
236        """
237        return self._dpa_peer_to_peer
238
239    @dpa_peer_to_peer.setter
240    def dpa_peer_to_peer(self, value: bool):
241        self._dpa_peer_to_peer = value
242
243    def get_dpa_peer_to_peer_byte(self) -> OsTrConfByte:
244        """Return DPA peer-to-peer configuration byte.
245
246        Returns:
247            :obj:`OsTrConfByte`: DPA peer-to-peer configuration byte.
248        """
249        return OsTrConfByte(
250            address=TrConfByteAddrs.DPA_CONFIG_BITS_0,
251            value=2 if self._dpa_peer_to_peer else 0,
252            mask=TrConfBitMasks.DPA_PEER_TO_PEER
253        )
254
255    @property
256    def routing_off(self) -> bool:
257        """:obj:`bool`: Node does not route packets in background.
258
259        Getter and setter.
260        """
261        return self._routing_off
262
263    @routing_off.setter
264    def routing_off(self, value: bool):
265        self._routing_off = value
266
267    def get_routing_off_byte(self) -> OsTrConfByte:
268        """Returns routing off configuration byte.
269
270        Returns:
271            :obj:`OsTrConfByte`: Routing off configuration byte.
272        """
273        return OsTrConfByte(
274            address=TrConfByteAddrs.DPA_CONFIG_BITS_0,
275            value=8 if self._routing_off else 0,
276            mask=TrConfBitMasks.ROUTING_OFF
277        )
278
279    @property
280    def io_setup(self) -> bool:
281        """:obj:`bool`: Run IO Setup early during module boot time.
282
283        Getter and setter.
284        """
285        return self._io_setup
286
287    @io_setup.setter
288    def io_setup(self, value: bool):
289        self._io_setup = value
290
291    def get_io_setup_byte(self) -> OsTrConfByte:
292        """Returns IO setup configuration byte.
293
294        Returns:
295            :obj:`OsTrConfByte`: IO setup configuration byte.
296        """
297        return OsTrConfByte(
298            address=TrConfByteAddrs.DPA_CONFIG_BITS_0,
299            value=16 if self._io_setup else 0,
300            mask=TrConfBitMasks.IO_SETUP
301        )
302
303    @property
304    def user_peer_to_peer(self) -> bool:
305        """:obj:`bool`: Receive peer-to-peer packets and raise PeerToPeer event.
306
307        Getter and setter.
308        """
309        return self._user_peer_to_peer
310
311    @user_peer_to_peer.setter
312    def user_peer_to_peer(self, value: bool):
313        self._user_peer_to_peer = value
314
315    def get_user_peer_to_peer_byte(self) -> OsTrConfByte:
316        """Returns user peer-to-peer configuration byte.
317
318        Returns:
319            :obj:`OsTrConfByte`: User peer-to-peer configuration byte.
320        """
321        return OsTrConfByte(
322            address=TrConfByteAddrs.DPA_CONFIG_BITS_0,
323            value=32 if self._user_peer_to_peer else 0,
324            mask=TrConfBitMasks.USER_PEER_TO_PEER,
325        )
326
327    @property
328    def stay_awake_when_not_bonded(self) -> bool:
329        """:obj:`bool`: Stay awake during bonding process.
330
331        Getter and setter.
332        """
333        return self._stay_awake_when_not_bonded
334
335    @stay_awake_when_not_bonded.setter
336    def stay_awake_when_not_bonded(self, value: bool):
337        self._stay_awake_when_not_bonded = value
338
339    def get_stay_awake_when_not_bonded_byte(self) -> OsTrConfByte:
340        """Returns stay awake when not bonded configuration byte.
341
342        Returns:
343            :obj:`OsTrConfByte`: Stay awake when not bonded configuration byte.
344        """
345        return OsTrConfByte(
346            address=TrConfByteAddrs.DPA_CONFIG_BITS_0,
347            value=64 if self._stay_awake_when_not_bonded else 0,
348            mask=TrConfBitMasks.STAY_AWAKE_WHEN_NOT_BONDED,
349        )
350
351    @property
352    def std_and_lp_network(self) -> bool:
353        """:obj:`bool`: Control STD+LP network.
354
355        Getter and setter.
356        """
357        return self._std_and_lp_network
358
359    @std_and_lp_network.setter
360    def std_and_lp_network(self, value: bool):
361        self._std_and_lp_network = value
362
363    def get_std_and_lp_network_byte(self) -> OsTrConfByte:
364        """Returns STD and LP network configuration byte.
365
366        Returns:
367            :obj:`OsTrConfByte`: STD and LP network configuration byte.
368        """
369        return OsTrConfByte(
370            address=TrConfByteAddrs.DPA_CONFIG_BITS_0,
371            value=128 if self._std_and_lp_network else 0,
372            mask=TrConfBitMasks.STD_AND_LP_NETWORK
373        )
374
375    @staticmethod
376    def _validate_rf_output_power(rf_output_power: int) -> None:
377        """Validate rf output power parameter.
378
379        Args:
380            rf_output_power (int): RF output power.
381
382        Raises:
383            RequestParameterInvalidValueError: If rf_output_power is less than 0 or greater than 255.
384        """
385        if not dpa_constants.BYTE_MIN <= rf_output_power <= dpa_constants.BYTE_MAX:
386            raise RequestParameterInvalidValueError('RF output power value should be between 0 and 255.')
387
388    @property
389    def rf_output_power(self) -> int:
390        """:obj:`int`: RF output power.
391
392        Getter and setter.
393        """
394        return self._rf_output_power
395
396    @rf_output_power.setter
397    def rf_output_power(self, value: int):
398        self._validate_rf_output_power(rf_output_power=value)
399        self._rf_output_power = value
400
401    def get_rf_output_power_byte(self) -> OsTrConfByte:
402        """Returns RF output power configuration byte.
403
404        Returns:
405            :obj:`OsTrConfByte`: RF output power configuration byte.
406        """
407        return OsTrConfByte(
408            address=TrConfByteAddrs.RF_OUTPUT_POWER,
409            value=self._rf_output_power,
410            mask=0xFF
411        )
412
413    @staticmethod
414    def _validate_rf_signal_filter(rf_signal_filter: int) -> None:
415        """Validate rf signal filter parameter.
416
417        Args:
418            rf_signal_filter (int): RF signal filter.
419
420        Raises:
421            RequestParameterInvalidValueError: If rf_signal_filter is less than 0 or greater than 255.
422        """
423        if not dpa_constants.BYTE_MIN <= rf_signal_filter <= dpa_constants.BYTE_MAX:
424            raise RequestParameterInvalidValueError('RF signal filter value should be between 0 and 255.')
425
426    @property
427    def rf_signal_filter(self) -> int:
428        """:obj:`int`: RF signal filter.
429
430        Getter and setter.
431        """
432        return self._rf_signal_filter
433
434    @rf_signal_filter.setter
435    def rf_signal_filter(self, value: int):
436        self._validate_rf_signal_filter(rf_signal_filter=value)
437        self._rf_signal_filter = value
438
439    def get_rf_signal_filter_byte(self) -> OsTrConfByte:
440        """Returns RF signal filter configuration byte.
441
442        Returns:
443            :obj:`OsTrConfByte`: RF signal filter configuration byte.
444        """
445        return OsTrConfByte(
446            address=TrConfByteAddrs.RF_SIGNAL_FILTER,
447            value=self._rf_signal_filter,
448            mask=0xFF
449        )
450
451    @staticmethod
452    def _validate_lp_rf_timeout(lp_rf_timeout: int) -> None:
453        """Validate lp rf timeout parameter.
454
455        Args:
456            lp_rf_timeout (int): LP RF timeout.
457
458        Raises:
459            RequestParameterInvalidValueError: If lp_rf_timeout is less than 0 or greater than 255.
460        """
461        if not dpa_constants.BYTE_MIN <= lp_rf_timeout <= dpa_constants.BYTE_MAX:
462            raise RequestParameterInvalidValueError('LP RF timeout value should be between 0 and 255.')
463
464    @property
465    def lp_rf_timeout(self) -> int:
466        """:obj:`int`: LP RF timeout.
467
468        Getter and setter.
469        """
470        return self._lp_rf_timeout
471
472    @lp_rf_timeout.setter
473    def lp_rf_timeout(self, value: int):
474        self._validate_lp_rf_timeout(lp_rf_timeout=value)
475        self._lp_rf_timeout = value
476
477    def get_lp_rf_timeout_byte(self) -> OsTrConfByte:
478        """Returns LP RF timeout configuration byte.
479
480        Returns:
481            :obj:`OsTrConfByte`: LP RF timeout configuration byte.
482        """
483        return OsTrConfByte(
484            address=TrConfByteAddrs.LP_RF_TIMEOUT,
485            value=self._lp_rf_timeout,
486            mask=0xFF
487        )
488
489    @staticmethod
490    def _validate_uart_baud_rate(uart_baud_rate: Union[dpa_constants.BaudRates, int]) -> None:
491        """Validate uart baud rate parameter.
492
493        Args:
494            uart_baud_rate (Union[BaudRates, int]): UART Baud rate.
495
496        Raises:
497            RequestParameterInvalidValueError: If uart_baud_rate is less than 0 or greater than 255.
498        """
499        if not dpa_constants.BYTE_MIN <= uart_baud_rate <= dpa_constants.BYTE_MAX:
500            raise RequestParameterInvalidValueError('UART baud rate value should be between 0 and 255.')
501
502    @property
503    def uart_baud_rate(self) -> Union[dpa_constants.BaudRates, int]:
504        """:obj:`BaudRates` or :obj:`int`: UART baud rate.
505
506        Getter and setter.
507        """
508        return self._uart_baud_rate
509
510    @uart_baud_rate.setter
511    def uart_baud_rate(self, value: Union[dpa_constants.BaudRates, int]):
512        self._validate_uart_baud_rate(uart_baud_rate=value)
513        self._uart_baud_rate = value
514
515    def get_uart_baud_rate_byte(self) -> OsTrConfByte:
516        """Returns UART baud rate configuration byte.
517
518        Returns:
519            :obj:`OsTrConfByte`: UART baud rate configuration byte.
520        """
521        return OsTrConfByte(
522            address=TrConfByteAddrs.UART_BAUD_RATE,
523            value=self._uart_baud_rate,
524            mask=0xFF
525        )
526
527    @staticmethod
528    def _validate_alternative_dsm_channel(alternative_dsm_channels: int) -> None:
529        """Validate alternative dsm channel parameters.
530
531        Args:
532            alternative_dsm_channels (int): Alternative DSM channel.
533
534        Raises:
535            RequestParameterInvalidValueError: If alternative_dsm_channels is less than 0 or greater than 255.
536        """
537        if not dpa_constants.BYTE_MIN <= alternative_dsm_channels <= dpa_constants.BYTE_MAX:
538            raise RequestParameterInvalidValueError('Alternative DMS channel value should be between 0 and 255.')
539
540    @property
541    def alternative_dsm_channel(self) -> int:
542        """:obj:`int`: Alternative DSM channel.
543
544        Getter and setter.
545        """
546        return self._alternative_dsm_channel
547
548    @alternative_dsm_channel.setter
549    def alternative_dsm_channel(self, value: int):
550        self._validate_alternative_dsm_channel(alternative_dsm_channels=value)
551        self._alternative_dsm_channel = value
552
553    def get_alternative_dsm_channel_byte(self) -> OsTrConfByte:
554        """Returns alternative DSM channel configuration byte.
555
556        Returns:
557            :obj:`OsTrConfByte`: Alternative DSM channel configuration byte.
558        """
559        return OsTrConfByte(
560            address=TrConfByteAddrs.ALTERNATIVE_DSM_CHANNEL,
561            value=self._alternative_dsm_channel,
562            mask=0xFF
563        )
564
565    @property
566    def local_frc(self) -> bool:
567        """:obj:`bool`: Local FRC reception enabled.
568
569        Getter and setter.
570        """
571        return self._local_frc
572
573    @local_frc.setter
574    def local_frc(self, value: bool):
575        self._local_frc = value
576
577    def get_local_frc_byte(self) -> OsTrConfByte:
578        """Returns local FRC configuration byte.
579
580        Returns:
581            :obj:`OsTrConfByte`: Local FRC configuration byte.
582        """
583        return OsTrConfByte(
584            address=TrConfByteAddrs.DPA_CONFIG_BITS_1,
585            value=1 if self._local_frc else 0,
586            mask=TrConfBitMasks.LOCAL_FRC
587        )
588
589    @staticmethod
590    def _validate_rf_channel_a(rf_channel_a: int) -> None:
591        """Validate RF Channel A Parameter.
592
593        Args:
594            rf_channel_a (int): RF Channel A.
595
596        Raises:
597            RequestParameterInvalidValueError: If rf_channel_a is less than 0 or greater than 255.
598        """
599        if not dpa_constants.BYTE_MIN <= rf_channel_a <= dpa_constants.BYTE_MAX:
600            raise RequestParameterInvalidValueError('RF channel A value should be between 0 and 255.')
601
602    @property
603    def rf_channel_a(self) -> int:
604        """:obj:`int`: RF Channel A.
605
606        Getter and setter.
607        """
608        return self._rf_channel_a
609
610    @rf_channel_a.setter
611    def rf_channel_a(self, value: int):
612        self._validate_rf_channel_a(rf_channel_a=value)
613        self._rf_channel_a = value
614
615    def get_rf_channel_a_byte(self) -> OsTrConfByte:
616        """Returns RF channel A configuration byte.
617
618        Returns:
619            :obj:`OsTrConfByte`: RF channel A configuration byte.
620        """
621        return OsTrConfByte(
622            address=TrConfByteAddrs.RF_CHANNEL_A,
623            value=self._rf_channel_a,
624            mask=0xFF
625        )
626
627    @staticmethod
628    def _validate_rf_channel_b(rf_channel_b: int) -> None:
629        """Validate RF Channel B Parameter.
630
631        Args:
632            rf_channel_b (int): RF Channel B.
633
634        Raises:
635            RequestParameterInvalidValueError: If rf_channel_b is less than 0 or greater than 255.
636        """
637        if not dpa_constants.BYTE_MIN <= rf_channel_b <= dpa_constants.BYTE_MAX:
638            raise RequestParameterInvalidValueError('RF channel B value should be between 0 and 255.')
639
640    @property
641    def rf_channel_b(self) -> int:
642        """:obj:`int`: RF Channel B.
643
644        Getter and setter.
645        """
646        return self._rf_channel_b
647
648    @rf_channel_b.setter
649    def rf_channel_b(self, value: int):
650        self._validate_rf_channel_b(rf_channel_b=value)
651        self._rf_channel_b = value
652
653    def get_rf_channel_b_byte(self) -> OsTrConfByte:
654        """Returns RF channel B configuration byte.
655
656        Returns:
657            :obj:`OsTrConfByte`: RF channel B configuration byte.
658        """
659        return OsTrConfByte(
660            address=TrConfByteAddrs.RF_CHANNEL_B,
661            value=self._rf_channel_b,
662            mask=0xFF
663        )
664
665    @staticmethod
666    def _validate_reserved_block_0(data: List[int]) -> None:
667        """Validate undocumented data bytes.
668
669        Args:
670            data (List[int]): Reserved data bytes.
671
672        Raises:
673            RequestParameterInvalidValueError: If data does not contain 2 values or if values are not
674            in range from 0 to 255.
675        """
676        if len(data) != 2:
677            raise RequestParameterInvalidValueError('Reserved block 0 should be 2B long.')
678        if not Common.values_in_byte_range(data):
679            raise RequestParameterInvalidValueError('Reserved block 0 values should be between 0 and 255.')
680
681    @staticmethod
682    def _validate_reserved_block_1(data: List[int]) -> None:
683        """Validate undocumented data bytes.
684
685        Args:
686            data (List[int]): Reserved data bytes.
687
688        Raises:
689            RequestParameterInvalidValueError: If data does not contain 3 values or if values are not
690            in range from 0 to 255.
691        """
692        if len(data) != 3:
693            raise RequestParameterInvalidValueError('Reserved block 1 should be 3B long.')
694        if not Common.values_in_byte_range(data):
695            raise RequestParameterInvalidValueError('Reserved block 1 values should be between 0 and 255.')
696
697    @staticmethod
698    def _validate_reserved_block_2(data: List[int]) -> None:
699        """Validate undocumented data bytes.
700
701        Args:
702            data (List[int]): Reserved data bytes.
703
704        Raises:
705            RequestParameterInvalidValueError: If data does not contain 13 values or if values are not
706            in range from 0 to 255.
707        """
708        if len(data) != 13:
709            raise RequestParameterInvalidValueError('Reserved block 2 should be 13B long.')
710        if not Common.values_in_byte_range(data):
711            raise RequestParameterInvalidValueError('Reserved block 2 values should be between 0 and 255.')
712
713    @classmethod
714    def from_pdata(cls, data: Union[List[int], bytearray]) -> 'OsTrConfData':
715        """Deserialize DPA response pdata into OS TR Configuration data object.
716
717        Returns:
718            :obj:`OsTrConfData`: Deserialized OS TR Configuration data object.
719        """
720        if isinstance(data, bytearray):
721            data = list(data)
722        embed_pers_data = data[0:4]
723        embedded_pers = []
724        for i in range(0, len(embed_pers_data * 8)):
725            if embed_pers_data[int(i / 8)] & (1 << (i % 8)):
726                if i in EmbedPeripherals:
727                    embedded_pers.append(EmbedPeripherals(i))
728                else:
729                    embedded_pers.append(i)
730        embedded_peripherals = embedded_pers
731        custom_dpa_handler = bool(data[4] & 1)
732        dpa_peer_to_peer = bool(data[4] & 2)
733        routing_off = bool(data[4] & 8)
734        io_setup = bool(data[4] & 16)
735        user_peer_to_peer = bool(data[4] & 32)
736        stay_awake_when_not_bonded = bool(data[4] & 64)
737        std_and_lp_network = bool(data[4] & 128)
738        rf_output_power = data[7]
739        rf_signal_filter = data[8]
740        lp_rf_timeout = data[9]
741        uart_baud_rate = data[10]
742        alternative_dsm_channel = data[11]
743        local_frc = bool(data[12] & 1)
744        rf_channel_a = data[16]
745        rf_channel_b = data[17]
746        reserved_block_0 = data[5:7]
747        reserved_block_1 = data[13:16]
748        reserved_block_2 = data[18:]
749        return cls(embedded_peripherals=embedded_peripherals, custom_dpa_handler=custom_dpa_handler,
750                   dpa_peer_to_peer=dpa_peer_to_peer, routing_off=routing_off, io_setup=io_setup,
751                   user_peer_to_peer=user_peer_to_peer, stay_awake_when_not_bonded=stay_awake_when_not_bonded,
752                   std_and_lp_network=std_and_lp_network, rf_output_power=rf_output_power,
753                   rf_signal_filter=rf_signal_filter, lp_rf_timeout=lp_rf_timeout,
754                   uart_baud_rate=uart_baud_rate, alternative_dsm_channel=alternative_dsm_channel,
755                   local_frc=local_frc, rf_channel_a=rf_channel_a, rf_channel_b=rf_channel_b,
756                   reserved_block_0=reserved_block_0, reserved_block_1=reserved_block_1,
757                   reserved_block_2=reserved_block_2)
758
759    def to_pdata(self, to_bytes: bool = False) -> Union[List[int], bytearray]:
760        """Serialize OS TR Configuration data object to DPA request pdata.
761
762        Args:
763            to_bytes (bool): Serialize into bytes.
764
765        Returns:
766            :obj:`list` of :obj:`int`: Serialized OS TR Configuration data.\n
767            :obj:`bytearray`: Serialize OS TR Configuration data bytes if to_bytes is True.
768        """
769        embed_pers = Common.peripheral_list_to_bitmap(self.embedded_peripherals)
770        conf_bits_0 = int(self.custom_dpa_handler) | int(self.dpa_peer_to_peer) << 1 | int(self.routing_off) << 3 | \
771            int(self.io_setup) << 4 | int(self.user_peer_to_peer) << 5 | \
772            int(self.stay_awake_when_not_bonded) << 6 | int(self.std_and_lp_network) << 7
773        pdata = embed_pers + [conf_bits_0] + self._reserved_block_0 + \
774            [
775                self.rf_output_power,
776                self.rf_signal_filter,
777                self.lp_rf_timeout,
778                self.uart_baud_rate,
779                self.alternative_dsm_channel,
780                int(self.local_frc)
781            ] + self._reserved_block_1 + \
782            [
783                self.rf_channel_a,
784                self.rf_channel_b
785            ] + self._reserved_block_2
786        if to_bytes:
787            return bytearray(pdata)
788        return pdata
789
790    @staticmethod
791    def calculate_checksum(data: List[int]) -> int:
792        """Calculates checksum from TR configuration data.
793
794        Args:
795            data (List[int]): List of integers representing TR configuration data.
796
797        Returns:
798            int: Checksum value.
799        """
800        checksum = 0x5F
801        for val in data:
802            checksum ^= val
803        return checksum

OS TR Configuration data.

OsTrConfData( embedded_peripherals: Optional[List[Union[iqrfpy.enums.peripherals.EmbedPeripherals, int]]] = None, custom_dpa_handler: bool = False, dpa_peer_to_peer: bool = False, routing_off: bool = False, io_setup: bool = False, user_peer_to_peer: bool = False, stay_awake_when_not_bonded: bool = False, std_and_lp_network: bool = False, rf_output_power: int = 7, rf_signal_filter: int = 5, lp_rf_timeout: int = 6, uart_baud_rate: Union[iqrfpy.utils.dpa.BaudRates, int] = <BaudRates.B9600: 3>, alternative_dsm_channel: int = 0, local_frc: bool = False, rf_channel_a: int = 52, rf_channel_b: int = 2, reserved_block_0: Optional[List[int]] = None, reserved_block_1: Optional[List[int]] = None, reserved_block_2: Optional[List[int]] = None)
20    def __init__(self, embedded_peripherals: Optional[List[Union[EmbedPeripherals, int]]] = None,
21                 custom_dpa_handler: bool = False, dpa_peer_to_peer: bool = False, routing_off: bool = False,
22                 io_setup: bool = False, user_peer_to_peer: bool = False, stay_awake_when_not_bonded: bool = False,
23                 std_and_lp_network: bool = False, rf_output_power: int = 7, rf_signal_filter: int = 5,
24                 lp_rf_timeout: int = 6,
25                 uart_baud_rate: Union[dpa_constants.BaudRates, int] = dpa_constants.BaudRates.B9600,
26                 alternative_dsm_channel: int = 0, local_frc: bool = False, rf_channel_a: int = 52,
27                 rf_channel_b: int = 2, reserved_block_0: Optional[List[int]] = None,
28                 reserved_block_1: Optional[List[int]] = None, reserved_block_2: Optional[List[int]] = None):
29        """TR Configuration data constructor.
30
31        Args:
32            embedded_peripherals (List[int]): Enabled embedded peripherals.
33            custom_dpa_handler (bool): Custom DPA handler in use.
34            dpa_peer_to_peer (bool): DPA peer-to-peer enabled.
35            routing_off (bool): Node does not route packets in background.
36            io_setup (bool): Run IO Setup early during module boot time.
37            user_peer_to_peer (bool): Receive peer-to-peer packets and raise PeerToPeer event.
38            stay_awake_when_not_bonded (bool): Stay awake during bonding process.
39            std_and_lp_network (bool): Control STD+LP network.
40            rf_output_power (int): RF output power.
41            rf_signal_filter (int): RF signal filter.
42            lp_rf_timeout (int): LP RF timeout.
43            uart_baud_rate (Union[dpa_constants.BaudRates, int]): UART baud rate.
44            alternative_dsm_channel (int): Alternative DSM channel.
45            local_frc (bool): Local FRC reception enabled.
46            rf_channel_a (int): RF Channel A.
47            rf_channel_b (int): RF Channel B.
48            reserved_block_0 (List[int], optional): Reserved data block.
49            reserved_block_1 (List[int], optional): Reserved data block.
50            reserved_block_2 (List[int], optional): Reserved data block.
51        """
52        if embedded_peripherals is None:
53            embedded_peripherals = []
54        if reserved_block_0 is None:
55            reserved_block_0 = [0] * 2
56        if reserved_block_1 is None:
57            reserved_block_1 = [0] * 3
58        if reserved_block_2 is None:
59            reserved_block_2 = [0] * 13
60        self._validate(embedded_peripherals=embedded_peripherals, rf_output_power=rf_output_power,
61                       rf_signal_filter=rf_signal_filter, lp_rf_timeout=lp_rf_timeout, baud_rate=uart_baud_rate,
62                       alternative_dsm=alternative_dsm_channel, rf_channel_a=rf_channel_a, rf_channel_b=rf_channel_b,
63                       reserved_block_0=reserved_block_0, reserved_block_1=reserved_block_1,
64                       reserved_block_2=reserved_block_2)
65        self._embedded_peripherals = embedded_peripherals
66        self._custom_dpa_handler = custom_dpa_handler
67        self._dpa_peer_to_peer = dpa_peer_to_peer
68        self._routing_off = routing_off
69        self._io_setup = io_setup
70        self._user_peer_to_peer = user_peer_to_peer
71        self._stay_awake_when_not_bonded = stay_awake_when_not_bonded
72        self._std_and_lp_network = std_and_lp_network
73        self._rf_output_power = rf_output_power
74        self._rf_signal_filter = rf_signal_filter
75        self._lp_rf_timeout = lp_rf_timeout
76        self._uart_baud_rate = uart_baud_rate
77        self._alternative_dsm_channel = alternative_dsm_channel
78        self._local_frc = local_frc
79        self._rf_channel_a = rf_channel_a
80        self._rf_channel_b = rf_channel_b
81        self._reserved_block_0 = reserved_block_0
82        self._reserved_block_1 = reserved_block_1
83        self._reserved_block_2 = reserved_block_2

TR Configuration data constructor.

Arguments:
  • embedded_peripherals (List[int]): Enabled embedded peripherals.
  • custom_dpa_handler (bool): Custom DPA handler in use.
  • dpa_peer_to_peer (bool): DPA peer-to-peer enabled.
  • routing_off (bool): Node does not route packets in background.
  • io_setup (bool): Run IO Setup early during module boot time.
  • user_peer_to_peer (bool): Receive peer-to-peer packets and raise PeerToPeer event.
  • stay_awake_when_not_bonded (bool): Stay awake during bonding process.
  • std_and_lp_network (bool): Control STD+LP network.
  • rf_output_power (int): RF output power.
  • rf_signal_filter (int): RF signal filter.
  • lp_rf_timeout (int): LP RF timeout.
  • uart_baud_rate (Union[dpa_constants.BaudRates, int]): UART baud rate.
  • alternative_dsm_channel (int): Alternative DSM channel.
  • local_frc (bool): Local FRC reception enabled.
  • rf_channel_a (int): RF Channel A.
  • rf_channel_b (int): RF Channel B.
  • reserved_block_0 (List[int], optional): Reserved data block.
  • reserved_block_1 (List[int], optional): Reserved data block.
  • reserved_block_2 (List[int], optional): Reserved data block.
embedded_peripherals: List[Union[iqrfpy.enums.peripherals.EmbedPeripherals, int]]

list of EmbedPeripherals or int: Enabled embedded peripherals.

Getter and setter.

def enable_embedded_peripheral( self, peripheral: Union[iqrfpy.enums.peripherals.EmbedPeripherals, int]) -> None:
150    def enable_embedded_peripheral(self, peripheral: Union[EmbedPeripherals, int]) -> None:
151        """Enables embedded peripheral.
152
153        Args:
154            peripheral (:obj:`EmbeddedPeripherals` or :obj:`int`): Embedded peripheral.
155
156        Raises:
157            ValueError: If peripheral value is less than 0 or greater than 31.
158        """
159        if not (0 <= peripheral <= 31):
160            raise ValueError('Peripheral value should be between 0 and 31')
161        if peripheral not in self._embedded_peripherals:
162            self._embedded_peripherals.append(peripheral)

Enables embedded peripheral.

Arguments:
  • peripheral (EmbeddedPeripherals or int): Embedded peripheral.
Raises:
  • ValueError: If peripheral value is less than 0 or greater than 31.
def disable_embedded_peripheral( self, peripheral: Union[iqrfpy.enums.peripherals.EmbedPeripherals, int]) -> None:
164    def disable_embedded_peripheral(self, peripheral: Union[EmbedPeripherals, int]) -> None:
165        """Disables embedded peripheral.
166
167        Args:
168            peripheral (:obj:`EmbeddedPeripherals` or :obj:`int`): Embedded peripheral.
169
170        Raises:
171            ValueError: If peripheral value is less than 0 or greater than 31.
172        """
173        if not (0 <= peripheral <= 31):
174            raise ValueError('Peripheral value should be between 0 and 31')
175        if peripheral in self._embedded_peripherals:
176            self._embedded_peripherals.remove(peripheral)

Disables embedded peripheral.

Arguments:
  • peripheral (EmbeddedPeripherals or int): Embedded peripheral.
Raises:
  • ValueError: If peripheral value is less than 0 or greater than 31.
def get_embedded_peripheral_byte( self, peripheral: Union[iqrfpy.enums.peripherals.EmbedPeripherals, int]) -> OsTrConfByte:
178    def get_embedded_peripheral_byte(self, peripheral: Union[EmbedPeripherals, int]) -> OsTrConfByte:
179        """Returns embedded peripheral configuration byte.
180
181        Args:
182            peripheral (:obj:`EmbeddedPeripherals` or :obj:`int`): Embedded peripheral.
183
184        Raises:
185            ValueError: If peripheral value is less than 0 or greater than 31.
186
187        Returns:
188            :obj:`OsTrConfByte`: Embedded peripheral configuration byte.
189        """
190        if not (0 <= peripheral <= 31):
191            raise ValueError('Peripheral value should be between 0 and 31')
192        if 0 <= peripheral <= 7:
193            address = 1
194        elif 8 <= peripheral <= 15:
195            address = 2
196        elif 16 <= peripheral <= 23:
197            address = 3
198        else:
199            address = 4
200        value = 1 << (peripheral % 8) if peripheral in self._embedded_peripherals else 0
201        return OsTrConfByte(
202            address=address,
203            value=value,
204            mask=value
205        )

Returns embedded peripheral configuration byte.

Arguments:
  • peripheral (EmbeddedPeripherals or int): Embedded peripheral.
Raises:
  • ValueError: If peripheral value is less than 0 or greater than 31.
Returns:

OsTrConfByte: Embedded peripheral configuration byte.

custom_dpa_handler: bool

bool: Custom DPA handler in use.

Getter and setter.

def get_custom_dpa_handler_byte(self) -> OsTrConfByte:
219    def get_custom_dpa_handler_byte(self) -> OsTrConfByte:
220        """Returns custom DPA handler configuration byte.
221
222        Returns:
223            :obj:`OsTrConfByte`: Custom DPA handler configuration byte.
224        """
225        return OsTrConfByte(
226            address=TrConfByteAddrs.DPA_CONFIG_BITS_0,
227            value=1 if self._custom_dpa_handler else 0,
228            mask=TrConfBitMasks.CUSTOM_DPA_HANDLER
229        )

Returns custom DPA handler configuration byte.

Returns:

OsTrConfByte: Custom DPA handler configuration byte.

dpa_peer_to_peer: bool

bool: DPA peer-to-peer enabled.

Getter and setter.

def get_dpa_peer_to_peer_byte(self) -> OsTrConfByte:
243    def get_dpa_peer_to_peer_byte(self) -> OsTrConfByte:
244        """Return DPA peer-to-peer configuration byte.
245
246        Returns:
247            :obj:`OsTrConfByte`: DPA peer-to-peer configuration byte.
248        """
249        return OsTrConfByte(
250            address=TrConfByteAddrs.DPA_CONFIG_BITS_0,
251            value=2 if self._dpa_peer_to_peer else 0,
252            mask=TrConfBitMasks.DPA_PEER_TO_PEER
253        )

Return DPA peer-to-peer configuration byte.

Returns:

OsTrConfByte: DPA peer-to-peer configuration byte.

routing_off: bool

bool: Node does not route packets in background.

Getter and setter.

def get_routing_off_byte(self) -> OsTrConfByte:
267    def get_routing_off_byte(self) -> OsTrConfByte:
268        """Returns routing off configuration byte.
269
270        Returns:
271            :obj:`OsTrConfByte`: Routing off configuration byte.
272        """
273        return OsTrConfByte(
274            address=TrConfByteAddrs.DPA_CONFIG_BITS_0,
275            value=8 if self._routing_off else 0,
276            mask=TrConfBitMasks.ROUTING_OFF
277        )

Returns routing off configuration byte.

Returns:

OsTrConfByte: Routing off configuration byte.

io_setup: bool

bool: Run IO Setup early during module boot time.

Getter and setter.

def get_io_setup_byte(self) -> OsTrConfByte:
291    def get_io_setup_byte(self) -> OsTrConfByte:
292        """Returns IO setup configuration byte.
293
294        Returns:
295            :obj:`OsTrConfByte`: IO setup configuration byte.
296        """
297        return OsTrConfByte(
298            address=TrConfByteAddrs.DPA_CONFIG_BITS_0,
299            value=16 if self._io_setup else 0,
300            mask=TrConfBitMasks.IO_SETUP
301        )

Returns IO setup configuration byte.

Returns:

OsTrConfByte: IO setup configuration byte.

user_peer_to_peer: bool

bool: Receive peer-to-peer packets and raise PeerToPeer event.

Getter and setter.

def get_user_peer_to_peer_byte(self) -> OsTrConfByte:
315    def get_user_peer_to_peer_byte(self) -> OsTrConfByte:
316        """Returns user peer-to-peer configuration byte.
317
318        Returns:
319            :obj:`OsTrConfByte`: User peer-to-peer configuration byte.
320        """
321        return OsTrConfByte(
322            address=TrConfByteAddrs.DPA_CONFIG_BITS_0,
323            value=32 if self._user_peer_to_peer else 0,
324            mask=TrConfBitMasks.USER_PEER_TO_PEER,
325        )

Returns user peer-to-peer configuration byte.

Returns:

OsTrConfByte: User peer-to-peer configuration byte.

stay_awake_when_not_bonded: bool

bool: Stay awake during bonding process.

Getter and setter.

def get_stay_awake_when_not_bonded_byte(self) -> OsTrConfByte:
339    def get_stay_awake_when_not_bonded_byte(self) -> OsTrConfByte:
340        """Returns stay awake when not bonded configuration byte.
341
342        Returns:
343            :obj:`OsTrConfByte`: Stay awake when not bonded configuration byte.
344        """
345        return OsTrConfByte(
346            address=TrConfByteAddrs.DPA_CONFIG_BITS_0,
347            value=64 if self._stay_awake_when_not_bonded else 0,
348            mask=TrConfBitMasks.STAY_AWAKE_WHEN_NOT_BONDED,
349        )

Returns stay awake when not bonded configuration byte.

Returns:

OsTrConfByte: Stay awake when not bonded configuration byte.

std_and_lp_network: bool

bool: Control STD+LP network.

Getter and setter.

def get_std_and_lp_network_byte(self) -> OsTrConfByte:
363    def get_std_and_lp_network_byte(self) -> OsTrConfByte:
364        """Returns STD and LP network configuration byte.
365
366        Returns:
367            :obj:`OsTrConfByte`: STD and LP network configuration byte.
368        """
369        return OsTrConfByte(
370            address=TrConfByteAddrs.DPA_CONFIG_BITS_0,
371            value=128 if self._std_and_lp_network else 0,
372            mask=TrConfBitMasks.STD_AND_LP_NETWORK
373        )

Returns STD and LP network configuration byte.

Returns:

OsTrConfByte: STD and LP network configuration byte.

rf_output_power: int

int: RF output power.

Getter and setter.

def get_rf_output_power_byte(self) -> OsTrConfByte:
401    def get_rf_output_power_byte(self) -> OsTrConfByte:
402        """Returns RF output power configuration byte.
403
404        Returns:
405            :obj:`OsTrConfByte`: RF output power configuration byte.
406        """
407        return OsTrConfByte(
408            address=TrConfByteAddrs.RF_OUTPUT_POWER,
409            value=self._rf_output_power,
410            mask=0xFF
411        )

Returns RF output power configuration byte.

Returns:

OsTrConfByte: RF output power configuration byte.

rf_signal_filter: int

int: RF signal filter.

Getter and setter.

def get_rf_signal_filter_byte(self) -> OsTrConfByte:
439    def get_rf_signal_filter_byte(self) -> OsTrConfByte:
440        """Returns RF signal filter configuration byte.
441
442        Returns:
443            :obj:`OsTrConfByte`: RF signal filter configuration byte.
444        """
445        return OsTrConfByte(
446            address=TrConfByteAddrs.RF_SIGNAL_FILTER,
447            value=self._rf_signal_filter,
448            mask=0xFF
449        )

Returns RF signal filter configuration byte.

Returns:

OsTrConfByte: RF signal filter configuration byte.

lp_rf_timeout: int

int: LP RF timeout.

Getter and setter.

def get_lp_rf_timeout_byte(self) -> OsTrConfByte:
477    def get_lp_rf_timeout_byte(self) -> OsTrConfByte:
478        """Returns LP RF timeout configuration byte.
479
480        Returns:
481            :obj:`OsTrConfByte`: LP RF timeout configuration byte.
482        """
483        return OsTrConfByte(
484            address=TrConfByteAddrs.LP_RF_TIMEOUT,
485            value=self._lp_rf_timeout,
486            mask=0xFF
487        )

Returns LP RF timeout configuration byte.

Returns:

OsTrConfByte: LP RF timeout configuration byte.

uart_baud_rate: Union[iqrfpy.utils.dpa.BaudRates, int]

BaudRates or int: UART baud rate.

Getter and setter.

def get_uart_baud_rate_byte(self) -> OsTrConfByte:
515    def get_uart_baud_rate_byte(self) -> OsTrConfByte:
516        """Returns UART baud rate configuration byte.
517
518        Returns:
519            :obj:`OsTrConfByte`: UART baud rate configuration byte.
520        """
521        return OsTrConfByte(
522            address=TrConfByteAddrs.UART_BAUD_RATE,
523            value=self._uart_baud_rate,
524            mask=0xFF
525        )

Returns UART baud rate configuration byte.

Returns:

OsTrConfByte: UART baud rate configuration byte.

alternative_dsm_channel: int

int: Alternative DSM channel.

Getter and setter.

def get_alternative_dsm_channel_byte(self) -> OsTrConfByte:
553    def get_alternative_dsm_channel_byte(self) -> OsTrConfByte:
554        """Returns alternative DSM channel configuration byte.
555
556        Returns:
557            :obj:`OsTrConfByte`: Alternative DSM channel configuration byte.
558        """
559        return OsTrConfByte(
560            address=TrConfByteAddrs.ALTERNATIVE_DSM_CHANNEL,
561            value=self._alternative_dsm_channel,
562            mask=0xFF
563        )

Returns alternative DSM channel configuration byte.

Returns:

OsTrConfByte: Alternative DSM channel configuration byte.

local_frc: bool

bool: Local FRC reception enabled.

Getter and setter.

def get_local_frc_byte(self) -> OsTrConfByte:
577    def get_local_frc_byte(self) -> OsTrConfByte:
578        """Returns local FRC configuration byte.
579
580        Returns:
581            :obj:`OsTrConfByte`: Local FRC configuration byte.
582        """
583        return OsTrConfByte(
584            address=TrConfByteAddrs.DPA_CONFIG_BITS_1,
585            value=1 if self._local_frc else 0,
586            mask=TrConfBitMasks.LOCAL_FRC
587        )

Returns local FRC configuration byte.

Returns:

OsTrConfByte: Local FRC configuration byte.

rf_channel_a: int

int: RF Channel A.

Getter and setter.

def get_rf_channel_a_byte(self) -> OsTrConfByte:
615    def get_rf_channel_a_byte(self) -> OsTrConfByte:
616        """Returns RF channel A configuration byte.
617
618        Returns:
619            :obj:`OsTrConfByte`: RF channel A configuration byte.
620        """
621        return OsTrConfByte(
622            address=TrConfByteAddrs.RF_CHANNEL_A,
623            value=self._rf_channel_a,
624            mask=0xFF
625        )

Returns RF channel A configuration byte.

Returns:

OsTrConfByte: RF channel A configuration byte.

rf_channel_b: int

int: RF Channel B.

Getter and setter.

def get_rf_channel_b_byte(self) -> OsTrConfByte:
653    def get_rf_channel_b_byte(self) -> OsTrConfByte:
654        """Returns RF channel B configuration byte.
655
656        Returns:
657            :obj:`OsTrConfByte`: RF channel B configuration byte.
658        """
659        return OsTrConfByte(
660            address=TrConfByteAddrs.RF_CHANNEL_B,
661            value=self._rf_channel_b,
662            mask=0xFF
663        )

Returns RF channel B configuration byte.

Returns:

OsTrConfByte: RF channel B configuration byte.

@classmethod
def from_pdata( cls, data: Union[List[int], bytearray]) -> OsTrConfData:
713    @classmethod
714    def from_pdata(cls, data: Union[List[int], bytearray]) -> 'OsTrConfData':
715        """Deserialize DPA response pdata into OS TR Configuration data object.
716
717        Returns:
718            :obj:`OsTrConfData`: Deserialized OS TR Configuration data object.
719        """
720        if isinstance(data, bytearray):
721            data = list(data)
722        embed_pers_data = data[0:4]
723        embedded_pers = []
724        for i in range(0, len(embed_pers_data * 8)):
725            if embed_pers_data[int(i / 8)] & (1 << (i % 8)):
726                if i in EmbedPeripherals:
727                    embedded_pers.append(EmbedPeripherals(i))
728                else:
729                    embedded_pers.append(i)
730        embedded_peripherals = embedded_pers
731        custom_dpa_handler = bool(data[4] & 1)
732        dpa_peer_to_peer = bool(data[4] & 2)
733        routing_off = bool(data[4] & 8)
734        io_setup = bool(data[4] & 16)
735        user_peer_to_peer = bool(data[4] & 32)
736        stay_awake_when_not_bonded = bool(data[4] & 64)
737        std_and_lp_network = bool(data[4] & 128)
738        rf_output_power = data[7]
739        rf_signal_filter = data[8]
740        lp_rf_timeout = data[9]
741        uart_baud_rate = data[10]
742        alternative_dsm_channel = data[11]
743        local_frc = bool(data[12] & 1)
744        rf_channel_a = data[16]
745        rf_channel_b = data[17]
746        reserved_block_0 = data[5:7]
747        reserved_block_1 = data[13:16]
748        reserved_block_2 = data[18:]
749        return cls(embedded_peripherals=embedded_peripherals, custom_dpa_handler=custom_dpa_handler,
750                   dpa_peer_to_peer=dpa_peer_to_peer, routing_off=routing_off, io_setup=io_setup,
751                   user_peer_to_peer=user_peer_to_peer, stay_awake_when_not_bonded=stay_awake_when_not_bonded,
752                   std_and_lp_network=std_and_lp_network, rf_output_power=rf_output_power,
753                   rf_signal_filter=rf_signal_filter, lp_rf_timeout=lp_rf_timeout,
754                   uart_baud_rate=uart_baud_rate, alternative_dsm_channel=alternative_dsm_channel,
755                   local_frc=local_frc, rf_channel_a=rf_channel_a, rf_channel_b=rf_channel_b,
756                   reserved_block_0=reserved_block_0, reserved_block_1=reserved_block_1,
757                   reserved_block_2=reserved_block_2)

Deserialize DPA response pdata into OS TR Configuration data object.

Returns:

OsTrConfData: Deserialized OS TR Configuration data object.

def to_pdata(self, to_bytes: bool = False) -> Union[List[int], bytearray]:
759    def to_pdata(self, to_bytes: bool = False) -> Union[List[int], bytearray]:
760        """Serialize OS TR Configuration data object to DPA request pdata.
761
762        Args:
763            to_bytes (bool): Serialize into bytes.
764
765        Returns:
766            :obj:`list` of :obj:`int`: Serialized OS TR Configuration data.\n
767            :obj:`bytearray`: Serialize OS TR Configuration data bytes if to_bytes is True.
768        """
769        embed_pers = Common.peripheral_list_to_bitmap(self.embedded_peripherals)
770        conf_bits_0 = int(self.custom_dpa_handler) | int(self.dpa_peer_to_peer) << 1 | int(self.routing_off) << 3 | \
771            int(self.io_setup) << 4 | int(self.user_peer_to_peer) << 5 | \
772            int(self.stay_awake_when_not_bonded) << 6 | int(self.std_and_lp_network) << 7
773        pdata = embed_pers + [conf_bits_0] + self._reserved_block_0 + \
774            [
775                self.rf_output_power,
776                self.rf_signal_filter,
777                self.lp_rf_timeout,
778                self.uart_baud_rate,
779                self.alternative_dsm_channel,
780                int(self.local_frc)
781            ] + self._reserved_block_1 + \
782            [
783                self.rf_channel_a,
784                self.rf_channel_b
785            ] + self._reserved_block_2
786        if to_bytes:
787            return bytearray(pdata)
788        return pdata

Serialize OS TR Configuration data object to DPA request pdata.

Arguments:
  • to_bytes (bool): Serialize into bytes.
Returns:

list of int: Serialized OS TR Configuration data.

bytearray: Serialize OS TR Configuration data bytes if to_bytes is True.

@staticmethod
def calculate_checksum(data: List[int]) -> int:
790    @staticmethod
791    def calculate_checksum(data: List[int]) -> int:
792        """Calculates checksum from TR configuration data.
793
794        Args:
795            data (List[int]): List of integers representing TR configuration data.
796
797        Returns:
798            int: Checksum value.
799        """
800        checksum = 0x5F
801        for val in data:
802            checksum ^= val
803        return checksum

Calculates checksum from TR configuration data.

Arguments:
  • data (List[int]): List of integers representing TR configuration data.
Returns:

int: Checksum value.

@dataclass
class SensorData:
 9@dataclass
10class SensorData:
11    """Class representing Sensor (quantity) information and value."""
12
13    __slots__ = 'sensor_type', 'index', 'name', 'short_name', 'unit', 'decimal_places', 'frc_commands', 'value'
14
15    sensor_type: SensorTypes
16    index: int
17    name: str
18    short_name: str
19    unit: str
20    decimal_places: int
21    frc_commands: List[int]
22    value: Union[int, float, List[int], SensorFrcErrors, None]
23
24    def __init__(self, sensor_type: SensorTypes, index: int, name: str,
25                 short_name: str, unit: str, decimal_places: int, frc_commands: List[int],
26                 value: Union[int, float, List[int], SensorFrcErrors, None] = None):
27        """Class representing Sensor (quantity) information and value.
28
29        Args:
30            sensor_type (SensorTypes): Sensor type (represents a quantity).
31            index (int): Index of sensor.
32            name (str): Quantity name.
33            short_name (str): Short quantity name.
34            unit (str): Quantity unit.
35            decimal_places (int): Precision.
36            frc_commands (List[int]): Implemented FRC commands.
37            value (Union[int, float, List[int], SensorFrcErrors, None]): Measured value.
38        """
39        self.sensor_type = sensor_type
40        """Sensor type (represents a quantity)."""
41        self.index = index
42        """Index of sensor."""
43        self.name = name
44        """Quantity name"""
45        self.short_name = short_name
46        """Short quantity name."""
47        self.unit = unit
48        """Quantity unit."""
49        self.decimal_places = decimal_places
50        """Precision."""
51        self.frc_commands = frc_commands
52        """Implemented FRC commands."""
53        self.value = value
54        """Measured value."""

Class representing Sensor (quantity) information and value.

SensorData( sensor_type: iqrfpy.utils.sensor_constants.SensorTypes, index: int, name: str, short_name: str, unit: str, decimal_places: int, frc_commands: List[int], value: Union[int, float, List[int], iqrfpy.utils.sensor_constants.SensorFrcErrors, NoneType] = None)
24    def __init__(self, sensor_type: SensorTypes, index: int, name: str,
25                 short_name: str, unit: str, decimal_places: int, frc_commands: List[int],
26                 value: Union[int, float, List[int], SensorFrcErrors, None] = None):
27        """Class representing Sensor (quantity) information and value.
28
29        Args:
30            sensor_type (SensorTypes): Sensor type (represents a quantity).
31            index (int): Index of sensor.
32            name (str): Quantity name.
33            short_name (str): Short quantity name.
34            unit (str): Quantity unit.
35            decimal_places (int): Precision.
36            frc_commands (List[int]): Implemented FRC commands.
37            value (Union[int, float, List[int], SensorFrcErrors, None]): Measured value.
38        """
39        self.sensor_type = sensor_type
40        """Sensor type (represents a quantity)."""
41        self.index = index
42        """Index of sensor."""
43        self.name = name
44        """Quantity name"""
45        self.short_name = short_name
46        """Short quantity name."""
47        self.unit = unit
48        """Quantity unit."""
49        self.decimal_places = decimal_places
50        """Precision."""
51        self.frc_commands = frc_commands
52        """Implemented FRC commands."""
53        self.value = value
54        """Measured value."""

Class representing Sensor (quantity) information and value.

Arguments:
  • sensor_type (SensorTypes): Sensor type (represents a quantity).
  • index (int): Index of sensor.
  • name (str): Quantity name.
  • short_name (str): Short quantity name.
  • unit (str): Quantity unit.
  • decimal_places (int): Precision.
  • frc_commands (List[int]): Implemented FRC commands.
  • value (Union[int, float, List[int], SensorFrcErrors, None]): Measured value.

Sensor type (represents a quantity).

index: int

Index of sensor.

name: str

Quantity name

short_name: str

Short quantity name.

unit: str

Quantity unit.

decimal_places: int

Precision.

frc_commands: List[int]

Implemented FRC commands.

value: Union[int, float, List[int], iqrfpy.utils.sensor_constants.SensorFrcErrors, NoneType]

Measured value.

class SensorWrittenData:
 9class SensorWrittenData:
10    """Sensor Written Data class."""
11
12    __slots__ = '_index', '_data'
13
14    def __init__(self, index: int, data: List[int]):
15        """Sensor Written Data constructor.
16
17        Args:
18            index (int): Sensor index.
19            data (List[int]): Data to write.
20        """
21        self._validate(index=index, data=data)
22        self._index = index
23        self._data = data
24
25    def _validate(self, index: int, data: List[int]):
26        """Validate parameters.
27
28        Args:
29            index (int): Sensor index.
30            data (List[int]): Data to write.
31        """
32        self._validate_index(index)
33        self._validate_data(data)
34
35    @staticmethod
36    def _validate_index(index: int):
37        """Validate sensor index parameter.
38
39        Args:
40            index (int): Sensor index.
41
42        Raises:
43            RequestParameterInvalidValueError: If index is less than 0 or greater than 31.
44        """
45        if not dpa_constants.SENSOR_INDEX_MIN <= index <= dpa_constants.SENSOR_INDEX_MAX:
46            raise RequestParameterInvalidValueError('Index value should be between 0 and 31.')
47
48    @property
49    def index(self) -> int:
50        """:obj:`int`: Sensor index.
51
52        Getter and setter.
53        """
54        return self._index
55
56    @index.setter
57    def index(self, value: int):
58        self._validate_index(value)
59        self._index = value
60
61    @staticmethod
62    def _validate_data(data: List[int]):
63        """Validate data to write.
64
65        Args:
66            data (List[int]): Data to write.
67
68        Raises:
69            RequestParameterInvalidValueError: If data contains values not in range from 0 to 255.
70        """
71        if not Common.values_in_byte_range(data):
72            raise RequestParameterInvalidValueError('Data values should be between 0 and 255.')
73
74    @property
75    def data(self) -> List[int]:
76        """:obj:`list` of :obj:`int`: Data to write.
77
78        Getter and setter.
79        """
80        return self._data
81
82    @data.setter
83    def data(self, value: List[int]):
84        self._validate_data(value)
85        self._data = value
86
87    def to_pdata(self) -> List[int]:
88        """Serialize index and data to parameters.
89
90        Returns:
91            :obj:`list` of `int`: Serialized written data.
92        """
93        return [self.index] + self.data

Sensor Written Data class.

SensorWrittenData(index: int, data: List[int])
14    def __init__(self, index: int, data: List[int]):
15        """Sensor Written Data constructor.
16
17        Args:
18            index (int): Sensor index.
19            data (List[int]): Data to write.
20        """
21        self._validate(index=index, data=data)
22        self._index = index
23        self._data = data

Sensor Written Data constructor.

Arguments:
  • index (int): Sensor index.
  • data (List[int]): Data to write.
index: int

int: Sensor index.

Getter and setter.

data: List[int]

list of int: Data to write.

Getter and setter.

def to_pdata(self) -> List[int]:
87    def to_pdata(self) -> List[int]:
88        """Serialize index and data to parameters.
89
90        Returns:
91            :obj:`list` of `int`: Serialized written data.
92        """
93        return [self.index] + self.data

Serialize index and data to parameters.

Returns:

list of int: Serialized written data.

@dataclass
class TrMcuTypeData:
10@dataclass
11class TrMcuTypeData:
12    """TR MCU Type data class."""
13
14    __slots__ = 'mcu_type', 'tr_series', 'fcc_certified', 'value'
15
16    def __init__(self, val: int):
17        """TR MCU Type constructor.
18
19        Args:
20            val (int): TR MCU Type value.
21        """
22        mcu_type = val & 0x07
23        self.mcu_type: Optional[McuTypes] = McuTypes(mcu_type) if mcu_type in McuTypes else None
24        """MCU type."""
25        tr_series = (val & 0xF0) >> 4
26        tr_series_val = None
27        if self.mcu_type == McuTypes.PIC16LF1938 and tr_series in TrDTypes:
28            tr_series_val = TrDTypes(tr_series)
29        elif self.mcu_type == McuTypes.PIC16LF18877 and tr_series in TrGTypes:
30            tr_series_val = TrGTypes(tr_series)
31        self.tr_series: Optional[Union[TrDTypes, TrGTypes]] = tr_series_val
32        """TR series."""
33        self.fcc_certified = bool(val & 0x08)
34        """FCC certified."""
35        self.value: int = val
36        """Raw value."""

TR MCU Type data class.

TrMcuTypeData(val: int)
16    def __init__(self, val: int):
17        """TR MCU Type constructor.
18
19        Args:
20            val (int): TR MCU Type value.
21        """
22        mcu_type = val & 0x07
23        self.mcu_type: Optional[McuTypes] = McuTypes(mcu_type) if mcu_type in McuTypes else None
24        """MCU type."""
25        tr_series = (val & 0xF0) >> 4
26        tr_series_val = None
27        if self.mcu_type == McuTypes.PIC16LF1938 and tr_series in TrDTypes:
28            tr_series_val = TrDTypes(tr_series)
29        elif self.mcu_type == McuTypes.PIC16LF18877 and tr_series in TrGTypes:
30            tr_series_val = TrGTypes(tr_series)
31        self.tr_series: Optional[Union[TrDTypes, TrGTypes]] = tr_series_val
32        """TR series."""
33        self.fcc_certified = bool(val & 0x08)
34        """FCC certified."""
35        self.value: int = val
36        """Raw value."""

TR MCU Type constructor.

Arguments:
  • val (int): TR MCU Type value.
mcu_type: Optional[iqrfpy.utils.dpa.McuTypes]

MCU type.

TR series.

fcc_certified

FCC certified.

value: int

Raw value.