Goby v2
iridium_shore_driver.h
1 // Copyright 2009-2018 Toby Schneider (http://gobysoft.org/index.wt/people/toby)
2 // GobySoft, LLC (2013-)
3 // Massachusetts Institute of Technology (2007-2014)
4 // Community contributors (see AUTHORS file)
5 //
6 //
7 // This file is part of the Goby Underwater Autonomy Project Libraries
8 // ("The Goby Libraries").
9 //
10 // The Goby Libraries are free software: you can redistribute them and/or modify
11 // them under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 2.1 of the License, or
13 // (at your option) any later version.
14 //
15 // The Goby Libraries are distributed in the hope that they will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with Goby. If not, see <http://www.gnu.org/licenses/>.
22 
23 #ifndef IridiumShoreDriver20140508H
24 #define IridiumShoreDriver20140508H
25 
26 #include <boost/bimap.hpp>
27 #include <boost/circular_buffer.hpp>
28 
29 #include "goby/acomms/modemdriver/driver_base.h"
30 #include "goby/acomms/modemdriver/iridium_driver_common.h"
31 #include "goby/acomms/modemdriver/iridium_shore_rudics.h"
32 #include "goby/acomms/modemdriver/iridium_shore_sbd.h"
33 #include "goby/acomms/protobuf/iridium_driver.pb.h"
34 #include "goby/acomms/protobuf/iridium_sbd_directip.pb.h"
35 #include "goby/acomms/protobuf/iridium_shore_driver.pb.h"
36 #include "goby/common/time.h"
37 
38 namespace goby
39 {
40 namespace acomms
41 {
43 {
44  public:
47  void startup(const protobuf::DriverConfig& cfg);
48 
49  void modem_init();
50 
51  void shutdown();
52  void do_work();
53 
55  void process_transmission(protobuf::ModemTransmission msg);
56 
57  private:
58  typedef unsigned ModemId;
59 
60  void receive(const protobuf::ModemTransmission& msg);
61  void send(const protobuf::ModemTransmission& msg);
62 
63  void decode_mo(protobuf::DirectIPMOPreHeader* pre_header, protobuf::DirectIPMOHeader* header,
64  protobuf::DirectIPMOPayload* body, const std::string& data);
65  std::string create_sbd_mt_data_message(const std::string& payload, const std::string& imei);
66  void receive_sbd_mo();
67  void send_sbd_mt(const std::string& bytes, const std::string& imei);
68 
69  void rudics_send(const std::string& data, ModemId id);
70  void rudics_disconnect(boost::shared_ptr<RUDICSConnection> connection);
71  void rudics_line(const std::string& line, boost::shared_ptr<RUDICSConnection> connection);
72  void rudics_connect(boost::shared_ptr<RUDICSConnection> connection);
73 
74  private:
75  protobuf::DriverConfig driver_cfg_;
76 
77  protobuf::ModemTransmission rudics_mac_msg_;
78 
79  goby::uint32 next_frame_;
80 
81  struct RemoteNode
82  {
83  enum
84  {
85  DATA_BUFFER_CAPACITY = 30
86  };
87  RemoteNode() : data_out(DATA_BUFFER_CAPACITY) {}
88 
89  boost::shared_ptr<OnCallBase> on_call;
90  boost::circular_buffer<protobuf::ModemTransmission> data_out;
91  };
92 
93  std::map<ModemId, RemoteNode> remote_;
94 
95  boost::asio::io_service rudics_io_;
96  boost::shared_ptr<RUDICSServer> rudics_server_;
97  boost::asio::io_service sbd_io_;
98  boost::shared_ptr<SBDServer> mo_sbd_server_;
99 
100  // maps remote modem to connection
101  boost::bimap<ModemId, boost::shared_ptr<RUDICSConnection> > clients_;
102 
103  typedef std::string IMEI;
104  std::map<ModemId, IMEI> modem_id_to_imei_;
105 };
106 } // namespace acomms
107 } // namespace goby
108 #endif
void do_work()
Allows the modem driver to do its work.
void startup(const protobuf::DriverConfig &cfg)
Starts the modem driver. Must be called before poll().
google::protobuf::uint32 uint32
an unsigned 32 bit integer
void handle_initiate_transmission(const protobuf::ModemTransmission &m)
Virtual initiate_transmission method. Typically connected to MACManager::signal_initiate_transmission...
void shutdown()
Shuts down the modem driver.
The global namespace for the Goby project.
provides an abstract base class for acoustic modem drivers. This is subclassed by the various drivers...
Definition: driver_base.h:47