mirror of
https://github.com/tcivie/meshtastic-metrics-exporter.git
synced 2024-12-28 23:19:48 -08:00
17 lines
507 B
Python
17 lines
507 B
Python
|
from meshtastic.mesh_pb2 import MeshPacket
|
||
|
from prometheus_client import CollectorRegistry
|
||
|
|
||
|
from exporter.registry import ProcessorRegistry
|
||
|
|
||
|
|
||
|
class MessageProcessor:
|
||
|
def __init__(self, registry: CollectorRegistry):
|
||
|
self.registry = registry
|
||
|
|
||
|
def process(self, mesh_packet: MeshPacket):
|
||
|
port_num = mesh_packet.decoded.portnum
|
||
|
payload = mesh_packet.decoded.payload
|
||
|
processor = ProcessorRegistry.get_processor(port_num)(self.registry)
|
||
|
|
||
|
processor.process(payload)
|