Goby3 3.7.0
2026.11.12
Loading...
Searching...
No Matches
iridium_driver.h
Go to the documentation of this file.
1// Copyright 2011-2026:
2// GobySoft, LLC (2013-)
3// Massachusetts Institute of Technology (2007-2014)
4// Community contributors (see AUTHORS file)
5// File authors:
6// Toby Schneider <toby@gobysoft.org>
7//
8//
9// This file is part of the Goby Underwater Autonomy Project Libraries
10// ("The Goby Libraries").
11//
12// The Goby Libraries are free software: you can redistribute them and/or modify
13// them under the terms of the GNU Lesser General Public License as published by
14// the Free Software Foundation, either version 2.1 of the License, or
15// (at your option) any later version.
16//
17// The Goby Libraries are distributed in the hope that they will be useful,
18// but WITHOUT ANY WARRANTY; without even the implied warranty of
19// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20// GNU Lesser General Public License for more details.
21//
22// You should have received a copy of the GNU Lesser General Public License
23// along with Goby. If not, see <http://www.gnu.org/licenses/>.
24
25#ifndef GOBY_ACOMMS_MODEMDRIVER_IRIDIUM_DRIVER_H
26#define GOBY_ACOMMS_MODEMDRIVER_IRIDIUM_DRIVER_H
27
28#include <cstdint> // for uint32_t
29#include <deque> // for deque
30#include <iosfwd> // for ostream
31#include <memory> // for shared_ptr
32#include <random> // for mt19937
33
34#include "goby/acomms/modemdriver/driver_base.h" // for ModemDriverBase
35#include "goby/acomms/protobuf/driver_base.pb.h" // for DriverConfig
36#include "goby/acomms/protobuf/iridium_driver.pb.h" // for Config, MessageT...
37#include "goby/acomms/protobuf/modem_message.pb.h" // for ModemTransmission
38#include "goby/time/steady_clock.h" // for SteadyClock
39#include "iridium_driver_fsm.h" // for IridiumDriverFSM
40
41namespace goby
42{
43namespace util
44{
45class TCPClient;
46} // namespace util
47
48namespace acomms
49{
51{
52 public:
54 ~IridiumDriver() override;
55 void startup(const protobuf::DriverConfig& cfg) override;
56
57 void modem_init();
58
59 void shutdown() override;
60 void do_work() override;
61
64
65 private:
66 void shutdown(bool flush_eeprom);
67 void process_transmission(protobuf::ModemTransmission msg, bool dial);
68 void start_sbd_session();
69 void complete_sbd_session_request();
70
71 void receive(const protobuf::ModemTransmission& msg);
72 void send(const protobuf::ModemTransmission& msg);
73
74 void try_serial_tx();
75 void display_state_cfg(std::ostream* os);
76
77 void hangup();
78 void set_dtr(bool state);
79 bool query_dtr();
80
81 const iridium::protobuf::Config& iridium_driver_cfg()
82 {
83 return driver_cfg_.GetExtension(iridium::protobuf::config);
84 };
85
86 private:
87 protobuf::DriverConfig driver_cfg_;
89
90 std::shared_ptr<goby::util::TCPClient> debug_client_;
91
92 double last_triple_plus_time_{0};
93 enum
94 {
95 TRIPLE_PLUS_WAIT = 2
96 };
97
98 protobuf::ModemTransmission rudics_mac_msg_;
99
100 // SBD data is requested only once the session is cleared to start (signal check passed)
101 std::unique_ptr<protobuf::ModemTransmission> sbd_data_request_;
102 std::deque<protobuf::ModemTransmission> sbd_acks_;
103 bool sbd_session_requested_{false};
104 goby::time::SteadyClock::time_point sbd_data_request_start_;
105 std::mt19937 rng_{std::random_device()()};
106 // don't re-poll +CSQ continuously for queued acks or MT while the signal is too weak
107 goby::time::SteadyClock::time_point sbd_followup_not_before_;
108 bool shutting_down_{false};
109 enum
110 {
111 SBD_SIGNAL_RECHECK_SECONDS = 10,
112 // on top of the +SBDIX timeout, for +CSQ and the other commands of a session
113 SHUTDOWN_WAIT_MARGIN_SECONDS = 30,
114 FLUSH_EEPROM_WAIT_SECONDS = 15
115 };
116
117 std::uint32_t next_frame_{0};
118
119 bool running_{false};
120};
121} // namespace acomms
122} // namespace goby
123#endif
void handle_initiate_transmission(const protobuf::ModemTransmission &m) override
Virtual initiate_transmission method. Typically connected to MACManager::signal_initiate_transmission...
void do_work() override
Allows the modem driver to do its work.
void report(goby::acomms::protobuf::ModemReport *report) override
Returns report including modem availability and signal quality (if known)
void startup(const protobuf::DriverConfig &cfg) override
Starts the modem driver. Must be called before poll().
void shutdown() override
Shuts down the modem driver.
provides an abstract base class for acoustic modem drivers. This is subclassed by the various drivers...
Definition driver_base.h:58
_proto_TypeTraits::Singular::ConstType GetExtension(const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< DriverConfig, _proto_TypeTraits, _field_type, _is_packed > &id) const
extern ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< ::goby::acomms::protobuf::DriverConfig, ::PROTOBUF_NAMESPACE_ID::internal::MessageTypeTraits< ::goby::acomms::iridium::protobuf::Config >, 11, false > config
The global namespace for the Goby project.
extern ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< ::PROTOBUF_NAMESPACE_ID::MessageOptions, ::PROTOBUF_NAMESPACE_ID::internal::MessageTypeTraits< ::goby::GobyMessageOptions >, 11, false > msg
std::chrono::time_point< SteadyClock > time_point