Skip to content

Commit

Permalink
Merge pull request mavlink#514 from Dronecode/fix-discovery
Browse files Browse the repository at this point in the history
core: disable fallback to system ID for now
  • Loading branch information
JonasVautherin authored Aug 30, 2018
2 parents 0430397 + c3eb7bb commit 921b81f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions core/system_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ void SystemImpl::request_autopilot_version()
return;
}

#if defined(ENABLE_FALLBACK_TO_SYSTEM_ID)
if (!_autopilot_version_pending && _uuid_retries >= 3) {
// We give up getting a UUID and use the system ID.

Expand All @@ -433,6 +434,7 @@ void SystemImpl::request_autopilot_version()
set_connected();
return;
}
#endif

_autopilot_version_pending = true;

Expand All @@ -444,7 +446,9 @@ void SystemImpl::request_autopilot_version()
command.target_component_id = get_autopilot_id();

send_command_async(command, nullptr);
#if defined(ENABLE_FALLBACK_TO_SYSTEM_ID)
++_uuid_retries;
#endif

// We set a timeout to stay "pending" for half a second. This way, we don't give up too
// early e.g. because multiple components send heartbeats and we receive them all at once
Expand Down
5 changes: 5 additions & 0 deletions core/system_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
#include <mutex>
#include <future>

// TODO: Figure out what to do with systems without UUID.
//#define ENABLE_FALLBACK_TO_SYSTEM_ID

namespace dronecode_sdk {

class DronecodeSDKImpl;
Expand Down Expand Up @@ -225,7 +228,9 @@ class SystemImpl {

uint64_t _uuid{0};

#if defined(ENABLE_FALLBACK_TO_SYSTEM_ID)
int _uuid_retries = 0;
#endif
std::atomic<bool> _uuid_initialized{false};

uint8_t _non_autopilot_heartbeats = 0;
Expand Down

0 comments on commit 921b81f

Please sign in to comment.