aboutsummaryrefslogtreecommitdiff
path: root/extmod
diff options
context:
space:
mode:
authorDamien George2020-02-20 14:27:30 +1100
committerDamien George2020-03-06 12:35:20 +1100
commitc44d52f33e4ec626c7f6293323300baaeb55e856 (patch)
treec5478e1ff120e8da55d79252de9d13061e7fd586 /extmod
parent44aa5b220073830e3cc1477c803cac7acabfcc17 (diff)
extmod/modbluetooth_nimble: Move nimble specific code, factor nimble.mk.
Move extmod/modbluetooth_nimble.* to extmod/nimble. And move common Makefile lines to extmod/nimble/nimble.mk (which was previously only used by stm32). This allows (upcoming) btstack to follow a similar structure. Work done in collaboration with Jim Mussared aka @jimmo.
Diffstat (limited to 'extmod')
-rw-r--r--extmod/nimble/modbluetooth_nimble.c (renamed from extmod/modbluetooth_nimble.c)4
-rw-r--r--extmod/nimble/modbluetooth_nimble.h (renamed from extmod/modbluetooth_nimble.h)6
-rw-r--r--extmod/nimble/nimble.mk19
3 files changed, 20 insertions, 9 deletions
diff --git a/extmod/modbluetooth_nimble.c b/extmod/nimble/modbluetooth_nimble.c
index aa1b032f2..f7602c35f 100644
--- a/extmod/modbluetooth_nimble.c
+++ b/extmod/nimble/modbluetooth_nimble.c
@@ -31,8 +31,8 @@
#if MICROPY_PY_BLUETOOTH && MICROPY_BLUETOOTH_NIMBLE
-#include "modbluetooth_nimble.h"
-#include "modbluetooth.h"
+#include "extmod/nimble/modbluetooth_nimble.h"
+#include "extmod/modbluetooth.h"
#include "host/ble_hs.h"
#include "host/util/util.h"
diff --git a/extmod/modbluetooth_nimble.h b/extmod/nimble/modbluetooth_nimble.h
index e2474a6ee..c70c3bc90 100644
--- a/extmod/modbluetooth_nimble.h
+++ b/extmod/nimble/modbluetooth_nimble.h
@@ -24,8 +24,8 @@
* THE SOFTWARE.
*/
-#ifndef MICROPY_INCLUDED_EXTMOD_MODBLUETOOTH_NIMBLE_H
-#define MICROPY_INCLUDED_EXTMOD_MODBLUETOOTH_NIMBLE_H
+#ifndef MICROPY_INCLUDED_EXTMOD_NIMBLE_MODBLUETOOTH_NIMBLE_H
+#define MICROPY_INCLUDED_EXTMOD_NIMBLE_MODBLUETOOTH_NIMBLE_H
#define MP_BLUETOOTH_NIMBLE_MAX_SERVICES (8)
@@ -51,4 +51,4 @@ void mp_bluetooth_nimble_port_postinit(void);
void mp_bluetooth_nimble_port_deinit(void);
void mp_bluetooth_nimble_port_start(void);
-#endif // MICROPY_INCLUDED_EXTMOD_MODBLUETOOTH_NIMBLE_H
+#endif // MICROPY_INCLUDED_EXTMOD_NIMBLE_MODBLUETOOTH_NIMBLE_H
diff --git a/extmod/nimble/nimble.mk b/extmod/nimble/nimble.mk
index e554e9ff0..4d2c6637a 100644
--- a/extmod/nimble/nimble.mk
+++ b/extmod/nimble/nimble.mk
@@ -1,10 +1,21 @@
-# Makefile directives for Apache mynewt nimble BLE component
+# Makefile directives for Apache Mynewt NimBLE component
ifeq ($(MICROPY_BLUETOOTH_NIMBLE),1)
-NIMBLE_LIB_DIR = lib/mynewt-nimble
+EXTMOD_SRC_C += extmod/nimble/modbluetooth_nimble.c
+
+CFLAGS_MOD += -DMICROPY_BLUETOOTH_NIMBLE=1
+
NIMBLE_EXTMOD_DIR = extmod/nimble
+# Use NimBLE from the submodule in lib/mynewt-nimble by default,
+# allowing a port to use their own system version (e.g. ESP32).
+MICROPY_BLUETOOTH_NIMBLE_BINDINGS_ONLY ?= 0
+
+ifeq ($(MICROPY_BLUETOOTH_NIMBLE_BINDINGS_ONLY),0)
+
+NIMBLE_LIB_DIR = lib/mynewt-nimble
+
SRC_LIB += $(addprefix $(NIMBLE_LIB_DIR)/, \
$(addprefix ext/tinycrypt/src/, \
aes_encrypt.c \
@@ -76,8 +87,6 @@ EXTMOD_SRC_C += $(addprefix $(NIMBLE_EXTMOD_DIR)/, \
nimble/hci_uart.c \
)
-CFLAGS_MOD += -DMICROPY_BLUETOOTH_NIMBLE=1
-
INC += -I$(TOP)/$(NIMBLE_EXTMOD_DIR)
INC += -I$(TOP)/$(NIMBLE_LIB_DIR)
INC += -I$(TOP)/$(NIMBLE_LIB_DIR)/ext/tinycrypt/include
@@ -93,3 +102,5 @@ INC += -I$(TOP)/$(NIMBLE_LIB_DIR)/porting/nimble/include
$(BUILD)/$(NIMBLE_LIB_DIR)/%.o: CFLAGS += -Wno-maybe-uninitialized -Wno-pointer-arith -Wno-unused-but-set-variable -Wno-format
endif
+
+endif