-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbluetooth_manager.py
More file actions
31 lines (21 loc) · 890 Bytes
/
bluetooth_manager.py
File metadata and controls
31 lines (21 loc) · 890 Bytes
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
import subprocess
# Define the Bluetooth device address
device_address = '88:F5:6E:00:41:FB' # Replace with the Bluetooth device address
# Define the message to be sent
message = 'Hello, Bluetooth World!'
# Create the command to turn on Bluetooth
enable_command = 'blueutil --power on'
# Create the command to establish a Bluetooth connection
connect_command = 'blueutil --connect ' + device_address
# Create the command to send the message
send_command = 'blueutil --send "' + message + '"'
# Create the command to close the Bluetooth connection
disconnect_command = 'blueutil --disconnect'
# Turn on Bluetooth
subprocess.call(enable_command, shell=True)
# Establish the Bluetooth connection
subprocess.call(connect_command, shell=True)
# Send the message
subprocess.call(send_command, shell=True)
# Close the Bluetooth connection
subprocess.call(disconnect_command, shell=True)