mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-16 08:42:28 +00:00
fix syntax for Python 3, see #393
This commit is contained in:
parent
a027ff0287
commit
1a686d5ebc
@ -27,10 +27,10 @@ Usage: ./compile-gatt.py profile.gatt profile.h
|
|||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
print '''
|
print('''
|
||||||
BLE configuration generator for use with BTstack, v0.1
|
BLE configuration generator for use with BTstack, v0.1
|
||||||
Copyright 2011 Matthias Ringwald
|
Copyright 2011 Matthias Ringwald
|
||||||
'''
|
''')
|
||||||
|
|
||||||
assigned_uuids = {
|
assigned_uuids = {
|
||||||
'GAP_SERVICE' : 0x1800,
|
'GAP_SERVICE' : 0x1800,
|
||||||
@ -120,7 +120,7 @@ def parseProperties(properties):
|
|||||||
if property in property_flags:
|
if property in property_flags:
|
||||||
value |= property_flags[property]
|
value |= property_flags[property]
|
||||||
else:
|
else:
|
||||||
print "WARNING: property %s undefined" % (property)
|
print("WARNING: property %s undefined" % (property))
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def write_8(fout, value):
|
def write_8(fout, value):
|
||||||
@ -164,7 +164,7 @@ def parseService(fout, parts, service_type):
|
|||||||
|
|
||||||
if current_service_uuid_string:
|
if current_service_uuid_string:
|
||||||
fout.write("\n")
|
fout.write("\n")
|
||||||
# print "append service %s = [%d, %d]\n" % (current_characteristic_uuid_string, current_service_start_handle, handle-1)
|
# print("append service %s = [%d, %d]\n" % (current_characteristic_uuid_string, current_service_start_handle, handle-1))
|
||||||
services[current_service_uuid_string] = [current_service_start_handle, handle-1]
|
services[current_service_uuid_string] = [current_service_start_handle, handle-1]
|
||||||
|
|
||||||
property = property_flags['READ'];
|
property = property_flags['READ'];
|
||||||
@ -212,7 +212,7 @@ def parseIncludeService(fout, parts):
|
|||||||
uuid_size = len(uuid)
|
uuid_size = len(uuid)
|
||||||
if uuid_size > 2:
|
if uuid_size > 2:
|
||||||
uuid_size = 0
|
uuid_size = 0
|
||||||
# print "Include Service ", keyForUUID(uuid)
|
# print("Include Service ", keyForUUID(uuid))
|
||||||
|
|
||||||
size = 2 + 2 + 2 + 2 + 4 + uuid_size
|
size = 2 + 2 + 2 + 2 + 4 + uuid_size
|
||||||
|
|
||||||
@ -385,7 +385,7 @@ def parseCharacteristicFormat(fout, parts):
|
|||||||
|
|
||||||
identifier = parts[1]
|
identifier = parts[1]
|
||||||
presentation_formats[identifier] = handle
|
presentation_formats[identifier] = handle
|
||||||
# print "format '%s' with handle %d\n" % (identifier, handle)
|
# print("format '%s' with handle %d\n" % (identifier, handle))
|
||||||
|
|
||||||
format = parts[2]
|
format = parts[2]
|
||||||
exponent = parts[3]
|
exponent = parts[3]
|
||||||
@ -428,7 +428,7 @@ def parseCharacteristicAggregateFormat(fout, parts):
|
|||||||
for identifier in parts[1:]:
|
for identifier in parts[1:]:
|
||||||
format_handle = presentation_formats[identifier]
|
format_handle = presentation_formats[identifier]
|
||||||
if format == 0:
|
if format == 0:
|
||||||
print "ERROR: identifier '%s' in CHARACTERISTIC_AGGREGATE_FORMAT undefined" % identifier
|
print("ERROR: identifier '%s' in CHARACTERISTIC_AGGREGATE_FORMAT undefined" % identifier)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
write_16(fout, format_handle)
|
write_16(fout, format_handle)
|
||||||
fout.write("\n")
|
fout.write("\n")
|
||||||
@ -488,7 +488,7 @@ def parse(fname_in, fin, fname_out, fout):
|
|||||||
parseCharacteristicAggregateFormat(fout, parts)
|
parseCharacteristicAggregateFormat(fout, parts)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
print "WARNING: unknown token: %s\n" % (parts[0])
|
print("WARNING: unknown token: %s\n" % (parts[0]))
|
||||||
|
|
||||||
write_indent(fout)
|
write_indent(fout)
|
||||||
fout.write("// END\n");
|
fout.write("// END\n");
|
||||||
@ -509,7 +509,7 @@ def listHandles(fout):
|
|||||||
fout.write('\n')
|
fout.write('\n')
|
||||||
|
|
||||||
if (len(sys.argv) < 3):
|
if (len(sys.argv) < 3):
|
||||||
print usage
|
print(usage)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
try:
|
try:
|
||||||
filename = sys.argv[2]
|
filename = sys.argv[2]
|
||||||
@ -518,13 +518,10 @@ try:
|
|||||||
parse(sys.argv[1], fin, filename, fout)
|
parse(sys.argv[1], fin, filename, fout)
|
||||||
listHandles(fout)
|
listHandles(fout)
|
||||||
fout.close()
|
fout.close()
|
||||||
print 'Created', filename
|
print('Created', filename)
|
||||||
|
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print usage
|
print(usage)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
print 'Compilation successful!\n'
|
print('Compilation successful!\n')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user