Skip to content

Instantly share code, notes, and snippets.

@gchiu
Created April 12, 2018 06:54
Show Gist options
  • Save gchiu/3e0b74b068be2896ac9b010887c2763f to your computer and use it in GitHub Desktop.
Save gchiu/3e0b74b068be2896ac9b010887c2763f to your computer and use it in GitHub Desktop.
Drone GUI server
Rebol [
date: 12-April-2018
title: "simple GUI drone test"
]
attempt [close listen]
print "opening server on port 9000"
listen: open udp://:9000
awake: function [evt][
print "Client event"
dump evt/type
port: evt/port
switch evt/type [
connect []
read [
print to string! port/data
clear port/data
read port
]
close [exit]
exit
]
]
listen/awake: function [evt][
print "Listen event"
dump evt/type
switch evt/type [
connect read accept [
print "accepted connection"
client: first evt/port
client/awake: :awake
read client
]
]
]
view [
down
button "Connect" on-action [
drone: open udp://192.168.10.1:8889
write drone to binary! "connect"
read listen
; add Listen to wait list?
]
button "Take Off" on-action [write drone to binary! "takeoff"]
button "Land" on-action [write drone to binary! "land"]
button "Quit" on-action [close drone quit]
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment