MRAS
Multi Rocket Avionics System
Loading...
Searching...
No Matches
TelemetrySystem.h
1//
2// Created by Tom Danvers on 05/01/2023.
3//
4
5#ifndef MRAS_TELEMETRYSYSTEM_H
6#define MRAS_TELEMETRYSYSTEM_H
7
8
9#include "Subsystem.h"
10#include "RadioLib.h"
11#include "MRAS_Config.h"
12#include "TelemetryMessage.h"
13#include "system_messages/TelemetryMessageQueueMsg.h"
14#include "system_messages/TelemetryMessageReceivedMsg.h"
15
23class TelemetrySystem : public Subsystem {
24protected:
25 // create subsystem boilerplate
26 SUBSYSTEM_NAME("TelemetrySystem")
27
28
29 // create setup and loop functions
30 int8_t setup() override;
31
32 SX1262 radio = new Module(RADIO_CHIP_SELECT_PIN,
33 RADIO_DIO1_PIN,
34 RADIO_RESET_PIN,
35 RADIO_BUSY_PIN,
36 RADIO_SPI_BUS);
37
38 enum TelemetrySystemState {
39 IDLE,
40 TX,
41 RX
42 } telemetry_system_state = IDLE;
43
44 int16_t radio_state = 0;
45
46protected:
47 virtual TelemetryMessageQueueMsg* get_default_message() = 0;
48
49 void transmit_next_message();
50
55 void start_receiving_next_message(uint32_t timeout = 0xFFFFFF);
56
65 bool read_new_message_from_buffer(TelemetryMessageReceivedMsg* output, bool receive_again = true);
66
67public:
68 explicit TelemetrySystem(uint8_t id) : Subsystem(id) {}
69 int16_t get_radio_state() const;
70};
71
72
73#endif //MRAS_TELEMETRYSYSTEM_H
Definition: Subsystem.h:30
A subsystem for sending and receiving telemetry data using the LoRa radio.
Definition: TelemetrySystem.h:23
void start_receiving_next_message(uint32_t timeout=0xFFFFFF)
Definition: TelemetrySystem.cpp:73
bool read_new_message_from_buffer(TelemetryMessageReceivedMsg *output, bool receive_again=true)
Definition: TelemetrySystem.cpp:79
A SystemMessage that is used to queue a TelemetryMessage for sending to the ground or the rocket.
Definition: TelemetryMessageQueueMsg.h:17
A SystemMessage that is output by the TelemetrySystem when a TelemetryMessage is received from the gr...
Definition: TelemetryMessageReceivedMsg.h:15