summaryrefslogtreecommitdiffstats
path: root/dfu.py
diff options
context:
space:
mode:
Diffstat (limited to 'dfu.py')
-rwxr-xr-xdfu.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/dfu.py b/dfu.py
index 69532c4..cce6321 100755
--- a/dfu.py
+++ b/dfu.py
@@ -2,9 +2,9 @@
import os
import pexpect
-import sys
import optparse
import time
+import sys
from intelhex import IntelHex
# DFU Opcodes
@@ -50,7 +50,7 @@ class BleDfuUploader(object):
def __init__(self, target_mac, hexfile_path):
self.hexfile_path = hexfile_path
self.ble_conn = pexpect.spawn("gatttool -b '%s' -t random --interactive" % target_mac)
- self.ble_conn.logfile = sys.stdout
+ self.ble_conn.logfile = sys.stdout
# Connect to peer device.
def scan_and_connect(self):
@@ -62,17 +62,18 @@ class BleDfuUploader(object):
self.ble_conn.sendline('connect')
try:
- #res = self.ble_conn.expect('\[CON\].*>', timeout=10)
res = self.ble_conn.expect('Connection successful', timeout=10)
except pexpect.TIMEOUT, e:
print "timeout"
+
+ time.sleep(1)
def _dfu_state_set(self, opcode):
self.ble_conn.sendline('char-write-req 0x%02x %02x' % (self.ctrlpt_handle, opcode))
# Verify that command was successfully written
try:
- res = self.ble_conn.expect('.* Characteristic value was written successfully', timeout=10)
+ res = self.ble_conn.expect('Characteristic value was written successfully', timeout=10)
except pexpect.TIMEOUT, e:
print "timeout"
@@ -82,7 +83,7 @@ class BleDfuUploader(object):
# Verify that data was successfully written
try:
- res = self.ble_conn.expect('.* Characteristic value was written successfully', timeout=10)
+ res = self.ble_conn.expect('Characteristic value was written successfully', timeout=10)
except pexpect.TIMEOUT, e:
print "timeout"
@@ -93,7 +94,7 @@ class BleDfuUploader(object):
# Verify that CCCD was successfully written
try:
- res = self.ble_conn.expect('.* Characteristic value was written successfully', timeout=10)
+ res = self.ble_conn.expect('Characteristic value was written successfully', timeout=10)
except pexpect.TIMEOUT, e:
print "timeout"