Goby3 3.2.3
2025.05.13
Loading...
Searching...
No Matches
iridium_shore_driver.h
Go to the documentation of this file.
1// Copyright 2015-2023:
2// GobySoft, LLC (2013-)
3// Community contributors (see AUTHORS file)
4// File authors:
5// Toby Schneider <toby@gobysoft.org>
6//
7//
8// This file is part of the Goby Underwater Autonomy Project Libraries
9// ("The Goby Libraries").
10//
11// The Goby Libraries are free software: you can redistribute them and/or modify
12// them under the terms of the GNU Lesser General Public License as published by
13// the Free Software Foundation, either version 2.1 of the License, or
14// (at your option) any later version.
15//
16// The Goby Libraries are distributed in the hope that they will be useful,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19// GNU Lesser General Public License for more details.
20//
21// You should have received a copy of the GNU Lesser General Public License
22// along with Goby. If not, see <http://www.gnu.org/licenses/>.
23
24#ifndef GOBY_ACOMMS_MODEMDRIVER_IRIDIUM_SHORE_DRIVER_H
25#define GOBY_ACOMMS_MODEMDRIVER_IRIDIUM_SHORE_DRIVER_H
26
27#include <cstdint> // for uint32_t
28#include <map> // for map
29#include <memory> // for shared_ptr
30#include <string> // for string
31
32#include <boost/asio/io_service.hpp> // for io_service
33#include <boost/bimap.hpp>
34#include <boost/circular_buffer.hpp> // for circular_b...
35
36#include "goby/acomms/modemdriver/driver_base.h" // for ModemDrive...
37#include "goby/acomms/protobuf/driver_base.pb.h" // for DriverConfig
38#include "goby/acomms/protobuf/iridium_driver.pb.h" // for MessageTyp...
39#include "goby/acomms/protobuf/iridium_shore_driver.pb.h" // for ShoreConfig
40#include "goby/acomms/protobuf/modem_message.pb.h" // for ModemTrans...
41
42namespace goby
43{
44namespace acomms
45{
46class OnCallBase;
47class RUDICSConnection;
48class RUDICSServer;
49namespace directip
50{
51class SBDServer;
52} // namespace directip
53namespace iridium
54{
55namespace protobuf
56{
60} // namespace protobuf
61} // namespace iridium
62
64{
65 public:
68 void startup(const protobuf::DriverConfig& cfg) override;
69
70 void modem_init();
71
72 void shutdown() override;
73 void do_work() override;
74
77
78 private:
79 typedef unsigned ModemId;
80
81 void receive(const protobuf::ModemTransmission& msg);
82 void send(const protobuf::ModemTransmission& msg);
83
84 void decode_mo(iridium::protobuf::DirectIPMOPreHeader* pre_header,
86 iridium::protobuf::DirectIPMOPayload* body, const std::string& data);
87
88 void receive_sbd_mo();
89 void receive_sbd_mo_data(const std::string& data, protobuf::ModemTransmission* modem_msg);
90
91 void send_sbd_mt(const std::string& bytes, const std::string& imei);
92
93 void rudics_send(const std::string& data, ModemId id);
94 void rudics_disconnect(const std::shared_ptr<RUDICSConnection>& connection);
95 void rudics_line(const std::string& line, const std::shared_ptr<RUDICSConnection>& connection);
96 void rudics_connect(const std::shared_ptr<RUDICSConnection>& connection);
97
98 const iridium::protobuf::Config& iridium_driver_cfg() const
99 {
100 return driver_cfg_.GetExtension(iridium::protobuf::config);
101 }
102
103 const iridium::protobuf::ShoreConfig& iridium_shore_driver_cfg() const
104 {
106 }
107
108 // in iridium_shore_driver_sbd_directip.cpp
109 void startup_sbd_directip(const protobuf::DriverConfig& cfg);
110 void receive_sbd_mo_directip();
111 void send_sbd_mt_directip(const std::string& bytes, const std::string& imei);
112
113 // in iridium_shore_driver_sbd_rockblock.cpp
114 void startup_sbd_rockblock(const protobuf::DriverConfig& cfg);
115 void receive_sbd_mo_rockblock();
116 void send_sbd_mt_rockblock(const std::string& bytes, const std::string& imei);
117
118 private:
119 protobuf::DriverConfig driver_cfg_;
120
121 protobuf::ModemTransmission rudics_mac_msg_;
122
123 std::uint32_t next_frame_{0};
124
125 struct RemoteNode
126 {
127 enum
128 {
129 DATA_BUFFER_CAPACITY = 30
130 };
131 RemoteNode() : data_out(DATA_BUFFER_CAPACITY) {}
132
133 std::shared_ptr<OnCallBase> on_call;
134 boost::circular_buffer<protobuf::ModemTransmission> data_out;
135 };
136
137 std::map<ModemId, RemoteNode> remote_;
138
139 std::unique_ptr<boost::asio::io_service> rudics_io_;
140 std::unique_ptr<RUDICSServer> rudics_server_;
141 std::unique_ptr<boost::asio::io_service> sbd_io_;
142 std::unique_ptr<directip::SBDServer> directip_mo_sbd_server_;
143
144 // maps remote modem to connection
145 boost::bimap<ModemId, std::shared_ptr<RUDICSConnection>> clients_;
146
147 using IMEI = std::string;
148 std::map<ModemId, IMEI> modem_id_to_imei_;
149
150 struct RockblockHTTPMessage
151 {
152 enum class MessageState
153 {
154 HEADER,
155 BODY,
156 COMPLETE
157 };
158 MessageState state{MessageState::HEADER};
159 std::map<std::string, std::string> header;
160 std::string body;
161 };
162
163 std::unique_ptr<RockblockHTTPMessage> rb_msg_;
164};
165} // namespace acomms
166} // namespace goby
167#endif
void startup(const protobuf::DriverConfig &cfg) override
Starts the modem driver. Must be called before poll().
void do_work() override
Allows the modem driver to do its work.
void process_transmission(protobuf::ModemTransmission msg)
void handle_initiate_transmission(const protobuf::ModemTransmission &m) override
Virtual initiate_transmission method. Typically connected to MACManager::signal_initiate_transmission...
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:59
_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::ShoreConfig >, 11, false > shore_config
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