From f936392b8506e7240b72f4bffe985b4b31a51497 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Mon, 25 Sep 2017 21:35:38 +0200 Subject: [PATCH] esp32: create examples in examples folder, fix update_gatt.sh --- port/esp32/create_examples.py | 21 ++++++++++++--------- port/esp32/delete_examples.py | 8 +++++--- port/esp32/integrate_btstack.sh | 3 +++ 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/port/esp32/create_examples.py b/port/esp32/create_examples.py index 6911ed8e6..f79d51dd1 100755 --- a/port/esp32/create_examples.py +++ b/port/esp32/create_examples.py @@ -26,10 +26,9 @@ import os import sys script_path = os.path.abspath(os.path.dirname(sys.argv[0])) -btstack_root = script_path + '/../../../' -compile_gatt = btstack_root + 'tool/compile_gatt.py' -print("Creating src/EXAMPLE.h from EXAMPLE.gatt") -sys.argv= [compile_gatt, btstack_root + "example/EXAMPLE.gatt", script_path + "/main/EXAMPLE.h"] +compile_gatt = os.environ['IDF_PATH'] + '/components/btstack/tool/compile_gatt.py' +print("Creating src/gatt_battery_query.h from src/gatt_battery_query.gatt") +sys.argv= [compile_gatt, script_path + "/main/EXAMPLE.gatt", script_path + "/main/EXAMPLE.h"] exec(open(compile_gatt).read(), globals()) ''' @@ -39,10 +38,14 @@ script_path = os.path.abspath(os.path.dirname(sys.argv[0])) # path to examples examples_embedded = script_path + "/../../example/" -# path to zephyr/samples/btstack -apps_btstack = "" +# path to samples +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 for file in os.listdir(examples_embedded): @@ -55,7 +58,7 @@ for file in os.listdir(examples_embedded): gatt_path = examples_embedded + example + ".gatt" # create folder - apps_folder = apps_btstack + example + "/" + apps_folder = examples_folder + example + "/" if os.path.exists(apps_folder): shutil.rmtree(apps_folder) os.makedirs(apps_folder) @@ -67,7 +70,6 @@ for file in os.listdir(examples_embedded): # mark set_port.sh as executable os.chmod(apps_folder + '/set_port.sh', 0o755) - # create Makefile file with open(apps_folder + "Makefile", "wt") as fout: 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 gatt_path = examples_embedded + example + ".gatt" if os.path.exists(gatt_path): + shutil.copy(gatt_path, apps_folder + "/main/" + example + ".gatt") update_gatt_script = apps_folder + "update_gatt_db.py" with open(update_gatt_script, "wt") as fout: fout.write(gatt_update_template.replace("EXAMPLE", example)) diff --git a/port/esp32/delete_examples.py b/port/esp32/delete_examples.py index 833efc915..ad8a61c2d 100755 --- a/port/esp32/delete_examples.py +++ b/port/esp32/delete_examples.py @@ -15,11 +15,9 @@ script_path = os.path.abspath(os.path.dirname(sys.argv[0])) examples_embedded = script_path + "/../../example/" # path to port/esp32 -apps_btstack = "" +apps_btstack = script_path + "/" print("Deleting examples in local folder") - -# iterate over btstack examples for file in os.listdir(examples_embedded): if not file.endswith(".c"): continue @@ -29,3 +27,7 @@ for file in os.listdir(examples_embedded): shutil.rmtree(apps_folder) print("- %s" % example) +print("Deleting examples folder") +examples_folder = apps_btstack + "/examples" +if os.path.exists(examples_folder): + shutil.rmtree(examples_folder) diff --git a/port/esp32/integrate_btstack.sh b/port/esp32/integrate_btstack.sh index d9e27306a..099a42f72 100755 --- a/port/esp32/integrate_btstack.sh +++ b/port/esp32/integrate_btstack.sh @@ -29,5 +29,8 @@ rsync -a ../../platform/freertos ${IDF_PATH}/components/btstack/platform # sync embedded run loop 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_examples.py