From eb5ffede462b373b106d9b11ad1f4cbfb7617fc6 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Wed, 17 Apr 2024 13:53:05 +1200 Subject: [PATCH] info: add flight information subscription (#2285) That's better than having to call get once a second. Signed-off-by: Julian Oes --- proto | 2 +- src/integration_tests/info.cpp | 2 +- .../plugins/info/include/plugins/info/info.h | 20 + src/mavsdk/plugins/info/info.cpp | 11 + src/mavsdk/plugins/info/info_impl.cpp | 73 +-- src/mavsdk/plugins/info/info_impl.h | 11 +- src/mavsdk/plugins/info/mocks/info_mock.h | 4 + .../src/generated/info/info.grpc.pb.cc | 35 ++ .../src/generated/info/info.grpc.pb.h | 167 ++++++- .../src/generated/info/info.pb.cc | 415 ++++++++++++++--- .../src/generated/info/info.pb.h | 437 +++++++++++++++++- .../src/plugins/info/info_service_impl.h | 42 ++ 12 files changed, 1122 insertions(+), 97 deletions(-) diff --git a/proto b/proto index e3f50d4c23..debaacd172 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit e3f50d4c23a1a0a660e41e814e27f21933602048 +Subproject commit debaacd17271803520a264120165d19bf6d24c37 diff --git a/src/integration_tests/info.cpp b/src/integration_tests/info.cpp index 8960a298ed..5191b7f76e 100644 --- a/src/integration_tests/info.cpp +++ b/src/integration_tests/info.cpp @@ -74,7 +74,7 @@ TEST(SitlTest, PX4Info) if (flight_info_result.first == Info::Result::Success) { std::cout << flight_info_result.second << '\n'; } else { - LogWarn() << "Product request result: " << flight_info_result.first; + LogWarn() << "Flight info request result: " << flight_info_result.first; } std::this_thread::sleep_for(std::chrono::seconds(2)); diff --git a/src/mavsdk/plugins/info/include/plugins/info/info.h b/src/mavsdk/plugins/info/include/plugins/info/info.h index ca418ecac7..5d3dd00a5b 100644 --- a/src/mavsdk/plugins/info/include/plugins/info/info.h +++ b/src/mavsdk/plugins/info/include/plugins/info/info.h @@ -254,6 +254,26 @@ class Info : public PluginBase { */ std::pair get_speed_factor() const; + /** + * @brief Callback type for subscribe_flight_information. + */ + using FlightInformationCallback = std::function; + + /** + * @brief Handle type for subscribe_flight_information. + */ + using FlightInformationHandle = Handle; + + /** + * @brief Subscribe to 'flight information' updates. + */ + FlightInformationHandle subscribe_flight_information(const FlightInformationCallback& callback); + + /** + * @brief Unsubscribe from subscribe_flight_information + */ + void unsubscribe_flight_information(FlightInformationHandle handle); + /** * @brief Copy constructor. */ diff --git a/src/mavsdk/plugins/info/info.cpp b/src/mavsdk/plugins/info/info.cpp index db0da4a8a7..6e9734be1a 100644 --- a/src/mavsdk/plugins/info/info.cpp +++ b/src/mavsdk/plugins/info/info.cpp @@ -46,6 +46,17 @@ std::pair Info::get_speed_factor() const return _impl->get_speed_factor(); } +Info::FlightInformationHandle +Info::subscribe_flight_information(const FlightInformationCallback& callback) +{ + return _impl->subscribe_flight_information(callback); +} + +void Info::unsubscribe_flight_information(FlightInformationHandle handle) +{ + _impl->unsubscribe_flight_information(handle); +} + bool operator==(const Info::FlightInfo& lhs, const Info::FlightInfo& rhs) { return (rhs.time_boot_ms == lhs.time_boot_ms) && (rhs.flight_uid == lhs.flight_uid) && diff --git a/src/mavsdk/plugins/info/info_impl.cpp b/src/mavsdk/plugins/info/info_impl.cpp index cf19da1a60..44241d7cfe 100644 --- a/src/mavsdk/plugins/info/info_impl.cpp +++ b/src/mavsdk/plugins/info/info_impl.cpp @@ -1,11 +1,15 @@ -#include #include +#include +#include #include #include "info_impl.h" #include "system.h" +#include "callback_list.tpp" namespace mavsdk { +template class CallbackList; + InfoImpl::InfoImpl(System& system) : PluginImplBase(system) { _system_impl->register_plugin(this); @@ -50,8 +54,10 @@ void InfoImpl::enable() _system_impl->add_call_every( [this]() { _system_impl->send_autopilot_version_request(); }, 1.0f, &_call_every_cookie); - // We're hoping to get flight information regularly to update flight time. - _system_impl->set_msg_rate(MAVLINK_MSG_ID_FLIGHT_INFORMATION, 1.0); + if (!_flight_info_subscriptions.empty()) { + // We're hoping to get flight information regularly to update flight time. + _system_impl->set_msg_rate(MAVLINK_MSG_ID_FLIGHT_INFORMATION, 1.0); + } } void InfoImpl::disable() @@ -59,7 +65,6 @@ void InfoImpl::disable() _system_impl->remove_call_every(_call_every_cookie); std::lock_guard lock(_mutex); - _flight_information_received = false; _identification_received = false; } @@ -158,7 +163,8 @@ void InfoImpl::process_flight_information(const mavlink_message_t& message) _flight_info.duration_since_takeoff_ms = 0; } - _flight_information_received = true; + _flight_info_subscriptions.queue( + _flight_info, [this](const auto& func) { _system_impl->call_user_callback(func); }); } std::string InfoImpl::swap_and_translate_binary_to_str(uint8_t* binary, unsigned binary_len) @@ -220,15 +226,23 @@ std::pair InfoImpl::get_product() const _product); } -std::pair InfoImpl::get_flight_information() const +std::pair InfoImpl::get_flight_information() { - wait_for_information(); - std::lock_guard lock(_mutex); - - return std::make_pair<>( - (_flight_information_received ? Info::Result::Success : - Info::Result::InformationNotReceivedYet), - _flight_info); + std::promise> prom; + auto fut = prom.get_future(); + _system_impl->request_message().request( + MAVLINK_MSG_ID_FLIGHT_INFORMATION, + MAV_COMP_ID_AUTOPILOT1, + [&](MavlinkCommandSender::Result result, const mavlink_message_t& message) { + if (result == MavlinkCommandSender::Result::Success) { + // This call might happen twice but that's ok. + process_flight_information(message); + prom.set_value({Info::Result::Success, _flight_info}); + } else { + prom.set_value({Info::Result::InformationNotReceivedYet, Info::FlightInfo{}}); + } + }); + return fut.get(); } const std::string InfoImpl::vendor_id_str(uint16_t vendor_id) @@ -292,8 +306,8 @@ std::pair InfoImpl::get_speed_factor() const void InfoImpl::wait_for_identification() const { - // Wait 1.5 seconds max - for (unsigned i = 0; i < 150; ++i) { + // Wait 0.5 seconds max + for (unsigned i = 0; i < 50; ++i) { { std::lock_guard lock(_mutex); if (_identification_received) { @@ -304,18 +318,25 @@ void InfoImpl::wait_for_identification() const } } -void InfoImpl::wait_for_information() const +Info::FlightInformationHandle +InfoImpl::subscribe_flight_information(const Info::FlightInformationCallback& callback) { - // Wait 1.5 seconds max - for (unsigned i = 0; i < 150; ++i) { - { - std::lock_guard lock(_mutex); - if (_flight_information_received) { - break; - } - } - std::this_thread::sleep_for(std::chrono::milliseconds(10)); - } + std::lock_guard lock(_mutex); + + // Make sure we get the message regularly. + _system_impl->set_msg_rate(MAVLINK_MSG_ID_FLIGHT_INFORMATION, 1.0); + + return _flight_info_subscriptions.subscribe(callback); +} + +void InfoImpl::unsubscribe_flight_information(Info::FlightInformationHandle handle) +{ + std::lock_guard lock(_mutex); + + // Reset message to default + _system_impl->set_msg_rate(MAVLINK_MSG_ID_FLIGHT_INFORMATION, 0.0); + + _flight_info_subscriptions.unsubscribe(handle); } } // namespace mavsdk diff --git a/src/mavsdk/plugins/info/info_impl.h b/src/mavsdk/plugins/info/info_impl.h index 355ebab65a..da27cc9b37 100644 --- a/src/mavsdk/plugins/info/info_impl.h +++ b/src/mavsdk/plugins/info/info_impl.h @@ -6,6 +6,7 @@ #include "plugins/info/info.h" #include "plugin_impl_base.h" #include "ringbuffer.h" +#include "callback_list.h" namespace mavsdk { @@ -24,9 +25,13 @@ class InfoImpl : public PluginImplBase { std::pair get_identification() const; std::pair get_version() const; std::pair get_product() const; - std::pair get_flight_information() const; + std::pair get_flight_information(); std::pair get_speed_factor() const; + Info::FlightInformationHandle + subscribe_flight_information(const Info::FlightInformationCallback& callback); + void unsubscribe_flight_information(Info::FlightInformationHandle handle); + InfoImpl(const InfoImpl&) = delete; InfoImpl& operator=(const InfoImpl&) = delete; @@ -40,7 +45,6 @@ class InfoImpl : public PluginImplBase { get_flight_software_version_type(FIRMWARE_VERSION_TYPE); void wait_for_identification() const; - void wait_for_information() const; mutable std::mutex _mutex{}; @@ -50,7 +54,6 @@ class InfoImpl : public PluginImplBase { bool _identification_received{false}; Info::FlightInfo _flight_info{}; - bool _flight_information_received{false}; void* _call_every_cookie{nullptr}; @@ -71,6 +74,8 @@ class InfoImpl : public PluginImplBase { SteadyTimePoint _last_time_attitude_arrived{}; uint32_t _last_time_boot_ms{0}; + CallbackList _flight_info_subscriptions{}; + static const std::string vendor_id_str(uint16_t vendor_id); static const std::string product_id_str(uint16_t product_id); diff --git a/src/mavsdk/plugins/info/mocks/info_mock.h b/src/mavsdk/plugins/info/mocks/info_mock.h index 463103e55c..1df48b61b2 100644 --- a/src/mavsdk/plugins/info/mocks/info_mock.h +++ b/src/mavsdk/plugins/info/mocks/info_mock.h @@ -12,6 +12,10 @@ class MockInfo { MOCK_CONST_METHOD0(get_product, std::pair()){}; MOCK_CONST_METHOD0(get_version, std::pair()){}; MOCK_CONST_METHOD0(get_speed_factor, std::pair()){}; + MOCK_CONST_METHOD1( + subscribe_flight_information, + Info::FlightInformationHandle(Info::FlightInformationCallback)){}; + MOCK_CONST_METHOD1(unsubscribe_flight_information, void(Info::FlightInformationHandle)){}; }; } // namespace testing diff --git a/src/mavsdk_server/src/generated/info/info.grpc.pb.cc b/src/mavsdk_server/src/generated/info/info.grpc.pb.cc index 4337168665..7aec0a04ae 100644 --- a/src/mavsdk_server/src/generated/info/info.grpc.pb.cc +++ b/src/mavsdk_server/src/generated/info/info.grpc.pb.cc @@ -29,6 +29,7 @@ static const char* InfoService_method_names[] = { "/mavsdk.rpc.info.InfoService/GetProduct", "/mavsdk.rpc.info.InfoService/GetVersion", "/mavsdk.rpc.info.InfoService/GetSpeedFactor", + "/mavsdk.rpc.info.InfoService/SubscribeFlightInformation", }; std::unique_ptr< InfoService::Stub> InfoService::NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel, const ::grpc::StubOptions& options) { @@ -43,6 +44,7 @@ InfoService::Stub::Stub(const std::shared_ptr< ::grpc::ChannelInterface>& channe , rpcmethod_GetProduct_(InfoService_method_names[2], options.suffix_for_stats(),::grpc::internal::RpcMethod::NORMAL_RPC, channel) , rpcmethod_GetVersion_(InfoService_method_names[3], options.suffix_for_stats(),::grpc::internal::RpcMethod::NORMAL_RPC, channel) , rpcmethod_GetSpeedFactor_(InfoService_method_names[4], options.suffix_for_stats(),::grpc::internal::RpcMethod::NORMAL_RPC, channel) + , rpcmethod_SubscribeFlightInformation_(InfoService_method_names[5], options.suffix_for_stats(),::grpc::internal::RpcMethod::SERVER_STREAMING, channel) {} ::grpc::Status InfoService::Stub::GetFlightInformation(::grpc::ClientContext* context, const ::mavsdk::rpc::info::GetFlightInformationRequest& request, ::mavsdk::rpc::info::GetFlightInformationResponse* response) { @@ -160,6 +162,22 @@ ::grpc::ClientAsyncResponseReader< ::mavsdk::rpc::info::GetSpeedFactorResponse>* return result; } +::grpc::ClientReader< ::mavsdk::rpc::info::FlightInformationResponse>* InfoService::Stub::SubscribeFlightInformationRaw(::grpc::ClientContext* context, const ::mavsdk::rpc::info::SubscribeFlightInformationRequest& request) { + return ::grpc::internal::ClientReaderFactory< ::mavsdk::rpc::info::FlightInformationResponse>::Create(channel_.get(), rpcmethod_SubscribeFlightInformation_, context, request); +} + +void InfoService::Stub::async::SubscribeFlightInformation(::grpc::ClientContext* context, const ::mavsdk::rpc::info::SubscribeFlightInformationRequest* request, ::grpc::ClientReadReactor< ::mavsdk::rpc::info::FlightInformationResponse>* reactor) { + ::grpc::internal::ClientCallbackReaderFactory< ::mavsdk::rpc::info::FlightInformationResponse>::Create(stub_->channel_.get(), stub_->rpcmethod_SubscribeFlightInformation_, context, request, reactor); +} + +::grpc::ClientAsyncReader< ::mavsdk::rpc::info::FlightInformationResponse>* InfoService::Stub::AsyncSubscribeFlightInformationRaw(::grpc::ClientContext* context, const ::mavsdk::rpc::info::SubscribeFlightInformationRequest& request, ::grpc::CompletionQueue* cq, void* tag) { + return ::grpc::internal::ClientAsyncReaderFactory< ::mavsdk::rpc::info::FlightInformationResponse>::Create(channel_.get(), cq, rpcmethod_SubscribeFlightInformation_, context, request, true, tag); +} + +::grpc::ClientAsyncReader< ::mavsdk::rpc::info::FlightInformationResponse>* InfoService::Stub::PrepareAsyncSubscribeFlightInformationRaw(::grpc::ClientContext* context, const ::mavsdk::rpc::info::SubscribeFlightInformationRequest& request, ::grpc::CompletionQueue* cq) { + return ::grpc::internal::ClientAsyncReaderFactory< ::mavsdk::rpc::info::FlightInformationResponse>::Create(channel_.get(), cq, rpcmethod_SubscribeFlightInformation_, context, request, false, nullptr); +} + InfoService::Service::Service() { AddMethod(new ::grpc::internal::RpcServiceMethod( InfoService_method_names[0], @@ -211,6 +229,16 @@ InfoService::Service::Service() { ::mavsdk::rpc::info::GetSpeedFactorResponse* resp) { return service->GetSpeedFactor(ctx, req, resp); }, this))); + AddMethod(new ::grpc::internal::RpcServiceMethod( + InfoService_method_names[5], + ::grpc::internal::RpcMethod::SERVER_STREAMING, + new ::grpc::internal::ServerStreamingHandler< InfoService::Service, ::mavsdk::rpc::info::SubscribeFlightInformationRequest, ::mavsdk::rpc::info::FlightInformationResponse>( + [](InfoService::Service* service, + ::grpc::ServerContext* ctx, + const ::mavsdk::rpc::info::SubscribeFlightInformationRequest* req, + ::grpc::ServerWriter<::mavsdk::rpc::info::FlightInformationResponse>* writer) { + return service->SubscribeFlightInformation(ctx, req, writer); + }, this))); } InfoService::Service::~Service() { @@ -251,6 +279,13 @@ ::grpc::Status InfoService::Service::GetSpeedFactor(::grpc::ServerContext* conte return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } +::grpc::Status InfoService::Service::SubscribeFlightInformation(::grpc::ServerContext* context, const ::mavsdk::rpc::info::SubscribeFlightInformationRequest* request, ::grpc::ServerWriter< ::mavsdk::rpc::info::FlightInformationResponse>* writer) { + (void) context; + (void) request; + (void) writer; + return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); +} + } // namespace mavsdk } // namespace rpc diff --git a/src/mavsdk_server/src/generated/info/info.grpc.pb.h b/src/mavsdk_server/src/generated/info/info.grpc.pb.h index 732975edf3..251c487ec3 100644 --- a/src/mavsdk_server/src/generated/info/info.grpc.pb.h +++ b/src/mavsdk_server/src/generated/info/info.grpc.pb.h @@ -78,6 +78,16 @@ class InfoService final { std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::mavsdk::rpc::info::GetSpeedFactorResponse>> PrepareAsyncGetSpeedFactor(::grpc::ClientContext* context, const ::mavsdk::rpc::info::GetSpeedFactorRequest& request, ::grpc::CompletionQueue* cq) { return std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::mavsdk::rpc::info::GetSpeedFactorResponse>>(PrepareAsyncGetSpeedFactorRaw(context, request, cq)); } + // Subscribe to 'flight information' updates. + std::unique_ptr< ::grpc::ClientReaderInterface< ::mavsdk::rpc::info::FlightInformationResponse>> SubscribeFlightInformation(::grpc::ClientContext* context, const ::mavsdk::rpc::info::SubscribeFlightInformationRequest& request) { + return std::unique_ptr< ::grpc::ClientReaderInterface< ::mavsdk::rpc::info::FlightInformationResponse>>(SubscribeFlightInformationRaw(context, request)); + } + std::unique_ptr< ::grpc::ClientAsyncReaderInterface< ::mavsdk::rpc::info::FlightInformationResponse>> AsyncSubscribeFlightInformation(::grpc::ClientContext* context, const ::mavsdk::rpc::info::SubscribeFlightInformationRequest& request, ::grpc::CompletionQueue* cq, void* tag) { + return std::unique_ptr< ::grpc::ClientAsyncReaderInterface< ::mavsdk::rpc::info::FlightInformationResponse>>(AsyncSubscribeFlightInformationRaw(context, request, cq, tag)); + } + std::unique_ptr< ::grpc::ClientAsyncReaderInterface< ::mavsdk::rpc::info::FlightInformationResponse>> PrepareAsyncSubscribeFlightInformation(::grpc::ClientContext* context, const ::mavsdk::rpc::info::SubscribeFlightInformationRequest& request, ::grpc::CompletionQueue* cq) { + return std::unique_ptr< ::grpc::ClientAsyncReaderInterface< ::mavsdk::rpc::info::FlightInformationResponse>>(PrepareAsyncSubscribeFlightInformationRaw(context, request, cq)); + } class async_interface { public: virtual ~async_interface() {} @@ -96,6 +106,8 @@ class InfoService final { // Get the speed factor of a simulation (with lockstep a simulation can run faster or slower than realtime). virtual void GetSpeedFactor(::grpc::ClientContext* context, const ::mavsdk::rpc::info::GetSpeedFactorRequest* request, ::mavsdk::rpc::info::GetSpeedFactorResponse* response, std::function) = 0; virtual void GetSpeedFactor(::grpc::ClientContext* context, const ::mavsdk::rpc::info::GetSpeedFactorRequest* request, ::mavsdk::rpc::info::GetSpeedFactorResponse* response, ::grpc::ClientUnaryReactor* reactor) = 0; + // Subscribe to 'flight information' updates. + virtual void SubscribeFlightInformation(::grpc::ClientContext* context, const ::mavsdk::rpc::info::SubscribeFlightInformationRequest* request, ::grpc::ClientReadReactor< ::mavsdk::rpc::info::FlightInformationResponse>* reactor) = 0; }; typedef class async_interface experimental_async_interface; virtual class async_interface* async() { return nullptr; } @@ -111,6 +123,9 @@ class InfoService final { virtual ::grpc::ClientAsyncResponseReaderInterface< ::mavsdk::rpc::info::GetVersionResponse>* PrepareAsyncGetVersionRaw(::grpc::ClientContext* context, const ::mavsdk::rpc::info::GetVersionRequest& request, ::grpc::CompletionQueue* cq) = 0; virtual ::grpc::ClientAsyncResponseReaderInterface< ::mavsdk::rpc::info::GetSpeedFactorResponse>* AsyncGetSpeedFactorRaw(::grpc::ClientContext* context, const ::mavsdk::rpc::info::GetSpeedFactorRequest& request, ::grpc::CompletionQueue* cq) = 0; virtual ::grpc::ClientAsyncResponseReaderInterface< ::mavsdk::rpc::info::GetSpeedFactorResponse>* PrepareAsyncGetSpeedFactorRaw(::grpc::ClientContext* context, const ::mavsdk::rpc::info::GetSpeedFactorRequest& request, ::grpc::CompletionQueue* cq) = 0; + virtual ::grpc::ClientReaderInterface< ::mavsdk::rpc::info::FlightInformationResponse>* SubscribeFlightInformationRaw(::grpc::ClientContext* context, const ::mavsdk::rpc::info::SubscribeFlightInformationRequest& request) = 0; + virtual ::grpc::ClientAsyncReaderInterface< ::mavsdk::rpc::info::FlightInformationResponse>* AsyncSubscribeFlightInformationRaw(::grpc::ClientContext* context, const ::mavsdk::rpc::info::SubscribeFlightInformationRequest& request, ::grpc::CompletionQueue* cq, void* tag) = 0; + virtual ::grpc::ClientAsyncReaderInterface< ::mavsdk::rpc::info::FlightInformationResponse>* PrepareAsyncSubscribeFlightInformationRaw(::grpc::ClientContext* context, const ::mavsdk::rpc::info::SubscribeFlightInformationRequest& request, ::grpc::CompletionQueue* cq) = 0; }; class Stub final : public StubInterface { public: @@ -150,6 +165,15 @@ class InfoService final { std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::mavsdk::rpc::info::GetSpeedFactorResponse>> PrepareAsyncGetSpeedFactor(::grpc::ClientContext* context, const ::mavsdk::rpc::info::GetSpeedFactorRequest& request, ::grpc::CompletionQueue* cq) { return std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::mavsdk::rpc::info::GetSpeedFactorResponse>>(PrepareAsyncGetSpeedFactorRaw(context, request, cq)); } + std::unique_ptr< ::grpc::ClientReader< ::mavsdk::rpc::info::FlightInformationResponse>> SubscribeFlightInformation(::grpc::ClientContext* context, const ::mavsdk::rpc::info::SubscribeFlightInformationRequest& request) { + return std::unique_ptr< ::grpc::ClientReader< ::mavsdk::rpc::info::FlightInformationResponse>>(SubscribeFlightInformationRaw(context, request)); + } + std::unique_ptr< ::grpc::ClientAsyncReader< ::mavsdk::rpc::info::FlightInformationResponse>> AsyncSubscribeFlightInformation(::grpc::ClientContext* context, const ::mavsdk::rpc::info::SubscribeFlightInformationRequest& request, ::grpc::CompletionQueue* cq, void* tag) { + return std::unique_ptr< ::grpc::ClientAsyncReader< ::mavsdk::rpc::info::FlightInformationResponse>>(AsyncSubscribeFlightInformationRaw(context, request, cq, tag)); + } + std::unique_ptr< ::grpc::ClientAsyncReader< ::mavsdk::rpc::info::FlightInformationResponse>> PrepareAsyncSubscribeFlightInformation(::grpc::ClientContext* context, const ::mavsdk::rpc::info::SubscribeFlightInformationRequest& request, ::grpc::CompletionQueue* cq) { + return std::unique_ptr< ::grpc::ClientAsyncReader< ::mavsdk::rpc::info::FlightInformationResponse>>(PrepareAsyncSubscribeFlightInformationRaw(context, request, cq)); + } class async final : public StubInterface::async_interface { public: @@ -163,6 +187,7 @@ class InfoService final { void GetVersion(::grpc::ClientContext* context, const ::mavsdk::rpc::info::GetVersionRequest* request, ::mavsdk::rpc::info::GetVersionResponse* response, ::grpc::ClientUnaryReactor* reactor) override; void GetSpeedFactor(::grpc::ClientContext* context, const ::mavsdk::rpc::info::GetSpeedFactorRequest* request, ::mavsdk::rpc::info::GetSpeedFactorResponse* response, std::function) override; void GetSpeedFactor(::grpc::ClientContext* context, const ::mavsdk::rpc::info::GetSpeedFactorRequest* request, ::mavsdk::rpc::info::GetSpeedFactorResponse* response, ::grpc::ClientUnaryReactor* reactor) override; + void SubscribeFlightInformation(::grpc::ClientContext* context, const ::mavsdk::rpc::info::SubscribeFlightInformationRequest* request, ::grpc::ClientReadReactor< ::mavsdk::rpc::info::FlightInformationResponse>* reactor) override; private: friend class Stub; explicit async(Stub* stub): stub_(stub) { } @@ -184,11 +209,15 @@ class InfoService final { ::grpc::ClientAsyncResponseReader< ::mavsdk::rpc::info::GetVersionResponse>* PrepareAsyncGetVersionRaw(::grpc::ClientContext* context, const ::mavsdk::rpc::info::GetVersionRequest& request, ::grpc::CompletionQueue* cq) override; ::grpc::ClientAsyncResponseReader< ::mavsdk::rpc::info::GetSpeedFactorResponse>* AsyncGetSpeedFactorRaw(::grpc::ClientContext* context, const ::mavsdk::rpc::info::GetSpeedFactorRequest& request, ::grpc::CompletionQueue* cq) override; ::grpc::ClientAsyncResponseReader< ::mavsdk::rpc::info::GetSpeedFactorResponse>* PrepareAsyncGetSpeedFactorRaw(::grpc::ClientContext* context, const ::mavsdk::rpc::info::GetSpeedFactorRequest& request, ::grpc::CompletionQueue* cq) override; + ::grpc::ClientReader< ::mavsdk::rpc::info::FlightInformationResponse>* SubscribeFlightInformationRaw(::grpc::ClientContext* context, const ::mavsdk::rpc::info::SubscribeFlightInformationRequest& request) override; + ::grpc::ClientAsyncReader< ::mavsdk::rpc::info::FlightInformationResponse>* AsyncSubscribeFlightInformationRaw(::grpc::ClientContext* context, const ::mavsdk::rpc::info::SubscribeFlightInformationRequest& request, ::grpc::CompletionQueue* cq, void* tag) override; + ::grpc::ClientAsyncReader< ::mavsdk::rpc::info::FlightInformationResponse>* PrepareAsyncSubscribeFlightInformationRaw(::grpc::ClientContext* context, const ::mavsdk::rpc::info::SubscribeFlightInformationRequest& request, ::grpc::CompletionQueue* cq) override; const ::grpc::internal::RpcMethod rpcmethod_GetFlightInformation_; const ::grpc::internal::RpcMethod rpcmethod_GetIdentification_; const ::grpc::internal::RpcMethod rpcmethod_GetProduct_; const ::grpc::internal::RpcMethod rpcmethod_GetVersion_; const ::grpc::internal::RpcMethod rpcmethod_GetSpeedFactor_; + const ::grpc::internal::RpcMethod rpcmethod_SubscribeFlightInformation_; }; static std::unique_ptr NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel, const ::grpc::StubOptions& options = ::grpc::StubOptions()); @@ -206,6 +235,8 @@ class InfoService final { virtual ::grpc::Status GetVersion(::grpc::ServerContext* context, const ::mavsdk::rpc::info::GetVersionRequest* request, ::mavsdk::rpc::info::GetVersionResponse* response); // Get the speed factor of a simulation (with lockstep a simulation can run faster or slower than realtime). virtual ::grpc::Status GetSpeedFactor(::grpc::ServerContext* context, const ::mavsdk::rpc::info::GetSpeedFactorRequest* request, ::mavsdk::rpc::info::GetSpeedFactorResponse* response); + // Subscribe to 'flight information' updates. + virtual ::grpc::Status SubscribeFlightInformation(::grpc::ServerContext* context, const ::mavsdk::rpc::info::SubscribeFlightInformationRequest* request, ::grpc::ServerWriter< ::mavsdk::rpc::info::FlightInformationResponse>* writer); }; template class WithAsyncMethod_GetFlightInformation : public BaseClass { @@ -307,7 +338,27 @@ class InfoService final { ::grpc::Service::RequestAsyncUnary(4, context, request, response, new_call_cq, notification_cq, tag); } }; - typedef WithAsyncMethod_GetFlightInformation > > > > AsyncService; + template + class WithAsyncMethod_SubscribeFlightInformation : public BaseClass { + private: + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} + public: + WithAsyncMethod_SubscribeFlightInformation() { + ::grpc::Service::MarkMethodAsync(5); + } + ~WithAsyncMethod_SubscribeFlightInformation() override { + BaseClassMustBeDerivedFromService(this); + } + // disable synchronous version of this method + ::grpc::Status SubscribeFlightInformation(::grpc::ServerContext* /*context*/, const ::mavsdk::rpc::info::SubscribeFlightInformationRequest* /*request*/, ::grpc::ServerWriter< ::mavsdk::rpc::info::FlightInformationResponse>* /*writer*/) override { + abort(); + return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); + } + void RequestSubscribeFlightInformation(::grpc::ServerContext* context, ::mavsdk::rpc::info::SubscribeFlightInformationRequest* request, ::grpc::ServerAsyncWriter< ::mavsdk::rpc::info::FlightInformationResponse>* writer, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { + ::grpc::Service::RequestAsyncServerStreaming(5, context, request, writer, new_call_cq, notification_cq, tag); + } + }; + typedef WithAsyncMethod_GetFlightInformation > > > > > AsyncService; template class WithCallbackMethod_GetFlightInformation : public BaseClass { private: @@ -443,7 +494,29 @@ class InfoService final { virtual ::grpc::ServerUnaryReactor* GetSpeedFactor( ::grpc::CallbackServerContext* /*context*/, const ::mavsdk::rpc::info::GetSpeedFactorRequest* /*request*/, ::mavsdk::rpc::info::GetSpeedFactorResponse* /*response*/) { return nullptr; } }; - typedef WithCallbackMethod_GetFlightInformation > > > > CallbackService; + template + class WithCallbackMethod_SubscribeFlightInformation : public BaseClass { + private: + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} + public: + WithCallbackMethod_SubscribeFlightInformation() { + ::grpc::Service::MarkMethodCallback(5, + new ::grpc::internal::CallbackServerStreamingHandler< ::mavsdk::rpc::info::SubscribeFlightInformationRequest, ::mavsdk::rpc::info::FlightInformationResponse>( + [this]( + ::grpc::CallbackServerContext* context, const ::mavsdk::rpc::info::SubscribeFlightInformationRequest* request) { return this->SubscribeFlightInformation(context, request); })); + } + ~WithCallbackMethod_SubscribeFlightInformation() override { + BaseClassMustBeDerivedFromService(this); + } + // disable synchronous version of this method + ::grpc::Status SubscribeFlightInformation(::grpc::ServerContext* /*context*/, const ::mavsdk::rpc::info::SubscribeFlightInformationRequest* /*request*/, ::grpc::ServerWriter< ::mavsdk::rpc::info::FlightInformationResponse>* /*writer*/) override { + abort(); + return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); + } + virtual ::grpc::ServerWriteReactor< ::mavsdk::rpc::info::FlightInformationResponse>* SubscribeFlightInformation( + ::grpc::CallbackServerContext* /*context*/, const ::mavsdk::rpc::info::SubscribeFlightInformationRequest* /*request*/) { return nullptr; } + }; + typedef WithCallbackMethod_GetFlightInformation > > > > > CallbackService; typedef CallbackService ExperimentalCallbackService; template class WithGenericMethod_GetFlightInformation : public BaseClass { @@ -531,6 +604,23 @@ class InfoService final { } }; template + class WithGenericMethod_SubscribeFlightInformation : public BaseClass { + private: + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} + public: + WithGenericMethod_SubscribeFlightInformation() { + ::grpc::Service::MarkMethodGeneric(5); + } + ~WithGenericMethod_SubscribeFlightInformation() override { + BaseClassMustBeDerivedFromService(this); + } + // disable synchronous version of this method + ::grpc::Status SubscribeFlightInformation(::grpc::ServerContext* /*context*/, const ::mavsdk::rpc::info::SubscribeFlightInformationRequest* /*request*/, ::grpc::ServerWriter< ::mavsdk::rpc::info::FlightInformationResponse>* /*writer*/) override { + abort(); + return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); + } + }; + template class WithRawMethod_GetFlightInformation : public BaseClass { private: void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} @@ -631,6 +721,26 @@ class InfoService final { } }; template + class WithRawMethod_SubscribeFlightInformation : public BaseClass { + private: + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} + public: + WithRawMethod_SubscribeFlightInformation() { + ::grpc::Service::MarkMethodRaw(5); + } + ~WithRawMethod_SubscribeFlightInformation() override { + BaseClassMustBeDerivedFromService(this); + } + // disable synchronous version of this method + ::grpc::Status SubscribeFlightInformation(::grpc::ServerContext* /*context*/, const ::mavsdk::rpc::info::SubscribeFlightInformationRequest* /*request*/, ::grpc::ServerWriter< ::mavsdk::rpc::info::FlightInformationResponse>* /*writer*/) override { + abort(); + return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); + } + void RequestSubscribeFlightInformation(::grpc::ServerContext* context, ::grpc::ByteBuffer* request, ::grpc::ServerAsyncWriter< ::grpc::ByteBuffer>* writer, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { + ::grpc::Service::RequestAsyncServerStreaming(5, context, request, writer, new_call_cq, notification_cq, tag); + } + }; + template class WithRawCallbackMethod_GetFlightInformation : public BaseClass { private: void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} @@ -741,6 +851,28 @@ class InfoService final { ::grpc::CallbackServerContext* /*context*/, const ::grpc::ByteBuffer* /*request*/, ::grpc::ByteBuffer* /*response*/) { return nullptr; } }; template + class WithRawCallbackMethod_SubscribeFlightInformation : public BaseClass { + private: + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} + public: + WithRawCallbackMethod_SubscribeFlightInformation() { + ::grpc::Service::MarkMethodRawCallback(5, + new ::grpc::internal::CallbackServerStreamingHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>( + [this]( + ::grpc::CallbackServerContext* context, const::grpc::ByteBuffer* request) { return this->SubscribeFlightInformation(context, request); })); + } + ~WithRawCallbackMethod_SubscribeFlightInformation() override { + BaseClassMustBeDerivedFromService(this); + } + // disable synchronous version of this method + ::grpc::Status SubscribeFlightInformation(::grpc::ServerContext* /*context*/, const ::mavsdk::rpc::info::SubscribeFlightInformationRequest* /*request*/, ::grpc::ServerWriter< ::mavsdk::rpc::info::FlightInformationResponse>* /*writer*/) override { + abort(); + return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); + } + virtual ::grpc::ServerWriteReactor< ::grpc::ByteBuffer>* SubscribeFlightInformation( + ::grpc::CallbackServerContext* /*context*/, const ::grpc::ByteBuffer* /*request*/) { return nullptr; } + }; + template class WithStreamedUnaryMethod_GetFlightInformation : public BaseClass { private: void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} @@ -876,8 +1008,35 @@ class InfoService final { virtual ::grpc::Status StreamedGetSpeedFactor(::grpc::ServerContext* context, ::grpc::ServerUnaryStreamer< ::mavsdk::rpc::info::GetSpeedFactorRequest,::mavsdk::rpc::info::GetSpeedFactorResponse>* server_unary_streamer) = 0; }; typedef WithStreamedUnaryMethod_GetFlightInformation > > > > StreamedUnaryService; - typedef Service SplitStreamedService; - typedef WithStreamedUnaryMethod_GetFlightInformation > > > > StreamedService; + template + class WithSplitStreamingMethod_SubscribeFlightInformation : public BaseClass { + private: + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} + public: + WithSplitStreamingMethod_SubscribeFlightInformation() { + ::grpc::Service::MarkMethodStreamed(5, + new ::grpc::internal::SplitServerStreamingHandler< + ::mavsdk::rpc::info::SubscribeFlightInformationRequest, ::mavsdk::rpc::info::FlightInformationResponse>( + [this](::grpc::ServerContext* context, + ::grpc::ServerSplitStreamer< + ::mavsdk::rpc::info::SubscribeFlightInformationRequest, ::mavsdk::rpc::info::FlightInformationResponse>* streamer) { + return this->StreamedSubscribeFlightInformation(context, + streamer); + })); + } + ~WithSplitStreamingMethod_SubscribeFlightInformation() override { + BaseClassMustBeDerivedFromService(this); + } + // disable regular version of this method + ::grpc::Status SubscribeFlightInformation(::grpc::ServerContext* /*context*/, const ::mavsdk::rpc::info::SubscribeFlightInformationRequest* /*request*/, ::grpc::ServerWriter< ::mavsdk::rpc::info::FlightInformationResponse>* /*writer*/) override { + abort(); + return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); + } + // replace default version of method with split streamed + virtual ::grpc::Status StreamedSubscribeFlightInformation(::grpc::ServerContext* context, ::grpc::ServerSplitStreamer< ::mavsdk::rpc::info::SubscribeFlightInformationRequest,::mavsdk::rpc::info::FlightInformationResponse>* server_split_streamer) = 0; + }; + typedef WithSplitStreamingMethod_SubscribeFlightInformation SplitStreamedService; + typedef WithStreamedUnaryMethod_GetFlightInformation > > > > > StreamedService; }; } // namespace info diff --git a/src/mavsdk_server/src/generated/info/info.pb.cc b/src/mavsdk_server/src/generated/info/info.pb.cc index 5894329053..05fd517ab7 100644 --- a/src/mavsdk_server/src/generated/info/info.pb.cc +++ b/src/mavsdk_server/src/generated/info/info.pb.cc @@ -57,6 +57,18 @@ struct VersionDefaultTypeInternal { PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 VersionDefaultTypeInternal _Version_default_instance_; + template +PROTOBUF_CONSTEXPR SubscribeFlightInformationRequest::SubscribeFlightInformationRequest(::_pbi::ConstantInitialized) {} +struct SubscribeFlightInformationRequestDefaultTypeInternal { + PROTOBUF_CONSTEXPR SubscribeFlightInformationRequestDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~SubscribeFlightInformationRequestDefaultTypeInternal() {} + union { + SubscribeFlightInformationRequest _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 SubscribeFlightInformationRequestDefaultTypeInternal _SubscribeFlightInformationRequest_default_instance_; inline constexpr Product::Impl_::Impl_( ::_pbi::ConstantInitialized) noexcept @@ -309,10 +321,29 @@ struct GetFlightInformationResponseDefaultTypeInternal { PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 GetFlightInformationResponseDefaultTypeInternal _GetFlightInformationResponse_default_instance_; + +inline constexpr FlightInformationResponse::Impl_::Impl_( + ::_pbi::ConstantInitialized) noexcept + : _cached_size_{0}, + flight_info_{nullptr} {} + +template +PROTOBUF_CONSTEXPR FlightInformationResponse::FlightInformationResponse(::_pbi::ConstantInitialized) + : _impl_(::_pbi::ConstantInitialized()) {} +struct FlightInformationResponseDefaultTypeInternal { + PROTOBUF_CONSTEXPR FlightInformationResponseDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~FlightInformationResponseDefaultTypeInternal() {} + union { + FlightInformationResponse _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FlightInformationResponseDefaultTypeInternal _FlightInformationResponse_default_instance_; } // namespace info } // namespace rpc } // namespace mavsdk -static ::_pb::Metadata file_level_metadata_info_2finfo_2eproto[15]; +static ::_pb::Metadata file_level_metadata_info_2finfo_2eproto[17]; static const ::_pb::EnumDescriptor* file_level_enum_descriptors_info_2finfo_2eproto[2]; static constexpr const ::_pb::ServiceDescriptor** file_level_service_descriptors_info_2finfo_2eproto = nullptr; @@ -419,6 +450,24 @@ const ::uint32_t TableStruct_info_2finfo_2eproto::offsets[] PROTOBUF_SECTION_VAR 0, ~0u, ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::info::SubscribeFlightInformationRequest, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::info::FlightInformationResponse, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::info::FlightInformationResponse, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::info::FlightInformationResponse, _impl_.flight_info_), + 0, + ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::info::FlightInfo, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ @@ -496,11 +545,13 @@ static const ::_pbi::MigrationSchema {68, 78, -1, sizeof(::mavsdk::rpc::info::GetVersionResponse)}, {80, -1, -1, sizeof(::mavsdk::rpc::info::GetSpeedFactorRequest)}, {88, 98, -1, sizeof(::mavsdk::rpc::info::GetSpeedFactorResponse)}, - {100, -1, -1, sizeof(::mavsdk::rpc::info::FlightInfo)}, - {112, -1, -1, sizeof(::mavsdk::rpc::info::Identification)}, - {122, -1, -1, sizeof(::mavsdk::rpc::info::Product)}, - {134, -1, -1, sizeof(::mavsdk::rpc::info::Version)}, - {154, -1, -1, sizeof(::mavsdk::rpc::info::InfoResult)}, + {100, -1, -1, sizeof(::mavsdk::rpc::info::SubscribeFlightInformationRequest)}, + {108, 117, -1, sizeof(::mavsdk::rpc::info::FlightInformationResponse)}, + {118, -1, -1, sizeof(::mavsdk::rpc::info::FlightInfo)}, + {130, -1, -1, sizeof(::mavsdk::rpc::info::Identification)}, + {140, -1, -1, sizeof(::mavsdk::rpc::info::Product)}, + {152, -1, -1, sizeof(::mavsdk::rpc::info::Version)}, + {172, -1, -1, sizeof(::mavsdk::rpc::info::InfoResult)}, }; static const ::_pb::Message* const file_default_instances[] = { @@ -514,6 +565,8 @@ static const ::_pb::Message* const file_default_instances[] = { &::mavsdk::rpc::info::_GetVersionResponse_default_instance_._instance, &::mavsdk::rpc::info::_GetSpeedFactorRequest_default_instance_._instance, &::mavsdk::rpc::info::_GetSpeedFactorResponse_default_instance_._instance, + &::mavsdk::rpc::info::_SubscribeFlightInformationRequest_default_instance_._instance, + &::mavsdk::rpc::info::_FlightInformationResponse_default_instance_._instance, &::mavsdk::rpc::info::_FlightInfo_default_instance_._instance, &::mavsdk::rpc::info::_Identification_default_instance_._instance, &::mavsdk::rpc::info::_Product_default_instance_._instance, @@ -540,50 +593,56 @@ const char descriptor_table_protodef_info_2finfo_2eproto[] PROTOBUF_SECTION_VARI ".rpc.info.Version\"\027\n\025GetSpeedFactorReque" "st\"`\n\026GetSpeedFactorResponse\0220\n\013info_res" "ult\030\001 \001(\0132\033.mavsdk.rpc.info.InfoResult\022\024" - "\n\014speed_factor\030\002 \001(\001\"{\n\nFlightInfo\022\024\n\014ti" - "me_boot_ms\030\001 \001(\r\022\022\n\nflight_uid\030\002 \001(\004\022 \n\030" - "duration_since_arming_ms\030\003 \001(\r\022!\n\031durati" - "on_since_takeoff_ms\030\004 \001(\r\":\n\016Identificat" - "ion\022\024\n\014hardware_uid\030\001 \001(\t\022\022\n\nlegacy_uid\030" - "\002 \001(\004\"[\n\007Product\022\021\n\tvendor_id\030\001 \001(\005\022\023\n\013v" - "endor_name\030\002 \001(\t\022\022\n\nproduct_id\030\003 \001(\005\022\024\n\014" - "product_name\030\004 \001(\t\"\207\005\n\007Version\022\027\n\017flight" - "_sw_major\030\001 \001(\005\022\027\n\017flight_sw_minor\030\002 \001(\005" - "\022\027\n\017flight_sw_patch\030\003 \001(\005\022\036\n\026flight_sw_v" - "endor_major\030\004 \001(\005\022\036\n\026flight_sw_vendor_mi" - "nor\030\005 \001(\005\022\036\n\026flight_sw_vendor_patch\030\006 \001(" - "\005\022\023\n\013os_sw_major\030\007 \001(\005\022\023\n\013os_sw_minor\030\010 " - "\001(\005\022\023\n\013os_sw_patch\030\t \001(\005\022\032\n\022flight_sw_gi" - "t_hash\030\n \001(\t\022\026\n\016os_sw_git_hash\030\013 \001(\t\022R\n\026" - "flight_sw_version_type\030\014 \001(\01622.mavsdk.rp" - "c.info.Version.FlightSoftwareVersionType" - "\"\211\002\n\031FlightSoftwareVersionType\022(\n$FLIGHT" - "_SOFTWARE_VERSION_TYPE_UNKNOWN\020\000\022$\n FLIG" - "HT_SOFTWARE_VERSION_TYPE_DEV\020\001\022&\n\"FLIGHT" - "_SOFTWARE_VERSION_TYPE_ALPHA\020\002\022%\n!FLIGHT" - "_SOFTWARE_VERSION_TYPE_BETA\020\003\022#\n\037FLIGHT_" - "SOFTWARE_VERSION_TYPE_RC\020\004\022(\n$FLIGHT_SOF" - "TWARE_VERSION_TYPE_RELEASE\020\005\"\305\001\n\nInfoRes" - "ult\0222\n\006result\030\001 \001(\0162\".mavsdk.rpc.info.In" - "foResult.Result\022\022\n\nresult_str\030\002 \001(\t\"o\n\006R" - "esult\022\022\n\016RESULT_UNKNOWN\020\000\022\022\n\016RESULT_SUCC" - "ESS\020\001\022\'\n#RESULT_INFORMATION_NOT_RECEIVED" - "_YET\020\002\022\024\n\020RESULT_NO_SYSTEM\020\0032\235\004\n\013InfoSer" - "vice\022y\n\024GetFlightInformation\022,.mavsdk.rp" - "c.info.GetFlightInformationRequest\032-.mav" - "sdk.rpc.info.GetFlightInformationRespons" - "e\"\004\200\265\030\001\022p\n\021GetIdentification\022).mavsdk.rp" - "c.info.GetIdentificationRequest\032*.mavsdk" - ".rpc.info.GetIdentificationResponse\"\004\200\265\030" - "\001\022[\n\nGetProduct\022\".mavsdk.rpc.info.GetPro" - "ductRequest\032#.mavsdk.rpc.info.GetProduct" - "Response\"\004\200\265\030\001\022[\n\nGetVersion\022\".mavsdk.rp" - "c.info.GetVersionRequest\032#.mavsdk.rpc.in" - "fo.GetVersionResponse\"\004\200\265\030\001\022g\n\016GetSpeedF" - "actor\022&.mavsdk.rpc.info.GetSpeedFactorRe" - "quest\032\'.mavsdk.rpc.info.GetSpeedFactorRe" - "sponse\"\004\200\265\030\001B\033\n\016io.mavsdk.infoB\tInfoProt" - "ob\006proto3" + "\n\014speed_factor\030\002 \001(\001\"#\n!SubscribeFlightI" + "nformationRequest\"M\n\031FlightInformationRe" + "sponse\0220\n\013flight_info\030\001 \001(\0132\033.mavsdk.rpc" + ".info.FlightInfo\"{\n\nFlightInfo\022\024\n\014time_b" + "oot_ms\030\001 \001(\r\022\022\n\nflight_uid\030\002 \001(\004\022 \n\030dura" + "tion_since_arming_ms\030\003 \001(\r\022!\n\031duration_s" + "ince_takeoff_ms\030\004 \001(\r\":\n\016Identification\022" + "\024\n\014hardware_uid\030\001 \001(\t\022\022\n\nlegacy_uid\030\002 \001(" + "\004\"[\n\007Product\022\021\n\tvendor_id\030\001 \001(\005\022\023\n\013vendo" + "r_name\030\002 \001(\t\022\022\n\nproduct_id\030\003 \001(\005\022\024\n\014prod" + "uct_name\030\004 \001(\t\"\207\005\n\007Version\022\027\n\017flight_sw_" + "major\030\001 \001(\005\022\027\n\017flight_sw_minor\030\002 \001(\005\022\027\n\017" + "flight_sw_patch\030\003 \001(\005\022\036\n\026flight_sw_vendo" + "r_major\030\004 \001(\005\022\036\n\026flight_sw_vendor_minor\030" + "\005 \001(\005\022\036\n\026flight_sw_vendor_patch\030\006 \001(\005\022\023\n" + "\013os_sw_major\030\007 \001(\005\022\023\n\013os_sw_minor\030\010 \001(\005\022" + "\023\n\013os_sw_patch\030\t \001(\005\022\032\n\022flight_sw_git_ha" + "sh\030\n \001(\t\022\026\n\016os_sw_git_hash\030\013 \001(\t\022R\n\026flig" + "ht_sw_version_type\030\014 \001(\01622.mavsdk.rpc.in" + "fo.Version.FlightSoftwareVersionType\"\211\002\n" + "\031FlightSoftwareVersionType\022(\n$FLIGHT_SOF" + "TWARE_VERSION_TYPE_UNKNOWN\020\000\022$\n FLIGHT_S" + "OFTWARE_VERSION_TYPE_DEV\020\001\022&\n\"FLIGHT_SOF" + "TWARE_VERSION_TYPE_ALPHA\020\002\022%\n!FLIGHT_SOF" + "TWARE_VERSION_TYPE_BETA\020\003\022#\n\037FLIGHT_SOFT" + "WARE_VERSION_TYPE_RC\020\004\022(\n$FLIGHT_SOFTWAR" + "E_VERSION_TYPE_RELEASE\020\005\"\305\001\n\nInfoResult\022" + "2\n\006result\030\001 \001(\0162\".mavsdk.rpc.info.InfoRe" + "sult.Result\022\022\n\nresult_str\030\002 \001(\t\"o\n\006Resul" + "t\022\022\n\016RESULT_UNKNOWN\020\000\022\022\n\016RESULT_SUCCESS\020" + "\001\022\'\n#RESULT_INFORMATION_NOT_RECEIVED_YET" + "\020\002\022\024\n\020RESULT_NO_SYSTEM\020\0032\244\005\n\013InfoService" + "\022y\n\024GetFlightInformation\022,.mavsdk.rpc.in" + "fo.GetFlightInformationRequest\032-.mavsdk." + "rpc.info.GetFlightInformationResponse\"\004\200" + "\265\030\001\022p\n\021GetIdentification\022).mavsdk.rpc.in" + "fo.GetIdentificationRequest\032*.mavsdk.rpc" + ".info.GetIdentificationResponse\"\004\200\265\030\001\022[\n" + "\nGetProduct\022\".mavsdk.rpc.info.GetProduct" + "Request\032#.mavsdk.rpc.info.GetProductResp" + "onse\"\004\200\265\030\001\022[\n\nGetVersion\022\".mavsdk.rpc.in" + "fo.GetVersionRequest\032#.mavsdk.rpc.info.G" + "etVersionResponse\"\004\200\265\030\001\022g\n\016GetSpeedFacto" + "r\022&.mavsdk.rpc.info.GetSpeedFactorReques" + "t\032\'.mavsdk.rpc.info.GetSpeedFactorRespon" + "se\"\004\200\265\030\001\022\204\001\n\032SubscribeFlightInformation\022" + "2.mavsdk.rpc.info.SubscribeFlightInforma" + "tionRequest\032*.mavsdk.rpc.info.FlightInfo" + "rmationResponse\"\004\200\265\030\0000\001B\033\n\016io.mavsdk.inf" + "oB\tInfoProtob\006proto3" }; static const ::_pbi::DescriptorTable* const descriptor_table_info_2finfo_2eproto_deps[1] = { @@ -593,13 +652,13 @@ static ::absl::once_flag descriptor_table_info_2finfo_2eproto_once; const ::_pbi::DescriptorTable descriptor_table_info_2finfo_2eproto = { false, false, - 2489, + 2740, descriptor_table_protodef_info_2finfo_2eproto, "info/info.proto", &descriptor_table_info_2finfo_2eproto_once, descriptor_table_info_2finfo_2eproto_deps, 1, - 15, + 17, schemas, file_default_instances, TableStruct_info_2finfo_2eproto::offsets, @@ -2158,6 +2217,248 @@ ::google::protobuf::Metadata GetSpeedFactorResponse::GetMetadata() const { } // =================================================================== +class SubscribeFlightInformationRequest::_Internal { + public: +}; + +SubscribeFlightInformationRequest::SubscribeFlightInformationRequest(::google::protobuf::Arena* arena) + : ::google::protobuf::internal::ZeroFieldsBase(arena) { + // @@protoc_insertion_point(arena_constructor:mavsdk.rpc.info.SubscribeFlightInformationRequest) +} +SubscribeFlightInformationRequest::SubscribeFlightInformationRequest( + ::google::protobuf::Arena* arena, + const SubscribeFlightInformationRequest& from) + : ::google::protobuf::internal::ZeroFieldsBase(arena) { + SubscribeFlightInformationRequest* const _this = this; + (void)_this; + _internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>( + from._internal_metadata_); + + // @@protoc_insertion_point(copy_constructor:mavsdk.rpc.info.SubscribeFlightInformationRequest) +} + + + + + + + + + +::google::protobuf::Metadata SubscribeFlightInformationRequest::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_info_2finfo_2eproto_getter, &descriptor_table_info_2finfo_2eproto_once, + file_level_metadata_info_2finfo_2eproto[10]); +} +// =================================================================== + +class FlightInformationResponse::_Internal { + public: + using HasBits = decltype(std::declval()._impl_._has_bits_); + static constexpr ::int32_t kHasBitsOffset = + 8 * PROTOBUF_FIELD_OFFSET(FlightInformationResponse, _impl_._has_bits_); + static const ::mavsdk::rpc::info::FlightInfo& flight_info(const FlightInformationResponse* msg); + static void set_has_flight_info(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } +}; + +const ::mavsdk::rpc::info::FlightInfo& FlightInformationResponse::_Internal::flight_info(const FlightInformationResponse* msg) { + return *msg->_impl_.flight_info_; +} +FlightInformationResponse::FlightInformationResponse(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(arena) { + SharedCtor(arena); + // @@protoc_insertion_point(arena_constructor:mavsdk.rpc.info.FlightInformationResponse) +} +inline PROTOBUF_NDEBUG_INLINE FlightInformationResponse::Impl_::Impl_( + ::google::protobuf::internal::InternalVisibility visibility, ::google::protobuf::Arena* arena, + const Impl_& from) + : _has_bits_{from._has_bits_}, + _cached_size_{0} {} + +FlightInformationResponse::FlightInformationResponse( + ::google::protobuf::Arena* arena, + const FlightInformationResponse& from) + : ::google::protobuf::Message(arena) { + FlightInformationResponse* const _this = this; + (void)_this; + _internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>( + from._internal_metadata_); + new (&_impl_) Impl_(internal_visibility(), arena, from._impl_); + ::uint32_t cached_has_bits = _impl_._has_bits_[0]; + _impl_.flight_info_ = (cached_has_bits & 0x00000001u) + ? CreateMaybeMessage<::mavsdk::rpc::info::FlightInfo>(arena, *from._impl_.flight_info_) + : nullptr; + + // @@protoc_insertion_point(copy_constructor:mavsdk.rpc.info.FlightInformationResponse) +} +inline PROTOBUF_NDEBUG_INLINE FlightInformationResponse::Impl_::Impl_( + ::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena) + : _cached_size_{0} {} + +inline void FlightInformationResponse::SharedCtor(::_pb::Arena* arena) { + new (&_impl_) Impl_(internal_visibility(), arena); + _impl_.flight_info_ = {}; +} +FlightInformationResponse::~FlightInformationResponse() { + // @@protoc_insertion_point(destructor:mavsdk.rpc.info.FlightInformationResponse) + _internal_metadata_.Delete<::google::protobuf::UnknownFieldSet>(); + SharedDtor(); +} +inline void FlightInformationResponse::SharedDtor() { + ABSL_DCHECK(GetArena() == nullptr); + delete _impl_.flight_info_; + _impl_.~Impl_(); +} + +PROTOBUF_NOINLINE void FlightInformationResponse::Clear() { +// @@protoc_insertion_point(message_clear_start:mavsdk.rpc.info.FlightInformationResponse) + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + cached_has_bits = _impl_._has_bits_[0]; + if (cached_has_bits & 0x00000001u) { + ABSL_DCHECK(_impl_.flight_info_ != nullptr); + _impl_.flight_info_->Clear(); + } + _impl_._has_bits_.Clear(); + _internal_metadata_.Clear<::google::protobuf::UnknownFieldSet>(); +} + +const char* FlightInformationResponse::_InternalParse( + const char* ptr, ::_pbi::ParseContext* ctx) { + ptr = ::_pbi::TcParser::ParseLoop(this, ptr, ctx, &_table_.header); + return ptr; +} + + +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 +const ::_pbi::TcParseTable<0, 1, 1, 0, 2> FlightInformationResponse::_table_ = { + { + PROTOBUF_FIELD_OFFSET(FlightInformationResponse, _impl_._has_bits_), + 0, // no _extensions_ + 1, 0, // max_field_number, fast_idx_mask + offsetof(decltype(_table_), field_lookup_table), + 4294967294, // skipmap + offsetof(decltype(_table_), field_entries), + 1, // num_field_entries + 1, // num_aux_entries + offsetof(decltype(_table_), aux_entries), + &_FlightInformationResponse_default_instance_._instance, + ::_pbi::TcParser::GenericFallback, // fallback + }, {{ + // .mavsdk.rpc.info.FlightInfo flight_info = 1; + {::_pbi::TcParser::FastMtS1, + {10, 0, 0, PROTOBUF_FIELD_OFFSET(FlightInformationResponse, _impl_.flight_info_)}}, + }}, {{ + 65535, 65535 + }}, {{ + // .mavsdk.rpc.info.FlightInfo flight_info = 1; + {PROTOBUF_FIELD_OFFSET(FlightInformationResponse, _impl_.flight_info_), _Internal::kHasBitsOffset + 0, 0, + (0 | ::_fl::kFcOptional | ::_fl::kMessage | ::_fl::kTvTable)}, + }}, {{ + {::_pbi::TcParser::GetTable<::mavsdk::rpc::info::FlightInfo>()}, + }}, {{ + }}, +}; + +::uint8_t* FlightInformationResponse::_InternalSerialize( + ::uint8_t* target, + ::google::protobuf::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:mavsdk.rpc.info.FlightInformationResponse) + ::uint32_t cached_has_bits = 0; + (void)cached_has_bits; + + cached_has_bits = _impl_._has_bits_[0]; + // .mavsdk.rpc.info.FlightInfo flight_info = 1; + if (cached_has_bits & 0x00000001u) { + target = ::google::protobuf::internal::WireFormatLite::InternalWriteMessage( + 1, _Internal::flight_info(this), + _Internal::flight_info(this).GetCachedSize(), target, stream); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = + ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::google::protobuf::UnknownFieldSet>(::google::protobuf::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:mavsdk.rpc.info.FlightInformationResponse) + return target; +} + +::size_t FlightInformationResponse::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:mavsdk.rpc.info.FlightInformationResponse) + ::size_t total_size = 0; + + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // .mavsdk.rpc.info.FlightInfo flight_info = 1; + cached_has_bits = _impl_._has_bits_[0]; + if (cached_has_bits & 0x00000001u) { + total_size += + 1 + ::google::protobuf::internal::WireFormatLite::MessageSize(*_impl_.flight_info_); + } + + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); +} + +const ::google::protobuf::Message::ClassData FlightInformationResponse::_class_data_ = { + FlightInformationResponse::MergeImpl, + nullptr, // OnDemandRegisterArenaDtor +}; +const ::google::protobuf::Message::ClassData* FlightInformationResponse::GetClassData() const { + return &_class_data_; +} + +void FlightInformationResponse::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:mavsdk.rpc.info.FlightInformationResponse) + ABSL_DCHECK_NE(&from, _this); + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + if ((from._impl_._has_bits_[0] & 0x00000001u) != 0) { + _this->_internal_mutable_flight_info()->::mavsdk::rpc::info::FlightInfo::MergeFrom( + from._internal_flight_info()); + } + _this->_internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>(from._internal_metadata_); +} + +void FlightInformationResponse::CopyFrom(const FlightInformationResponse& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:mavsdk.rpc.info.FlightInformationResponse) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +PROTOBUF_NOINLINE bool FlightInformationResponse::IsInitialized() const { + return true; +} + +::_pbi::CachedSize* FlightInformationResponse::AccessCachedSize() const { + return &_impl_._cached_size_; +} +void FlightInformationResponse::InternalSwap(FlightInformationResponse* PROTOBUF_RESTRICT other) { + using std::swap; + _internal_metadata_.InternalSwap(&other->_internal_metadata_); + swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); + swap(_impl_.flight_info_, other->_impl_.flight_info_); +} + +::google::protobuf::Metadata FlightInformationResponse::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_info_2finfo_2eproto_getter, &descriptor_table_info_2finfo_2eproto_once, + file_level_metadata_info_2finfo_2eproto[11]); +} +// =================================================================== + class FlightInfo::_Internal { public: }; @@ -2402,7 +2703,7 @@ void FlightInfo::InternalSwap(FlightInfo* PROTOBUF_RESTRICT other) { ::google::protobuf::Metadata FlightInfo::GetMetadata() const { return ::_pbi::AssignDescriptors( &descriptor_table_info_2finfo_2eproto_getter, &descriptor_table_info_2finfo_2eproto_once, - file_level_metadata_info_2finfo_2eproto[10]); + file_level_metadata_info_2finfo_2eproto[12]); } // =================================================================== @@ -2618,7 +2919,7 @@ void Identification::InternalSwap(Identification* PROTOBUF_RESTRICT other) { ::google::protobuf::Metadata Identification::GetMetadata() const { return ::_pbi::AssignDescriptors( &descriptor_table_info_2finfo_2eproto_getter, &descriptor_table_info_2finfo_2eproto_once, - file_level_metadata_info_2finfo_2eproto[11]); + file_level_metadata_info_2finfo_2eproto[13]); } // =================================================================== @@ -2903,7 +3204,7 @@ void Product::InternalSwap(Product* PROTOBUF_RESTRICT other) { ::google::protobuf::Metadata Product::GetMetadata() const { return ::_pbi::AssignDescriptors( &descriptor_table_info_2finfo_2eproto_getter, &descriptor_table_info_2finfo_2eproto_once, - file_level_metadata_info_2finfo_2eproto[12]); + file_level_metadata_info_2finfo_2eproto[14]); } // =================================================================== @@ -3368,7 +3669,7 @@ void Version::InternalSwap(Version* PROTOBUF_RESTRICT other) { ::google::protobuf::Metadata Version::GetMetadata() const { return ::_pbi::AssignDescriptors( &descriptor_table_info_2finfo_2eproto_getter, &descriptor_table_info_2finfo_2eproto_once, - file_level_metadata_info_2finfo_2eproto[13]); + file_level_metadata_info_2finfo_2eproto[15]); } // =================================================================== @@ -3584,7 +3885,7 @@ void InfoResult::InternalSwap(InfoResult* PROTOBUF_RESTRICT other) { ::google::protobuf::Metadata InfoResult::GetMetadata() const { return ::_pbi::AssignDescriptors( &descriptor_table_info_2finfo_2eproto_getter, &descriptor_table_info_2finfo_2eproto_once, - file_level_metadata_info_2finfo_2eproto[14]); + file_level_metadata_info_2finfo_2eproto[16]); } // @@protoc_insertion_point(namespace_scope) } // namespace info diff --git a/src/mavsdk_server/src/generated/info/info.pb.h b/src/mavsdk_server/src/generated/info/info.pb.h index 534a6fb739..53919b5f86 100644 --- a/src/mavsdk_server/src/generated/info/info.pb.h +++ b/src/mavsdk_server/src/generated/info/info.pb.h @@ -64,6 +64,9 @@ namespace info { class FlightInfo; struct FlightInfoDefaultTypeInternal; extern FlightInfoDefaultTypeInternal _FlightInfo_default_instance_; +class FlightInformationResponse; +struct FlightInformationResponseDefaultTypeInternal; +extern FlightInformationResponseDefaultTypeInternal _FlightInformationResponse_default_instance_; class GetFlightInformationRequest; struct GetFlightInformationRequestDefaultTypeInternal; extern GetFlightInformationRequestDefaultTypeInternal _GetFlightInformationRequest_default_instance_; @@ -103,6 +106,9 @@ extern InfoResultDefaultTypeInternal _InfoResult_default_instance_; class Product; struct ProductDefaultTypeInternal; extern ProductDefaultTypeInternal _Product_default_instance_; +class SubscribeFlightInformationRequest; +struct SubscribeFlightInformationRequestDefaultTypeInternal; +extern SubscribeFlightInformationRequestDefaultTypeInternal _SubscribeFlightInformationRequest_default_instance_; class Version; struct VersionDefaultTypeInternal; extern VersionDefaultTypeInternal _Version_default_instance_; @@ -254,7 +260,7 @@ class Version final : &_Version_default_instance_); } static constexpr int kIndexInFileMessages = - 13; + 15; friend void swap(Version& a, Version& b) { a.Swap(&b); @@ -538,6 +544,142 @@ class Version final : friend struct ::TableStruct_info_2finfo_2eproto; };// ------------------------------------------------------------------- +class SubscribeFlightInformationRequest final : + public ::google::protobuf::internal::ZeroFieldsBase /* @@protoc_insertion_point(class_definition:mavsdk.rpc.info.SubscribeFlightInformationRequest) */ { + public: + inline SubscribeFlightInformationRequest() : SubscribeFlightInformationRequest(nullptr) {} + template + explicit PROTOBUF_CONSTEXPR SubscribeFlightInformationRequest(::google::protobuf::internal::ConstantInitialized); + + inline SubscribeFlightInformationRequest(const SubscribeFlightInformationRequest& from) + : SubscribeFlightInformationRequest(nullptr, from) {} + SubscribeFlightInformationRequest(SubscribeFlightInformationRequest&& from) noexcept + : SubscribeFlightInformationRequest() { + *this = ::std::move(from); + } + + inline SubscribeFlightInformationRequest& operator=(const SubscribeFlightInformationRequest& from) { + CopyFrom(from); + return *this; + } + inline SubscribeFlightInformationRequest& operator=(SubscribeFlightInformationRequest&& from) noexcept { + if (this == &from) return *this; + if (GetArena() == from.GetArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + return _internal_metadata_.unknown_fields<::google::protobuf::UnknownFieldSet>(::google::protobuf::UnknownFieldSet::default_instance); + } + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() + ABSL_ATTRIBUTE_LIFETIME_BOUND { + return _internal_metadata_.mutable_unknown_fields<::google::protobuf::UnknownFieldSet>(); + } + + static const ::google::protobuf::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::google::protobuf::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::google::protobuf::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const SubscribeFlightInformationRequest& default_instance() { + return *internal_default_instance(); + } + static inline const SubscribeFlightInformationRequest* internal_default_instance() { + return reinterpret_cast( + &_SubscribeFlightInformationRequest_default_instance_); + } + static constexpr int kIndexInFileMessages = + 10; + + friend void swap(SubscribeFlightInformationRequest& a, SubscribeFlightInformationRequest& b) { + a.Swap(&b); + } + inline void Swap(SubscribeFlightInformationRequest* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetArena() != nullptr && + GetArena() == other->GetArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetArena() == other->GetArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::google::protobuf::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(SubscribeFlightInformationRequest* other) { + if (other == this) return; + ABSL_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + SubscribeFlightInformationRequest* New(::google::protobuf::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::google::protobuf::internal::ZeroFieldsBase::CopyFrom; + inline void CopyFrom(const SubscribeFlightInformationRequest& from) { + ::google::protobuf::internal::ZeroFieldsBase::CopyImpl(*this, from); + } + using ::google::protobuf::internal::ZeroFieldsBase::MergeFrom; + void MergeFrom(const SubscribeFlightInformationRequest& from) { + ::google::protobuf::internal::ZeroFieldsBase::MergeImpl(*this, from); + } + public: + + private: + friend class ::google::protobuf::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "mavsdk.rpc.info.SubscribeFlightInformationRequest"; + } + protected: + explicit SubscribeFlightInformationRequest(::google::protobuf::Arena* arena); + SubscribeFlightInformationRequest(::google::protobuf::Arena* arena, const SubscribeFlightInformationRequest& from); + public: + + ::google::protobuf::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + // @@protoc_insertion_point(class_scope:mavsdk.rpc.info.SubscribeFlightInformationRequest) + private: + class _Internal; + + friend class ::google::protobuf::MessageLite; + friend class ::google::protobuf::Arena; + template + friend class ::google::protobuf::Arena::InternalHelper; + using InternalArenaConstructable_ = void; + using DestructorSkippable_ = void; + struct Impl_ { + + inline explicit constexpr Impl_( + ::google::protobuf::internal::ConstantInitialized) noexcept; + inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena); + inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena, const Impl_& from); + PROTOBUF_TSAN_DECLARE_MEMBER + }; + friend struct ::TableStruct_info_2finfo_2eproto; +};// ------------------------------------------------------------------- + class Product final : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:mavsdk.rpc.info.Product) */ { public: @@ -597,7 +739,7 @@ class Product final : &_Product_default_instance_); } static constexpr int kIndexInFileMessages = - 12; + 14; friend void swap(Product& a, Product& b) { a.Swap(&b); @@ -820,7 +962,7 @@ class InfoResult final : &_InfoResult_default_instance_); } static constexpr int kIndexInFileMessages = - 14; + 16; friend void swap(InfoResult& a, InfoResult& b) { a.Swap(&b); @@ -1035,7 +1177,7 @@ class Identification final : &_Identification_default_instance_); } static constexpr int kIndexInFileMessages = - 11; + 13; friend void swap(Identification& a, Identification& b) { a.Swap(&b); @@ -1908,7 +2050,7 @@ class FlightInfo final : &_FlightInfo_default_instance_); } static constexpr int kIndexInFileMessages = - 10; + 12; friend void swap(FlightInfo& a, FlightInfo& b) { a.Swap(&b); @@ -3043,6 +3185,187 @@ class GetFlightInformationResponse final : }; union { Impl_ _impl_; }; friend struct ::TableStruct_info_2finfo_2eproto; +};// ------------------------------------------------------------------- + +class FlightInformationResponse final : + public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:mavsdk.rpc.info.FlightInformationResponse) */ { + public: + inline FlightInformationResponse() : FlightInformationResponse(nullptr) {} + ~FlightInformationResponse() override; + template + explicit PROTOBUF_CONSTEXPR FlightInformationResponse(::google::protobuf::internal::ConstantInitialized); + + inline FlightInformationResponse(const FlightInformationResponse& from) + : FlightInformationResponse(nullptr, from) {} + FlightInformationResponse(FlightInformationResponse&& from) noexcept + : FlightInformationResponse() { + *this = ::std::move(from); + } + + inline FlightInformationResponse& operator=(const FlightInformationResponse& from) { + CopyFrom(from); + return *this; + } + inline FlightInformationResponse& operator=(FlightInformationResponse&& from) noexcept { + if (this == &from) return *this; + if (GetArena() == from.GetArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + return _internal_metadata_.unknown_fields<::google::protobuf::UnknownFieldSet>(::google::protobuf::UnknownFieldSet::default_instance); + } + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() + ABSL_ATTRIBUTE_LIFETIME_BOUND { + return _internal_metadata_.mutable_unknown_fields<::google::protobuf::UnknownFieldSet>(); + } + + static const ::google::protobuf::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::google::protobuf::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::google::protobuf::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const FlightInformationResponse& default_instance() { + return *internal_default_instance(); + } + static inline const FlightInformationResponse* internal_default_instance() { + return reinterpret_cast( + &_FlightInformationResponse_default_instance_); + } + static constexpr int kIndexInFileMessages = + 11; + + friend void swap(FlightInformationResponse& a, FlightInformationResponse& b) { + a.Swap(&b); + } + inline void Swap(FlightInformationResponse* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetArena() != nullptr && + GetArena() == other->GetArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetArena() == other->GetArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::google::protobuf::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(FlightInformationResponse* other) { + if (other == this) return; + ABSL_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + FlightInformationResponse* New(::google::protobuf::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::google::protobuf::Message::CopyFrom; + void CopyFrom(const FlightInformationResponse& from); + using ::google::protobuf::Message::MergeFrom; + void MergeFrom( const FlightInformationResponse& from) { + FlightInformationResponse::MergeImpl(*this, from); + } + private: + static void MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg); + public: + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + ::size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::google::protobuf::internal::ParseContext* ctx) final; + ::uint8_t* _InternalSerialize( + ::uint8_t* target, ::google::protobuf::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const { return _impl_._cached_size_.Get(); } + + private: + ::google::protobuf::internal::CachedSize* AccessCachedSize() const final; + void SharedCtor(::google::protobuf::Arena* arena); + void SharedDtor(); + void InternalSwap(FlightInformationResponse* other); + + private: + friend class ::google::protobuf::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "mavsdk.rpc.info.FlightInformationResponse"; + } + protected: + explicit FlightInformationResponse(::google::protobuf::Arena* arena); + FlightInformationResponse(::google::protobuf::Arena* arena, const FlightInformationResponse& from); + public: + + static const ClassData _class_data_; + const ::google::protobuf::Message::ClassData*GetClassData() const final; + + ::google::protobuf::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kFlightInfoFieldNumber = 1, + }; + // .mavsdk.rpc.info.FlightInfo flight_info = 1; + bool has_flight_info() const; + void clear_flight_info() ; + const ::mavsdk::rpc::info::FlightInfo& flight_info() const; + PROTOBUF_NODISCARD ::mavsdk::rpc::info::FlightInfo* release_flight_info(); + ::mavsdk::rpc::info::FlightInfo* mutable_flight_info(); + void set_allocated_flight_info(::mavsdk::rpc::info::FlightInfo* value); + void unsafe_arena_set_allocated_flight_info(::mavsdk::rpc::info::FlightInfo* value); + ::mavsdk::rpc::info::FlightInfo* unsafe_arena_release_flight_info(); + + private: + const ::mavsdk::rpc::info::FlightInfo& _internal_flight_info() const; + ::mavsdk::rpc::info::FlightInfo* _internal_mutable_flight_info(); + + public: + // @@protoc_insertion_point(class_scope:mavsdk.rpc.info.FlightInformationResponse) + private: + class _Internal; + + friend class ::google::protobuf::internal::TcParser; + static const ::google::protobuf::internal::TcParseTable< + 0, 1, 1, + 0, 2> + _table_; + friend class ::google::protobuf::MessageLite; + friend class ::google::protobuf::Arena; + template + friend class ::google::protobuf::Arena::InternalHelper; + using InternalArenaConstructable_ = void; + using DestructorSkippable_ = void; + struct Impl_ { + + inline explicit constexpr Impl_( + ::google::protobuf::internal::ConstantInitialized) noexcept; + inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena); + inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena, const Impl_& from); + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable ::google::protobuf::internal::CachedSize _cached_size_; + ::mavsdk::rpc::info::FlightInfo* flight_info_; + PROTOBUF_TSAN_DECLARE_MEMBER + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_info_2finfo_2eproto; }; // =================================================================== @@ -3986,6 +4309,110 @@ inline void GetSpeedFactorResponse::_internal_set_speed_factor(double value) { // ------------------------------------------------------------------- +// SubscribeFlightInformationRequest + +// ------------------------------------------------------------------- + +// FlightInformationResponse + +// .mavsdk.rpc.info.FlightInfo flight_info = 1; +inline bool FlightInformationResponse::has_flight_info() const { + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; + PROTOBUF_ASSUME(!value || _impl_.flight_info_ != nullptr); + return value; +} +inline void FlightInformationResponse::clear_flight_info() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + if (_impl_.flight_info_ != nullptr) _impl_.flight_info_->Clear(); + _impl_._has_bits_[0] &= ~0x00000001u; +} +inline const ::mavsdk::rpc::info::FlightInfo& FlightInformationResponse::_internal_flight_info() const { + PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race); + const ::mavsdk::rpc::info::FlightInfo* p = _impl_.flight_info_; + return p != nullptr ? *p : reinterpret_cast(::mavsdk::rpc::info::_FlightInfo_default_instance_); +} +inline const ::mavsdk::rpc::info::FlightInfo& FlightInformationResponse::flight_info() const ABSL_ATTRIBUTE_LIFETIME_BOUND { + // @@protoc_insertion_point(field_get:mavsdk.rpc.info.FlightInformationResponse.flight_info) + return _internal_flight_info(); +} +inline void FlightInformationResponse::unsafe_arena_set_allocated_flight_info(::mavsdk::rpc::info::FlightInfo* value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + if (GetArena() == nullptr) { + delete reinterpret_cast<::google::protobuf::MessageLite*>(_impl_.flight_info_); + } + _impl_.flight_info_ = reinterpret_cast<::mavsdk::rpc::info::FlightInfo*>(value); + if (value != nullptr) { + _impl_._has_bits_[0] |= 0x00000001u; + } else { + _impl_._has_bits_[0] &= ~0x00000001u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:mavsdk.rpc.info.FlightInformationResponse.flight_info) +} +inline ::mavsdk::rpc::info::FlightInfo* FlightInformationResponse::release_flight_info() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + + _impl_._has_bits_[0] &= ~0x00000001u; + ::mavsdk::rpc::info::FlightInfo* released = _impl_.flight_info_; + _impl_.flight_info_ = nullptr; +#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE + auto* old = reinterpret_cast<::google::protobuf::MessageLite*>(released); + released = ::google::protobuf::internal::DuplicateIfNonNull(released); + if (GetArena() == nullptr) { + delete old; + } +#else // PROTOBUF_FORCE_COPY_IN_RELEASE + if (GetArena() != nullptr) { + released = ::google::protobuf::internal::DuplicateIfNonNull(released); + } +#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE + return released; +} +inline ::mavsdk::rpc::info::FlightInfo* FlightInformationResponse::unsafe_arena_release_flight_info() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + // @@protoc_insertion_point(field_release:mavsdk.rpc.info.FlightInformationResponse.flight_info) + + _impl_._has_bits_[0] &= ~0x00000001u; + ::mavsdk::rpc::info::FlightInfo* temp = _impl_.flight_info_; + _impl_.flight_info_ = nullptr; + return temp; +} +inline ::mavsdk::rpc::info::FlightInfo* FlightInformationResponse::_internal_mutable_flight_info() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_._has_bits_[0] |= 0x00000001u; + if (_impl_.flight_info_ == nullptr) { + auto* p = CreateMaybeMessage<::mavsdk::rpc::info::FlightInfo>(GetArena()); + _impl_.flight_info_ = reinterpret_cast<::mavsdk::rpc::info::FlightInfo*>(p); + } + return _impl_.flight_info_; +} +inline ::mavsdk::rpc::info::FlightInfo* FlightInformationResponse::mutable_flight_info() ABSL_ATTRIBUTE_LIFETIME_BOUND { + ::mavsdk::rpc::info::FlightInfo* _msg = _internal_mutable_flight_info(); + // @@protoc_insertion_point(field_mutable:mavsdk.rpc.info.FlightInformationResponse.flight_info) + return _msg; +} +inline void FlightInformationResponse::set_allocated_flight_info(::mavsdk::rpc::info::FlightInfo* value) { + ::google::protobuf::Arena* message_arena = GetArena(); + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + if (message_arena == nullptr) { + delete reinterpret_cast<::mavsdk::rpc::info::FlightInfo*>(_impl_.flight_info_); + } + + if (value != nullptr) { + ::google::protobuf::Arena* submessage_arena = reinterpret_cast<::mavsdk::rpc::info::FlightInfo*>(value)->GetArena(); + if (message_arena != submessage_arena) { + value = ::google::protobuf::internal::GetOwnedMessage(message_arena, value, submessage_arena); + } + _impl_._has_bits_[0] |= 0x00000001u; + } else { + _impl_._has_bits_[0] &= ~0x00000001u; + } + + _impl_.flight_info_ = reinterpret_cast<::mavsdk::rpc::info::FlightInfo*>(value); + // @@protoc_insertion_point(field_set_allocated:mavsdk.rpc.info.FlightInformationResponse.flight_info) +} + +// ------------------------------------------------------------------- + // FlightInfo // uint32 time_boot_ms = 1; diff --git a/src/mavsdk_server/src/plugins/info/info_service_impl.h b/src/mavsdk_server/src/plugins/info/info_service_impl.h index f5e96216aa..cf0155fcbc 100644 --- a/src/mavsdk_server/src/plugins/info/info_service_impl.h +++ b/src/mavsdk_server/src/plugins/info/info_service_impl.h @@ -405,6 +405,48 @@ class InfoServiceImpl final : public rpc::info::InfoService::Service { return grpc::Status::OK; } + grpc::Status SubscribeFlightInformation( + grpc::ServerContext* /* context */, + const mavsdk::rpc::info::SubscribeFlightInformationRequest* /* request */, + grpc::ServerWriter* writer) override + { + if (_lazy_plugin.maybe_plugin() == nullptr) { + return grpc::Status::OK; + } + + auto stream_closed_promise = std::make_shared>(); + auto stream_closed_future = stream_closed_promise->get_future(); + register_stream_stop_promise(stream_closed_promise); + + auto is_finished = std::make_shared(false); + auto subscribe_mutex = std::make_shared(); + + const mavsdk::Info::FlightInformationHandle handle = + _lazy_plugin.maybe_plugin()->subscribe_flight_information( + [this, &writer, &stream_closed_promise, is_finished, subscribe_mutex, &handle]( + const mavsdk::Info::FlightInfo flight_information) { + rpc::info::FlightInformationResponse rpc_response; + + rpc_response.set_allocated_flight_info( + translateToRpcFlightInfo(flight_information).release()); + + std::unique_lock lock(*subscribe_mutex); + if (!*is_finished && !writer->Write(rpc_response)) { + _lazy_plugin.maybe_plugin()->unsubscribe_flight_information(handle); + + *is_finished = true; + unregister_stream_stop_promise(stream_closed_promise); + stream_closed_promise->set_value(); + } + }); + + stream_closed_future.wait(); + std::unique_lock lock(*subscribe_mutex); + *is_finished = true; + + return grpc::Status::OK; + } + void stop() { _stopped.store(true);