esp32: create examples in examples folder, fix update_gatt.sh

This commit is contained in:
Matthias Ringwald 2017-09-25 21:35:38 +02:00
parent 6f952a2331
commit f936392b85
3 changed files with 20 additions and 12 deletions

View File

@ -26,10 +26,9 @@ import os
import sys import sys
script_path = os.path.abspath(os.path.dirname(sys.argv[0])) script_path = os.path.abspath(os.path.dirname(sys.argv[0]))
btstack_root = script_path + '/../../../' compile_gatt = os.environ['IDF_PATH'] + '/components/btstack/tool/compile_gatt.py'
compile_gatt = btstack_root + 'tool/compile_gatt.py' print("Creating src/gatt_battery_query.h from src/gatt_battery_query.gatt")
print("Creating src/EXAMPLE.h from EXAMPLE.gatt") sys.argv= [compile_gatt, script_path + "/main/EXAMPLE.gatt", script_path + "/main/EXAMPLE.h"]
sys.argv= [compile_gatt, btstack_root + "example/EXAMPLE.gatt", script_path + "/main/EXAMPLE.h"]
exec(open(compile_gatt).read(), globals()) exec(open(compile_gatt).read(), globals())
''' '''
@ -39,10 +38,14 @@ script_path = os.path.abspath(os.path.dirname(sys.argv[0]))
# path to examples # path to examples
examples_embedded = script_path + "/../../example/" examples_embedded = script_path + "/../../example/"
# path to zephyr/samples/btstack # path to samples
apps_btstack = "" examples_folder = script_path + "/examples/"
print("Creating examples in local folder") print("Creating examples folder")
if not os.path.exists(examples_folder):
os.makedirs(examples_folder)
print("Creating examples in examples folder")
# iterate over btstack examples # iterate over btstack examples
for file in os.listdir(examples_embedded): for file in os.listdir(examples_embedded):
@ -55,7 +58,7 @@ for file in os.listdir(examples_embedded):
gatt_path = examples_embedded + example + ".gatt" gatt_path = examples_embedded + example + ".gatt"
# create folder # create folder
apps_folder = apps_btstack + example + "/" apps_folder = examples_folder + example + "/"
if os.path.exists(apps_folder): if os.path.exists(apps_folder):
shutil.rmtree(apps_folder) shutil.rmtree(apps_folder)
os.makedirs(apps_folder) os.makedirs(apps_folder)
@ -67,7 +70,6 @@ for file in os.listdir(examples_embedded):
# mark set_port.sh as executable # mark set_port.sh as executable
os.chmod(apps_folder + '/set_port.sh', 0o755) os.chmod(apps_folder + '/set_port.sh', 0o755)
# create Makefile file # create Makefile file
with open(apps_folder + "Makefile", "wt") as fout: with open(apps_folder + "Makefile", "wt") as fout:
fout.write(mk_template.replace("EXAMPLE", example).replace("TOOL", script_path).replace("DATE",time.strftime("%c"))) fout.write(mk_template.replace("EXAMPLE", example).replace("TOOL", script_path).replace("DATE",time.strftime("%c")))
@ -91,6 +93,7 @@ for file in os.listdir(examples_embedded):
# create update_gatt.sh if .gatt file is present # create update_gatt.sh if .gatt file is present
gatt_path = examples_embedded + example + ".gatt" gatt_path = examples_embedded + example + ".gatt"
if os.path.exists(gatt_path): if os.path.exists(gatt_path):
shutil.copy(gatt_path, apps_folder + "/main/" + example + ".gatt")
update_gatt_script = apps_folder + "update_gatt_db.py" update_gatt_script = apps_folder + "update_gatt_db.py"
with open(update_gatt_script, "wt") as fout: with open(update_gatt_script, "wt") as fout:
fout.write(gatt_update_template.replace("EXAMPLE", example)) fout.write(gatt_update_template.replace("EXAMPLE", example))

View File

@ -15,11 +15,9 @@ script_path = os.path.abspath(os.path.dirname(sys.argv[0]))
examples_embedded = script_path + "/../../example/" examples_embedded = script_path + "/../../example/"
# path to port/esp32 # path to port/esp32
apps_btstack = "" apps_btstack = script_path + "/"
print("Deleting examples in local folder") print("Deleting examples in local folder")
# iterate over btstack examples
for file in os.listdir(examples_embedded): for file in os.listdir(examples_embedded):
if not file.endswith(".c"): if not file.endswith(".c"):
continue continue
@ -29,3 +27,7 @@ for file in os.listdir(examples_embedded):
shutil.rmtree(apps_folder) shutil.rmtree(apps_folder)
print("- %s" % example) print("- %s" % example)
print("Deleting examples folder")
examples_folder = apps_btstack + "/examples"
if os.path.exists(examples_folder):
shutil.rmtree(examples_folder)

View File

@ -29,5 +29,8 @@ rsync -a ../../platform/freertos ${IDF_PATH}/components/btstack/platform
# sync embedded run loop # sync embedded run loop
rsync -a ../../platform/embedded ${IDF_PATH}/components/btstack/platform rsync -a ../../platform/embedded ${IDF_PATH}/components/btstack/platform
# sync tools - used to access compile_gatt.py
rsync -a ../../tool ${IDF_PATH}/components/btstack
# create samples/btstack # create samples/btstack
./create_examples.py ./create_examples.py