Skip to content

Commit

Permalink
fix for unicode decode errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Ernst79 committed Dec 5, 2023
1 parent 49c632d commit c6c2490
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions custom_components/ble_monitor/ble_parser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,16 @@ def parse_raw_data(self, data):
service_class_uuid128 = adstruct[2:]
elif adstuct_type == 0x08:
# AD type 'shortened local name'
shortened_local_name = adstruct[2:].decode("utf-8")
try:
shortened_local_name = adstruct[2:].decode("utf-8")
except UnicodeDecodeError:
shortened_local_name = ""
elif adstuct_type == 0x09:
# AD type 'complete local name'
complete_local_name = adstruct[2:].decode("utf-8")
try:
complete_local_name = adstruct[2:].decode("utf-8")
except UnicodeDecodeError:
complete_local_name = ""
elif adstuct_type == 0x16 and adstuct_size > 4:
# AD type 'Service Data - 16-bit UUID'
service_data_list.append(adstruct)
Expand Down

0 comments on commit c6c2490

Please sign in to comment.