Exemple #1
0
def wheel_com_init():
    global Device1, Device2
    Device1 = BLEDevice("DD:43:89:16:43:81")  #right wheel
    Device2 = BLEDevice("F4:82:B3:50:ED:55")  #left  wheel
    Device1.writereq(0xd, '54524F5F0D0A')  #RUN_flag
    Device1.notify()
    Device2.writereq(0xd, '54524F5F0D0A')  #RUN_flag
    Device2.notify()
    Device1.writereq(0xd, '544443790D0A')  #FRONT
    Device1.notify()
    Device2.writereq(0xd, '544443790D0A')  #FRONT
    Device2.notify()

    desired_speed1(10)
    desired_speed2(10)

    time.sleep(2)
    desired_speed1(0)
    desired_speed2(0)
    global state
    state = STOP
Exemple #2
0
    def do_connect(self, state):
        global device
        global AllDevices
        global isConnected

        if (device != -1 and isConnected is False):
            try:
                device = BLEDevice(SelectedDevice)
                print "DEBUG ..device initialized"
                AllDevices = ['Connected']
                isConnected = True
                self._smState = SMState.connected
            except:
                print "DEBUG: in exception block for connect"
                AllDevices = ['Not able to connect']
        elif (isConnected is True):
            self.promptWithCustomString(
                state, 'Already Connected to {0}'.format(device['name']))
        else:
            AllDevices = ['No Devices to Connect']
 def connect(self):
     global bulb
     bulb = BLEDevice(self.bl.get())
Exemple #4
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 #5
0
import sys, time
import threading
import keyboard
import numpy as np

from bledevice import scanble, BLEDevice

Device1 = BLEDevice("DD:43:89:16:43:81")
Device2 = BLEDevice("F4:82:B3:50:ED:55")
Device1.writereq(0xd, '54524F5F0D0A')  #RUN_flag
Device1.notify()
Device2.writereq(0xd, '54524F5F0D0A')  #RUN_flag
Device2.notify()
Device1.writereq(0xd, '544443790D0A')  #FRONT
Device1.notify()
Device2.writereq(0xd, '544443790D0A')  #FRONT
Device2.notify()
desired = 0
flag = 1
now_velocity1 = 0
now_velocity2 = 0

STOP = 0
IDLE = 1
FWD = 2
LEFT = 3
RIGHT = 4
ROTATE = 6

direction1 = 1
direction2 = 1
Exemple #6
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 #7
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 #8
0
import sys, time
import threading
import keyboard
import numpy as np

from bledevice import scanble, BLEDevice
Device2 = BLEDevice("F4:82:B3:50:ED:55")
Device2.writereq(0xd, '54524F5F0D0A')  #RUN_flag

desired = 0
flag = 1
now_velocity = 0


def M_FWD():
    global now_velocity
    if now_velocity < 16:
        now_velocity = 16
    now_velocity = now_velocity + 1
    return now_velocity


def M_BWD():
    global now_velocity
    if now_velocity < 16:
        now_velocity = 16
    now_velocity = now_velocity - 1
    return now_velocity


def M_STOP():