From 8e69592b516c5876bb205d276a512b09b28fd3a6 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Wed, 16 May 2018 15:45:53 -0400 Subject: [PATCH 1/4] core: add_any_connection has no default anymore --- core/dronecore.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/core/dronecore.h b/core/dronecore.h index 08b15f257f..8924cf3db2 100644 --- a/core/dronecore.h +++ b/core/dronecore.h @@ -50,9 +50,6 @@ class DroneCore * - TCP - tcp://[Remote_host][:Remote_port] * - Serial - serial://Dev_Node[:Baudrate] * - * Default URL : udp://0.0.0.0:14540. - * - Default Bind host IP is any local interface (0.0.0.0) - * * @param connection_url connection URL string. * @return The result of adding the connection. */ From d098c505b6381f618ce8a43217781cacf5637f83 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Wed, 16 May 2018 15:53:41 -0400 Subject: [PATCH 2/4] core: remove duplicated defaults --- core/serial_connection.cpp | 10 +--------- core/serial_connection.h | 6 ++---- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/core/serial_connection.cpp b/core/serial_connection.cpp index e557903bfc..5d0a92e910 100644 --- a/core/serial_connection.cpp +++ b/core/serial_connection.cpp @@ -53,15 +53,7 @@ namespace dronecore { SerialConnection::SerialConnection(DroneCoreImpl &parent, const std::string &path, int baudrate): Connection(parent), _serial_node(path), - _baudrate(baudrate) -{ - if (baudrate == 0) { - _baudrate = DEFAULT_SERIAL_BAUDRATE; - } - if (path == "") { - _serial_node = DEFAULT_SERIAL_DEV_PATH; - } -} + _baudrate(baudrate) {} SerialConnection::~SerialConnection() { diff --git a/core/serial_connection.h b/core/serial_connection.h index b8a86acb48..64f0560bf8 100644 --- a/core/serial_connection.h +++ b/core/serial_connection.h @@ -32,10 +32,8 @@ class SerialConnection : public Connection void start_recv_thread(); static void receive(SerialConnection *parent); - static constexpr int DEFAULT_SERIAL_BAUDRATE = 9600; - static constexpr auto DEFAULT_SERIAL_DEV_PATH = "/dev/ttyS0"; - std::string _serial_node = {}; - int _baudrate = DEFAULT_SERIAL_BAUDRATE; + std::string _serial_node; + int _baudrate; std::mutex _mutex = {}; #if !defined(WINDOWS) From 54e35ea53b1bdaccc3389ca142983f4c3d6bfae8 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Wed, 16 May 2018 16:17:02 -0400 Subject: [PATCH 3/4] core: add comments for constexprs --- core/dronecore.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/dronecore.h b/core/dronecore.h index 8924cf3db2..f3adb15f89 100644 --- a/core/dronecore.h +++ b/core/dronecore.h @@ -23,10 +23,15 @@ class System; class DroneCore { public: + /** @brief Default UDP bind IP (accepts any incoming connections). */ static constexpr auto DEFAULT_UDP_BIND_IP = "0.0.0.0"; + /** @brief Default UDP bind port (same port as used by MAVROS). */ static constexpr int DEFAULT_UDP_PORT = 14540; + /** @brief Default TCP remote IP (localhost). */ static constexpr auto DEFAULT_TCP_REMOTE_IP = "127.0.0.1"; + /**< @brief Default TCP remote port. */ static constexpr int DEFAULT_TCP_REMOTE_PORT = 5760; + /**< @brief Default serial baudrate. */ static constexpr int DEFAULT_SERIAL_BAUDRATE = 57600; /** From 043c5897c4afdad5ebceb9d5105ce39dd363efa7 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Wed, 16 May 2018 16:18:36 -0400 Subject: [PATCH 4/4] core: remove default for IP for TCP connection We need to remove the default for the TCP connection because this will lead to ambiguous function calls if add_tcp_connection() without any arguments is called which could then be either of the two overloaded methods. When using add_tcp_connection with two arguments, the IP needs to be specified, otherwise one could use add_tcp_connection with one argument. --- core/dronecore.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/dronecore.h b/core/dronecore.h index f3adb15f89..85f67abb53 100644 --- a/core/dronecore.h +++ b/core/dronecore.h @@ -94,11 +94,11 @@ class DroneCore /** * @brief Adds a TCP connection with a specific IP address and port number. * - * @param remote_ip Remote IP address to connect to (defaults to 127.0.0.1). + * @param remote_ip Remote IP address to connect to. * @param remote_port The TCP port to connect to (defaults to 5760). * @return The result of adding the connection. */ - ConnectionResult add_tcp_connection(const std::string &remote_ip = DEFAULT_TCP_REMOTE_IP, + ConnectionResult add_tcp_connection(const std::string &remote_ip, int remote_port = DEFAULT_TCP_REMOTE_PORT); /**