-
-
Notifications
You must be signed in to change notification settings - Fork 520
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
444 additions
and
256 deletions.
There are no files selected for viewing
Submodule proto
updated
8 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#pragma once | ||
|
||
namespace mavsdk { | ||
|
||
class ServerComponentImpl; | ||
|
||
/** | ||
* TODO: add comments | ||
*/ | ||
class ServerComponent { | ||
public: | ||
private: | ||
std::shared_ptr<ServerComponentImpl> server_component_impl() { return _server_component_impl; }; | ||
|
||
std::shared_ptr<ServerComponentImpl> _server_component_impl; | ||
|
||
friend ServerPluginImplBase; | ||
}; | ||
|
||
} // namespace mavsdk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#pragma once | ||
#include "server_component_impl.h" | ||
#include <memory> | ||
|
||
namespace mavsdk { | ||
|
||
class ServerComponent; | ||
class ServerComponentImpl; | ||
|
||
class ServerPluginBase { | ||
public: | ||
/** | ||
* @brief Default Constructor. | ||
*/ | ||
ServerPluginBase() = default; | ||
|
||
/** | ||
* @brief Default Destructor. | ||
*/ | ||
virtual ~ServerPluginBase() = default; | ||
|
||
/** | ||
* @brief Copy constructor (object is not copyable). | ||
*/ | ||
ServerPluginBase(const ServerPluginBase&) = delete; | ||
|
||
/** | ||
* @brief Assign operator (object is not copyable). | ||
*/ | ||
const ServerPluginBase& operator=(const ServerPluginBase&) = delete; | ||
}; | ||
|
||
} // namespace mavsdk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
#include "server_component_impl.h" | ||
#include "mavsdk_impl.h" | ||
|
||
namespace mavsdk { | ||
|
||
ServerComponentImpl::ServerComponentImpl(MavsdkImpl& mavsdk_impl) : | ||
_mavsdk_impl(mavsdk_impl), | ||
_mavlink_command_receiver(mavsdk_impl) | ||
{ | ||
|
||
} | ||
|
||
ServerComponentImpl::~ServerComponentImpl() | ||
{ | ||
} | ||
|
||
void ServerComponentImpl::register_mavlink_command_handler( | ||
uint16_t cmd_id, | ||
const MavlinkCommandReceiver::MavlinkCommandIntHandler& callback, | ||
const void* cookie) | ||
{ | ||
_mavlink_command_receiver.register_mavlink_command_handler(cmd_id, callback, cookie); | ||
} | ||
|
||
void ServerComponentImpl::register_mavlink_command_handler( | ||
uint16_t cmd_id, | ||
const MavlinkCommandReceiver::MavlinkCommandLongHandler& callback, | ||
const void* cookie) | ||
{ | ||
_mavlink_command_receiver.register_mavlink_command_handler(cmd_id, callback, cookie); | ||
} | ||
|
||
void ServerComponentImpl::unregister_mavlink_command_handler(uint16_t cmd_id, const void* cookie) | ||
{ | ||
_mavlink_command_receiver.unregister_mavlink_command_handler(cmd_id, cookie); | ||
} | ||
|
||
void ServerComponentImpl::unregister_all_mavlink_command_handlers(const void* cookie) | ||
{ | ||
_mavlink_command_receiver.unregister_all_mavlink_command_handlers(cookie); | ||
} | ||
|
||
uint8_t ServerComponentImpl::get_own_system_id() const | ||
{ | ||
return _mavsdk_impl.get_own_system_id(); | ||
} | ||
|
||
void ServerComponentImpl::set_own_component_id(uint8_t own_component_id) | ||
{ | ||
_own_component_id = own_component_id; | ||
} | ||
uint8_t ServerComponentImpl::get_own_component_id() const | ||
{ | ||
return _own_component_id; | ||
} | ||
|
||
Time& ServerComponentImpl::get_time() | ||
{ | ||
return _mavsdk_impl.time; | ||
} | ||
|
||
bool ServerComponentImpl::send_message(mavlink_message_t& message) | ||
{ | ||
return _mavsdk_impl.send_message(message); | ||
} | ||
|
||
void ServerComponentImpl::add_call_every(std::function<void()> callback, float interval_s, void** cookie) | ||
{ | ||
_mavsdk_impl.call_every_handler.add(std::move(callback), static_cast<double>(interval_s), cookie); | ||
} | ||
|
||
void ServerComponentImpl::change_call_every(float interval_s, const void* cookie) | ||
{ | ||
_mavsdk_impl.call_every_handler.change(static_cast<double>(interval_s), cookie); | ||
} | ||
|
||
void ServerComponentImpl::reset_call_every(const void* cookie) | ||
{ | ||
_mavsdk_impl.call_every_handler.reset(cookie); | ||
} | ||
|
||
void ServerComponentImpl::remove_call_every(const void* cookie) | ||
{ | ||
_mavsdk_impl.call_every_handler.remove(cookie); | ||
} | ||
|
||
mavlink_message_t ServerComponentImpl::make_command_ack_message( | ||
const MavlinkCommandReceiver::CommandLong& command, MAV_RESULT result) | ||
{ | ||
const uint8_t progress = std::numeric_limits<uint8_t>::max(); | ||
const uint8_t result_param2 = 0; | ||
|
||
mavlink_message_t msg{}; | ||
mavlink_msg_command_ack_pack( | ||
get_own_system_id(), | ||
get_own_component_id(), | ||
&msg, | ||
command.command, | ||
result, | ||
progress, | ||
result_param2, | ||
command.origin_system_id, | ||
command.origin_component_id); | ||
return msg; | ||
} | ||
|
||
} // namespace mavsdk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#pragma once | ||
|
||
#include <cstdint> | ||
#include "mavlink_include.h" | ||
#include "mavlink_command_receiver.h" | ||
#include "mavsdk_time.h" | ||
|
||
namespace mavsdk { | ||
|
||
class MavsdkImpl; | ||
|
||
class ServerComponentImpl { | ||
public: | ||
explicit ServerComponentImpl(MavsdkImpl& parent); | ||
~ServerComponentImpl(); | ||
|
||
void register_mavlink_command_handler( | ||
uint16_t cmd_id, | ||
const MavlinkCommandReceiver::MavlinkCommandIntHandler& callback, | ||
const void* cookie); | ||
void register_mavlink_command_handler( | ||
uint16_t cmd_id, | ||
const MavlinkCommandReceiver::MavlinkCommandLongHandler& callback, | ||
const void* cookie); | ||
void unregister_mavlink_command_handler(uint16_t cmd_id, const void* cookie); | ||
void unregister_all_mavlink_command_handlers(const void* cookie); | ||
|
||
uint8_t get_own_system_id() const; | ||
|
||
void set_own_component_id(uint8_t own_component_id); | ||
uint8_t get_own_component_id() const; | ||
|
||
Time& get_time(); | ||
|
||
bool send_message(mavlink_message_t& message); | ||
|
||
void add_call_every(std::function<void()> callback, float interval_s, void** cookie); | ||
void change_call_every(float interval_s, const void* cookie); | ||
void reset_call_every(const void* cookie); | ||
void remove_call_every(const void* cookie); | ||
|
||
mavlink_message_t | ||
make_command_ack_message(const MavlinkCommandReceiver::CommandLong& command, MAV_RESULT result); | ||
|
||
private: | ||
MavsdkImpl& _mavsdk_impl; | ||
MavlinkCommandReceiver _mavlink_command_receiver; | ||
uint8_t _own_component_id{MAV_COMP_ID_AUTOPILOT1}; | ||
}; | ||
|
||
} // namespace mavsdk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include "server_plugin_impl_base.h" | ||
#include "server_component.h" | ||
|
||
namespace mavsdk { | ||
|
||
ServerPluginImplBase::ServerPluginImplBase(std::shared_ptr<ServerComponent> server_component) : | ||
_server_component_impl(server_component->server_component_impl()) | ||
{} | ||
|
||
} // namespace mavsdk |
Oops, something went wrong.