24 #ifndef GOBY_ACOMMS_MODEMDRIVER_IRIDIUM_DRIVER_COMMON_H
25 #define GOBY_ACOMMS_MODEMDRIVER_IRIDIUM_DRIVER_COMMON_H
27 #include <dccl/codec.h>
28 #include <dccl/field_codec_fixed.h>
29 #include <dccl/field_codec_manager.h>
57 : last_tx_time_(
time::SystemClock::now().time_since_epoch() / std::chrono::seconds(1)),
84 total_bytes_sent_ += i;
92 int total_bytes_sent_;
102 virtual unsigned size() {
return 0; }
109 auto iridium_id_name =
"iridium_header_id";
110 #ifdef DCCL_VERSION_4_1_OR_NEWER
113 dccl::FieldCodecManager::add<IridiumHeaderIdentifierCodec>(iridium_id_name);
120 const goby::acomms::protobuf::ModemTransmission& in)
122 goby::acomms::iridium::protobuf::IridiumHeader header;
123 header.set_src(in.src());
124 header.set_dest(in.dest());
126 header.set_rate(in.rate());
127 header.set_type(in.type());
128 if (in.has_ack_requested())
129 header.set_ack_requested(in.ack_requested());
130 if (in.has_frame_start())
131 header.set_frame_start(in.frame_start());
132 if (in.acked_frame_size())
133 header.set_acked_frame(in.acked_frame(0));
141 goby::acomms::protobuf::ModemTransmission* out)
143 goby::acomms::iridium::protobuf::IridiumHeader header;
146 out->set_src(header.src());
147 out->set_dest(header.dest());
148 if (header.has_rate())
149 out->set_rate(header.rate());
150 out->set_type(header.type());
151 if (header.has_ack_requested())
152 out->set_ack_requested(header.ack_requested());
153 if (header.has_frame_start())
154 out->set_frame_start(header.frame_start());
155 if (header.has_acked_frame())
156 out->add_acked_frame(header.acked_frame());
169 goby::Exception(
"Must use device = DEVICE_VOICE_ENABLED_ISU for RUDICS support."));
175 const auto head_bytes{goby::acomms::iridium::protobuf::IridiumHeader::descriptor()
182 const auto overhead_bytes = head_bytes + crc_bytes;
208 default:
throw(
goby::Exception(
"Invalid direction for the Iridium driver"));
simple exception class for goby applications
int total_bytes_sent() const
void set_last_tx_time(double d)
double last_rx_tx_time() const
void set_last_bytes_sent(int i)
int last_bytes_sent() const
void set_bye_received(bool b)
double last_tx_time() const
void set_bye_sent(bool b)
double last_rx_time() const
bool bye_received() const
void set_last_rx_time(double d)
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values
unit< time_dimension, si::system > time
@ DEVICE_VOICE_ENABLED_ISU
@ DEVICE_IRIDIUM_9602_9603
constexpr int IRIDIUM_SBD_CRC_BYTE_SIZE
void serialize_iridium_modem_message(std::string *out, const goby::acomms::protobuf::ModemTransmission &in)
void parse_iridium_modem_message(std::string in, goby::acomms::protobuf::ModemTransmission *out)
@ DIRECTION_MOBILE_TERMINATED
@ DIRECTION_MOBILE_ORIGINATED
std::shared_ptr< dccl::Codec > iridium_header_dccl_
unsigned iridium_rate_to_bytes(int rate, iridium::protobuf::DeviceType device, Direction direction)
The global namespace for the Goby project.
extern ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< ::google::protobuf::MessageOptions, ::PROTOBUF_NAMESPACE_ID::internal::MessageTypeTraits< ::goby::GobyMessageOptions >, 11, false > msg