I have built a simple Node JS program to interface with the Tello SDK. This program just runs in the console on a windows machine. My Tello will only respond to the "command", "takeoff" and "land" commands. Please see code below. Could anyone educate me as to why this code is not working. Thank you in advance.
const readline = require("readline");
const { createSocket } = require("dgram");
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
const PORT = 8889;
const HOST = "192.168.10.1";
const socket = createSocket("udp4");
socket.bind(PORT);
socket.send("command", 0, 7, PORT, HOST);
rl.on('line', (input) => {
if (input == 't') {
socket.send("takeoff", 0, 7, PORT, HOST);
console.log("takeoff")
}
if (input == 'l') {
socket.send("land", 0, 4, PORT, HOST);
console.log("land")
}
if (input == 'f') {
socket.send("forward 200", 0, 11, PORT, HOST)
console.log("forward 200")
}
if (input == 'b') {
socket.send("back 200", 0, 8, PORT, HOST)
console.log("back 200")
}
if (input == 'r') {
socket.send("right 200", 0, 9, PORT, HOST)
console.log("right 200")
}
if (input == 'le') {
socket.send("left 200", 0, 8, PORT, HOST)
console.log("left 200")
}
if (input == 'u') {
socket.send("up 200", 0, 6, PORT, HOST)
console.log("up 200")
}
if (input == 'd') {
socket.send("down 200", 0, 8, PORT, HOST)
console.log("down 200")
}
});
const readline = require("readline");
const { createSocket } = require("dgram");
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
const PORT = 8889;
const HOST = "192.168.10.1";
const socket = createSocket("udp4");
socket.bind(PORT);
socket.send("command", 0, 7, PORT, HOST);
rl.on('line', (input) => {
if (input == 't') {
socket.send("takeoff", 0, 7, PORT, HOST);
console.log("takeoff")
}
if (input == 'l') {
socket.send("land", 0, 4, PORT, HOST);
console.log("land")
}
if (input == 'f') {
socket.send("forward 200", 0, 11, PORT, HOST)
console.log("forward 200")
}
if (input == 'b') {
socket.send("back 200", 0, 8, PORT, HOST)
console.log("back 200")
}
if (input == 'r') {
socket.send("right 200", 0, 9, PORT, HOST)
console.log("right 200")
}
if (input == 'le') {
socket.send("left 200", 0, 8, PORT, HOST)
console.log("left 200")
}
if (input == 'u') {
socket.send("up 200", 0, 6, PORT, HOST)
console.log("up 200")
}
if (input == 'd') {
socket.send("down 200", 0, 8, PORT, HOST)
console.log("down 200")
}
});