Skip to content

Commit

Permalink
core: disable fallback to system ID for now
Browse files Browse the repository at this point in the history
The fallback to system ID causes problems on systems with multiple
components that might answer but do not actually mean that a vehicle is
connected. For instance the remote controller might also send heartbeats
and trigger a discovery event when really the drone is not discovered
(yet).

In the future we might add an option for UUID vs. system ID but for now
this should resolve the issues described.
  • Loading branch information
julianoes committed Aug 29, 2018
1 parent e17c3be commit 50beb8d
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 50beb8d

Please sign in to comment.