wiced-h4: support WICED Studio (incl. 5.2)

This commit is contained in:
Matthias Ringwald 2017-11-06 12:25:47 +01:00
parent 23c00ae5e8
commit 20334a06fd
2 changed files with 36 additions and 7 deletions

View File

@ -21,6 +21,9 @@ GLOBAL_INCLUDES += .
$(NAME)_SOURCES := ../../../libraries/btstack/example/EXAMPLE.c
$(NAME)_COMPONENTS += btstack/port/wiced-h4
$(NAME)_CFLAGS += ADDITIONAL_CFLAGS
BT_FIRMWARE_PATH := BLUETOOTH_FIRMWARE_PATH
BT_FIRMWARE_FILE := BLUETOOTH_FIRMWARE_FILE
'''
gatt_update_template = '''#!/bin/sh
@ -35,18 +38,29 @@ script_path = os.path.abspath(os.path.dirname(sys.argv[0]))
# validate WICED root by reading version.txt
wiced_root = script_path + "/../../../../"
wiced_version = ""
wiced_version_txt = ""
try:
with open(wiced_root + 'version.txt', 'r') as fin:
wiced_version = fin.read() # Read the contents of the file into memory.
wiced_version_txt = fin.read() # Read the contents of the file into memory.
except:
pass
if not "WICED Version" in wiced_version:
if not "WICED Version" in wiced_version_txt:
print("Cannot find WICED root. Make sure BTstack is checked out in WICED-SDK-X/libraries")
sys.exit(1)
# check for 5.2+ version syntax
if 'Wiced_' in wiced_version_txt:
wiced_version_string = (wiced_version_txt.split()[2]).split('_')[1]
wiced_version_major = int(wiced_version_string.split('.')[0])
wiced_version_minor = int(wiced_version_string.split('.')[1])
else:
wiced_version = wiced_version_txt.split()[2]
wiced_version_major = int(wiced_version.split('.')[0])
wiced_version_minor = int(wiced_version.split('.')[1])
wiced_version = "%u.%u" % (wiced_version_major, wiced_version_minor)
# show WICED version
wiced_version = wiced_version.split()[2]
print("Found WICED SDK version: %s" % wiced_version)
additional_cflags = ""
@ -54,6 +68,21 @@ if wiced_version < "3.4.0":
print("Adding WICED_UART_READ_DOES_NOT_RETURN_BYTES_READ for SDK < 3.4.0")
additional_cflags = "-DWICED_UART_READ_DOES_NOT_RETURN_BYTES_READ"
# NOTE: it would be more robust to check for files on disk
# drivers folder was moved into librarias with 4.0
if wiced_version < "4.0":
bluetooth_firmware_path = 'drivers/bluetooth/firmware'
else:
bluetooth_firmware_path = 'libraries/drivers/bluetooth/firmware'
print("Bluetooth Firmware in %s" % bluetooth_firmware_path)
# bluetooth firmware image name changed in 5.2
if wiced_version < "5.2":
bluetooth_firmware_file = 'bt_firmware_image.c'
else:
bluetooth_firmware_file = 'bt_firmware_controller.c'
print("Bluetooth Firmware name: %s" % bluetooth_firmware_file)
# path to examples
examples_embedded = script_path + "/../../example/"
@ -76,7 +105,7 @@ for file in os.listdir(examples_embedded):
# create .mk file
with open(apps_folder + example + ".mk", "wt") as fout:
fout.write(mk_template.replace("EXAMPLE", example).replace("TOOL", script_path).replace("ADDITIONAL_CFLAGS", additional_cflags).replace("DATE",time.strftime("%c")))
fout.write(mk_template.replace("EXAMPLE", example).replace("TOOL", script_path).replace("ADDITIONAL_CFLAGS", additional_cflags).replace("DATE",time.strftime("%c")).replace('BLUETOOTH_FIRMWARE_PATH', bluetooth_firmware_path).replace('BLUETOOTH_FIRMWARE_FILE', bluetooth_firmware_file))
# create update_gatt.sh if .gatt file is present
gatt_path = examples_embedded + example + ".gatt"

View File

@ -63,7 +63,7 @@ $(NAME)_SOURCES += \
../../chipset/bcm/btstack_chipset_bcm.c \
ifeq ($(BT_CHIP_XTAL_FREQUENCY),)
$(NAME)_SOURCES += ../../../drivers/bluetooth/firmware/$(BT_CHIP)$(BT_CHIP_REVISION)/bt_firmware_image.c
$(NAME)_SOURCES += ../../../../$(BT_FIRMWARE_PATH)/$(BT_CHIP)$(BT_CHIP_REVISION)/$(BT_FIRMWARE_FILE)
else
$(NAME)_SOURCES += ../../../drivers/bluetooth/firmware/$(BT_CHIP)$(BT_CHIP_REVISION)/$(BT_CHIP_XTAL_FREQUENCY)/bt_firmware_image.c
$(NAME)_SOURCES += ../../../../$(BT_FIRMWARE_PATH)/$(BT_CHIP)$(BT_CHIP_REVISION)/$(BT_CHIP_XTAL_FREQUENCY)/$(BT_FIRMWARE_FILE)
endif