diff --git a/libraries/AP_Networking/AP_Networking_Config.h b/libraries/AP_Networking/AP_Networking_Config.h index bfc4af537f226d..33fb5055358b6b 100644 --- a/libraries/AP_Networking/AP_Networking_Config.h +++ b/libraries/AP_Networking/AP_Networking_Config.h @@ -31,6 +31,9 @@ #define AP_NETWORKING_DHCP_AVAILABLE 1 // for non-ChibiOS, assume it's available #endif +#ifndef AP_NETWORKING_SOCKETS_BROADCAST_ALLOWED +#define AP_NETWORKING_SOCKETS_BROADCAST_ALLOWED 0 +#endif // --------------------------- // Below are default params diff --git a/libraries/AP_Networking/AP_Networking_port.cpp b/libraries/AP_Networking/AP_Networking_port.cpp index f9f7248dba6656..92df2addfbd8f1 100644 --- a/libraries/AP_Networking/AP_Networking_port.cpp +++ b/libraries/AP_Networking/AP_Networking_port.cpp @@ -93,6 +93,13 @@ void AP_Networking::Port::udp_client_init(const uint32_t size_rx, const uint32_t if (sock == nullptr) { return; } + +#if AP_NETWORKING_SOCKETS_BROADCAST_ALLOWED + // TODO: add support for broadcast that is more + // secure (example: lock onto first person you hear back from) + sock->set_broadcast(); +#endif + if (!hal.scheduler->thread_create(FUNCTOR_BIND_MEMBER(&AP_Networking::Port::udp_client_loop, void), "NET", 2048, AP_HAL::Scheduler::PRIORITY_UART, 0)) { AP_BoardConfig::allocation_error("Failed to allocate UDP client thread"); }