Created
April 28, 2018 01:04
-
-
Save gchiu/1c026e671b4a973587dbce2a231203d6 to your computer and use it in GitHub Desktop.
tello client in ren-c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rebol [ | |
date: 28-April-2018 | |
title: "simple tello client" | |
author: "Graham" | |
] | |
attempt [close tello] | |
okbin: to binary! {OK} | |
commands: copy [2 "speed?" 2 "takeoff" 10 "land" 1 "quit"] | |
tello: open [ | |
scheme: 'udp | |
host: 192.168.10.1 | |
port-id: 8889 | |
local-id: 9000 | |
awake: function [evt] [ | |
dump evt/type | |
port: evt/port | |
switch evt/type [ | |
wrote [ | |
print "wrote to tello, now reading response" | |
read tello | |
] | |
read [ | |
print "looking at port data" | |
data: copy port/data | |
clear port/data | |
dump data | |
attempt [print to string! data] | |
either not empty? commands [ | |
c: take commands | |
if integer? c [ | |
print spaced ["sleeping" c "seconds"] | |
sleep c c: take commands | |
] | |
if c = "quit" [ | |
print "Has Quit command so quitting." | |
close port | |
return true | |
] | |
write port to binary! c | |
][ | |
close port | |
return true | |
] | |
] | |
error [ | |
close port | |
return true | |
] | |
] | |
false | |
] | |
] | |
open tello | |
read tello | |
print "send command" | |
write tello to binary! "command" | |
wait tello |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment