Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,7 @@ Pipfile.lock
# Jupyter Notebook
######################
.ipynb_checkpoints

# Clangd cache
######################
.cache/
7 changes: 5 additions & 2 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"gcc",
"MICROPY_MODULE_FROZEN_MPY",
"MICROPY_ROM_TEXT_COMPRESSION",
"HAVE_UMM_MALLOC=1"
],
"compilerArgs": [
"-Wall",
Expand Down Expand Up @@ -286,7 +287,8 @@
],
"defines": [
"MICROPY_MODULE_FROZEN_MPY",
"MICROPY_ROM_TEXT_COMPRESSION"
"MICROPY_ROM_TEXT_COMPRESSION",
"HAVE_UMM_MALLOC=1"
],
"compilerArgs": [
"-mthumb",
Expand Down Expand Up @@ -404,7 +406,8 @@
],
"defines": [
"MICROPY_MODULE_FROZEN_MPY",
"MICROPY_USE_READLINE=1"
"MICROPY_USE_READLINE=1",
"HAVE_UMM_MALLOC=1",
],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
Expand Down
13 changes: 12 additions & 1 deletion bricks/_common/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,16 @@ BTSTACK_BLE_SRC_C += $(addprefix lib/btstack/src/ble/,\
sm.c \
)

BTSTACK_CLASSIC_SRC_C = $(addprefix lib/btstack/src/classic/,\
btstack_link_key_db_memory.c \
rfcomm.c \
sdp_client.c \
sdp_client_rfcomm.c \
sdp_server.c \
sdp_util.c \
spp_server.c \
)

BTSTACK_SRC_C += $(addprefix lib/btstack/chipset/cc256x/,\
btstack_chipset_cc256x.c \
)
Expand Down Expand Up @@ -517,7 +527,7 @@ SRC_STM32_USB_DEV += $(addprefix lib/pbio/drv/usb/stm32_usbd/,\
SRC_UMM_MALLOC = lib/umm_malloc/src/umm_malloc.c

ifeq ($(PB_LIB_UMM_MALLOC),1)
CFLAGS += -I$(PBTOP)/lib/umm_malloc/src
CFLAGS += -I$(PBTOP)/lib/umm_malloc/src -DHAVE_UMM_MALLOC=1
endif

# NXT OS
Expand Down Expand Up @@ -571,6 +581,7 @@ ifeq ($(PB_LIB_BTSTACK),1)
ifneq ($(CI_MODE),1)
OBJ += $(addprefix $(BUILD)/, $(BTSTACK_SRC_C:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(BTSTACK_BLE_SRC_C:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(BTSTACK_CLASSIC_SRC_C:.c=.o))
$(BUILD)/lib/btstack/%.o: CFLAGS += -Wno-error
endif
endif
Expand Down
2 changes: 1 addition & 1 deletion bricks/_common/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
#define MICROPY_MULTIPLE_INHERITANCE (0)
#define MICROPY_PY_ARRAY (0)
#define MICROPY_PY_BUILTINS_BYTEARRAY (PYBRICKS_OPT_EXTRA_LEVEL1)
#define MICROPY_PY_BUILTINS_MEMORYVIEW (0)
#define MICROPY_PY_BUILTINS_MEMORYVIEW (PYBRICKS_OPT_EXTRA_LEVEL2)
#define MICROPY_PY_BUILTINS_ENUMERATE (PYBRICKS_OPT_EXTRA_LEVEL1)
#define MICROPY_PY_BUILTINS_FILTER (0)
#define MICROPY_PY_BUILTINS_FROZENSET (0)
Expand Down
5 changes: 5 additions & 0 deletions lib/pbio/drv/bluetooth/bluetooth.c
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ void pbdrv_bluetooth_cancel_operation_request(void) {
#if PBDRV_CONFIG_BLUETOOTH_NUM_CLASSIC_CONNECTIONS
// Revisit: Cancel all.
pbdrv_bluetooth_classic_task_context.cancel = true;
pbdrv_bluetooth_rfcomm_cancel_connection();
#endif // PBDRV_CONFIG_BLUETOOTH_NUM_CLASSIC_CONNECTIONS
}

Expand Down Expand Up @@ -684,6 +685,10 @@ pbio_error_t pbdrv_bluetooth_close_user_tasks(pbio_os_state_t *state, pbio_os_ti
// Requests peripheral operations to cancel, if they support it.
pbdrv_bluetooth_cancel_operation_request();

#if PBDRV_CONFIG_BLUETOOTH_NUM_CLASSIC_CONNECTIONS
pbdrv_bluetooth_rfcomm_disconnect_all();
#endif // PBDRV_CONFIG_BLUETOOTH_NUM_CLASSIC_CONNECTIONS

for (peri_index = 0; peri_index < PBDRV_CONFIG_BLUETOOTH_NUM_PERIPHERALS; peri_index++) {
peri = pbdrv_bluetooth_peripheral_get_by_index(peri_index);

Expand Down
11 changes: 11 additions & 0 deletions lib/pbio/drv/bluetooth/bluetooth.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,17 @@ typedef struct {

pbio_error_t pbdrv_bluetooth_inquiry_scan_func(pbio_os_state_t *state, void *context);

// The following functions are defined in each Bluetooth implementation that
// supports RFCOMM sockets.

// Cancels all pending connection attempts. Called e.g. when the user interrupts
// execution to drop into the debug REPL.
void pbdrv_bluetooth_rfcomm_cancel_connection();

// Disconnects all active RFCOMM connections and cleans up all sockets. Called
// during user program termination.
void pbdrv_bluetooth_rfcomm_disconnect_all();

#endif // PBDRV_CONFIG_BLUETOOTH

#endif // _INTERNAL_PBDRV_BLUETOOTH_H_
Loading