1 #include "ais_helper.hpp"
2 #include <marnav/utils/unique.hpp>
8 /// Creates and returns a container of VDM sentences, created from the specified
11 /// @param[in] payload The payload to create VDM sentences from.
12 /// @param[in] seq_msg_id The optional sequence message ID to be configured for
13 /// the resulting sentences.
14 /// @param[in] radio_channel Specifies which AIS radio channel to configure for
15 /// the resulting sentences.
16 /// @return Container of NMEA sentences containing VDM sentences.
17 std::vector
<std::unique_ptr
<nmea::sentence
>> make_vdms(
18 const std::vector
<std::pair
<std::string
, uint32_t>> & payload
,
19 utils::optional
<uint32_t> seq_msg_id
, ais_channel radio_channel
)
21 std::vector
<std::unique_ptr
<nmea::sentence
>> sentences
;
23 for (uint32_t fragment
= 0; fragment
< payload
.size(); ++fragment
) {
24 auto sentence
= utils::make_unique
<vdm
>();
26 sentence
->set_n_fragments(payload
.size());
27 sentence
->set_fragment(fragment
+ 1);
28 sentence
->set_radio_channel(radio_channel
);
29 sentence
->set_payload(payload
[fragment
]);
32 sentence
->set_seq_msg_id(*seq_msg_id
);
34 sentences
.push_back(std::move(sentence
));