Merge pull request #848 from btchip/firmwareupdate

Firmwareupdate
This commit is contained in:
ThomasV 2014-09-19 16:24:00 +02:00
commit 7dd7918a30
1 changed files with 12 additions and 7 deletions

View File

@ -27,6 +27,7 @@ try:
from btchip.btchipUtils import compress_public_key,format_transaction, get_regular_input_script from btchip.btchipUtils import compress_public_key,format_transaction, get_regular_input_script
from btchip.bitcoinTransaction import bitcoinTransaction from btchip.bitcoinTransaction import bitcoinTransaction
from btchip.btchipPersoWizard import StartBTChipPersoDialog from btchip.btchipPersoWizard import StartBTChipPersoDialog
from btchip.btchipFirmwareWizard import checkFirmware, updateFirmware
from btchip.btchipException import BTChipException from btchip.btchipException import BTChipException
BTCHIP = True BTCHIP = True
BTCHIP_DEBUG = False BTCHIP_DEBUG = False
@ -143,12 +144,16 @@ class BTChipWallet(NewWallet):
d.setWaitImpl(DongleWaitQT(d)) d.setWaitImpl(DongleWaitQT(d))
self.client = btchip(d) self.client = btchip(d)
firmware = self.client.getFirmwareVersion()['version'].split(".") firmware = self.client.getFirmwareVersion()['version'].split(".")
if int(firmware[0]) <> 1 or int(firmware[1]) <> 4: if (not checkFirmware(firmware)) or (int(firmware[0]) <> 1) or (int(firmware[1]) <> 4) or (int(firmware[2]) < 9):
d.close()
try:
updateFirmware()
except Exception, e:
aborted = True aborted = True
raise Exception("Unsupported firmware version") raise e
if int(firmware[2]) < 9: d = getDongle(BTCHIP_DEBUG)
aborted = True d.setWaitImpl(DongleWaitQT(d))
raise Exception("Please update your firmware - 1.4.9 or higher is necessary") self.client = btchip(d)
try: try:
self.client.getOperationMode() self.client.getOperationMode()
except BTChipException, e: except BTChipException, e:
@ -194,7 +199,7 @@ class BTChipWallet(NewWallet):
pass pass
self.client = None self.client = None
if not aborted: if not aborted:
raise Exception("Could not connect to your BTChip dongle. Please verify access permissions or PIN") raise Exception("Could not connect to your BTChip dongle. Please verify access permissions, PIN, or unplug the dongle and plug it again")
else: else:
raise e raise e
self.client.bad = False self.client.bad = False