• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mavlink / MAVSDK / 22121965442

18 Feb 2026 12:52AM UTC coverage: 48.988% (-0.02%) from 49.009%
22121965442

Pull #2769

github

web-flow
Merge 6d7328dc3 into 72946bd67
Pull Request #2769: core: add set_callback_executor API for custom callback dispatch

10 of 42 new or added lines in 3 files covered. (23.81%)

7 existing lines in 5 files now uncovered.

18362 of 37483 relevant lines covered (48.99%)

671.51 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

58.24
/cpp/src/mavsdk/core/mavsdk.cpp
1
#include "mavsdk.h"
2

3
#include "mavsdk_impl.h"
4

5
namespace mavsdk {
6

7
Mavsdk::Mavsdk(Configuration configuration)
148✔
8
{
9
    _impl = std::make_shared<MavsdkImpl>(configuration);
148✔
10
}
148✔
11

12
Mavsdk::~Mavsdk() = default;
148✔
13

14
std::string Mavsdk::version() const
1✔
15
{
16
    return _impl->version();
1✔
17
}
18

19
ConnectionResult
20
Mavsdk::add_any_connection(const std::string& connection_url, ForwardingOption forwarding_option)
142✔
21
{
22
    return _impl->add_any_connection(connection_url, forwarding_option).first;
142✔
23
}
24

25
std::pair<ConnectionResult, Mavsdk::ConnectionHandle> Mavsdk::add_any_connection_with_handle(
12✔
26
    const std::string& connection_url, ForwardingOption forwarding_option)
27
{
28
    return _impl->add_any_connection(connection_url, forwarding_option);
12✔
29
}
30

31
void Mavsdk::remove_connection(ConnectionHandle handle)
12✔
32
{
33
    _impl->remove_connection(handle);
12✔
34
}
12✔
35

36
std::vector<std::shared_ptr<System>> Mavsdk::systems() const
58✔
37
{
38
    return _impl->systems();
58✔
39
}
40

41
std::optional<std::shared_ptr<System>> Mavsdk::first_autopilot(double timeout_s) const
62✔
42
{
43
    return _impl->first_autopilot(timeout_s);
62✔
44
}
45

46
void Mavsdk::set_configuration(Configuration configuration)
×
47
{
48
    _impl->set_configuration(configuration);
×
49
}
×
50

51
void Mavsdk::set_timeout_s(double timeout_s)
64✔
52
{
53
    _impl->set_timeout_s(timeout_s);
64✔
54
}
64✔
55

56
void Mavsdk::set_heartbeat_timeout_s(double timeout_s)
×
57
{
58
    _impl->set_heartbeat_timeout_s(timeout_s);
×
59
}
×
60

61
double Mavsdk::get_heartbeat_timeout_s() const
×
62
{
63
    return _impl->heartbeat_timeout_s();
×
64
}
65

NEW
66
void Mavsdk::set_callback_executor(std::function<void(std::function<void()>)> executor)
×
67
{
NEW
68
    _impl->set_callback_executor(std::move(executor));
×
NEW
69
}
×
70

71
Mavsdk::NewSystemHandle Mavsdk::subscribe_on_new_system(const NewSystemCallback& callback)
10✔
72
{
73
    return _impl->subscribe_on_new_system(callback);
10✔
74
}
75

76
void Mavsdk::unsubscribe_on_new_system(NewSystemHandle handle)
9✔
77
{
78
    _impl->unsubscribe_on_new_system(handle);
9✔
79
}
9✔
80

81
std::shared_ptr<ServerComponent> Mavsdk::server_component(unsigned instance)
58✔
82
{
83
    return _impl->server_component(instance);
58✔
84
}
85

86
std::shared_ptr<ServerComponent>
87
Mavsdk::server_component_by_type(ComponentType server_component_type, unsigned instance)
×
88
{
89
    return _impl->server_component_by_type(server_component_type, instance);
×
90
}
91

92
std::shared_ptr<ServerComponent> Mavsdk::server_component_by_id(uint8_t component_id)
×
93
{
94
    return _impl->server_component_by_id(component_id, _impl->get_mav_type());
×
95
}
96

97
Mavsdk::Configuration::Configuration(
×
98
    uint8_t system_id, uint8_t component_id, bool always_send_heartbeats) :
×
99
    _system_id(system_id),
×
100
    _component_id(component_id),
×
101
    _always_send_heartbeats(always_send_heartbeats),
×
102
    _component_type(component_type_for_component_id(component_id)),
×
103
    _mav_type(static_cast<MAV_TYPE>(
×
104
        MavsdkImpl::mav_type_for_component_type(component_type_for_component_id(component_id))))
×
105
{}
×
106

107
ComponentType Mavsdk::Configuration::component_type_for_component_id(uint8_t component_id)
×
108
{
109
    switch (component_id) {
×
110
        case Mavsdk::DEFAULT_COMPONENT_ID_AUTOPILOT:
×
111
            return ComponentType::Autopilot;
×
112
        case Mavsdk::DEFAULT_COMPONENT_ID_GCS:
×
113
            return ComponentType::GroundStation;
×
114
        case Mavsdk::DEFAULT_COMPONENT_ID_CC:
×
115
            return ComponentType::CompanionComputer;
×
116
        case Mavsdk::DEFAULT_COMPONENT_ID_CAMERA:
×
117
            return ComponentType::Camera;
×
118
        case Mavsdk::DEFAULT_COMPONENT_ID_GIMBAL:
×
119
            return ComponentType::Gimbal;
×
120
        case Mavsdk::DEFAULT_COMPONENT_ID_REMOTEID:
×
121
            return ComponentType::RemoteId;
×
122
        default:
×
123
            return ComponentType::Custom;
×
124
    }
125
}
126

127
Mavsdk::Configuration::Configuration(ComponentType component_type) :
297✔
128
    _system_id(Mavsdk::DEFAULT_SYSTEM_ID_GCS),
297✔
129
    _component_id(Mavsdk::DEFAULT_COMPONENT_ID_GCS),
297✔
130
    _always_send_heartbeats(false),
297✔
131
    _component_type(component_type),
297✔
132
    _mav_type(static_cast<MAV_TYPE>(MavsdkImpl::mav_type_for_component_type(component_type)))
297✔
133
{
134
    switch (component_type) {
297✔
135
        case ComponentType::GroundStation:
222✔
136
            _system_id = Mavsdk::DEFAULT_SYSTEM_ID_GCS;
222✔
137
            _component_id = Mavsdk::DEFAULT_COMPONENT_ID_GCS;
222✔
138
            _always_send_heartbeats = false;
222✔
139
            break;
222✔
140
        case ComponentType::CompanionComputer:
3✔
141
            // TODO implement auto-detection of system ID - maybe from heartbeats?
142
            _system_id = Mavsdk::DEFAULT_SYSTEM_ID_CC;
3✔
143
            _component_id = Mavsdk::DEFAULT_COMPONENT_ID_CC;
3✔
144
            _always_send_heartbeats = true;
3✔
145
            break;
3✔
146
        case ComponentType::Autopilot:
63✔
147
            _system_id = Mavsdk::DEFAULT_SYSTEM_ID_AUTOPILOT;
63✔
148
            _component_id = Mavsdk::DEFAULT_COMPONENT_ID_AUTOPILOT;
63✔
149
            _always_send_heartbeats = true;
63✔
150
            break;
63✔
151
        case ComponentType::Camera:
9✔
152
            _system_id = Mavsdk::DEFAULT_SYSTEM_ID_CAMERA;
9✔
153
            _component_id = Mavsdk::DEFAULT_COMPONENT_ID_CAMERA;
9✔
154
            _always_send_heartbeats = true;
9✔
155
            break;
9✔
156
        case ComponentType::Gimbal:
×
157
            _system_id = Mavsdk::DEFAULT_SYSTEM_ID_GIMBAL;
×
158
            _component_id = Mavsdk::DEFAULT_COMPONENT_ID_GIMBAL;
×
159
            _always_send_heartbeats = true;
×
160
            break;
×
161
        case ComponentType::RemoteId:
×
162
            _system_id = Mavsdk::DEFAULT_SYSTEM_ID_REMOTEID;
×
163
            _component_id = Mavsdk::DEFAULT_COMPONENT_ID_REMOTEID;
×
164
            _always_send_heartbeats = true;
×
165
            break;
×
166
        default:
×
167
            break;
×
168
    }
169
}
297✔
170

171
uint8_t Mavsdk::Configuration::get_system_id() const
221✔
172
{
173
    return _system_id;
221✔
174
}
175

176
void Mavsdk::Configuration::set_system_id(uint8_t system_id)
×
177
{
178
    _system_id = system_id;
×
179
}
×
180

181
uint8_t Mavsdk::Configuration::get_component_id() const
442✔
182
{
183
    return _component_id;
442✔
184
}
185

186
void Mavsdk::Configuration::set_component_id(uint8_t component_id)
×
187
{
188
    _component_id = component_id;
×
189
}
×
190

191
bool Mavsdk::Configuration::get_always_send_heartbeats() const
590✔
192
{
193
    return _always_send_heartbeats;
590✔
194
}
195

196
void Mavsdk::Configuration::set_always_send_heartbeats(bool always_send_heartbeats)
73✔
197
{
198
    _always_send_heartbeats = always_send_heartbeats;
73✔
199
}
73✔
200

201
ComponentType Mavsdk::Configuration::get_component_type() const
18,670✔
202
{
203
    return _component_type;
18,670✔
204
}
205

206
void Mavsdk::Configuration::set_component_type(ComponentType component_type)
×
207
{
208
    _component_type = component_type;
×
209
}
×
210

211
uint8_t Mavsdk::Configuration::get_mav_type() const
223✔
212
{
213
    return _mav_type;
223✔
214
}
215

216
void Mavsdk::Configuration::set_mav_type(uint8_t mav_type)
1✔
217
{
218
    _mav_type = static_cast<MAV_TYPE>(mav_type);
1✔
219
}
1✔
220

221
Autopilot Mavsdk::Configuration::get_autopilot() const
254✔
222
{
223
    return _autopilot;
254✔
224
}
225

226
void Mavsdk::Configuration::set_autopilot(Autopilot autopilot)
×
227
{
228
    _autopilot = autopilot;
×
229
}
×
230

231
CompatibilityMode Mavsdk::Configuration::get_compatibility_mode() const
1,567✔
232
{
233
    return _compatibility_mode;
1,567✔
234
}
235

236
void Mavsdk::Configuration::set_compatibility_mode(CompatibilityMode mode)
×
237
{
238
    _compatibility_mode = mode;
×
239
}
×
240

241
void Mavsdk::intercept_incoming_messages_async(std::function<bool(mavlink_message_t&)> callback)
28✔
242
{
243
    _impl->intercept_incoming_messages_async(callback);
28✔
244
}
28✔
245

246
void Mavsdk::intercept_outgoing_messages_async(std::function<bool(mavlink_message_t&)> callback)
16✔
247
{
248
    _impl->intercept_outgoing_messages_async(callback);
16✔
249
}
16✔
250

251
void Mavsdk::pass_received_raw_bytes(const char* bytes, size_t length)
1✔
252
{
253
    _impl->pass_received_raw_bytes(bytes, length);
1✔
254
}
1✔
255

256
Mavsdk::RawBytesHandle Mavsdk::subscribe_raw_bytes_to_be_sent(RawBytesCallback callback)
1✔
257
{
258
    return _impl->subscribe_raw_bytes_to_be_sent(callback);
1✔
259
}
260

261
void Mavsdk::unsubscribe_raw_bytes_to_be_sent(RawBytesHandle handle)
1✔
262
{
263
    _impl->unsubscribe_raw_bytes_to_be_sent(handle);
1✔
264
}
1✔
265

266
Mavsdk::ConnectionErrorHandle
267
Mavsdk::subscribe_connection_errors(Mavsdk::ConnectionErrorCallback callback)
×
268
{
269
    return _impl->subscribe_connection_errors(callback);
×
270
}
271

272
void Mavsdk::unsubscribe_connection_errors(ConnectionErrorHandle handle)
×
273
{
274
    return _impl->unsubscribe_connection_errors(handle);
×
275
}
276

277
Mavsdk::InterceptJsonHandle
278
Mavsdk::subscribe_incoming_messages_json(const InterceptJsonCallback& callback)
1✔
279
{
280
    return _impl->subscribe_incoming_messages_json(callback);
1✔
281
}
282

283
void Mavsdk::unsubscribe_incoming_messages_json(InterceptJsonHandle handle)
1✔
284
{
285
    _impl->unsubscribe_incoming_messages_json(handle);
1✔
286
}
1✔
287

288
Mavsdk::InterceptJsonHandle
289
Mavsdk::subscribe_outgoing_messages_json(const InterceptJsonCallback& callback)
1✔
290
{
291
    return _impl->subscribe_outgoing_messages_json(callback);
1✔
292
}
293

294
void Mavsdk::unsubscribe_outgoing_messages_json(InterceptJsonHandle handle)
1✔
295
{
296
    _impl->unsubscribe_outgoing_messages_json(handle);
1✔
297
}
1✔
298

299
} // namespace mavsdk
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc