Skip to content

Commit

Permalink
esp32: create examples in examples folder, fix update_gatt.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
mringwal committed Sep 28, 2017
1 parent 6f952a2 commit f936392
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
21 changes: 12 additions & 9 deletions port/esp32/create_examples.py
Expand Up @@ -26,10 +26,9 @@
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())
'''

Expand All @@ -39,10 +38,14 @@
# 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):
Expand All @@ -55,7 +58,7 @@
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)
Expand All @@ -67,7 +70,6 @@
# 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")))
Expand All @@ -91,6 +93,7 @@
# 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))
Expand Down
8 changes: 5 additions & 3 deletions port/esp32/delete_examples.py
Expand Up @@ -15,11 +15,9 @@
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
Expand All @@ -29,3 +27,7 @@
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)
3 changes: 3 additions & 0 deletions port/esp32/integrate_btstack.sh
Expand Up @@ -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

0 comments on commit f936392

Please sign in to comment.