waterlinkedsonar
C++ client library for the Water Linked Sonar 3D-15
Loading...
Searching...
No Matches
types.hpp
Go to the documentation of this file.
1
3
4#ifndef WATERLINKEDSONAR_TYPES_HPP
5#define WATERLINKEDSONAR_TYPES_HPP
6
7#include <chrono>
8#include <cstddef>
9#include <cstdint>
10#include <optional>
11#include <stdexcept>
12#include <string>
13
14namespace waterlinked::sonar {
15
17inline constexpr const char* DEFAULT_IP = "192.168.194.96";
19inline constexpr const char* MULTICAST_GROUP = "224.0.0.96";
21inline constexpr std::uint16_t MULTICAST_PORT = 4747;
23inline constexpr std::size_t MAX_DATAGRAM_SIZE = 65507;
24
26struct About {
27 std::string chipid;
31 std::string product_name;
32 std::string variant;
33 std::string version;
34 std::string version_short;
35};
36
39 std::string id;
40 std::string message;
41 std::string status;
43};
44
55
58enum class AcousticsMode : std::uint8_t { LOW_FREQUENCY, HIGH_FREQUENCY };
59
61enum class Salinity : std::uint8_t { SALT, FRESH };
62
64struct Range {
65 double min;
66 double max;
67};
68
70struct UdpConfig {
71 enum class Mode : std::uint8_t { MULTICAST, UNICAST, DISABLED };
76 std::uint16_t unicast_destination_port{0};
77};
78
80struct TimeStatus {
81 std::chrono::system_clock::time_point system_time;
83 std::string ntp_synced_to;
84 std::optional<std::int64_t> ntp_seconds_since_last_sync;
85};
86
89 bool success;
90 std::string message;
92};
93
95class HttpError : public std::runtime_error {
96 public:
99 HttpError(const std::string& what, long status_code)
100 : std::runtime_error(what), status_code_(status_code) {}
101
103 [[nodiscard]] long status_code() const { return status_code_; }
104
105 private:
106 long status_code_;
107};
108
110class VersionError : public std::runtime_error {
111 public:
114 VersionError(const std::string& what, const std::string& min_version,
115 const std::string& device_version)
116 : std::runtime_error(what + " requires Sonar 3D-15 release " +
117 min_version + " or newer; device is " +
118 device_version) {}
119};
120
122class ProtocolError : public std::runtime_error {
123 using std::runtime_error::runtime_error;
124};
125
129 public:
131 : HttpError("system time is already synchronized", 409) {}
132};
133
137 public:
138 ForceSyncOngoingError() : HttpError("a force-sync is already ongoing", 409) {}
139};
140
142const char* to_string(AcousticsMode mode);
143
145const char* to_string(Salinity salinity);
146
149const char* to_string(UdpConfig::Mode mode);
150
151} // namespace waterlinked::sonar
152
153#endif // WATERLINKEDSONAR_TYPES_HPP
force_sync_ntp() while another force-sync is running; the device answers HTTP 409.
Definition types.hpp:136
ForceSyncOngoingError()
Definition types.hpp:138
Transport failure or non-2xx HTTP response.
Definition types.hpp:95
HttpError(const std::string &what, long status_code)
status_code is the HTTP status, or 0 when the request never completed (connect failure or timeout).
Definition types.hpp:99
long status_code() const
HTTP status code of the response, or 0 for transport failure.
Definition types.hpp:103
Device answered with a body the client cannot interpret.
Definition types.hpp:122
set_time_manual() while the device is already NTP-synchronized; the device answers HTTP 409.
Definition types.hpp:128
TimeAlreadySynchronizedError()
Definition types.hpp:130
Device firmware is older than the endpoint requires.
Definition types.hpp:110
VersionError(const std::string &what, const std::string &min_version, const std::string &device_version)
The message reads "\p what requires Sonar 3D-15 release \p min_version or newer; device is \p device_...
Definition types.hpp:114
Definition client.hpp:14
const char * to_string(AcousticsMode mode)
Name used on the wire by the HTTP API: "low-frequency" or "high-frequency".
AcousticsMode
Imaging mode: low frequency gives a 90x40 degree field of view at 5 Hz, high frequency 40x40 degrees ...
Definition types.hpp:58
Salinity
Water salinity, used by the sonar's automatic speed of sound.
Definition types.hpp:61
constexpr const char * MULTICAST_GROUP
Multicast group address for sonar data streams.
Definition types.hpp:19
constexpr std::uint16_t MULTICAST_PORT
Multicast port for sonar data streams.
Definition types.hpp:21
constexpr std::size_t MAX_DATAGRAM_SIZE
Largest UDP payload the sonar can send; receive buffers are sized to it.
Definition types.hpp:23
constexpr const char * DEFAULT_IP
Factory default IP address of the sonar.
Definition types.hpp:17
Device identity from GET /about.
Definition types.hpp:26
std::string version
Full build string.
Definition types.hpp:33
std::string variant
Definition types.hpp:32
std::string product_name
Definition types.hpp:31
std::string chipid
Definition types.hpp:27
std::string version_short
e.g. "1.8.0".
Definition types.hpp:34
int product_id
Definition types.hpp:30
bool is_ready
Definition types.hpp:29
int hardware_revision
Definition types.hpp:28
Outcome of a forced NTP sync.
Definition types.hpp:88
std::string message
Definition types.hpp:90
bool success
Definition types.hpp:89
TimeStatus status
Device clock state after the attempt.
Definition types.hpp:91
Imaging range limits in meters.
Definition types.hpp:64
double max
Definition types.hpp:66
double min
Definition types.hpp:65
One subsystem's health from GET /status.
Definition types.hpp:38
std::string status
"ok", "warning", or "error".
Definition types.hpp:41
std::string message
Definition types.hpp:40
std::string id
Definition types.hpp:39
bool operational
Definition types.hpp:42
Subsystem health from GET /status.
Definition types.hpp:48
StatusEntry temperature
Definition types.hpp:50
std::optional< StatusEntry > time
Present from firmware 1.7.1.
Definition types.hpp:53
StatusEntry systems_check
Definition types.hpp:51
StatusEntry api
Definition types.hpp:49
Device clock state from GET /time/status.
Definition types.hpp:80
std::optional< std::int64_t > ntp_seconds_since_last_sync
Definition types.hpp:84
std::chrono::system_clock::time_point system_time
Definition types.hpp:81
std::string ntp_synced_to
Definition types.hpp:83
bool ntp_synced
Definition types.hpp:82
How the sonar streams data, from GET/POST /udp.
Definition types.hpp:70
std::string unicast_destination_ip
Used only when mode is UNICAST.
Definition types.hpp:74
std::uint16_t unicast_destination_port
Used only when mode is UNICAST.
Definition types.hpp:76
Mode
Definition types.hpp:71
Mode mode
Definition types.hpp:72