File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed
Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change 33import sys
44
55class BluetoothConnection :
6- def __init__ (self ):
6+ def __init__ (self , bd_address = None , port = None ):
77 self .device = []
88 self .target_name = "mybuddy"
99 self .nearby_devices = None
10+ self .bd_address = bd_address
11+ self .port = port
1012
1113 def find_target_device (self ):
1214 available_addr = []
@@ -19,6 +21,10 @@ def find_target_device(self):
1921 return None
2022
2123 def connect_target_device (self ):
24+ if self .bd_address :
25+ sock = bluetooth .BluetoothSocket (bluetooth .RFCOMM )
26+ sock .connect ((self .bd_address , self .port ))
27+ return sock
2228 target_address = self .find_target_device ()
2329 if target_address :
2430 if len (target_address ) > 1 :
Original file line number Diff line number Diff line change 99
1010class MyBuddyBlueTooth (MyBuddyCommandGenerator ):
1111 """MyBuddy bluetooth API"""
12- def __init__ (self ):
12+ def __init__ (self , bt_address = None , port = 10 ):
1313 """There is a default Bluetooth search time of 5 seconds"""
1414 super (MyBuddyBlueTooth ).__init__ ()
15- self .ble = BluetoothConnection ()
15+ self .ble = BluetoothConnection (bt_address , port )
1616 self .ble_obj = self .ble .connect_target_device ()
1717
1818 def __read (self ):
You can’t perform that action at this time.
0 commit comments