44from queue import *
55from threading import Thread
66
7+ from bluefang import commands
8+
79q = Queue ()
810
911class L2CAPClientThread (Thread ):
@@ -21,24 +23,47 @@ def run(self):
2123
2224 def process_command (self , command ):
2325 logging .info ("Received command: " + command )
24- if command == "left" :
26+ # Keyboard Reports
27+ if command == commands .LEFT :
2528 self .socket .send (bytes (bytearray ((0xA1 , 0x01 , 0x00 , 0x00 , 0x50 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ))))
2629 self .socket .send (bytes (bytearray ((0xA1 , 0x01 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ))))
27- elif command == "right" :
30+ elif command == commands . RIGHT :
2831 self .socket .send (bytes (bytearray ((0xA1 , 0x01 , 0x00 , 0x00 , 0x4F , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ))))
2932 self .socket .send (bytes (bytearray ((0xA1 , 0x01 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ))))
30- elif command == "up" :
33+ elif command == commands . UP :
3134 self .socket .send (bytes (bytearray ((0xA1 , 0x01 , 0x00 , 0x00 , 0x52 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ))))
3235 self .socket .send (bytes (bytearray ((0xA1 , 0x01 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ))))
33- elif command == "down" :
36+ elif command == commands . DOWN :
3437 self .socket .send (bytes (bytearray ((0xA1 , 0x01 , 0x00 , 0x00 , 0x51 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ))))
3538 self .socket .send (bytes (bytearray ((0xA1 , 0x01 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ))))
36- elif command == "enter" :
39+ elif command == commands . ENTER :
3740 self .socket .send (bytes (bytearray ((0xA1 , 0x01 , 0x00 , 0x00 , 0x28 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ))))
3841 self .socket .send (bytes (bytearray ((0xA1 , 0x01 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ))))
39- elif command == "cancel" :
42+ elif command == commands . CANCEL :
4043 self .socket .send (bytes (bytearray ((0xA1 , 0x01 , 0x00 , 0x00 , 0x29 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ))))
4144 self .socket .send (bytes (bytearray ((0xA1 , 0x01 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ))))
45+ elif command == commands .MUTE_VOLUME :
46+ self .socket .send (bytes (bytearray ((0xA1 , 0x01 , 0x00 , 0x00 , 0x7F , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ))))
47+ self .socket .send (bytes (bytearray ((0xA1 , 0x01 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ))))
48+ elif command == commands .VOLUME_UP :
49+ self .socket .send (bytes (bytearray ((0xA1 , 0x01 , 0x00 , 0x00 , 0x80 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ))))
50+ self .socket .send (bytes (bytearray ((0xA1 , 0x01 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ))))
51+ elif command == commands .VOLUME_DOWN :
52+ self .socket .send (bytes (bytearray ((0xA1 , 0x01 , 0x00 , 0x00 , 0x81 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ))))
53+ self .socket .send (bytes (bytearray ((0xA1 , 0x01 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ))))
54+ # Consumer Reports
55+ elif command == commands .PLAY :
56+ self .socket .send (bytes (bytearray ((0xA1 , 0x03 , 0xB0 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ))))
57+ self .socket .send (bytes (bytearray ((0xA1 , 0x03 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ))))
58+ elif command == commands .PAUSE :
59+ self .socket .send (bytes (bytearray ((0xA1 , 0x03 , 0xB1 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ))))
60+ self .socket .send (bytes (bytearray ((0xA1 , 0x03 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ))))
61+ elif command == commands .NEXT_TRACK :
62+ self .socket .send (bytes (bytearray ((0xA1 , 0x03 , 0xB5 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ))))
63+ self .socket .send (bytes (bytearray ((0xA1 , 0x03 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ))))
64+ elif command == commands .PREV_TRACK :
65+ self .socket .send (bytes (bytearray ((0xA1 , 0x03 , 0xB6 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ))))
66+ self .socket .send (bytes (bytearray ((0xA1 , 0x03 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ))))
4267 else :
4368 logging .warning ("Unknown command: " + command )
4469
0 commit comments