-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
38 lines (29 loc) · 853 Bytes
/
test.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
import socket
def main():
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
host = '0.0.0.0'
port = 6009
client.connect((host, port))
# receive initial message
response_connected = client.recv(1024)
print(response_connected)
# set auth
client.send('ATH 12345 wury\r\n'.encode())
response_auth = client.recv(1024)
print(response_auth)
# set data
client.send('SET 1 wury\r\n'.encode())
response_set = client.recv(1024)
print(response_set)
client.send('GET 1\r\n'.encode())
response_get = client.recv(1024)
print(response_get)
# exit with data
# client.send('EXIT\r\n'.encode())
# response_exit = client.recv(1024)
# print(response_exit)
# manual exit
client.shutdown(socket.SHUT_RDWR)
client.close()
if __name__ == '__main__':
main()