Skip to content

Commit

Permalink
makefiles/pkg/nimble.adv.mk: add utility to assign adv instance
Browse files Browse the repository at this point in the history
  • Loading branch information
fjmolinas committed Apr 27, 2022
1 parent 81cd999 commit 1de00ba
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
2 changes: 2 additions & 0 deletions Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ CLEAN = $(filter clean, $(MAKECMDGOALS))
include $(RIOTMAKE)/utils/variables.mk
include $(RIOTMAKE)/utils/strings.mk

# include nimble makefile tools
include $(RIOTMAKE)/pkg/nimble.adv.mk

# UNAME is always needed so use simple variable expansion so only evaluated once
UNAME := $(shell uname -m -s)
Expand Down
15 changes: 15 additions & 0 deletions makefiles/pkg/nimble.adv.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Adds an external Advertisement Instance
# Parameter 1: The value for the advertisement instance without the CONFIG_ prefix
# Result:
# - Increases BLE_MULTI_ADV_INSTANCES count by 1, note that the actual amount
# of advertisement instances is MYNEWT_VAL_BLE_MULTI_ADV_INSTANCES + 1, which
# is why BLE_MULTI_ADV_INSTANCES starts at -1
# - Sets the adv instance for CONFIG_$1 index to $(BLE_MULTI_ADV_INSTANCES)
BLE_MULTI_ADV_INSTANCES ?= -1
define _add_ext_adv_instance
# Increase the count in one
BLE_MULTI_ADV_INSTANCES := $$(shell echo $$$$(($(BLE_MULTI_ADV_INSTANCES) + 1)))
# Export the definition in CFLAGS
$(1) := $$(BLE_MULTI_ADV_INSTANCES)
CFLAGS += -DCONFIG_$(1)=$$($(1))
endef
15 changes: 8 additions & 7 deletions pkg/nimble/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -94,22 +94,23 @@ ifneq (,$(filter nimble_autoconn,$(USEMODULE)))
INCLUDES += -I$(RIOTPKG)/nimble/autoconn/include
endif


ifneq (,$(filter nimble_adv_ext,$(USEMODULE)))
CFLAGS += -DMYNEWT_VAL_BLE_EXT_ADV=1
CFLAGS += -DMYNEWT_VAL_BLE_LL_EXT_ADV_AUX_PTR_CNT=2
CFLAGS += -DMYNEWT_VAL_BLE_LL_SCAN_AUX_SEGMENT_CNT=1
ifneq (,$(filter nimble_controller,$(USEMODULE)))
CFLAGS += -DMYNEWT_VAL_BLE_LL_CFG_FEAT_LL_EXT_ADV=1
endif
NIMBLE_ADVERTISING_INSTANCES ?= 0
ifneq (,$(filter nimble_netif,$(USEMODULE)))
ifneq (,$(filter nimble_autoadv,$(USEMODULE)))
NIMBLE_ADVERTISING_INSTANCES = 1
CFLAGS += -DCONFIG_NIMBLE_AUTO_ADV_INST=1
endif
$(eval $(call _add_ext_adv_instance,NIMBLE_NETIF_ADV_INSTANCE))
endif
ifneq (,$(filter nimble_autoadv,$(USEMODULE)))
$(eval $(call _add_ext_adv_instance,NIMBLE_AUTOADV_INSTANCE))
endif
# check that an advertisement instances was configured
ifneq (-1,$(BLE_MULTI_ADV_INSTANCES))
CFLAGS += -DMYNEWT_VAL_BLE_MULTI_ADV_INSTANCES=$(BLE_MULTI_ADV_INSTANCES)
endif
CFLAGS += -DMYNEWT_VAL_BLE_MULTI_ADV_INSTANCES=$(NIMBLE_ADVERTISING_INSTANCES)
endif

ifneq (,$(filter nimble_netif,$(USEMODULE)))
Expand Down

0 comments on commit 1de00ba

Please sign in to comment.