summaryrefslogtreecommitdiff
path: root/dcs8000lh-configure.py
blob: 35fa47603cf868d6c66a2724c375f31bac76b650 (plain)
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
32
33
34
35
36
37
38
39
40
#!/usr/bin/python3

import sys
from bluepy.btle import Peripheral

class BleCam(object):
    def __init__(self, address):
        try:
            self.periph = Peripheral(address)
        except BTLEDisconnectError:
            print("failed to connect to <addr>".format(address))
            return
        self.ipcamservice()
        self.dumpchars()
        self.experiment()

    def ipcamservice(self):
        try:
            print("getting service")
            self.service = self.periph.getServiceByUUID(0xD001)
        except BTLEEException:
            print("no such service")
            return

    def dumpchars(self):
        handles = self.service.getCharacteristics()
        print("dumping %s" % handles)
        for h in handles:
            print("%s - Properties=%s Handle=%#06x " % (h.uuid, h.propertiesToString(), h.getHandle()))

    def experiment(self):
        print("read %s" % self.service.getCharacteristics(0xa001)[0].read().decode())
            
if __name__ == '__main__':
    if len(sys.argv) < 2:
        print("Usage: {} <addr>".format(sys.argv[0]))
        sys.exit(1)

    BleCam(sys.argv[1])
print("Done.")