Fix reporting on broadcast address

This commit is contained in:
Lorenz Meier
2016-04-02 00:04:26 +02:00
parent f4f1f5f027
commit e832f7dbf5
2 changed files with 7 additions and 1 deletions

View File

@@ -178,6 +178,8 @@ Mavlink::Mavlink() :
_myaddr{},
_src_addr{},
_bcast_addr{},
_src_addr_initialized(false),
_broadcast_reported(false),
#endif
_socket_fd(-1),
_protocol(SERIAL),
@@ -888,7 +890,10 @@ Mavlink::send_message(const uint8_t msgid, const void *msg, uint8_t component_ID
int bret = sendto(_socket_fd, buf, packet_len, 0, (struct sockaddr *)&_bcast_addr, sizeof(_bcast_addr));
if (bret <= 0) {
PX4_WARN("sending broadcast failed, errno: %d: %s", errno, strerror(errno));
if (!_broadcast_reported) {
PX4_WARN("sending broadcast failed, errno: %d: %s", errno, strerror(errno));
_broadcast_reported = true;
}
}
}

View File

@@ -435,6 +435,7 @@ private:
struct sockaddr_in _src_addr;
struct sockaddr_in _bcast_addr;
bool _src_addr_initialized;
bool _broadcast_reported;
#endif
int _socket_fd;