mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-03 20:54:18 +00:00
bluetooth_sdp: follow changes on Bluetooth SIG site
This commit is contained in:
parent
0d9cb02c2e
commit
cccaab8051
@ -12,6 +12,8 @@ import os
|
|||||||
import codecs
|
import codecs
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
headers = {'user-agent': 'curl/7.63.0'}
|
||||||
|
|
||||||
program_info = '''
|
program_info = '''
|
||||||
BTstack SDP UUID Scraper for BTstack
|
BTstack SDP UUID Scraper for BTstack
|
||||||
Copyright 2017, BlueKitchen GmbH
|
Copyright 2017, BlueKitchen GmbH
|
||||||
@ -52,18 +54,19 @@ def create_pretty_define(name):
|
|||||||
name = name.replace('(','_')
|
name = name.replace('(','_')
|
||||||
name = name.replace(')','')
|
name = name.replace(')','')
|
||||||
name = name.replace('-','_')
|
name = name.replace('-','_')
|
||||||
|
name = name.replace('.','_')
|
||||||
name = name.replace('PnP', 'PNP')
|
name = name.replace('PnP', 'PNP')
|
||||||
name = name.replace('IPv', 'IPV')
|
name = name.replace('IPv', 'IPV')
|
||||||
name = name.replace('ServiceDiscoveryServerServiceClassID', 'ServiceDiscoveryServer')
|
name = name.replace('ServiceDiscoveryServerServiceClassID', 'ServiceDiscoveryServer')
|
||||||
name = name.replace('BrowseGroupDescriptorServiceClassID', 'BrowseGroupDescriptor')
|
name = name.replace('BrowseGroupDescriptorServiceClassID', 'BrowseGroupDescriptor')
|
||||||
name = name.replace('&','and')
|
name = name.replace('&','and')
|
||||||
|
name = name.replace('__','_')
|
||||||
return camel_to_underscore(name).replace('__','_').replace('3_D','3D').replace('L2_CAP','L2CAP')
|
return camel_to_underscore(name).replace('__','_').replace('3_D','3D').replace('L2_CAP','L2CAP')
|
||||||
|
|
||||||
def remove_newlines(remark):
|
def remove_newlines(remark):
|
||||||
return " ".join(remark.split())
|
return " ".join(remark.split())
|
||||||
|
|
||||||
def process_table(fout, tbody, pattern):
|
def process_rows(fout, rows, pattern):
|
||||||
rows = tbody.getchildren()
|
|
||||||
for row in rows:
|
for row in rows:
|
||||||
columns = row.getchildren()
|
columns = row.getchildren()
|
||||||
name = columns[0].text_content().encode('ascii','ignore')
|
name = columns[0].text_content().encode('ascii','ignore')
|
||||||
@ -87,17 +90,12 @@ def process_table(fout, tbody, pattern):
|
|||||||
fout.write(pattern % (name, value, remark))
|
fout.write(pattern % (name, value, remark))
|
||||||
defines.append(name)
|
defines.append(name)
|
||||||
|
|
||||||
def scrape_attributes(fout, tree, table_name):
|
|
||||||
tables = tree.xpath("//table[preceding-sibling::h3 = '" + table_name +"']")
|
|
||||||
tbody = tables[0].getchildren()[0]
|
|
||||||
process_table(fout, tbody, '#define BLUETOOTH_ATTRIBUTE_%-54s %s // %s\n')
|
|
||||||
|
|
||||||
def scrape_page(fout, url):
|
def scrape_page(fout, url):
|
||||||
print("Parsing %s" % url)
|
print("Parsing %s" % url)
|
||||||
fout.write(header.format(page=url,datetime=str(datetime.datetime.now())))
|
fout.write(header.format(page=url,datetime=str(datetime.datetime.now())))
|
||||||
|
|
||||||
# get from web
|
# get from web
|
||||||
r = requests.get(url)
|
r = requests.get(url, headers=headers)
|
||||||
content = r.text
|
content = r.text
|
||||||
|
|
||||||
# test: fetch from local file 'service-discovery.html'
|
# test: fetch from local file 'service-discovery.html'
|
||||||
@ -106,22 +104,20 @@ def scrape_page(fout, url):
|
|||||||
|
|
||||||
tree = html.fromstring(content)
|
tree = html.fromstring(content)
|
||||||
|
|
||||||
# # Protocol Identifiers
|
# Protocol Identifiers
|
||||||
fout.write('/**\n')
|
fout.write('/**\n')
|
||||||
fout.write(' * Protocol Identifiers\n')
|
fout.write(' * Protocol Identifiers\n')
|
||||||
fout.write(' */\n')
|
fout.write(' */\n')
|
||||||
tables = tree.xpath("//table[preceding-sibling::h3 = 'Protocol Identifiers']")
|
rows = tree.xpath("//table[2]/tbody/tr")
|
||||||
tbody = tables[0].getchildren()[0]
|
process_rows(fout, rows, '#define BLUETOOTH_PROTOCOL_%-55s %s // %s\n')
|
||||||
process_table(fout, tbody, '#define BLUETOOTH_PROTOCOL_%-55s %s // %s\n')
|
|
||||||
fout.write('\n')
|
fout.write('\n')
|
||||||
|
|
||||||
# # Service Classes
|
# Service Classes
|
||||||
fout.write('/**\n')
|
fout.write('/**\n')
|
||||||
fout.write(' * Service Classes\n')
|
fout.write(' * Service Classes\n')
|
||||||
fout.write(' */\n')
|
fout.write(' */\n')
|
||||||
tables = tree.xpath("//table[preceding-sibling::h3 = 'Protocol Identifiers']")
|
rows = tree.xpath("//table[3]/tr")
|
||||||
tbody = tables[1].getchildren()[0]
|
process_rows(fout, rows, '#define BLUETOOTH_SERVICE_CLASS_%-50s %s // %s\n')
|
||||||
process_table(fout, tbody, '#define BLUETOOTH_SERVICE_CLASS_%-50s %s // %s\n')
|
|
||||||
fout.write('\n')
|
fout.write('\n')
|
||||||
|
|
||||||
# Attributes
|
# Attributes
|
||||||
@ -161,7 +157,9 @@ def scrape_page(fout, url):
|
|||||||
'Calendar Tasks and Notes',
|
'Calendar Tasks and Notes',
|
||||||
]
|
]
|
||||||
for table_name in table_names:
|
for table_name in table_names:
|
||||||
scrape_attributes(fout, tree, table_name)
|
rows = tree.xpath("//table[preceding-sibling::h3 = '" + table_name +"']/tr")
|
||||||
|
process_rows(fout, rows, '#define BLUETOOTH_ATTRIBUTE_%-54s %s // %s\n')
|
||||||
|
# scrape_attributes(fout, tree, table_name)
|
||||||
# see above
|
# see above
|
||||||
fout.write('#define BLUETOOTH_ATTRIBUTE_GNSS_SUPPORTED_FEATURES 0x0200\n');
|
fout.write('#define BLUETOOTH_ATTRIBUTE_GNSS_SUPPORTED_FEATURES 0x0200\n');
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user