-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLowPower.cpp
More file actions
68 lines (63 loc) · 1.68 KB
/
LowPower.cpp
File metadata and controls
68 lines (63 loc) · 1.68 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
/*
* LowPower.cpp
* Author: Alex St. Clair
* Created: July 2019
*
* This file implements the RACHuTS low power mode.
*/
#include "StratoPIB.h"
enum LPStates_t : uint8_t {
LP_ENTRY = MODE_ENTRY,
// add any desired states between entry and shutdown
LP_ALERT_MCB,
LP_CHECK_MCB,
LP_LOOP,
LP_ERROR_LANDING = MODE_ERROR,
LP_SHUTDOWN = MODE_SHUTDOWN,
LP_EXIT = MODE_EXIT
};
void StratoPIB::LowPowerMode()
{
switch (inst_substate) {
case LP_ENTRY:
// perform setup
log_nominal("Entering LP");
inst_substate = LP_ALERT_MCB;
break;
case LP_ALERT_MCB:
log_nominal("Commanding MCB low power");
mcbComm.TX_ASCII(MCB_GO_LOW_POWER);
scheduler.AddAction(RESEND_MCB_LP, MCB_RESEND_TIMEOUT);
inst_substate = LP_CHECK_MCB;
break;
case LP_CHECK_MCB:
log_debug("Waiting on MCB LP ack");
if (mcb_low_power) {
mcb_low_power = false;
inst_substate = LP_LOOP;
} else if (CheckAction(RESEND_MCB_LP)) {
inst_substate = LP_ALERT_MCB;
}
break;
case LP_LOOP:
// nominal ops
log_debug("LP loop");
break;
case LP_ERROR_LANDING:
log_debug("LP error");
break;
case LP_SHUTDOWN:
// prep for shutdown
log_nominal("Shutdown warning received in LP");
break;
case LP_EXIT:
// perform cleanup
log_nominal("Exiting LP");
break;
default:
// todo: throw error
log_error("Unknown substate in LP");
inst_substate = LP_ENTRY; // reset
break;
}
}