Skip to content

Commit 067206a

Browse files
committed
Cleaning up whitespace (tabs and spaces only)
1 parent 8cb1ea8 commit 067206a

8 files changed

+31
-34
lines changed

ble_legacy_dfu_controller.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def start(self, verbose=False):
128128

129129
# Send 'RECEIVE FIRMWARE IMAGE' command to set DFU in firmware receive state.
130130
self._dfu_send_command(Procedures.RECEIVE_FIRMWARE_IMAGE)
131-
131+
132132
# Send bin_array contents as as series of packets (burst mode).
133133
# Each segment is pkt_payload_size bytes long.
134134
# For every pkt_receipt_interval sends, wait for notification.
@@ -151,7 +151,7 @@ def start(self, verbose=False):
151151
duration = time.time() - time_start
152152
print "\nUpload complete in {} minutes and {} seconds".format(int(duration / 60), int(duration % 60))
153153
if verbose: print "segments sent: {}".format(segment_count)
154-
154+
155155
print "Waiting for DFU complete notification"
156156
# Wait for DFU complete notification
157157
self._wait_and_parse_notify()
@@ -193,26 +193,26 @@ def check_DFU_mode(self):
193193

194194
self.ble_conn.sendline(cmd)
195195

196-
# Skip two rows
196+
# Skip two rows
197197
try:
198198
res = self.ble_conn.expect('handle:.*', timeout=10)
199-
# res = self.ble_conn.expect('handle:', timeout=10)
199+
# res = self.ble_conn.expect('handle:', timeout=10)
200200
except pexpect.TIMEOUT, e:
201201
print "State timeout"
202202
except:
203203
pass
204204

205205
return self.ble_conn.after.find("value: 08 00")!=-1
206-
206+
207207
def switch_to_dfu_mode(self):
208208
(_, bl_value_handle, bl_cccd_handle) = self._get_handles(self.UUID_CONTROL_POINT)
209209

210-
#Enable notifications
210+
# Enable notifications
211211
cmd = 'char-write-req 0x%02x %02x' % (bl_cccd_handle, 1)
212212
if verbose: print cmd
213213
self.ble_conn.sendline(cmd)
214214

215-
#Reset the board in DFU mode. After reset the board will be disconnected
215+
# Reset the board in DFU mode. After reset the board will be disconnected
216216
cmd = 'char-write-req 0x%02x 0104' % (bl_value_handle)
217217
if verbose: print cmd
218218
self.ble_conn.sendline(cmd)
@@ -222,7 +222,7 @@ def switch_to_dfu_mode(self):
222222
#print "Send 'START DFU' + Application Command"
223223
#self._dfu_state_set(0x0104)
224224

225-
#Reconnect the board.
225+
# Reconnect the board.
226226
ret = self.scan_and_connect()
227227
if verbose: print "Connected " + str(ret)
228228

@@ -287,4 +287,4 @@ def _dfu_send_init(self):
287287
init_bin_array = array('B', open(self.datfile_path, 'rb').read())
288288

289289
# Transmit Init info
290-
self._dfu_send_data(init_bin_array)
290+
self._dfu_send_data(init_bin_array)

ble_secure_dfu_controller.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def start(self):
9898
self._dfu_send_init()
9999

100100
self._dfu_send_image()
101-
101+
102102
# --------------------------------------------------------------------------
103103
# Check if the peripheral is running in bootloader (DFU) or application mode
104104
# Returns True if the peripheral is in DFU mode
@@ -162,7 +162,7 @@ def _dfu_parse_notify(self, notify):
162162
crc32 = bytes_to_uint32_le(notify[7:11])
163163

164164
return (dfu_procedure, dfu_result, offset, crc32)
165-
165+
166166
elif(dfu_procedure == Procedures.SELECT and dfu_result == Results.SUCCESS):
167167
max_size = bytes_to_uint32_le(notify[3:7])
168168
offset = bytes_to_uint32_le(notify[7:11])
@@ -207,7 +207,7 @@ def _dfu_send_init(self):
207207
# Select command
208208
self._dfu_send_command(Procedures.SELECT, [Procedures.PARAM_COMMAND]);
209209
(proc, res, max_size, offset, crc32) = self._wait_and_parse_notify()
210-
210+
211211
if offset != init_size or crc32 != init_crc:
212212
if offset == 0 or offset > init_size:
213213
# Create command
@@ -224,7 +224,7 @@ def _dfu_send_init(self):
224224

225225
if (segment_count % self.pkt_receipt_interval) == 0:
226226
(proc, res, offset, crc32) = self._wait_and_parse_notify()
227-
227+
228228
if res != Results.SUCCESS:
229229
raise Exception("bad notification status: {}".format(Results.to_string(res)))
230230

@@ -298,13 +298,13 @@ def _dfu_send_object(self, offset, obj_max_size):
298298
except e:
299299
# Likely no notification received, need to re-transmit object
300300
return 0
301-
301+
302302
if res != Results.SUCCESS:
303303
raise Exception("bad notification status: {}".format(Results.to_string(res)))
304304

305305
if crc32 != crc32_unsigned(self.bin_array[0:offset]):
306306
# Something went wrong, need to re-transmit this object
307-
return 0
307+
return 0
308308

309309
print_progress(offset, self.image_size, prefix = 'Progress:', suffix = 'Complete', barLength = 50)
310310

@@ -320,4 +320,4 @@ def _dfu_send_object(self, offset, obj_max_size):
320320
self._wait_and_parse_notify()
321321

322322
# If everything executed correctly, return amount of bytes transfered
323-
return obj_max_size
323+
return obj_max_size

dfu.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@
1616

1717
from ble_secure_dfu_controller import BleDfuControllerSecure
1818
from ble_legacy_dfu_controller import BleDfuControllerLegacy
19-
19+
2020
def main():
2121

22-
init_msg = """
22+
init_msg = """
2323
================================
2424
== ==
2525
== DFU Server ==
2626
== ==
27-
================================
28-
"""
27+
================================
28+
"""
2929

3030
# print "DFU Server start"
3131
print init_msg
@@ -107,8 +107,8 @@ def main():
107107
unpacker = Unpacker()
108108
#print options.zipfile
109109
try:
110-
hexfile, datfile = unpacker.unpack_zipfile(options.zipfile)
111-
except Exception, e:
110+
hexfile, datfile = unpacker.unpack_zipfile(options.zipfile)
111+
except Exception, e:
112112
print "ERR"
113113
print e
114114
pass
@@ -158,7 +158,7 @@ def main():
158158

159159
ble_dfu.start()
160160

161-
# Disconnect from peer device if not done already and clean up.
161+
# Disconnect from peer device if not done already and clean up.
162162
ble_dfu.disconnect()
163163

164164
except Exception, e:
@@ -186,4 +186,3 @@ def main():
186186
sys.dont_write_bytecode = True
187187

188188
main()
189-

gen_dat.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ static dfu_init_t dfu_init = {
2727
.device_type = 0xffff,
2828
.device_rev = 0xffff,
2929
.app_version = 0xffffffff,
30-
.softdevice_1 = 0x0001,
30+
.softdevice_1 = 0x0001,
3131
.softdevice_2 = 0xfffe, // Any softdevice
3232
.crc = 0x0000,
3333
};
@@ -119,7 +119,7 @@ int main(int argc, char* argv[])
119119
/* Compute CRC-16. */
120120
dfu_init.crc = crc16_compute(bindata, binsize, 0);
121121

122-
/*
122+
/*
123123
* Write INIT file
124124
*/
125125
printf("Writing .dat file, size: %d\n", sizeof(dfu_init_t));
@@ -132,4 +132,4 @@ int main(int argc, char* argv[])
132132
fclose(binfile);
133133

134134
return 0;
135-
}
135+
}

nrf_ble_dfu_controller.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def _wait_and_parse_notify(self):
5757

5858
def __init__(self, target_mac, firmware_path, datfile_path):
5959
self.target_mac = target_mac
60-
60+
6161
self.firmware_path = firmware_path
6262
self.datfile_path = datfile_path
6363

@@ -263,4 +263,4 @@ def _enable_notifications(self, cccd_handle):
263263
try:
264264
res = self.ble_conn.expect('Characteristic value was written successfully.*', timeout=10)
265265
except pexpect.TIMEOUT, e:
266-
print "State timeout"
266+
print "State timeout"

scan.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def scan(self):
107107

108108
#scanner = Scan("DfuTarg") # specific advertisement name
109109
scanner = Scan(None) # any advertising name
110-
110+
111111
scanner.scan()
112112

113113
print "scan complete"

unpacker.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def unpack_zipfile(self, file):
4343

4444
# print "DAT file: " + datfile
4545
# print "BIN file: " + binfile
46-
46+
4747
return binfile, datfile
4848

4949
#--------------------------------------------------------------------------
@@ -52,5 +52,3 @@ def unpack_zipfile(self, file):
5252
def delete(self):
5353
# delete self.unzip_dir and its contents
5454
shutil.rmtree(self.unzip_dir)
55-
56-

util.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,4 @@ def print_progress(iteration, total, prefix = '', suffix = '', decimals = 1, bar
6767
sys.stdout.write('\r%s |%s| %s%s %s (%d of %d bytes)' % (prefix, bar, percents, '%', suffix, iteration, total)),
6868
if iteration == total:
6969
sys.stdout.write('\n')
70-
sys.stdout.flush()
70+
sys.stdout.flush()

0 commit comments

Comments
 (0)