-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
unix: Fix support for Bluetooth via libusb, add HCI dump feature #14006
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
yasnim24
wants to merge
5
commits into
micropython:master
Choose a base branch
from
yasnim24:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+145
−33
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d5fb523
ports/unix/Makefile: Move up "HAVE_LIBUSB" code to be effective.
yasnim24 afe2867
ports/unix: Fix "‘signal_sco_can_send_now’ defined but not used".
yasnim24 60a5e47
ports/unix: Fix so that "MICROPY_BLUETOOTH_BTSTACK_USB=1" is working.
yasnim24 e7d4cd3
ports/unix: Change 'STATIC' to 'static'.
yasnim24 44acdbf
ports/unix: Use 'mp_thread_init_state()' instead of own function.
yasnim24 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,37 @@ QSTR_GLOBAL_DEPENDENCIES += $(VARIANT_DIR)/mpconfigvariant.h | |
# OS name, for simple autoconfig | ||
UNAME_S := $(shell uname -s) | ||
|
||
# If the variant enables it, enable modbluetooth. | ||
ifeq ($(MICROPY_PY_BLUETOOTH),1) | ||
ifeq ($(MICROPY_BLUETOOTH_BTSTACK),1) | ||
HAVE_LIBUSB := $(shell (which pkg-config > /dev/null && pkg-config --exists libusb-1.0) 2>/dev/null && echo '1') | ||
|
||
# Figure out which BTstack transport to use. | ||
ifeq ($(HAVE_LIBUSB),1) | ||
# Default to btstack-over-usb. | ||
MICROPY_BLUETOOTH_BTSTACK_USB ?= 1 | ||
MICROPY_BLUETOOTH_BTSTACK_H4 ?= 0 | ||
else | ||
# Fallback to HCI controller via a H4 UART (e.g. Zephyr on nRF) over a /dev/tty serial port. | ||
MICROPY_BLUETOOTH_BTSTACK_USB ?= 0 | ||
MICROPY_BLUETOOTH_BTSTACK_H4 ?= 1 | ||
endif | ||
|
||
# MICROPY_BLUETOOTH_BTSTACK_HCI_DUMP could be set to 1 to activate logging | ||
# to file "/tmp/hci_dump.pklg" for btstack-over-usb. | ||
ifndef MICROPY_BLUETOOTH_BTSTACK_HCI_DUMP | ||
MICROPY_BLUETOOTH_BTSTACK_HCI_DUMP ?= 0 | ||
endif | ||
|
||
# Set the file that will be included by "extmod/btstack/btstack_config.h" | ||
# | ||
# The original file "extmod/btstack/btstack_config_common.h" | ||
# will be included by it. | ||
MICROPY_BLUETOOTH_BTSTACK_CONFIG_FILE ?= '"ports/unix/btstack_config.h"' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggest moving this up before the |
||
|
||
endif # MICROPY_BLUETOOTH_BTSTACK | ||
endif # MICROPY_PY_BLUETOOTH | ||
|
||
# include py core make definitions | ||
include $(TOP)/py/py.mk | ||
include $(TOP)/extmod/extmod.mk | ||
|
@@ -144,21 +175,23 @@ ifeq ($(MICROPY_SSL_AXTLS),1) | |
endif | ||
endif | ||
|
||
# If the variant enables it, enable modbluetooth. | ||
ifeq ($(MICROPY_PY_BLUETOOTH),1) | ||
ifeq ($(MICROPY_BLUETOOTH_BTSTACK),1) | ||
HAVE_LIBUSB := $(shell (which pkg-config > /dev/null && pkg-config --exists libusb-1.0) 2>/dev/null && echo '1') | ||
|
||
# Figure out which BTstack transport to use. | ||
ifeq ($(HAVE_LIBUSB),1) | ||
# Default to btstack-over-usb. | ||
MICROPY_BLUETOOTH_BTSTACK_USB ?= 1 | ||
else | ||
# Fallback to HCI controller via a H4 UART (e.g. Zephyr on nRF) over a /dev/tty serial port. | ||
MICROPY_BLUETOOTH_BTSTACK_H4 ?= 1 | ||
ifeq ($(MICROPY_BLUETOOTH_BTSTACK_USB),0) | ||
SRC_BTSTACK_C += lib/btstack/platform/embedded/btstack_run_loop_embedded.c | ||
endif | ||
|
||
ifeq ($(MICROPY_BLUETOOTH_BTSTACK_USB),1) | ||
SRC_BTSTACK_C += lib/btstack/platform/posix/btstack_run_loop_posix.c | ||
|
||
ifeq ($(MICROPY_BLUETOOTH_BTSTACK_HCI_DUMP),1) | ||
CFLAGS += -DMICROPY_BLUETOOTH_BTSTACK_HCI_DUMP=1 | ||
SRC_BTSTACK_C += lib/btstack/platform/posix/hci_dump_posix_fs.c | ||
endif | ||
|
||
endif | ||
|
||
SRC_BTSTACK_C += lib/btstack/platform/embedded/btstack_run_loop_embedded.c | ||
endif | ||
endif | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#ifndef MICROPY_INCLUDED_PORTS_UNIX_BTSTACK_CONFIG_H | ||
#define MICROPY_INCLUDED_PORTS_UNIX_BTSTACK_CONFIG_H | ||
|
||
|
||
#include "extmod/btstack/btstack_config_common.h" | ||
|
||
#ifdef MICROPY_BLUETOOTH_BTSTACK_USB | ||
#if MICROPY_BLUETOOTH_BTSTACK_USB | ||
|
||
// Workaround: | ||
// | ||
// If ENABLE_SCO_OVER_HCI is not defined there is a compiler error: | ||
// | ||
// ../../lib/btstack/platform/libusb/hci_transport_h2_libusb.c:1354:13: | ||
// error: ‘signal_sco_can_send_now’ defined but not used | ||
// | ||
// Because the problem is in an external code this workaround is done. | ||
#define ENABLE_SCO_OVER_HCI | ||
|
||
#endif | ||
#endif | ||
|
||
#endif // MICROPY_INCLUDED_PORTS_UNIX_BTSTACK_CONFIG_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I know the original version doesn't have this, but it makes it all a lot easier to read.)