waterlinkedsonar
C++ client library for the Water Linked Sonar 3D-15
Loading...
Searching...
No Matches
client.hpp
Go to the documentation of this file.
1
3
4#ifndef WATERLINKEDSONAR_HTTP_CLIENT_HPP
5#define WATERLINKEDSONAR_HTTP_CLIENT_HPP
6
7#include <chrono>
8#include <cstdint>
9#include <memory>
10#include <string>
13
14namespace waterlinked::sonar {
15
17inline constexpr const char* DEFAULT_IP = "192.168.194.96";
18
19namespace detail {
20class HttpTransport;
21} // namespace detail
22
32 public:
42 explicit SonarClient(
43 const std::string& host, std::uint16_t port = 80,
44 std::chrono::milliseconds timeout = std::chrono::seconds(5));
45
50 SonarClient(SonarClient&& other) noexcept;
52 SonarClient& operator=(SonarClient&& other) noexcept;
53 SonarClient(const SonarClient&) = delete;
54 SonarClient& operator=(const SonarClient&) = delete;
55
57 [[nodiscard]] const std::string& firmware_version() const noexcept {
58 return firmware_version_;
59 }
60
63
66
68 double temperature();
69
72
74 void set_acoustics_enabled(bool enabled);
75
78
81
85
88 void set_speed_of_sound(double speed);
89
92
95
98
101
104
106 void set_udp_config(const UdpConfig& config);
107
110
112 void set_imu_batch_enabled(bool enabled);
113
116
121 void set_time_manual(std::chrono::system_clock::time_point time);
122
124 std::string ntp_address();
125
127 void set_ntp_address(const std::string& address);
128
135 ForceSyncResult force_sync_ntp(std::chrono::duration<double> timeout);
136
137 private:
138 void require_firmware(const char* operation, const char* min_version) const;
139
140 std::unique_ptr<detail::HttpTransport> transport_;
141 std::string firmware_version_;
142};
143
144} // namespace waterlinked::sonar
145
146#endif // WATERLINKEDSONAR_HTTP_CLIENT_HPP
Blocking client for the integration API (https://docs.waterlinked.com/sonar-3d/sonar-3d-15-api/).
Definition client.hpp:31
ForceSyncResult force_sync_ntp(std::chrono::duration< double > timeout)
Makes the device sync its clock with the NTP server and waits for the outcome.
void set_imu_batch_enabled(bool enabled)
Turns IMU batch output on or off. Requires firmware 1.8.0.
void set_mode(AcousticsMode mode)
Sets the imaging mode. Requires firmware 1.7.0.
Status status()
Subsystem health. Requires firmware 1.7.0.
Range range()
Imaging range limits.
SonarClient(SonarClient &&other) noexcept
Takes over the connection of other, which may only be destroyed or assigned to afterwards.
UdpConfig udp_config()
Destination of the UDP stream.
void set_ntp_address(const std::string &address)
Sets the NTP server address, or "auto". Requires firmware 1.7.1.
TimeStatus time_status()
State of the device clock. Requires firmware 1.7.1.
void set_salinity(Salinity salinity)
Sets the water salinity. Requires firmware 1.7.0.
double temperature()
Water temperature at the sonar in degrees Celsius.
std::string ntp_address()
NTP server address, or "auto". Requires firmware 1.7.1.
void set_time_manual(std::chrono::system_clock::time_point time)
Sets the device clock, rounded down to microseconds.
~SonarClient()
Closes the connection.
SonarClient(const std::string &host, std::uint16_t port=80, std::chrono::milliseconds timeout=std::chrono::seconds(5))
Connects to the sonar and reads its firmware version.
void set_udp_config(const UdpConfig &config)
Sets the destination of the UDP stream.
void set_speed_of_sound(double speed)
Sets the speed of sound in m/s; 0 derives it from salinity and temperature.
About about()
Device identity.
SonarClient & operator=(SonarClient &&other) noexcept
Same as the move constructor.
AcousticsMode mode()
Imaging mode. Requires firmware 1.7.0.
void set_acoustics_enabled(bool enabled)
Turns acoustic imaging on or off.
void set_range(Range range)
Sets the imaging range limits.
const std::string & firmware_version() const noexcept
Firmware release read at construction, e.g. "1.8.0".
Definition client.hpp:57
bool acoustics_enabled()
Whether acoustic imaging is on.
Salinity salinity()
Water salinity. Requires firmware 1.7.0.
double speed_of_sound()
Speed of sound in m/s; 0 means the sonar derives it from salinity and temperature.
bool imu_batch_enabled()
Whether IMU batches are sent. Requires firmware 1.8.0.
constexpr const char * DEFAULT_IP
Factory default IP address of the sonar.
Definition client.hpp:17
Exceptions thrown by SonarClient.
Device identity.
Definition types.hpp:15
Outcome of a forced NTP sync.
Definition types.hpp:84
Imaging range limits in meters.
Definition types.hpp:55
Health of the device subsystems.
Definition types.hpp:35
State of the device clock.
Definition types.hpp:75
Destination of the sonar's UDP stream.
Definition types.hpp:61
Data types of the Sonar 3D-15 HTTP API.
AcousticsMode
Imaging mode, which sets the field of view and the image rate.
Definition types.hpp:43
Salinity
Water salinity used by the automatic speed of sound.
Definition types.hpp:49