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

mavlink / MAVSDK / 11767930807

10 Nov 2024 07:33PM UTC coverage: 38.608% (+0.7%) from 37.921%
11767930807

push

github

web-flow
Merge pull request #2394 from mavlink/pr-consolidate-ci

Consolidate CI

12030 of 31159 relevant lines covered (38.61%)

243.33 hits per line

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

54.1
/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)
71✔
8
{
9
    _impl = std::make_shared<MavsdkImpl>(configuration);
71✔
10
}
71✔
11

12
Mavsdk::~Mavsdk() = default;
71✔
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)
70✔
21
{
22
    return _impl->add_any_connection(connection_url, forwarding_option).first;
70✔
23
}
24

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

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

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

41
std::optional<std::shared_ptr<System>> Mavsdk::first_autopilot(double timeout_s) const
33✔
42
{
43
    return _impl->first_autopilot(timeout_s);
33✔
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)
60✔
52
{
53
    _impl->set_timeout_s(timeout_s);
60✔
54
}
60✔
55

56
Mavsdk::NewSystemHandle Mavsdk::subscribe_on_new_system(const NewSystemCallback& callback)
2✔
57
{
58
    return _impl->subscribe_on_new_system(callback);
2✔
59
}
60

61
void Mavsdk::unsubscribe_on_new_system(NewSystemHandle handle)
1✔
62
{
63
    _impl->unsubscribe_on_new_system(handle);
1✔
64
}
1✔
65

66
std::shared_ptr<ServerComponent> Mavsdk::server_component(unsigned instance)
35✔
67
{
68
    return _impl->server_component(instance);
35✔
69
}
70

71
std::shared_ptr<ServerComponent>
72
Mavsdk::server_component_by_type(ComponentType server_component_type, unsigned instance)
×
73
{
74
    return _impl->server_component_by_type(server_component_type, instance);
×
75
}
76

77
std::shared_ptr<ServerComponent> Mavsdk::server_component_by_id(uint8_t component_id)
×
78
{
79
    return _impl->server_component_by_id(component_id);
×
80
}
81

82
Mavsdk::Configuration::Configuration(
×
83
    uint8_t system_id, uint8_t component_id, bool always_send_heartbeats) :
×
84
    _system_id(system_id),
×
85
    _component_id(component_id),
×
86
    _always_send_heartbeats(always_send_heartbeats),
×
87
    _component_type(component_type_for_component_id(component_id))
×
88
{}
×
89

90
ComponentType Mavsdk::Configuration::component_type_for_component_id(uint8_t component_id)
×
91
{
92
    switch (component_id) {
×
93
        case Mavsdk::DEFAULT_COMPONENT_ID_AUTOPILOT:
×
94
            return ComponentType::Autopilot;
×
95
        case Mavsdk::DEFAULT_COMPONENT_ID_GCS:
×
96
            return ComponentType::GroundStation;
×
97
        case Mavsdk::DEFAULT_COMPONENT_ID_CC:
×
98
            return ComponentType::CompanionComputer;
×
99
        case Mavsdk::DEFAULT_COMPONENT_ID_CAMERA:
×
100
            return ComponentType::Camera;
×
101
        case Mavsdk::DEFAULT_COMPONENT_ID_GIMBAL:
×
102
            return ComponentType::Gimbal;
×
103
        case Mavsdk::DEFAULT_COMPONENT_ID_REMOTEID:
×
104
            return ComponentType::RemoteId;
×
105
        default:
×
106
            return ComponentType::Custom;
×
107
    }
108
}
109

110
Mavsdk::Configuration::Configuration(ComponentType component_type) :
142✔
111
    _system_id(Mavsdk::DEFAULT_SYSTEM_ID_GCS),
142✔
112
    _component_id(Mavsdk::DEFAULT_COMPONENT_ID_GCS),
142✔
113
    _always_send_heartbeats(false),
142✔
114
    _component_type(component_type)
142✔
115
{
116
    switch (component_type) {
142✔
117
        case ComponentType::GroundStation:
107✔
118
            _system_id = Mavsdk::DEFAULT_SYSTEM_ID_GCS;
107✔
119
            _component_id = Mavsdk::DEFAULT_COMPONENT_ID_GCS;
107✔
120
            _always_send_heartbeats = false;
107✔
121
            break;
107✔
122
        case ComponentType::CompanionComputer:
1✔
123
            // TODO implement auto-detection of system ID - maybe from heartbeats?
124
            _system_id = Mavsdk::DEFAULT_SYSTEM_ID_CC;
1✔
125
            _component_id = Mavsdk::DEFAULT_COMPONENT_ID_CC;
1✔
126
            _always_send_heartbeats = true;
1✔
127
            break;
1✔
128
        case ComponentType::Autopilot:
33✔
129
            _system_id = Mavsdk::DEFAULT_SYSTEM_ID_AUTOPILOT;
33✔
130
            _component_id = Mavsdk::DEFAULT_COMPONENT_ID_AUTOPILOT;
33✔
131
            _always_send_heartbeats = true;
33✔
132
            break;
33✔
133
        case ComponentType::Camera:
1✔
134
            _system_id = Mavsdk::DEFAULT_SYSTEM_ID_CAMERA;
1✔
135
            _component_id = Mavsdk::DEFAULT_COMPONENT_ID_CAMERA;
1✔
136
            _always_send_heartbeats = true;
1✔
137
            break;
1✔
138
        case ComponentType::Gimbal:
×
139
            _system_id = Mavsdk::DEFAULT_SYSTEM_ID_GIMBAL;
×
140
            _component_id = Mavsdk::DEFAULT_COMPONENT_ID_GIMBAL;
×
141
            _always_send_heartbeats = true;
×
142
            break;
×
143
        case ComponentType::RemoteId:
×
144
            _system_id = Mavsdk::DEFAULT_SYSTEM_ID_REMOTEID;
×
145
            _component_id = Mavsdk::DEFAULT_COMPONENT_ID_REMOTEID;
×
146
            _always_send_heartbeats = true;
×
147
            break;
×
148
        default:
×
149
            break;
×
150
    }
151
}
142✔
152

153
uint8_t Mavsdk::Configuration::get_system_id() const
4,247✔
154
{
155
    return _system_id;
4,247✔
156
}
157

158
void Mavsdk::Configuration::set_system_id(uint8_t system_id)
×
159
{
160
    _system_id = system_id;
×
161
}
×
162

163
uint8_t Mavsdk::Configuration::get_component_id() const
1,310✔
164
{
165
    return _component_id;
1,310✔
166
}
167

168
void Mavsdk::Configuration::set_component_id(uint8_t component_id)
×
169
{
170
    _component_id = component_id;
×
171
}
×
172

173
bool Mavsdk::Configuration::get_always_send_heartbeats() const
280✔
174
{
175
    return _always_send_heartbeats;
280✔
176
}
177

178
void Mavsdk::Configuration::set_always_send_heartbeats(bool always_send_heartbeats)
34✔
179
{
180
    _always_send_heartbeats = always_send_heartbeats;
34✔
181
}
34✔
182

183
ComponentType Mavsdk::Configuration::get_component_type() const
1,702✔
184
{
185
    return _component_type;
1,702✔
186
}
187

188
void Mavsdk::Configuration::set_component_type(ComponentType component_type)
×
189
{
190
    _component_type = component_type;
×
191
}
×
192

193
void Mavsdk::intercept_incoming_messages_async(std::function<bool(mavlink_message_t&)> callback)
22✔
194
{
195
    _impl->intercept_incoming_messages_async(callback);
22✔
196
}
22✔
197

198
void Mavsdk::intercept_outgoing_messages_async(std::function<bool(mavlink_message_t&)> callback)
14✔
199
{
200
    _impl->intercept_outgoing_messages_async(callback);
14✔
201
}
14✔
202

203
} // 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