Skip to content

Commit

Permalink
component_information_server: add file registry
Browse files Browse the repository at this point in the history
  • Loading branch information
julianoes committed Feb 18, 2022
1 parent 1dcc4db commit 4b76fb1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/mavsdk/core/mavlink_ftp.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ class MavlinkFtp {
uint8_t get_our_compid();
ClientResult set_target_compid(uint8_t component_id);

private:
void register_file(const std::string& path, const std::string& content);

private:
SystemImpl& _system_impl;

/// @brief Possible server results returned for requests.
Expand Down Expand Up @@ -265,8 +266,9 @@ class MavlinkFtp {
ServerResult _work_remove_file(PayloadHeader* payload);
ServerResult _work_rename(PayloadHeader* payload);
ServerResult _work_calc_file_CRC32(PayloadHeader* payload);
};

}

std::mutex _files_mutex{};
std::unordered_map<std::string, std::string> _files{};
};

} // namespace mavsdk
3 changes: 3 additions & 0 deletions src/mavsdk/core/system_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,9 @@ class SystemImpl : public Sender {
MAV_PROTOCOL_CAPABILITY_COMMAND_INT, 0, 0, 0, 0, 0, 0, {0}};

std::atomic<bool> _should_send_autopilot_version{false};

std::mutex _mavlink_ftp_files_mutex{};
std::unordered_map<std::string, std::string> _mavlink_ftp_files{};
};

} // namespace mavsdk
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ void ComponentInformationServerImpl::update_json_files_with_lock()
std::cout << "parameter: " << parameter_file << '\n';
std::cout << "meta: " << meta_file << '\n';

//_parent.register_mftp_file("general.json", meta_file);
//_parent.register_mftp_file("parameter.json", parameter_file);
_parent->mavlink_ftp().register_file("general.json", std::move(meta_file));
_parent->mavlink_ftp().register_file("parameter.json", std::move(parameter_file));
}

std::string ComponentInformationServerImpl::generate_parameter_file()
Expand Down

0 comments on commit 4b76fb1

Please sign in to comment.