示例#1
0
def check_version(ver):
    remote_ver = ''
    while remote_ver == '':
        try:
            central = connect_to_central()
            remote_ver = central.git_tag_get()
            central.disconnect()
            central.sleep(.2)
        except:
            pass
    return remote_ver == ver
示例#2
0
def send_file(img_path):
    try:
        central = connect_to_central()
        img = ''
        with open(img_path, 'rb') as f:
            img = f.read()
        print "preparing OTA bank..."
        central.bulk_transfer.erase(OTA_FILE)
        print "transfering image..."
        start_time = time.time()
        result = central.bulk_transfer.put(OTA_FILE, img)
        duration = time.time() - start_time
        if result:
            print "uploaded %d bytes, in %.1f seconds" %(len(img), duration)
            print "resetting device..."
            central.bulk_transfer.reset()
        else:
            print "transfer failed!"
    except Exception, e:
        print e
        sys.exit()
        running = False
示例#3
0
from __future__ import print_function
import sys
import time
from connection_utils import connect_to_central
from binascii import hexlify
from struct import unpack

central = connect_to_central()
if len(sys.argv) < 4:
    print("Error MUST specify destination file!")
    sys.exit()

file_handle = 1
start_time = time.time()
obj = central.bulk_transfer.get(file_handle)
duration = time.time() - start_time
print("downloaded %d bytes, in %.1f seconds" % (len(obj), duration))
central.bulk_transfer.erase(file_handle)
with open(sys.argv[3], 'wb') as f:
    f.write(obj)
    f.close()

central.disconnect()
time.sleep(.1)