diff --git a/libraries/SITL/SIM_ADSB.cpp b/libraries/SITL/SIM_ADSB.cpp index 256a171921..9e4317251a 100644 --- a/libraries/SITL/SIM_ADSB.cpp +++ b/libraries/SITL/SIM_ADSB.cpp @@ -117,8 +117,8 @@ void ADSB::send_report(void) // threading issue with non-blocking sockets and the initial wait on uartA return; } - if (!mavlink.connected && mav_socket.connect(target_address, target_port)) { - ::printf("ADSB connected to %s:%u\n", target_address, (unsigned)target_port); + if (!mavlink.connected && mav_socket.connect(target_address, target_port_base + 10 * instance)) { + ::printf("ADSB connected to %s:%u\n", target_address, (unsigned)target_port_base + 10 * instance); mavlink.connected = true; } if (!mavlink.connected) { diff --git a/libraries/SITL/SIM_ADSB.h b/libraries/SITL/SIM_ADSB.h index 4a8156fdc1..c7ee15b270 100644 --- a/libraries/SITL/SIM_ADSB.h +++ b/libraries/SITL/SIM_ADSB.h @@ -51,12 +51,14 @@ private: class ADSB { public: - ADSB(const struct sitl_fdm &_fdm, const Location& _home) : home(_home) {}; + ADSB(const struct sitl_fdm &_fdm, const Location& _home, const uint8_t _instance) : home(_home), instance(_instance) {}; void update(void); private: const char *target_address = "127.0.0.1"; - const uint16_t target_port = 5762; + const uint16_t target_port_base = 5762; + + const uint8_t instance = 0; const Location& home; uint8_t num_vehicles = 0;