-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathformation_setup.py
28 lines (23 loc) · 947 Bytes
/
formation_setup.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
import socket
def set_ap(ssid, password):
'''
A Function to set tello in AP mode
:param ssid: the ssid of the network (e.g. name of the Wi-Fi)
:param password: the password of the network
:return:
'''
my_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # socket for sending cmd
my_socket.bind(('', 8889))
cmd_str = 'command'
print ('sending command %s' % cmd_str)
my_socket.sendto(cmd_str.encode('utf-8'), ('192.168.10.1', 8889))
response, ip = my_socket.recvfrom(100)
print('from %s: %s' % (ip, response))
cmd_str = 'ap %s %s' % (ssid, password)
print ('sending command %s' % cmd_str)
my_socket.sendto(cmd_str.encode('utf-8'), ('192.168.10.1', 8889))
response, ip = my_socket.recvfrom(100)
print('from %s: %s' % (ip, response))
# example of setting Tello into command mode
# only works if server is connected to Tello Wi-Fi
set_ap('mrsteam', '748748748')