This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

how to add ble central on mqtt sample code in the nRF Connect SDK.

hi all ,

now , i need add create mqtt ble gateway .

it compiler failed follow message :

C:/temp/ncs/zephyr/drivers/serial/uart_nrfx_uarte.c:1272:9: error: 'DT_NORDIC_NRF_UARTE_UART_2_LABEL' undeclared here (not in a function); did you mean 'DT_NORDIC_NRF_UARTE_UART_1_LABEL'?
2> C:/temp/ncs/zephyr/include/device.h:107:11: note: in definition of macro 'DEVICE_AND_API_INIT'
2> C:/temp/ncs/zephyr/drivers/serial/uart_nrfx_uarte.c:1271:2: note: in expansion of macro 'DEVICE_DEFINE'
2> C:/temp/ncs/zephyr/drivers/serial/uart_nrfx_uarte.c:1346:2: note: in expansion of macro 'UART_NRF_UARTE_DEVICE'
Build failed

how to do it ?

in my setup

1. copy ble.c/ble.h files

from ~ncs\nrf\samples\nrf9160\lte_ble_gateway\src to ~ncs\nrf\samples\nrf9160\mqtt_simple\src

2.CMakeLists.txt

target_sources(app PRIVATE src/ble.c)

3. add or change prj.conf ,
# Enable the UART driver
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_SERIAL=y
CONFIG_CONSOLE=y
CONFIG_CONSOLE_HAS_DRIVER=y
CONFIG_UART_CONSOLE=y

# Enable Bluetooth stack and libraries
CONFIG_BT=y
CONFIG_BT_H4=y
CONFIG_BT_WAIT_NOP=y
CONFIG_BT_CENTRAL=y
CONFIG_BT_GATT_CLIENT=y
CONFIG_BT_GATT_DM=y
CONFIG_BT_SCAN=y
CONFIG_BT_SCAN_FILTER_ENABLE=y
CONFIG_BT_SCAN_UUID_CNT=1

CONFIG_UART_2_NRF_UARTE=y
CONFIG_UART_2_NRF_FLOW_CONTROL=y
CONFIG_UART_INTERRUPT_DRIVEN=y

# AT Host
#CONFIG_UART_INTERRUPT_DRIVEN=n
CONFIG_AT_HOST_LIBRARY=y

# Disable Modem traces, since we need UART1 for HCI
CONFIG_BSD_LIBRARY_TRACE_ENABLED=n

follow this linker about CONFIG_UART_2_NRF_UARTE , it need "Kconfig"  to enable menus

https://docs.zephyrproject.org/latest/reference/kconfig/CONFIG_UART_2_NRF_UARTE.html

os: win7 sp1

HW: nrf9160-DK 0.8.5

SDK board :

nRF connect SDK version : 0.4.0

root : ncs\nrf\samples\nrf9160\mqtt_simple

Related