mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-02 03:49:12 +08:00
mavlink: keep trying to find to broadcast
This should help the Snapdragon to connect if the network is not yet up by the time the mainapp starts. It will retry to find a network and broadcast once it finds one.
This commit is contained in:
@@ -885,8 +885,14 @@ Mavlink::send_message(const uint8_t msgid, const void *msg, uint8_t component_ID
|
|||||||
if ((_mode != MAVLINK_MODE_ONBOARD) &&
|
if ((_mode != MAVLINK_MODE_ONBOARD) &&
|
||||||
(!get_client_source_initialized()
|
(!get_client_source_initialized()
|
||||||
|| (hrt_elapsed_time(&tstatus.heartbeat_time) > 3 * 1000 * 1000))
|
|| (hrt_elapsed_time(&tstatus.heartbeat_time) > 3 * 1000 * 1000))
|
||||||
&& (msgid == MAVLINK_MSG_ID_HEARTBEAT)
|
&& (msgid == MAVLINK_MSG_ID_HEARTBEAT)) {
|
||||||
&& _broadcast_address_found) {
|
|
||||||
|
if (!_broadcast_address_found) {
|
||||||
|
// Try to initialize UDP and broadcast address again.
|
||||||
|
init_udp();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_broadcast_address_found) {
|
||||||
|
|
||||||
int bret = sendto(_socket_fd, buf, packet_len, 0, (struct sockaddr *)&_bcast_addr, sizeof(_bcast_addr));
|
int bret = sendto(_socket_fd, buf, packet_len, 0, (struct sockaddr *)&_bcast_addr, sizeof(_bcast_addr));
|
||||||
|
|
||||||
@@ -894,6 +900,7 @@ Mavlink::send_message(const uint8_t msgid, const void *msg, uint8_t component_ID
|
|||||||
PX4_WARN("sending broadcast failed, errno: %d: %s", errno, strerror(errno));
|
PX4_WARN("sending broadcast failed, errno: %d: %s", errno, strerror(errno));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else if (get_protocol() == TCP) {
|
} else if (get_protocol() == TCP) {
|
||||||
/* not implemented, but possible to do so */
|
/* not implemented, but possible to do so */
|
||||||
|
|||||||
Reference in New Issue
Block a user