forked from robotstreamer/robotstreamer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lovense_interface.py
35 lines (24 loc) · 956 Bytes
/
lovense_interface.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
import requests
from time import sleep
URL = "http://127-0-0-1.lovense.club:20010/Vibrate"
def init():
print("init")
def getSpeed(command):
# assume the command is like vibrate50 or vibrate100
return int(command[7:])
def handleCommand(command, keyPosition, price=0):
print("***********************************", command)
if command[0:7] == 'vibrate':
print('\a')
print("command is " + str(command))
PARAMS = {'v':getSpeed(command)}
print(URL, PARAMS)
r = requests.get(url = URL, params = PARAMS)
print(r)
print(r.content)
sleep(3)
PARAMS = {'v':0}
print(URL, PARAMS)
r = requests.get(url = URL, params = PARAMS)
print(r)
print(r.content)