
from time import sleep

from proto9x.usb import usb
from proto9x.tls import tls
from proto9x.flash import read_flash
from proto9x.init_flash import init_flash
from proto9x.upload_fwext import upload_fwext
from proto9x.calibrate import calibrate
from proto9x.init_db import init_db

#usb.trace_enabled=True
#tls.trace_enabled=True

def restart():
    print('Sleeping...')
    sleep(3)
    tls.reset()
    usb.open()
    usb.send_init()
    tls.parseTlsFlash(read_flash(1, 0, 0x1000))
    tls.open()

usb.open()
print('Initializing flash...')
init_flash()

restart()
print('Uploading firmware...')
upload_fwext()

restart()
print('Calibrating...')
calibrate()

print('Init database...')
init_db()

print('That\'s it, pairing\'s finished')

[((500, 510), 'proto9x.usb.usb.open', 'usb.open', ([], {}), '()\n', (508, 510), False, 'from proto9x.usb import usb\n'), ((542, 554), 'proto9x.init_flash.init_flash', 'init_flash', ([], {}), '()\n', (552, 554), False, 'from proto9x.init_flash import init_flash\n'), ((597, 611), 'proto9x.upload_fwext.upload_fwext', 'upload_fwext', ([], {}), '()\n', (609, 611), False, 'from proto9x.upload_fwext import upload_fwext\n'), ((647, 658), 'proto9x.calibrate.calibrate', 'calibrate', ([], {}), '()\n', (656, 658), False, 'from proto9x.calibrate import calibrate\n'), ((686, 695), 'proto9x.init_db.init_db', 'init_db', ([], {}), '()\n', (693, 695), False, 'from proto9x.init_db import init_db\n'), ((376, 384), 'time.sleep', 'sleep', (['(3)'], {}), '(3)\n', (381, 384), False, 'from time import sleep\n'), ((389, 400), 'proto9x.tls.tls.reset', 'tls.reset', ([], {}), '()\n', (398, 400), False, 'from proto9x.tls import tls\n'), ((405, 415), 'proto9x.usb.usb.open', 'usb.open', ([], {}), '()\n', (413, 415), False, 'from proto9x.usb import usb\n'), ((420, 435), 'proto9x.usb.usb.send_init', 'usb.send_init', ([], {}), '()\n', (433, 435), False, 'from proto9x.usb import usb\n'), ((488, 498), 'proto9x.tls.tls.open', 'tls.open', ([], {}), '()\n', (496, 498), False, 'from proto9x.tls import tls\n'), ((458, 480), 'proto9x.flash.read_flash', 'read_flash', (['(1)', '(0)', '(4096)'], {}), '(1, 0, 4096)\n', (468, 480), False, 'from proto9x.flash import read_flash\n')]