cc256x: skip BLE and AVRP add ons, try to match and include BLE add-on

This commit is contained in:
Matthias Ringwald 2015-04-11 23:34:35 +02:00
parent 179bfefa83
commit f6c32422ce

View File

@ -7,6 +7,7 @@
import glob import glob
import re import re
import sys import sys
import os
print ''' print '''
CC256x init script conversion tool for use with BTstack, v0.1 CC256x init script conversion tool for use with BTstack, v0.1
@ -95,23 +96,16 @@ def append_calibration_sequence(additions, str_list, data_indent):
str_list.append("0x01, 0x80, 0xfd, 0x06, 0x3c, 0xf0, 0x5f, 0x00, 0x00, 0x00,\n\n") str_list.append("0x01, 0x80, 0xfd, 0x06, 0x3c, 0xf0, 0x5f, 0x00, 0x00, 0x00,\n\n")
return 20 return 20
def convert_bts(bts_file): def convert_bts(main_bts_file, bts_add_on):
array_name = 'cc256x' array_name = 'cc256x'
c_file = bts_file.replace('bts', 'c') c_file = main_bts_file.replace('bts', 'c')
input_files = [ main_bts_file ]
if bts_add_on != "":
input_files.append(bts_add_on)
with open(c_file, 'w') as fout: with open(c_file, 'w') as fout:
with open (bts_file, 'rb') as fin:
print "Converting {0:32} to {1}".format(bts_file, c_file)
header = fin.read(32)
if header[0:4] != 'BTSB':
print 'Error', bts_file, 'is not a valid .BTS file'
sys.exit(1)
part_size = 0
# assert script contains templates for configuration by BTstack # assert script contains templates for configuration by BTstack
have_eHCILL = False have_eHCILL = False
have_power_vector_gfsk = False; have_power_vector_gfsk = False;
@ -119,12 +113,28 @@ def convert_bts(bts_file):
have_power_vector_edr3 = False; have_power_vector_edr3 = False;
have_class2_single_power = False; have_class2_single_power = False;
print "Creating {0}".format(c_file)
part_size = 0
parts = 0 parts = 0
str_list = [] str_list = []
part_strings = [] part_strings = []
part_sizes = [] part_sizes = []
additions = [] additions = []
for bts_file in input_files:
with open (bts_file, 'rb') as fin:
print "- parsing {0:32}".format(bts_file)
header = fin.read(32)
if header[0:4] != 'BTSB':
print 'Error', bts_file, 'is not a valid .BTS file'
sys.exit(1)
while True: while True:
action_type = read_little_endian_16(fin) action_type = read_little_endian_16(fin)
action_size = read_little_endian_16(fin) action_size = read_little_endian_16(fin)
@ -211,7 +221,10 @@ def convert_bts(bts_file):
part_sizes.append(part_size) part_sizes.append(part_size)
parts += 1 parts += 1
fout.write( '// init script created from {0}\n'.format(bts_file)) fout.write( '// init script created from\n')
fout.write( '// - {0}\n'.format(main_bts_file))
if bts_add_on != "":
fout.write( '// - {0}\n'.format(bts_add_on))
fout.write( '#include <stdint.h>\n') fout.write( '#include <stdint.h>\n')
part = 0 part = 0
@ -261,7 +274,24 @@ if not files:
# convert each of them # convert each of them
for name in files: for name in files:
convert_bts(name) # skip BLE and AVRP add-ons
if name.lower().startswith('ble_init_cc'):
print "Skipping BLE add-on", name
continue
if name.lower().startswith('avpr_init_cc'):
print "Skipping AVPR add-on", name
continue
# check for BLE add-on
add_on = ""
name_parts = re.match('bluetooth_init_(.....+_...)_.*.bts', name)
if name_parts:
potential_add_on = 'BLE_init_%s.bts' % name_parts.group(1)
if os.path.isfile(potential_add_on):
add_on = potential_add_on
print "Found", add_on, "add on for", name
convert_bts(name, add_on)
# done # done
print '\nConversion(s) successful!\n' print '\nConversion(s) successful!\n'