summaryrefslogtreecommitdiff
path: root/extmod/btstack
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2020-04-07 15:02:52 +1000
committerDamien George <damien.p.george@gmail.com>2020-04-29 16:45:46 +1000
commit7563d582100d7947eb61960c9116c8fc10f1e996 (patch)
treef7f3884fa8f98b012c8ffa8814d8ea5c46ae9511 /extmod/btstack
parentc987adb9e938dbcb1a50e7b0947913c4e37e0943 (diff)
unix: Add support for modbluetooth and BLE using btstack.
This commit adds full support to the unix port for Bluetooth using the common extmod/modbluetooth Python bindings. This uses the libusb HCI transport, which supports many common USB BT adaptors.
Diffstat (limited to 'extmod/btstack')
-rw-r--r--extmod/btstack/btstack.mk14
-rw-r--r--extmod/btstack/btstack_config.h3
2 files changed, 15 insertions, 2 deletions
diff --git a/extmod/btstack/btstack.mk b/extmod/btstack/btstack.mk
index ecb1c84bd..6c883578e 100644
--- a/extmod/btstack/btstack.mk
+++ b/extmod/btstack/btstack.mk
@@ -2,6 +2,8 @@
ifeq ($(MICROPY_BLUETOOTH_BTSTACK),1)
+MICROPY_BLUETOOTH_BTSTACK_USB ?= 0
+
BTSTACK_EXTMOD_DIR = extmod/btstack
EXTMOD_SRC_C += extmod/btstack/modbluetooth_btstack.c
@@ -24,9 +26,17 @@ INC += -I$(BTSTACK_DIR)/3rd-party/yxml
SRC_BTSTACK = \
$(addprefix lib/btstack/src/, $(SRC_FILES)) \
$(addprefix lib/btstack/src/ble/, $(filter-out %_tlv.c, $(SRC_BLE_FILES))) \
- lib/btstack/platform/embedded/btstack_run_loop_embedded.c \
+ lib/btstack/platform/embedded/btstack_run_loop_embedded.c
+
+ifeq ($(MICROPY_BLUETOOTH_BTSTACK_USB),1)
+SRC_BTSTACK += \
+ lib/btstack/platform/libusb/hci_transport_h2_libusb.c
+
+CFLAGS += $(shell pkg-config libusb-1.0 --cflags)
+LDFLAGS += $(shell pkg-config libusb-1.0 --libs)
+endif
-ifeq ($MICROPY_BLUETOOTH_BTSTACK_ENABLE_CLASSIC,1)
+ifeq ($(MICROPY_BLUETOOTH_BTSTACK_ENABLE_CLASSIC),1)
include $(BTSTACK_DIR)/src/classic/Makefile.inc
SRC_BTSTACK += \
$(addprefix lib/btstack/src/classic/, $(SRC_CLASSIC_FILES))
diff --git a/extmod/btstack/btstack_config.h b/extmod/btstack/btstack_config.h
index 0976bbe72..f420f47a5 100644
--- a/extmod/btstack/btstack_config.h
+++ b/extmod/btstack/btstack_config.h
@@ -41,4 +41,7 @@
// BTstack HAL configuration
#define HAVE_EMBEDDED_TIME_MS
+// Some USB dongles take longer to respond to HCI reset (e.g. BCM20702A).
+#define HCI_RESET_RESEND_TIMEOUT_MS 1000
+
#endif // MICROPY_INCLUDED_EXTMOD_BTSTACK_BTSTACK_CONFIG_H