assert templates for set power vector and set class2 single power exist

This commit is contained in:
matthias.ringwald@gmail.com 2014-10-31 13:04:19 +00:00
parent 2e97c1499b
commit 24f2c40e67

View File

@ -1,5 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python
# Matthias Ringwald (c) 2012 # BlueKitchen GmbH (c) 2012-2014
# documentation for TI Vendor Specific commands:
# http://processors.wiki.ti.com/index.php/CC256x_VS_HCI_Commands
import glob import glob
import re import re
@ -7,11 +10,11 @@ import sys
print ''' print '''
CC256x init script conversion tool for use with BTstack, v0.1 CC256x init script conversion tool for use with BTstack, v0.1
Copyright 2012 Matthias Ringwald Copyright 2012-2014 BlueKitchen GmbH
''' '''
usage = '''This script converts init scripts for TI's usage = '''This script perpares init scripts for TI's
CC2560/CC2567 chipset from the provided BTS file for use with BTstack . CC256x chipsets for use with BTstack .
Please download the Service Pack for your module from http://processors.wiki.ti.com/index.php/CC256x_Downloads Please download the Service Pack for your module from http://processors.wiki.ti.com/index.php/CC256x_Downloads
Then, unzip it and copy the *.bts file into this folder and start the script again. Then, unzip it and copy the *.bts file into this folder and start the script again.
@ -52,11 +55,19 @@ def convert_bts(bts_file):
sys.exit(1) sys.exit(1)
part_size = 0 part_size = 0
# assert script contains templates for configuration by BTstack
have_eHCILL = False have_eHCILL = False
have_power_vector_gfsk = False;
have_power_vector_edr2 = False;
have_power_vector_edr3 = False;
have_class2_single_power = False;
parts = 0 parts = 0
str_list = [] str_list = []
part_strings = [] part_strings = []
part_sizes = [] part_sizes = []
additions = []
while True: while True:
action_type = read_little_endian_16(fin) action_type = read_little_endian_16(fin)
@ -70,7 +81,51 @@ def convert_bts(bts_file):
continue # skip baud rate command continue # skip baud rate command
if opcode == 0xFD0C: if opcode == 0xFD0C:
have_eHCILL = True have_eHCILL = True
if opcode == 0xFD82:
modulation_type = ord(action_data[4])
if modulation_type == 0:
have_power_vector_gfsk = True
elif modulation_type == 1:
have_power_vector_edr2 + True
elif modulation_type == 2:
have_power_vector_edr3 = True
if opcode == 0xFD80:
# add missing power command templates
if not have_power_vector_gfsk:
additions.append("- added HCI_VS_SET_POWER_VECTOR(GFSK) template")
str_list.append(data_indent)
str_list.append('// BTstack: added HCI_VS_SET_POWER_VECTOR(GFSK) 0xFD82 template\n');
str_list.append(data_indent)
str_list.append("0x01, 0x82, 0xfd, 0x14, 0x00, 0x9c, 0x18, 0xd2, 0xd2, 0xd2, 0xd2, 0xd2, 0xd2, 0xd2, 0xdc,\n");
str_list.append(data_indent)
str_list.append("0xe6, 0xf0, 0xfa, 0x04, 0x0e, 0x18, 0xff, 0x00, 0x00,\n");
have_power_vector_gfsk = True;
if not have_power_vector_edr2:
additions.append("- added HCI_VS_SET_POWER_VECTOR(EDR2) template")
str_list.append(data_indent)
str_list.append('// BTstack: added HCI_VS_SET_POWER_VECTOR(EDR2) 0xFD82 template\n');
str_list.append(data_indent)
str_list.append("0x01, 0x82, 0xfd, 0x14, 0x01, 0x9c, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xd8, \n");
str_list.append(data_indent)
str_list.append("0xe2, 0xec, 0xf6, 0x00, 0x0a, 0x14, 0xff, 0x00, 0x00\n");
have_power_vector_edr2 = True;
if not have_power_vector_edr3:
additions.append("- added HCI_VS_SET_POWER_VECTOR(EDR3) template")
str_list.append(data_indent)
str_list.append('// BTstack: added HCI_VS_SET_POWER_VECTOR(EDR3) 0xFD82 for EDR3 template\n');
str_list.append(data_indent)
str_list.append("0x01, 0x82, 0xfd, 0x14, 0x02, 0x9c, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xd8,\n");
str_list.append(data_indent)
str_list.append("0xe2, 0xec, 0xf6, 0x00, 0x0a, 0x14, 0xff, 0x00, 0x00,\n");
have_power_vector_edr3 = True;
if not have_class2_single_power:
additions.append("- added HCI_VS_SET_CLASS2_SINGLE_POWER template")
str_list.append(data_indent)
str_list.append('// BTstack: added HCI_VS_SET_CLASS2_SINGLE_POWER 0xFD87 template\n');
str_list.append(data_indent)
str_list.append("0x01, 0x87, 0xfd, 0x03, 0x0d, 0x0d, 0x0d, \n");
have_class2_single_power = True;
counter = 0 counter = 0
str_list.append(data_indent) str_list.append(data_indent)
for byte in action_data: for byte in action_data:
@ -106,12 +161,13 @@ def convert_bts(bts_file):
if not have_eHCILL: if not have_eHCILL:
additions.append("- added eHCILL template")
str_list.append('\n') str_list.append('\n')
str_list.append(data_indent) str_list.append(data_indent)
str_list.append('// BTstack: added HCI_VS_Sleep_Mode_Configurations 0xFD0C template for eHCILL\n'); str_list.append('// BTstack: added HCI_VS_Sleep_Mode_Configurations 0xFD0C template for eHCILL\n');
str_list.append(data_indent) str_list.append(data_indent)
str_list.append('0x01, 0x0c, 0xfd, 9 , 1, 0, 0, 0xff, 0xff, 0xff, 0xff, 100, 0\n'); str_list.append('0x01, 0x0c, 0xfd, 9 , 1, 0, 0, 0xff, 0xff, 0xff, 0xff, 100, 0\n');
part_strings.append(''.join(str_list)) part_strings.append(''.join(str_list))
part_sizes.append(part_size) part_sizes.append(part_size)
parts += 1 parts += 1
@ -126,11 +182,15 @@ def convert_bts(bts_file):
size += part_size size += part_size
print "- part", part, "size", part_size print "- part", part, "size", part_size
if not have_eHCILL:
print "- adding eHCILL template"
print '- total size', size print '- total size', size
print "\n".join(additions)
# raise alaram if not all power commands have been incorporated
all_power_commands_provided = have_power_vector_gfsk and have_power_vector_edr2 and have_power_vector_edr3 and have_class2_single_power
if not all_power_commands_provided:
print "\nWARNING: init script doesn't contain a calibration sequence. Please report on the BTstack Dveloper mailing list\n"
part = 0 part = 0
for part_text in part_strings: for part_text in part_strings:
part += 1 part += 1