-
Notifications
You must be signed in to change notification settings - Fork 1
/
TFUNIPAYLOAD.ino
57 lines (42 loc) · 1.33 KB
/
TFUNIPAYLOAD.ino
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "ArduinoMavlink.h"
#include <HardwareSerial.h>
HardwareSerial &hs = Serial1;
ArduinoMavlink mav(hs);
unsigned long current_ms;
unsigned long heartbeat_previous_time = 0;
const long heartbeat_period = 500;
unsigned long data_previous_time = 0;
const long data_period = 1000;
boolean led_status = false;
//uint8_t data[] = "Hello World!";
uint8_t data[2];
void setup() {
Serial.begin(57600);
while(!mav.begin()){
Serial.println("Not Connected!");
delay(250);
}
mav.Stream();
delay(2000);
}
void loop() {
// periodical stuff
current_ms = millis();
if( current_ms > (heartbeat_previous_time + heartbeat_period)){
heartbeat_previous_time = current_ms;
mav.SendHeartBeat();
// mav.SendTunnelData(data, 10, 0, 1, 1);
}
if( current_ms > (data_previous_time + data_period)){
data_previous_time = current_ms;
data[0] = random(255);
data[1] = random(255);
// data array (max length 128), data array size, data type (0 default - unknown), target sysid, target compid
// For unicast (only for logging purposes) set sysid and compid to match the autopilot. For realtime visualisation, you can
// set sysid and comid to broadcast (0, 0)
mav.SendTunnelData(data, sizeof(data), 0, 0, 0);
led_status = !led_status;
digitalWrite(13, led_status);
}
delay(10);
}