feat: use uv and protobuf
This commit is contained in:
221
app/proto/__init__.py
Normal file
221
app/proto/__init__.py
Normal file
@ -0,0 +1,221 @@
|
||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# sources: nanopb.proto
|
||||
# plugin: python-betterproto
|
||||
# This file has been @generated
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import List
|
||||
|
||||
import betterproto
|
||||
import betterproto.lib.google.protobuf as betterproto_lib_google_protobuf
|
||||
|
||||
|
||||
class FieldType(betterproto.Enum):
|
||||
FT_DEFAULT = 0
|
||||
FT_CALLBACK = 1
|
||||
FT_POINTER = 4
|
||||
FT_STATIC = 2
|
||||
FT_IGNORE = 3
|
||||
FT_INLINE = 5
|
||||
|
||||
|
||||
class IntSize(betterproto.Enum):
|
||||
IS_DEFAULT = 0
|
||||
IS_8 = 8
|
||||
IS_16 = 16
|
||||
IS_32 = 32
|
||||
IS_64 = 64
|
||||
|
||||
|
||||
class TypenameMangling(betterproto.Enum):
|
||||
M_NONE = 0
|
||||
M_STRIP_PACKAGE = 1
|
||||
M_FLATTEN = 2
|
||||
M_PACKAGE_INITIALS = 3
|
||||
|
||||
|
||||
class DescriptorSize(betterproto.Enum):
|
||||
DS_AUTO = 0
|
||||
DS_1 = 1
|
||||
DS_2 = 2
|
||||
DS_4 = 4
|
||||
DS_8 = 8
|
||||
|
||||
|
||||
@dataclass(eq=False, repr=False)
|
||||
class NanoPbOptions(betterproto.Message):
|
||||
"""
|
||||
This is the inner options message, which basically defines options for
|
||||
a field. When it is used in message or file scope, it applies to all
|
||||
fields.
|
||||
"""
|
||||
|
||||
max_size: int = betterproto.int32_field(1)
|
||||
"""
|
||||
Allocated size for 'bytes' and 'string' fields.
|
||||
For string fields, this should include the space for null terminator.
|
||||
"""
|
||||
|
||||
max_length: int = betterproto.int32_field(14)
|
||||
"""
|
||||
Maximum length for 'string' fields. Setting this is equivalent
|
||||
to setting max_size to a value of length+1.
|
||||
"""
|
||||
|
||||
max_count: int = betterproto.int32_field(2)
|
||||
"""Allocated number of entries in arrays ('repeated' fields)"""
|
||||
|
||||
int_size: "IntSize" = betterproto.enum_field(7)
|
||||
"""
|
||||
Size of integer fields. Can save some memory if you don't need
|
||||
full 32 bits for the value.
|
||||
"""
|
||||
|
||||
enum_intsize: "IntSize" = betterproto.enum_field(34)
|
||||
"""Size for enum fields. Supported by C++11 and C23 standards."""
|
||||
|
||||
type: "FieldType" = betterproto.enum_field(3)
|
||||
"""Force type of field (callback or static allocation)"""
|
||||
|
||||
long_names: bool = betterproto.bool_field(4)
|
||||
"""Use long names for enums, i.e. EnumName_EnumValue."""
|
||||
|
||||
packed_struct: bool = betterproto.bool_field(5)
|
||||
"""
|
||||
Add 'packed' attribute to generated structs.
|
||||
Note: this cannot be used on CPUs that break on unaligned
|
||||
accesses to variables.
|
||||
"""
|
||||
|
||||
packed_enum: bool = betterproto.bool_field(10)
|
||||
"""Add 'packed' attribute to generated enums."""
|
||||
|
||||
skip_message: bool = betterproto.bool_field(6)
|
||||
"""Skip this message"""
|
||||
|
||||
no_unions: bool = betterproto.bool_field(8)
|
||||
"""Generate oneof fields as normal optional fields instead of union."""
|
||||
|
||||
msgid: int = betterproto.uint32_field(9)
|
||||
"""integer type tag for a message"""
|
||||
|
||||
anonymous_oneof: bool = betterproto.bool_field(11)
|
||||
"""decode oneof as anonymous union"""
|
||||
|
||||
proto3: bool = betterproto.bool_field(12)
|
||||
"""Proto3 singular field does not generate a "has_" flag"""
|
||||
|
||||
proto3_singular_msgs: bool = betterproto.bool_field(21)
|
||||
"""
|
||||
Force proto3 messages to have no "has_" flag.
|
||||
This was default behavior until nanopb-0.4.0.
|
||||
"""
|
||||
|
||||
enum_to_string: bool = betterproto.bool_field(13)
|
||||
"""
|
||||
Generate an enum->string mapping function (can take up lots of space).
|
||||
"""
|
||||
|
||||
enum_validate: bool = betterproto.bool_field(32)
|
||||
"""Generate validation methods for enums"""
|
||||
|
||||
fixed_length: bool = betterproto.bool_field(15)
|
||||
"""Generate bytes arrays with fixed length"""
|
||||
|
||||
fixed_count: bool = betterproto.bool_field(16)
|
||||
"""Generate repeated field with fixed count"""
|
||||
|
||||
submsg_callback: bool = betterproto.bool_field(22)
|
||||
"""
|
||||
Generate message-level callback that is called before decoding submessages.
|
||||
This can be used to set callback fields for submsgs inside oneofs.
|
||||
"""
|
||||
|
||||
mangle_names: "TypenameMangling" = betterproto.enum_field(17)
|
||||
"""
|
||||
Shorten or remove package names from type names.
|
||||
This option applies only on the file level.
|
||||
"""
|
||||
|
||||
callback_datatype: str = betterproto.string_field(18)
|
||||
"""Data type for storage associated with callback fields."""
|
||||
|
||||
callback_function: str = betterproto.string_field(19)
|
||||
"""
|
||||
Callback function used for encoding and decoding.
|
||||
Prior to nanopb-0.4.0, the callback was specified in per-field pb_callback_t
|
||||
structure. This is still supported, but does not work inside e.g. oneof or pointer
|
||||
fields. Instead, a new method allows specifying a per-message callback that
|
||||
will be called for all callback fields in a message type.
|
||||
"""
|
||||
|
||||
descriptorsize: "DescriptorSize" = betterproto.enum_field(20)
|
||||
"""
|
||||
Select the size of field descriptors. This option has to be defined
|
||||
for the whole message, not per-field. Usually automatic selection is
|
||||
ok, but if it results in compilation errors you can increase the field
|
||||
size here.
|
||||
"""
|
||||
|
||||
default_has: bool = betterproto.bool_field(23)
|
||||
"""Set default value for has_ fields."""
|
||||
|
||||
include: List[str] = betterproto.string_field(24)
|
||||
"""Extra files to include in generated `.pb.h`"""
|
||||
|
||||
exclude: List[str] = betterproto.string_field(26)
|
||||
"""
|
||||
Automatic includes to exclude from generated `.pb.h`
|
||||
Same as nanopb_generator.py command line flag -x.
|
||||
"""
|
||||
|
||||
package: str = betterproto.string_field(25)
|
||||
"""Package name that applies only for nanopb."""
|
||||
|
||||
type_override: "betterproto_lib_google_protobuf.FieldDescriptorProtoType" = (
|
||||
betterproto.enum_field(27)
|
||||
)
|
||||
"""
|
||||
Override type of the field in generated C code. Only to be used with related field types
|
||||
"""
|
||||
|
||||
label_override: "betterproto_lib_google_protobuf.FieldDescriptorProtoLabel" = (
|
||||
betterproto.enum_field(31)
|
||||
)
|
||||
"""
|
||||
Override of the label of the field (see FieldDescriptorProto.Label). Can be used to create
|
||||
fields which nanopb considers required in proto3, or whether nanopb treats the field as
|
||||
optional/required/repeated.
|
||||
"""
|
||||
|
||||
sort_by_tag: bool = betterproto.bool_field(28)
|
||||
"""
|
||||
Due to historical reasons, nanopb orders fields in structs by their tag number
|
||||
instead of the order in .proto. Set this to false to keep the .proto order.
|
||||
The default value will probably change to false in nanopb-0.5.0.
|
||||
"""
|
||||
|
||||
fallback_type: "FieldType" = betterproto.enum_field(29)
|
||||
"""
|
||||
Set the FT_DEFAULT field conversion strategy.
|
||||
A field that can become a static member of a c struct (e.g. int, bool, etc)
|
||||
will be a a static field.
|
||||
Fields with dynamic length are converted to either a pointer or a callback.
|
||||
"""
|
||||
|
||||
initializer: str = betterproto.string_field(30)
|
||||
"""
|
||||
Override initializer used in generated MyMessage_init_zero and MyMessage_init_default macros
|
||||
By default decided automatically based on field default value and datatype.
|
||||
"""
|
||||
|
||||
discard_unused_automatic_types: bool = betterproto.bool_field(33)
|
||||
"""
|
||||
Discard unused types that are automatically generated by protoc if they are not actually
|
||||
needed. Currently this applies to map< > types when the field is ignored by options.
|
||||
"""
|
||||
|
||||
discard_deprecated: bool = betterproto.bool_field(35)
|
||||
"""
|
||||
Discard messages and fields marked with [deprecated = true] in the proto file.
|
||||
"""
|
||||
96
app/proto/hr_packet/__init__.py
Normal file
96
app/proto/hr_packet/__init__.py
Normal file
@ -0,0 +1,96 @@
|
||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# sources: hr_packet.proto
|
||||
# plugin: python-betterproto
|
||||
# This file has been @generated
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import List
|
||||
|
||||
import betterproto
|
||||
|
||||
|
||||
class HrConfidence(betterproto.Enum):
|
||||
ZERO = 0
|
||||
"""[0,25)"""
|
||||
|
||||
LOW = 1
|
||||
"""[25,50)"""
|
||||
|
||||
MEDIUM = 2
|
||||
"""[50,75]"""
|
||||
|
||||
HIGH = 3
|
||||
"""(75,100]"""
|
||||
|
||||
|
||||
class LoRaBw(betterproto.Enum):
|
||||
BW_NONE = 0
|
||||
BW_10_4 = 8
|
||||
"""
|
||||
nobody is using 7.8 kHz bandwidth
|
||||
so to satisfy protobuf, we use NONE for zero value
|
||||
"""
|
||||
|
||||
BW_15_6 = 1
|
||||
BW_20_8 = 9
|
||||
BW_31_25 = 2
|
||||
BW_41_7 = 10
|
||||
BW_62_5 = 3
|
||||
BW_125_0 = 4
|
||||
BW_250_0 = 5
|
||||
BW_500_0 = 6
|
||||
|
||||
|
||||
@dataclass(eq=False, repr=False)
|
||||
class LoRaParameters(betterproto.Message):
|
||||
bw: "LoRaBw" = betterproto.enum_field(1)
|
||||
sf: int = betterproto.int32_field(2)
|
||||
frequency: float = betterproto.float_field(3)
|
||||
|
||||
|
||||
@dataclass(eq=False, repr=False)
|
||||
class StatusFlag(betterproto.Message):
|
||||
hr_confidence: "HrConfidence" = betterproto.enum_field(1)
|
||||
is_active: bool = betterproto.bool_field(2)
|
||||
is_on_skin: bool = betterproto.bool_field(3)
|
||||
battery: int = betterproto.uint32_field(4)
|
||||
|
||||
|
||||
@dataclass(eq=False, repr=False)
|
||||
class HrOnlyPacket(betterproto.Message):
|
||||
status: "StatusFlag" = betterproto.message_field(1)
|
||||
id: int = betterproto.uint32_field(2)
|
||||
packet_num: int = betterproto.uint32_field(3)
|
||||
hr: int = betterproto.uint32_field(4)
|
||||
|
||||
|
||||
@dataclass(eq=False, repr=False)
|
||||
class HrPpgPacket(betterproto.Message):
|
||||
status: "StatusFlag" = betterproto.message_field(1)
|
||||
id: int = betterproto.uint32_field(2)
|
||||
packet_num: int = betterproto.uint32_field(3)
|
||||
hr: int = betterproto.uint32_field(4)
|
||||
ppg_data: List[int] = betterproto.uint32_field(5)
|
||||
|
||||
|
||||
@dataclass(eq=False, repr=False)
|
||||
class PacketStatus(betterproto.Message):
|
||||
signal_rssi_pkt: int = betterproto.sint32_field(1)
|
||||
"""
|
||||
Estimation of RSSI of the LoRa® signal (after despreading) on last packet received.
|
||||
"""
|
||||
|
||||
|
||||
@dataclass(eq=False, repr=False)
|
||||
class GatewayInfo(betterproto.Message):
|
||||
region_id: int = betterproto.uint32_field(1)
|
||||
gateway_mac: bytes = betterproto.bytes_field(2)
|
||||
radio_parameters: "LoRaParameters" = betterproto.message_field(3)
|
||||
|
||||
|
||||
@dataclass(eq=False, repr=False)
|
||||
class HrPacket(betterproto.Message):
|
||||
gateway_info: "GatewayInfo" = betterproto.message_field(1)
|
||||
hr_only_packet: "HrOnlyPacket" = betterproto.message_field(2, group="packet")
|
||||
hr_ppg_packet: "HrPpgPacket" = betterproto.message_field(3, group="packet")
|
||||
packet_status: "PacketStatus" = betterproto.message_field(4)
|
||||
Reference in New Issue
Block a user