Skip to content

Commit

Permalink
Fixed naming
Browse files Browse the repository at this point in the history
  • Loading branch information
vovagorodok committed Mar 14, 2024
1 parent b218273 commit 814bdb0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions tools/bluezero_uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def scan_ota_devices(adapter_address=None, timeout=5.0):
yield dev


def handleResponse(resp):
def handle_response(resp):
resp = bytes_to_int(resp)
if resp == OK:
return True
Expand All @@ -86,7 +86,7 @@ def handleResponse(resp):
return False


def handleBeginResponse(resp):
def handle_begin_response(resp):
respList = list(bytearray(resp))
head = respList[HEAD_POS]
if head != OK:
Expand Down Expand Up @@ -143,7 +143,7 @@ def upload(rx_char, tx_char, path):
return False

rx_char.value = int_to_u8_bytes(BEGIN) + int_to_u32_bytes(firmware_len)
begin_resp = handleBeginResponse(tx_char.value)
begin_resp = handle_begin_response(tx_char.value)
if not begin_resp:
return False
attr_size, buffer_size = begin_resp
Expand All @@ -157,7 +157,7 @@ def upload(rx_char, tx_char, path):

rx_char.value = int_to_u8_bytes(PACKAGE) + list(data)
if current_buffer_len + len(data) > buffer_size:
if not handleResponse(tx_char.value):
if not handle_response(tx_char.value):
return False
current_buffer_len = 0
current_buffer_len += len(data)
Expand All @@ -167,7 +167,7 @@ def upload(rx_char, tx_char, path):
print(f"Uploaded: {uploaded_len}/{firmware_len}")

rx_char.value = int_to_u8_bytes(END) + int_to_u32_bytes(crc)
if not handleResponse(tx_char.value):
if not handle_response(tx_char.value):
return False

return True
Expand Down
10 changes: 5 additions & 5 deletions tools/uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ async def get_mtu(client: BleakClient):
return client.mtu_size


async def handleResponse(resp):
async def handle_response(resp):
resp = bytes_to_int(resp)
if resp == OK:
return True
Expand All @@ -111,7 +111,7 @@ async def handleResponse(resp):
return False


async def handleBeginResponse(resp):
async def handle_begin_response(resp):
head = resp[HEAD_POS]
if head != OK:
print(respToStr[head])
Expand Down Expand Up @@ -167,7 +167,7 @@ async def callback(char, array):

begin_req = int_to_u8_bytes(BEGIN) + int_to_u32_bytes(firmware_len)
await client.write_gatt_char(rx_char, begin_req)
begin_resp = await handleBeginResponse(await queue.get())
begin_resp = await handle_begin_response(await queue.get())
if not begin_resp:
return False
attr_size, buffer_size = begin_resp
Expand All @@ -187,7 +187,7 @@ async def callback(char, array):
package = int_to_u8_bytes(PACKAGE) + data
await client.write_gatt_char(rx_char, package)
if current_buffer_len + len(data) > buffer_size:
if not await handleResponse(await queue.get()):
if not await handle_response(await queue.get()):
return False
current_buffer_len = 0
current_buffer_len += len(data)
Expand All @@ -198,7 +198,7 @@ async def callback(char, array):

end_req = int_to_u8_bytes(END) + int_to_u32_bytes(crc)
await client.write_gatt_char(rx_char, end_req)
if not await handleResponse(await queue.get()):
if not await handle_response(await queue.get()):
return False

return True
Expand Down

0 comments on commit 814bdb0

Please sign in to comment.