Skip to content

Commit

Permalink
AP_Networking: Allow Broadcast
Browse files Browse the repository at this point in the history
  • Loading branch information
magicrub committed Nov 22, 2023
1 parent adc0ebf commit cf45761
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions libraries/AP_Networking/AP_Networking_Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions libraries/AP_Networking/AP_Networking_port.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down

0 comments on commit cf45761

Please sign in to comment.