-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRadioControlTask.hpp
More file actions
84 lines (69 loc) · 1.88 KB
/
RadioControlTask.hpp
File metadata and controls
84 lines (69 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#ifndef RADIO_CONTROLTASK_HPP_
#define RADIO_CONTROLTASK_HPP_
#include "RadioLib.h"
#include "sfr.hpp"
class RadioControlTask
{
public:
RadioControlTask();
/**
* @brief Executes the actions of the current radio state, as defined in the state machine
*/
void execute();
private:
/**
* @brief Sets up the radio module
*/
void init();
/**
* @brief Resets the transmit window start time and picks a new slot
*/
void downlinkSettings();
/**
* @brief Wrapper around RadioLib's transmit() to provide metadata
*/
bool transmit(uint8_t *packet, uint8_t size);
/**
* @brief Attempts to receive a 3 byte command
*/
bool receive();
/**
* @brief Transmits either a normal report packet or a callsign packet
*
* @return True on successful transmit, false otherwise
*/
bool executeDownlink();
/**
* @brief Constructs and downlinks a normal report
*
* @return True on successful transmit, false otherwise
*/
bool normalReportDownlink();
/**
* @brief Maps a floating point value to a bounded 8 bit integer
*
* @param value The value to map
* @param min The minimum value of the mapped integer
* @param max The maximum value of the mapped integer
* @return The mapped 8 bit integer
*/
uint8_t map_range(float value, int min, int max);
/**
* @brief Parses and processes uplinked commands
*/
void processUplink();
/**
* @brief The radio module instance
*/
RFM96 radio = new Module(constants::radio::radio_cs_pin, constants::radio::radio_di0_pin,
constants::radio::radio_rst_pin, constants::radio::radio_busy_pin);
/**
* @brief The received command
*/
uint8_t *received;
/**
* @brief RadioLib status code
*/
int16_t code;
};
#endif