diff --git a/libraries/AP_Networking/AP_Networking.cpp b/libraries/AP_Networking/AP_Networking.cpp index 6e0161bfe258e..1e3e1b47a0748 100644 --- a/libraries/AP_Networking/AP_Networking.cpp +++ b/libraries/AP_Networking/AP_Networking.cpp @@ -64,6 +64,10 @@ const AP_Param::GroupInfo AP_Networking::var_info[] = { // @RebootRequired: True // @User: Advanced AP_GROUPINFO("TESTS", 7, AP_Networking, param.tests, 0), + + // @Group: TEST_IP + // @Path: AP_Networking_address.cpp + AP_SUBGROUPINFO(param.test_ipaddr, "TEST_IP", 8, AP_Networking, AP_Networking_IPV4), #endif AP_GROUPEND diff --git a/libraries/AP_Networking/AP_Networking.h b/libraries/AP_Networking/AP_Networking.h index 10a120a4c9419..d7e9bee1d5950 100644 --- a/libraries/AP_Networking/AP_Networking.h +++ b/libraries/AP_Networking/AP_Networking.h @@ -167,6 +167,7 @@ class AP_Networking AP_Int32 options; #if AP_NETWORKING_TESTS_ENABLED AP_Int32 tests; + AP_Networking_IPV4 test_ipaddr{AP_NETWORKING_TEST_IP}; #endif } param; diff --git a/libraries/AP_Networking/AP_Networking_Config.h b/libraries/AP_Networking/AP_Networking_Config.h index 992c44ab4b685..16d105b230e5b 100644 --- a/libraries/AP_Networking/AP_Networking_Config.h +++ b/libraries/AP_Networking/AP_Networking_Config.h @@ -67,6 +67,6 @@ #if AP_NETWORKING_TESTS_ENABLED #ifndef AP_NETWORKING_TEST_IP -#define AP_NETWORKING_TEST_IP "192.168.13.15" +#define AP_NETWORKING_TEST_IP "192.168.13.2" #endif #endif diff --git a/libraries/AP_Networking/AP_Networking_SITL.h b/libraries/AP_Networking/AP_Networking_SITL.h new file mode 100644 index 0000000000000..915e43f5f7341 --- /dev/null +++ b/libraries/AP_Networking/AP_Networking_SITL.h @@ -0,0 +1,22 @@ +#pragma once + +#include "AP_Networking_Config.h" + +#if AP_NETWORKING_BACKEND_SITL +#include "AP_Networking_Backend.h" + +class AP_Networking_SITL : public AP_Networking_Backend +{ +public: + using AP_Networking_Backend::AP_Networking_Backend; + + /* Do not allow copies */ + CLASS_NO_COPY(AP_Networking_SITL); + + bool init() override { + return true; + } + void update() override {} +}; + +#endif // AP_NETWORKING_BACKEND_SITL diff --git a/libraries/AP_Networking/AP_Networking_tests.cpp b/libraries/AP_Networking/AP_Networking_tests.cpp index 29372b2bd949a..b4b335f872762 100644 --- a/libraries/AP_Networking/AP_Networking_tests.cpp +++ b/libraries/AP_Networking/AP_Networking_tests.cpp @@ -40,7 +40,7 @@ void AP_Networking::test_UDP_client(void) } hal.scheduler->delay(1000); GCS_SEND_TEXT(MAV_SEVERITY_INFO, "UDP_client: starting"); - const char *dest = AP_NETWORKING_TEST_IP; + const char *dest = param.test_ipaddr.get_str(); auto *sock = new SocketAPM(true); if (sock == nullptr) { GCS_SEND_TEXT(MAV_SEVERITY_ERROR, "UDP_client: failed to create socket"); @@ -75,7 +75,7 @@ void AP_Networking::test_TCP_client(void) } hal.scheduler->delay(1000); GCS_SEND_TEXT(MAV_SEVERITY_INFO, "TCP_client: starting"); - const char *dest = AP_NETWORKING_TEST_IP; + const char *dest = param.test_ipaddr.get_str(); auto *sock = new SocketAPM(false); if (sock == nullptr) { GCS_SEND_TEXT(MAV_SEVERITY_ERROR, "TCP_client: failed to create socket");