Skip to content

Commit

Permalink
AP_DDS: Add user-selectable UDP IP
Browse files Browse the repository at this point in the history
  • Loading branch information
magicrub committed Nov 13, 2023
1 parent c928d8d commit c4580bc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
4 changes: 4 additions & 0 deletions libraries/AP_DDS/AP_DDS_Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ const AP_Param::GroupInfo AP_DDS_Client::var_info[] {
// @User: Standard
AP_GROUPINFO("_PORT", 2, AP_DDS_Client, udp.port, 2019),

// @Group: _IP
// @Path: ../AP_Networking/AP_Networking_address.cpp
AP_SUBGROUPINFO(udp.ip, "_IP", 3, AP_DDS_Client, AP_Networking_IPV4),

#endif

AP_GROUPEND
Expand Down
3 changes: 2 additions & 1 deletion libraries/AP_DDS/AP_DDS_Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

#if AP_DDS_UDP_ENABLED
#include <AP_HAL/utility/Socket.h>
#include <AP_Networking/AP_Networking_address.h>
#endif

extern const AP_HAL::HAL& hal;
Expand Down Expand Up @@ -138,7 +139,7 @@ class AP_DDS_Client
struct {
AP_Int32 port;
// UDP endpoint
const char* ip = "127.0.0.1";
AP_Networking_IPV4 ip{AP_DDS_DEFAULT_UDP_IP_ADDR};
// UDP Allocation
uxrCustomTransport transport;
SocketAPM *socket;
Expand Down
2 changes: 1 addition & 1 deletion libraries/AP_DDS/AP_DDS_UDP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ bool AP_DDS_Client::udp_transport_open(uxrCustomTransport *t)
if (sock == nullptr) {
return false;
}
if (!sock->connect(dds->udp.ip, dds->udp.port.get())) {
if (!sock->connect(dds->udp.ip.get_str(), dds->udp.port.get())) {
return false;
}
dds->udp.socket = sock;
Expand Down
10 changes: 9 additions & 1 deletion libraries/AP_DDS/AP_DDS_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,18 @@

// UDP only on SITL for now
#ifndef AP_DDS_UDP_ENABLED
#define AP_DDS_UDP_ENABLED AP_DDS_ENABLED && AP_NETWORKING_SOCKETS_ENABLED
#define AP_DDS_UDP_ENABLED AP_DDS_ENABLED && AP_NETWORKING_ENABLED
#endif

#include <AP_VisualOdom/AP_VisualOdom_config.h>
#ifndef AP_DDS_VISUALODOM_ENABLED
#define AP_DDS_VISUALODOM_ENABLED HAL_VISUALODOM_ENABLED && AP_DDS_ENABLED
#endif

#ifndef AP_DDS_DEFAULT_UDP_IP_ADDR
#if CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS
#define AP_DDS_DEFAULT_UDP_IP_ADDR "192.168.13.2"
#else
#define AP_DDS_DEFAULT_UDP_IP_ADDR "127.0.0.1"
#endif
#endif

0 comments on commit c4580bc

Please sign in to comment.