from __future__ import annotations

from dataclasses import dataclass, field
from typing import List, Optional


@dataclass
class PeriodicMessage:
    header: int
    interval_ms: int
    bytes: List[int]
    id: int = field(default_factory=lambda: PeriodicMessage._next_id())
    timer: Optional["threading.Event"] = None

    _next_id_value = 0

    @classmethod
    def _next_id(cls) -> int:
        cls._next_id_value += 1
        return cls._next_id_value
