File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #!/usr/bin/python3
2+
3+ import socket
4+ import time
5+
6+ HOST = 'api.vklmotor.com'
7+ PORT = 6000
8+ TOKEN = '0123456789abcde'
9+
10+ def connect (s ):
11+ b = bytearray ()
12+ b .extend ([0x43 , 0x10 , 0x01 ])
13+ b .extend (b'0123456789abcde' )
14+ b .extend ([0x2b , 0x68 ])
15+ s .sendall (b )
16+
17+ def pub (s ):
18+ pass
19+
20+ def ack (s ):
21+ while True :
22+ buf = s .recv (4096 )
23+ if buf is None :
24+ return
25+ cmd = buf [0 ]
26+ key = buf [2 ]
27+ value = buf [3 ]
28+ if cmd == 0x6D :
29+ if key == 0xE1 :
30+ if value == 0xBA : #lock
31+ print ('lock' )
32+ elif value == 0xB5 : #unlock
33+ print ('unlock' )
34+ elif key == 0xE2 : #beep
35+ print ('beep' )
36+ elif key == 0xEA : #ping
37+ print ('ping' )
38+ msgidlen = buf [5 ]
39+ msgid = buf [6 :6 + msgidlen ]
40+ b = bytearray ()
41+ b .extend ([0x61 , msgidlen + 2 , 0xE8 , msgidlen ])
42+ b .extend (msgid )
43+ b .extend ([0x0 , 0x0 ])
44+ s .sendall (b )
45+
46+ if __name__ == '__main__' :
47+ while True :
48+ time .sleep (1 )
49+ s = socket .socket (socket .AF_INET , socket .SOCK_STREAM )
50+ s .setblocking (1 )
51+ s .settimeout (600000 )
52+ s .connect ((HOST , PORT ))
53+
54+ connect (s )
55+ ack (s )
56+
You can’t perform that action at this time.
0 commit comments