summaryrefslogtreecommitdiff
path: root/HoundTransmissionPolicy.hpp
blob: 052562c83cc67af3ca4620d15da8edf2ded7bb35 (plain)
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
#ifndef HOUND_TRANSMISSION_POLICY_HPP_
#define HOUND_TRANSMISSION_POLICY_HPP_

namespace HoundTransmissionPolicy
{
  enum class Protocol
  {
    Classic,
    SuperFox
  };

  enum class ReplyState
  {
    None,
    FirstReplyPending,
    FirstReplySent
  };

  enum class FrequencyAction
  {
    Keep,
    RandomizeCalling,
    Set
  };

  enum class TxMessage
  {
    None,
    Tx3
  };

  struct State
  {
    ReplyState replyState {ReplyState::None};
    int foxFrequency {0};
  };

  struct FrequencyDecision
  {
    FrequencyAction action {FrequencyAction::Keep};
    int frequency {0};
  };

  struct ReplyInput
  {
    Protocol protocol {Protocol::Classic};
    bool tune {false};
    bool autoEnabled {false};
    int sentReport {0};
    int decodedFoxFrequency {0};
    double trPeriod {0.0};
  };

  struct ReplyPlan
  {
    bool applyReply {false};
    TxMessage txMessage {TxMessage::None};
    int report {0};
    bool enableAuto {false};
    FrequencyDecision frequencyDecision;
    int timeoutMilliseconds {0};
    State nextState;
  };

  struct ClassicTxStartInput
  {
    bool autoEnabled {false};
    bool tune {false};
    int selectedTxMessage {0};
    int currentTxFrequency {0};
  };

  struct TxStartPlan
  {
    FrequencyDecision frequencyDecision;
    State nextState;
  };

  ReplyPlan planFoxReportReply (State const&, ReplyInput const&);
  TxStartPlan planClassicTxStart (State const&, ClassicTxStartInput const&);
}

#endif