Skip to content

Commit

Permalink
parse customs user UUID json
Browse files Browse the repository at this point in the history
  • Loading branch information
EdwinFairchild committed Sep 12, 2023
1 parent 5ec120e commit a7693b5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 11 deletions.
31 changes: 20 additions & 11 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import time
import numpy as np
import webbrowser

import json
from modules import *
from widgets import *
from pyqtgraph import PlotDataItem
Expand Down Expand Up @@ -495,23 +495,32 @@ def discovered_services(self,data):
self.add_char_widget(item, permissions)

def extract_uuid_name(self, data):
# data[0] looks like this: 00001801-0000-1000-8000-00805f9b34fb (Handle: 16): Generic Attribute Profile
char_uuid = self.extract_uuid_hex(data)
found_match = False
# check if UUID exist in ble numbers

with open("user_UUIDs.json", "r") as f:
json_data = json.load(f)

for uuid_type in [ble_uuid.service, ble_uuid.characteristic, ble_uuid.descriptor]:
try:
char_uuid = uuid_type[UUID(char_uuid)]
# replace the UUID with the name in item
data = char_uuid
found_match = True
temp = uuid_type[UUID(char_uuid)]

except:
if temp != char_uuid:
data = temp
found_match = True

break # Exit the loop if a match is found

except Exception as e:
pass
if found_match == False:
# TODO check if UUID exist in user_uuids.json
pass
#print(f"Exception occurred: {e}") # Debug print

if not found_match:
search_uuid = char_uuid

if search_uuid in json_data:
data = json_data[search_uuid]

return data

def extract_uuid_hex(self, data):
Expand Down
10 changes: 10 additions & 0 deletions user_UUIDs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{

"005f0002-2ff2-4ed5-b045-4c7463617865": "WDX Device Configuration Characteristic",
"005f0003-2ff2-4ed5-b045-4c7463617865": "WDX File Transfer Control Characteristic",
"005f0004-2ff2-4ed5-b045-4c7463617865": "WDX File Transfer Data Characteristic",
"005f0005-2ff2-4ed5-b045-4c7463617865": "WDX Authentication Characteristic",
"e0262760-08c2-11e1-9073-0e8ac72e1001": "ARM Prop. Data Service",
"e0262760-08c2-11e1-9073-0e8ac72e0001": "ARM Prop. Data Characteristic"

}

0 comments on commit a7693b5

Please sign in to comment.