-
Notifications
You must be signed in to change notification settings - Fork 0
/
swarm_flight_set_connection.py
61 lines (41 loc) · 1.06 KB
/
swarm_flight_set_connection.py
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
58
59
60
61
#
# Tello Python3 Control Demo
#
# http://www.ryzerobotics.com/
#
# 1/1/2018
import threading
import socket
import sys
import time
host = ''
port = 9000
locaddr = (host,port)
# Create a UDP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
tello_address = ('192.168.10.1', 8889)
sock.bind(locaddr)
def recv():
count = 0
while True:
try:
data, server = sock.recvfrom(1518)
print(data.decode(encoding="utf-8"))
except Exception:
print ('\nExit . . .\n')
break
print('Setting your Tello EDU Drone to connect to your local wifi ...')
#recvThread create
recvThread = threading.Thread(target=recv)
recvThread.start()
command_list = ['command']
local_wifi_name = ''
local_wifi_password = ''
connect_local_wifi_command = 'ap {0} {1}'.format(local_wifi_name, local_wifi_password)
command_list.append(connect_local_wifi_command)
for msg in command_list:
msg = msg.encode(encoding="utf-8")
sent = sock.sendto(msg, tello_address)
time.sleep(1)
sock.close()
print('DONE!')