Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
SalimTerryLi committed Feb 10, 2022
1 parent 22df2fe commit 24a762a
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 1,446 deletions.
2 changes: 2 additions & 0 deletions port/esp32/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ create_examples.pyc
example/
template/build/
sdkconfig_*
sdkconfig
__pycache__
8 changes: 4 additions & 4 deletions port/esp32/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ Each example project folder, e.g. port/esp32/examples/spp_and_le_counter, contai

To compile an example, run:

make
idf.py build


To upload the binary to your device, run:

make flash
idf.py flash


To get the debug output, run:

make monitor
idf.py monitor

You can quit the monitor with CTRL-].

Expand All @@ -42,7 +42,7 @@ Interestingly, if you run make a second time, it completes the compilation.

## Configuration

The sdkconfig of the example template disables the original Bluedroid stack by disabling the CONFIG_BLUEDROID_ENABLED kconfig option.
The sdkconfig of the example template disables the original Bluedroid stack by disabling the `CONFIG_BT_BLUEDROID_ENABLED` and enabling `CONFIG_BT_CONTROLLER_ONLY` kconfig option.

## Limitations

Expand Down
4 changes: 2 additions & 2 deletions port/esp32/components/btstack/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ COMPONENT_ADD_INCLUDEDIRS := \
3rd-party/bluedroid/encoder/include \
3rd-party/hxcmod-player \
3rd-party/hxcmod-player/mods \
../lwip/lwip/src/include \
${IDF_PATH}/components/lwip/lwip/src/include \
3rd-party/lwip/dhcp-server \
3rd-party/md5 \
3rd-party/yxml \
Expand All @@ -34,7 +34,7 @@ COMPONENT_SRCDIRS := \
3rd-party/bluedroid/encoder/srce \
3rd-party/hxcmod-player \
3rd-party/hxcmod-player/mods \
../lwip/lwip/src/apps/http \
${IDF_PATH}/components/lwip/lwip/src/apps/http \
3rd-party/lwip/dhcp-server \
3rd-party/micro-ecc \
3rd-party/md5 \
Expand Down
13 changes: 3 additions & 10 deletions port/esp32/create_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
main_cmake_template = '''
idf_component_register(
SRCS MAIN_FILES
INCLUDE_DIRS "${CMAKE_CURRENT_BINARY_DIR}")
INCLUDE_DIRS "${CMAKE_CURRENT_BINARY_DIR}"
REQUIRES btstack)
'''

main_cmake_gatt_add_on = '''
Expand Down Expand Up @@ -94,15 +95,7 @@ def create_examples(script_path, suffix):
os.makedirs(apps_folder)

# copy files
for item in ['sdkconfig', 'set_port.sh']:
src = script_path + '/template/' + item
if item == 'sdkconfig':
src = src + suffix
dst = apps_folder + '/' + item
shutil.copyfile(src, dst)

# mark set_port.sh as executable
os.chmod(apps_folder + '/set_port.sh', 0o755)
shutil.copyfile(script_path + '/template/' + 'sdkconfig.defaults' + suffix, apps_folder + '/' + 'sdkconfig.defaults')

# create Makefile file
with open(apps_folder + "Makefile", "wt") as fout:
Expand Down
32 changes: 32 additions & 0 deletions port/esp32/integrate_btstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@
import os
import sys
import shutil
import re
import create_examples

component_manager_yml = '''version: "BTSTACK_VERSION"
description: BTstack - BlueKitchen's implementation of the official Bluetooth stack.
url: https://github.com/bluekitchen/btstack
'''

if not 'IDF_PATH' in os.environ:
print('Error: IDF_PATH not defined. Please set IDF_PATH as described here:\nhttp://esp-idf.readthedocs.io/en/latest/get-started/index.html#get-started-get-esp-idf');
sys.exit(10)
Expand Down Expand Up @@ -56,5 +62,31 @@
# add hci dump stdout
shutil.copy(local_dir+'/../../platform/embedded/hci_dump_embedded_stdout.c', IDF_BTSTACK)

# add support for idf-component-manager
parsed_btstack_version = '0.0'
with open('../../CHANGELOG.md', 'r') as f:
dev_version = False
while True:
rawline = f.readline()
if not rawline:
break
matchobj = re.match(r'^##[\s]+(?:(?:Release v)|(?:))([^\n]+)[\s]*$', rawline)
if matchobj is not None:
if matchobj.groups()[0] == 'Unreleased':
dev_version = True
else:
if re.match(r'^[\d]+(?:(?:.[\d]+)|(?:))(?:(?:.[\d]+)|(?:))(?:(?:.[\d]+)|(?:))$', matchobj.groups()[0]) is None:
continue
parsed_btstack_version = matchobj.groups()[0]
if dev_version:
ver_num = parsed_btstack_version.split('.')
ver_num[len(ver_num)-1] = str(int(ver_num[len(ver_num)-1]) + 1)
parsed_btstack_version = '.'.join(ver_num)
parsed_btstack_version += '-alpha'
print('BTstack version: ' + parsed_btstack_version)
break
with open(IDF_BTSTACK + '/idf_component.yml', 'w') as f:
f.write(component_manager_yml.replace('BTSTACK_VERSION', parsed_btstack_version))

# create example/btstack
create_examples.create_examples(local_dir, '')
Loading

0 comments on commit 24a762a

Please sign in to comment.