Source code for caspia.node.broadcast

import time
from dataclasses import dataclass


[docs]@dataclass class Broadcast: source: int group: int data: bytes error_code: int = None priority: int = None timestamp: float = None def __post_init__(self): self.timestamp = self.timestamp or time.time() @property def is_component_broadcast(self) -> bool: return bool(self.group & 0x100) @property def is_system_broadcast(self) -> bool: return not self.is_component_broadcast @property def type(self) -> int: return self.group & 0x0FF @property def component_id(self) -> int: return self.data[0] & 0x0F @property def component_data(self) -> bytes: return self.data[1:]