-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_bt_check.py
More file actions
31 lines (25 loc) · 1.04 KB
/
_bt_check.py
File metadata and controls
31 lines (25 loc) · 1.04 KB
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 paramiko, time
c=paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect('10.131.52.31', username='cortex', password='Haziqshah21')
# Kill the running cortex process
stdin,stdout,stderr=c.exec_command('pkill -f "python -m rpi5"')
time.sleep(1)
print("Killed cortex process")
# Disconnect any active BT
stdin,stdout,stderr=c.exec_command('bluetoothctl disconnect 2C:BE:EE:2D:9E:E6')
print("Disconnect:", stdout.read().decode().strip())
time.sleep(1)
# Check CMF status
stdin,stdout,stderr=c.exec_command('bluetoothctl info 2C:BE:EE:2D:9E:E6')
info = stdout.read().decode()
for line in info.split("\n"):
if any(k in line for k in ['Name','Paired','Bonded','Trusted','Connected']):
print(line.strip())
print()
stdin,stdout,stderr=c.exec_command('bluetoothctl devices Paired')
print("Paired list:", stdout.read().decode().strip())
# Check show for pairable
stdin,stdout,stderr=c.exec_command('bluetoothctl show | grep Pairable')
print(stdout.read().decode().strip())
c.close()