Skip to content

Commit

Permalink
Fix PEP8 issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ukBaz committed Jun 10, 2024
1 parent 22a6c62 commit e252959
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
22 changes: 14 additions & 8 deletions btsocket/btmgmt_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,14 +699,20 @@ def __repr__(self):
Parameter(name='uuid[i]', width=16, repeat='uuid_count')]),
0x003b: Packet([Parameter(name='address_type', width=1,
bt_type='AddressTypeField')]),
0x003e: Packet([Parameter(name='instance', width=1),
Parameter(name='flags', width=4),
Parameter(name='duration', width=2),
Parameter(name='timeout', width=2),
Parameter(name='adv_data_len', width=1),
Parameter(name='scan_rsp_len', width=1),
Parameter(name='adv_data', width=None, repeat=1, bt_type='HexStr'),
Parameter(name='scan_rsp', width=None, repeat=1, bt_type='HexStr')]),
0x003e: Packet(
[
Parameter(name='instance', width=1),
Parameter(name='flags', width=4),
Parameter(name='duration', width=2),
Parameter(name='timeout', width=2),
Parameter(name='adv_data_len', width=1),
Parameter(name='scan_rsp_len', width=1),
Parameter(
name='adv_data', width=None, repeat=1, bt_type='HexStr'),
Parameter(
name='scan_rsp', width=None, repeat=1, bt_type='HexStr')
]
),
0x003f: Packet([Parameter(name='instance', width=1)]),
0x0040: Packet([Parameter(name='instance', width=1),
Parameter(name='flags', width=4)]),
Expand Down
7 changes: 5 additions & 2 deletions examples/create_advertisement_btmgmt_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ def advert_command(instance_id, flags, duration, timeout, adv_data, scan_rsp):
adv_data_len = little_bytes(len(adv_data), 1) # (1 Octet)
scan_rsp = bytes.fromhex(scan_rsp) # (0-255 Octets)
scan_rsp_len = little_bytes(len(scan_rsp), 1) # (1 Octet)
params = instance + flags + duration + timeout + adv_data_len + scan_rsp_len + adv_data + scan_rsp
params = (instance + flags + duration + timeout + adv_data_len +
scan_rsp_len + adv_data + scan_rsp)
param_len = little_bytes(len(params), 2)

return cmd + ctrl_idx + param_len + params
Expand All @@ -56,7 +57,9 @@ def test_asyncio_usage():
def reader():
raw_data = sock.recv(100)
data = btmgmt_protocol.reader(raw_data)
print("Received:", data.event_frame.command_opcode, data.event_frame.status)
print("Received:",
data.event_frame.command_opcode,
data.event_frame.status)

# We are done: unregister the file descriptor
loop.remove_reader(sock)
Expand Down
6 changes: 4 additions & 2 deletions examples/create_advertisement_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Flags(enum.IntEnum):
flags = Flags.GENERAL_DISCOVERABLE
duration = 0x00 # 0 means use default
timeout = 0x0 # 0 means use default
adv_data = "1bfff0ff6DB643CF7E8F471188665938D17AAA26495E131415161718" # (0-255 Octets)
adv_data = "1bfff0ff6DB643CF7E8F471188665938D17AAA26495E131415161718"
adv_data_len = len(bytes.fromhex(adv_data))
scan_rsp = "" # (0-255 Octets)
scan_rsp_len = len(bytes.fromhex(scan_rsp))
Expand All @@ -41,7 +41,9 @@ def show_result(pkt, mgmt_class):

def main():
mgmt = btmgmt_callback.Mgmt()
mgmt.add_event_callback(btmgmt_protocol.Events.CommandCompleteEvent, show_result)
mgmt.add_event_callback(
btmgmt_protocol.Events.CommandCompleteEvent,
show_result)
mgmt.send('AddAdvertising', ctrl_idx,
instance,
flags,
Expand Down
4 changes: 2 additions & 2 deletions examples/create_advertisement_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Flags(enum.IntEnum):
flags = Flags.GENERAL_DISCOVERABLE
duration = 0x00 # 0 means use default
timeout = 0x0 # 0 means use default
adv_data = "1bfff0ff6DB643CF7E8F471188665938D17AAA26495E131415161718" # (0-255 Octets)
adv_data = "1bfff0ff6DB643CF7E8F471188665938D17AAA26495E131415161718"
adv_data_len = len(bytes.fromhex(adv_data))
scan_rsp = "" # (0-255 Octets)
scan_rsp_len = len(bytes.fromhex(scan_rsp))
Expand Down Expand Up @@ -58,4 +58,4 @@ def show_result(data):
ctrl_idx,
instance,
)
)
)

0 comments on commit e252959

Please sign in to comment.