1+ #include " FreeRTOS.h"
12#include " GroundStationComms.hpp"
23#include " MavlinkTranslator.hpp"
34#include " TimerInterrupt.hpp"
4- #include " FreeRTOS.h"
55#include " task.h"
66
77TelemetryManager::TelemetryManager () {
88 this ->MT = MavlinkTranslator ();
99 this ->GSC = GroundStationComms ();
1010}
1111
12+ TelemetryManager::~TelemetryManager () {
13+ // Destructor
14+ }
15+
1216/* *
1317 * @brief Initialize TM threads and timer interrupts.
1418 *
1519 */
1620void TelemetryManager::init () {
1721 // initialize the timer interrupts
18- createTimerInterrupts ();
22+ initTimerInterrupts ();
23+
24+ // Init TM tasks
25+ initTasks ();
26+
27+ // Start the scheduler
28+ vTaskStartScheduler (); // should this be in system manager instead?
29+ }
30+
31+ void TelemetryManager::initTimerInterrupts () {
32+ /* *
33+ * @brief This interrupt service routine is called every 1000ms. It is responsible for
34+ * sending the highest priority drone "state" data to the ground station. Data such as
35+ * heartbeat message, altitude, attitude, latitude, longitude... And anything else deemed
36+ * important enough to be transmitted at a regular interval. This is the highest priority
37+ * data in the GSC.highPriorityTransmitBuffer.
38+ *
39+ */
40+ TimerInterrupt dispatchHighPriorityInterrupt1000Ms (
41+ " dispatchHighPriority1000Ms" , configMINIMAL_STACK_SIZE, tskIDLE_PRIORITY, 500 , *this ,
42+ [](TelemetryManager& tm) -> void {
43+ auto GSC = tm.GSC ;
44+
45+ // START: ingest drone state data and pack bytes into GSC.highPriorityTransmitBuffer
1946
47+ // END: ingest drone state data and pack bytes into GSC.highPriorityTransmitBuffer
48+
49+ // transmit the data via GSC.sendToGroundStation(); function
50+ GSC.sendToGroundStation (GSC.highPriorityTransmitBuffer );
51+ });
52+ }
53+
54+ void TelemetryManager::initTasks () {
2055 // Initialize translateToMavlinkThread as a FreeRTOS task
2156 xTaskCreate (TelemetryManager::translateToMavlinkThreadStatic, // Task function
2257 " translateToMavlinkThread" , // Task name
@@ -34,9 +69,6 @@ void TelemetryManager::init() {
3469 tskIDLE_PRIORITY + 1 , // Task priority
3570 NULL // Task handle
3671 );
37-
38- // Start the scheduler
39- vTaskStartScheduler (); // should this be in system manager instead?
4072}
4173
4274/* *
@@ -76,26 +108,3 @@ void TelemetryManager::sendLowPriorityData() {
76108 // transmit low priority the data via GSC.sendToGroundStation(); function
77109 GSC.sendToGroundStation (GSC.lowPriorityTransmitBuffer );
78110}
79-
80- void TelemetryManager::createTimerInterrupts () {
81- /* *
82- * @brief This interrupt service routine is called every 1000ms. It is responsible for
83- * sending the highest priority drone "state" data to the ground station. Data such as
84- * heartbeat message, altitude, attitude, latitude, longitude... And anything else deemed
85- * important enough to be transmitted at a regular interval. This is the highest priority
86- * data in the GSC.highPriorityTransmitBuffer.
87- *
88- */
89- TimerInterrupt dispatchHighPriorityInterrupt1000Ms (
90- " dispatchHighPriority1000Ms" , configMINIMAL_STACK_SIZE, tskIDLE_PRIORITY, 500 , *this ,
91- [](TelemetryManager& tm) -> void {
92- auto GSC = tm.GSC ;
93-
94- // START: ingest drone state data and pack bytes into GSC.highPriorityTransmitBuffer
95-
96- // END: ingest drone state data and pack bytes into GSC.highPriorityTransmitBuffer
97-
98- // transmit the data via GSC.sendToGroundStation(); function
99- GSC.sendToGroundStation (GSC.highPriorityTransmitBuffer );
100- });
101- }
0 commit comments