mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-30 16:20:24 +00:00
bluetooth_gatt: follow changes on Bluetooth SIG site
This commit is contained in:
parent
fcf9a26a1e
commit
0d9cb02c2e
@ -10,6 +10,8 @@ import requests
|
|||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
headers = {'user-agent': 'curl/7.63.0'}
|
||||||
|
|
||||||
program_info = '''
|
program_info = '''
|
||||||
BTstack GATT UUID Scraper for BTstack
|
BTstack GATT UUID Scraper for BTstack
|
||||||
Copyright 2016, BlueKitchen GmbH
|
Copyright 2016, BlueKitchen GmbH
|
||||||
@ -35,17 +37,23 @@ trailer = '''
|
|||||||
#endif
|
#endif
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
def strip_non_ascii(string):
|
||||||
|
stripped = (c for c in string if 0 < ord(c) < 127)
|
||||||
|
return ''.join(stripped)
|
||||||
|
|
||||||
def scrape_page(fout, url):
|
def scrape_page(fout, url):
|
||||||
print("Parsing %s" % url)
|
print("Parsing %s" % url)
|
||||||
fout.write(page_info.format(page=url))
|
fout.write(page_info.format(page=url))
|
||||||
page = requests.get(url)
|
page = requests.get(url, headers=headers)
|
||||||
tree = html.fromstring(page.content)
|
tree = html.fromstring(page.content)
|
||||||
# get all <tr> elements in <table id="gattTable">
|
# get all <tr> elements in <table>
|
||||||
rows = tree.xpath('//table[@id="gattTable"]/tbody/tr')
|
rows = tree.xpath('//table/tbody/tr')
|
||||||
for row in rows:
|
for row in rows:
|
||||||
children = row.getchildren()
|
children = row.getchildren()
|
||||||
summary = children[0].text_content()
|
summary = strip_non_ascii(children[0].text_content())
|
||||||
id = children[1].text_content()
|
id = children[1].text_content()
|
||||||
|
# fix unexpected suffix _
|
||||||
|
id = id.replace('.gatt_.', '.gatt.')
|
||||||
uuid = children[2].text_content()
|
uuid = children[2].text_content()
|
||||||
if (len(id)):
|
if (len(id)):
|
||||||
tag = id.upper().replace('.', '_').replace('-','_')
|
tag = id.upper().replace('.', '_').replace('-','_')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user