Example #1
0
 def scan(self):
     bllist = scanble(timeout=2)
     print bllist
     if len(bllist) != 0:
         self.bl.set(bllist[0]['addr'])
         menu = self.bles['menu']
         menu.delete(0, 'end')
         for bl in bllist:
             menu.add_command(label=bl, command=lambda v=bl: self.bl.set(v['addr']))
Example #2
0
 def scan(self):
     bllist = scanble(timeout=2)
     print bllist
     if len(bllist) != 0:
         self.bl.set(bllist[0]["addr"])
         menu = self.bles["menu"]
         menu.delete(0, "end")
         for bl in bllist:
             menu.add_command(label=bl, command=lambda v=bl: self.bl.set(v["addr"]))
Example #3
0
 def scan(self):
     bllist = scanble(timeout=2)
     print bllist
     if len(bllist) != 0:
         self.bl.set(bllist[0]['addr'])
         menu = self.bles['menu']
         menu.delete(0, 'end')
         for bl in bllist:
             menu.add_command(label=bl,
                              command=lambda v=bl: self.bl.set(v['addr']))
Example #4
0
    def do_scan(self, state):
        global AllDevices
        global device
        AllDevices = []

        device = 0
        self.devices = scanble(timeout=2)
        try:
            for device in self.devices:
                if (device['name'] != "(unknown)"):
                    AllDevices.append((device['name'], device['addr']))
            if (len(AllDevices) == 0):
                AllDevices = ['No Device Found']
        except:
            AllDevices = ['No Device Found']
            device = -1
Example #5
0
#!/usr/bin/env python
import sys, time
from bledevice import scanble, BLEDevice

if len(sys.argv) != 2:
    print "Usage: python blecomm.py <ble address>"
    print "Scan devices are as follows:"
    print scanble(timeout=3)
    sys.exit(1)

hm10 = BLEDevice(sys.argv[1])
while True:
    vh = hm10.getvaluehandle("ffe1")
    hm10.writecmd(vh, "test\r\n".encode('hex'))
    data = hm10.notify()
    if data is not None:
        print "Received: ", data
    time.sleep(1)
Example #6
0
#!/usr/bin/env python
import sys, time
from bledevice import scanble, BLEDevice

if len(sys.argv) != 2:
    print "Usage: python blecomm.py <ble address>"
    print "Scan devices are as follows:"
    print scanble(timeout=3)
    sys.exit(1)

hm10 = BLEDevice(sys.argv[1])
while True:
    vh = hm10.getvaluehandle("ffe1")
    hm10.writecmd(vh, "test\r\n".encode("hex"))
    data = hm10.notify()
    if data is not None:
        print "Received: ", data
    time.sleep(1)
Example #7
0
#!/usr/bin/python3
import sys, time
from bledevice import scanble, BLEDevice

if len(sys.argv) != 2:
    print("Usage: python blecomm.py <ble address>")
    print("Scan devices are as follows:")
    print(scanble(timeout=3))
    sys.exit(1)

hm10 = BLEDevice(sys.argv[1])
while True:
    #vh=hm10.getvaluehandle("ffe1")
    #hm10.writecmd(vh, "hello\r\n".encode('hex'))
    vh = hm10.getvaluehandle(b"0000ffe1")
    hm10.writecmd(vh, bytes("test\r\n".encode('utf-8')).hex())
    data = hm10.notify()
    if data is not None:
        print("Received: ", data)
    time.sleep(1)