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

mavlink / MAVSDK / 5227557003

pending completion
5227557003

push

github

web-flow
Merge pull request #2077 from mavlink/pr-remove-always-connected

core: remove always connected flag

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

7689 of 24891 relevant lines covered (30.89%)

21.06 hits per line

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

18.75
/src/mavsdk/core/ping.cpp
1
#include "log.h"
2
#include "ping.h"
3
#include "system_impl.h"
4

5
namespace mavsdk {
6

7
Ping::Ping(SystemImpl& system_impl) : _system_impl(system_impl)
20✔
8
{
9
    _system_impl.register_mavlink_message_handler(
20✔
10
        MAVLINK_MSG_ID_PING,
11
        [this](const mavlink_message_t& message) { Ping::process_ping(message); },
×
12
        this);
13
}
20✔
14

15
Ping::~Ping()
40✔
16
{
17
    _system_impl.unregister_all_mavlink_message_handlers(this);
20✔
18
}
20✔
19

20
void Ping::run_once()
×
21
{
22
    mavlink_message_t message;
×
23

24
    mavlink_msg_ping_pack(
×
25
        _system_impl.get_own_system_id(),
×
26
        _system_impl.get_own_component_id(),
×
27
        &message,
28
        _system_impl.get_time().elapsed_us(),
×
29
        _ping_sequence,
30
        0,
31
        0); // to all
32

33
    _system_impl.send_message(message);
×
34
}
×
35

36
void Ping::process_ping(const mavlink_message_t& message)
×
37
{
38
    mavlink_ping_t ping;
×
39
    mavlink_msg_ping_decode(&message, &ping);
×
40

41
    if (ping.target_system == 0 && ping.target_component == 0) {
×
42
        // Response to ping request.
43
        mavlink_message_t response_message;
×
44
        mavlink_msg_ping_pack(
×
45
            _system_impl.get_own_system_id(),
×
46
            _system_impl.get_own_component_id(),
×
47
            &response_message,
48
            ping.time_usec,
49
            ping.seq,
50
            message.sysid,
×
51
            message.compid);
×
52

53
        _system_impl.send_message(response_message);
×
54

55
    } else {
56
        // Answer from ping request.
57
        if (ping.seq != _ping_sequence) {
×
58
            LogWarn() << "Ignoring unknown ping sequence";
×
59
            return;
×
60
        }
61

62
        if (message.compid != MAV_COMP_ID_AUTOPILOT1) {
×
63
            // We're currently only interested in the ping of the autopilot.
64
            return;
×
65
        }
66

67
        _last_ping_time_us = _system_impl.get_time().elapsed_us() - ping.time_usec;
×
68
    }
69
}
70

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