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:
Julian Oes
2016-04-08 16:35:19 +02:00
committed by Lorenz Meier
parent 0ddf720759
commit 727783fe94
+9 -2
View File
@@ -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 */