stm32-f4discovery-cc256x: create update_gatt_db.py in python instead of shell script

This commit is contained in:
Matthias Ringwald 2017-10-23 18:07:57 +02:00
parent 858282951e
commit 2b25cc0e93

View File

@ -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)