forked from dronekit/dronekit-la
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathheart.cpp
37 lines (29 loc) · 822 Bytes
/
heart.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "heart.h"
#include "util.h"
#include "la-log.h"
void Heart::idle_10Hz()
{
uint64_t now_us = clock_gettime_us(CLOCK_MONOTONIC);
if (last_heartbeat_time + heartbeat_interval < now_us) {
last_heartbeat_time = now_us;
beat();
}
}
bool Heart::configure(INIReader *config) {
if (!MAVLink_Message_Handler::configure(config)) {
return false;
}
return true;
}
void Heart::beat()
{
mavlink_message_t msg;
uint8_t type = MAV_TYPE_GCS;
uint8_t autopilot = MAV_AUTOPILOT_INVALID;
uint8_t base_mode = 0;
uint32_t custom_mode = 0;
uint8_t system_status = 0;
la_log(LOG_DEBUG, "mh-h: sending heartbeat");
mavlink_msg_heartbeat_pack(system_id, component_id, &msg, type, autopilot, base_mode, custom_mode, system_status);
_mavlink_writer->send_message(msg);
}