This repository has been archived by the owner on Oct 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathradio_handler.h
48 lines (41 loc) · 1.69 KB
/
radio_handler.h
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
#ifndef RADIO_HANDLER_H_
#define RADIO_HANDLER_H_
#include "message_types.h"
#include <stdint.h>
/*
* The maximum allowable time between received messages.
* After this time, the vent valve is automatically opened.
*/
#define TIME_NO_CONTACT_BEFORE_SAFE_STATE 10000
/*
* Returns the state that the operators on the ground are telling us that the
* injector valve should be in. If we haven't heard from the operators ever (we
* just booted up and haven't established radio contact), this function will
* return VALVE_UNK, because we shouldn't assume that we should start with the
* injector valve in either state.
*
* If we haven't heard from the operator in TIME_NO_CONTACT_BEFORE_SAFE_STATE,
* this function will continue to spit out whatever value we last got from the
* operator, because going to safe state does not imply doing anything to the
* injector valve.
*/
enum VALVE_STATE radio_get_expected_inj_valve_state(void);
/*
* Returns the state that the operators on the ground are telling us that the
* vent valve should be in. If we haven't heard from the operators ever (we
* just booted up and haven't established radio contact), this function will
* return VALVE_OPEN, because in the presence of no information, we should
* always open the vent valve.
*
* If we haven't heard from the operator in TIME_NO_CONTACT_BEFORE_SAFE_STATE,
* this function will return VALVE_OPEN, because that's the safest state for the
* vent valve to be in
*/
enum VALVE_STATE radio_get_expected_vent_valve_state(void);
void radio_handle_input_character(uint8_t c);
/*
* Checks if we need to send an error message over UART. Call every loop
* through the application code
*/
void radio_heartbeat(void);
#endif