Skip to content

Instantly share code, notes, and snippets.

@Katharine
Created April 15, 2018 00:45
Show Gist options
  • Save Katharine/cacd11abcf0e540848384299859993d7 to your computer and use it in GitHub Desktop.
Save Katharine/cacd11abcf0e540848384299859993d7 to your computer and use it in GitHub Desktop.
A terrible, terrible script for controlling BLE switches when your BLE stack is flaky
#!/usr/bin/env python
import subprocess
import sys
import time
for i in xrange(5):
print "Attempt", i
try:
subprocess.call(["service", "bluetooth", "restart"])
subprocess.check_call(["/home/pi/switchmate/switchmate.py", sys.argv[1], "none", "switch", sys.argv[2]])
except:
time.sleep(0.1)
else:
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment