Exemple #1
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)

def send_pkt(pkt):
    if pkt
        print pkt[1]
        print pkt[2]
        print(type(pkt))
        hm10.writecmd(vh, "y".encode('hex'))

    


hm10 = BLEDevice("A8:10:87:1B:62:B0")
while True:
    vh=hm10.getvaluehandle("ffe1")

    sniff(iface = 'veth4', prn = lambda x: send_pkt(x))
     

Exemple #2
0
 def connect(self):
     global bulb
     bulb = BLEDevice(self.bl.get())
     time.sleep(0.1)
     bulb.writereq(bulb.getvaluehandle(WRITE_CHAR_UUID), COMMAND_STX+AUTH_CMD+AUTH_ON+COMMAND_ETX*15)
Exemple #3
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)
Exemple #4
0
 def connect(self):
     global bulb
     bulb = BLEDevice(self.bl.get())
     time.sleep(0.1)
     bulb.writereq(bulb.getvaluehandle(WRITE_CHAR_UUID),
                   COMMAND_STX + AUTH_CMD + AUTH_ON + COMMAND_ETX * 15)
Exemple #5
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)