Skip to content

Instantly share code, notes, and snippets.

@prefiks
Created September 3, 2019 21:34
Show Gist options
  • Save prefiks/e614116fc3983a8e7e5fe326800dc101 to your computer and use it in GitHub Desktop.
Save prefiks/e614116fc3983a8e7e5fe326800dc101 to your computer and use it in GitHub Desktop.
#!/usr/bin/python3
from bluepy import btle
import sys
class DiscoLH(btle.DefaultDelegate):
def __init__(self):
self.devices = []
btle.DefaultDelegate.__init__(self)
def handleDiscovery(self, dev, isNewDev, isNewData):
if not isNewDev:
return
isLH = False
name = ""
if dev.getValue(btle.ScanEntry.MANUFACTURER)[0:4] == b'\x5d\x05\x00\x02':
print('Found LightHouse %s: address = %s' %
(dev.getValue(btle.ScanEntry.COMPLETE_LOCAL_NAME), dev.addr))
self.devices.append(dev.addr)
if __name__ == '__main__':
scanner = btle.Scanner()
delegate = DiscoLH()
scanner.withDelegate(delegate)
scanner.scan(2)
for device in delegate.devices:
lh = btle.Peripheral()
print("Connecting to %s" % (device))
lh.connect(device, addrType = btle.ADDR_TYPE_RANDOM)
if len(sys.argv) > 1 and sys.argv[1] == 'on':
lh.writeCharacteristic(0x12, b'\x01')
else:
lh.writeCharacteristic(0x12, b'\x00')
lh.disconnect()
@Firestorm7893
Copy link

Fixed the problem, I forgot my base stations where 1.0 and not 2.0 so it would not be able to find them anyway. https://github.com/risa2000/lhctrl this is the script for 1.0 if anyone is interested
Thanks for the help :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment