From 2b25cc0e9339df67b6d1a0baa252ec4df0bd7083 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Mon, 23 Oct 2017 18:07:57 +0200 Subject: [PATCH] stm32-f4discovery-cc256x: create update_gatt_db.py in python instead of shell script --- .../create_examples.py | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/port/stm32-f4discovery-cc256x/create_examples.py b/port/stm32-f4discovery-cc256x/create_examples.py index 8a104ea06..c08f486df 100755 --- a/port/stm32-f4discovery-cc256x/create_examples.py +++ b/port/stm32-f4discovery-cc256x/create_examples.py @@ -9,13 +9,27 @@ import subprocess import sys -gatt_update_template = '''#!/bin/sh -DIR=`dirname $0` -PROJECT_LOC=$DIR -echo "Creating EXAMPLE.h from EXAMPLE.gatt" -$PROJECT_LOC/btstack/tool/compile_gatt.py $PROJECT_LOC/example/EXAMPLE.gatt $PROJECT_LOC/example/EXAMPLE.h +gatt_update_template = '''#!/usr/bin/env python + +import subprocess +import os +import sys + +# get project path +project_path = os.path.abspath(os.path.dirname(sys.argv[0])) + '/' + +print('Creating EXAMPLE.h from EXAMPLE.gatt') + +# execute script +compile_gatt_script = project_path + "/btstack/tool/compile_gatt.py" +gatt_file = project_path + '/example/EXAMPLE.gatt' +h_file = project_path + '/example/EXAMPLE.h' +print(gatt_file) +print(h_file) +subprocess.call([compile_gatt_script, gatt_file, h_file]) ''' + ## pick correct init script based on your hardware # - init script for CC2564B cc256x_init_script = 'bluetooth_init_cc2564B_1.6_BT_Spec_4.1.c' @@ -116,7 +130,7 @@ for file in example_files: shutil.copy(btstack_root + 'tool/compile_gatt.py', compile_gatt_path) os.chmod(compile_gatt_path, 0o755) # create example/update_gatt_db.sh - update_gatt_script = project_folder + "update_gatt_db.sh" + update_gatt_script = project_folder + "update_gatt_db.py" with open(update_gatt_script, "wt") as fout: fout.write(gatt_update_template.replace("EXAMPLE", example)) os.chmod(update_gatt_script, 0o755)