-
Notifications
You must be signed in to change notification settings - Fork 0
/
tello.js
executable file
·36 lines (32 loc) · 1.09 KB
/
tello.js
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
const dgram = require("dgram");
const server = dgram.createSocket("udp4");
server.bind(8001);
function sendMessage(message_text) {
let message = new Buffer(message_text);
let port = 8889;
let host = "192.168.10.1";
server.send(message, 0, message.length, port, host, function (err, bytes) {
if (err) throw err;
});
}
module.exports.init = () => {
server.on("message", (msg, info) => {
console.log("Data received from server : " + msg.toString());
console.log(info);
console.log(
"Received %d bytes from %s:%d\n",
msg.length,
info.address,
info.port
);
});
sendMessage("command");
};
module.exports.exit = () => server.close();
module.exports.takeoff = () => sendMessage("takeoff");
module.exports.land = () => sendMessage("land");
module.exports.speed = (value) => sendMessage("speed " + value);
module.exports.up = (value) => sendMessage("up " + value);
module.exports.down = (value) => sendMessage("down " + value);
module.exports.battery = () => sendMessage("battery?");
module.exports.forward = (distance) => sendMessage("forward " + distance);