# flake8: noqa
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# sources: radio.proto
# plugin: python-betterproto
from dataclasses import dataclass

import betterproto
from betterproto.grpc.grpclib_server import ServiceBase


class Radio(betterproto.Enum):
    R0 = 0
    R1 = 1


class Spreading(betterproto.Enum):
    SF_UNDEFINED = 0
    SF7 = 1
    SF8 = 2
    SF9 = 3
    SF10 = 4
    SF11 = 5
    SF12 = 6


class Bandwidth(betterproto.Enum):
    BW_UNDEFINED = 0
    BW7_8kHz = 1
    BW15_6kHz = 2
    BW31_2kHz = 3
    BW62_5kHz = 4
    BW125kHz = 5
    BW250kHz = 6
    BW500kHz = 7


class Coderate(betterproto.Enum):
    CR_UNDEFINED = 0
    CR4_5 = 1
    CR4_6 = 2
    CR4_7 = 3
    CR4_8 = 4


@dataclass(eq=False, repr=False)
class RadioReq(betterproto.Message):
    id: int = betterproto.uint32_field(1)
    tx: "RadioTxReq" = betterproto.message_field(2, group="kind")


@dataclass(eq=False, repr=False)
class RadioResp(betterproto.Message):
    id: int = betterproto.uint32_field(1)
    tx: "RadioTxResp" = betterproto.message_field(2, group="kind")
    rx_packet: "RadioRxPacket" = betterproto.message_field(3, group="kind")
    parse_err: bytes = betterproto.bytes_field(4, group="kind")


@dataclass(eq=False, repr=False)
class RadioTxReq(betterproto.Message):
    # Center frequency to transmit on.
    freq: int = betterproto.uint32_field(1)
    # Which radio to transmit on.
    radio: "Radio" = betterproto.enum_field(2)
    # TX power (in dBm).
    power: int = betterproto.int32_field(3)
    # Modulation bandwidth.
    bandwidth: "Bandwidth" = betterproto.enum_field(4)
    # Spreading factor to use with this packet.
    spreading: "Spreading" = betterproto.enum_field(5)
    # Error-correcting-code of the packet.
    coderate: "Coderate" = betterproto.enum_field(6)
    # Invert signal polarity for orthogonal downlinks.
    invert_polarity: bool = betterproto.bool_field(7)
    # Do not send a CRC in the packet.
    omit_crc: bool = betterproto.bool_field(8)
    # Enable implicit header mode.
    implicit_header: bool = betterproto.bool_field(9)
    # Arbitrary user-defined payload to transmit.
    payload: bytes = betterproto.bytes_field(10)


@dataclass(eq=False, repr=False)
class RadioRxPacket(betterproto.Message):
    # Center frequency of the channel this packet was received on.
    freq: int = betterproto.uint32_field(1)
    # Channel this packet packet was received on.
    if_chain: int = betterproto.uint32_field(2)
    # Status of CRC check.
    crc_check: bool = betterproto.bool_field(3)
    # 1uS-resolution timestamp derived from concentrator's internal counter.
    timestamp: int = betterproto.uint64_field(4)
    # RF chain this packet was received on.
    radio: "Radio" = betterproto.enum_field(5)
    # Modulation bandwidth.
    bandwidth: "Bandwidth" = betterproto.enum_field(6)
    # Spreading factor of this packet.
    spreading: "Spreading" = betterproto.enum_field(7)
    # Error Correcting Code rate of this packet.
    coderate: "Coderate" = betterproto.enum_field(8)
    # Average packet RSSI in dB.
    rssi: float = betterproto.float_field(9)
    # Average packet SNR, in dB.
    snr: float = betterproto.float_field(10)
    # This packet's payload.
    payload: bytes = betterproto.bytes_field(11)


@dataclass(eq=False, repr=False)
class RadioTxResp(betterproto.Message):
    success: bool = betterproto.bool_field(1)
