How to get the MQTT publisher example working on the nrf7002DK? I also want to test the TLS after that.

Hi,

I am trying to get the MQTT publisher example working on my nrf7002DK board. For this, i have done the following things

- SDK version: 2.6.1

- Board selected: nrf7002dk_nrf5340_cpuapp

- Include the prj.conf, overlay-nrf700x.conf and overlay-sample.conf(not sure if this is required)

- Updated the KConfig entries CONFIG_WIFI_CREDENTIALS_STATIC_SSID and CONFIG_WIFI_CREDENTIALS_STATIC_PASSWORD, with my SSID and password

- Build and run the code

This is my terminal output

*** Booting nRF Connect SDK v3.5.99-ncs1 ***
[00:00:00.465,911] <inf> net_config: Initializing network
[00:00:00.465,911] <inf> net_config: Waiting interface 1 (0x20000888) to be up...
uart:~$
[00:00:30.466,583] <inf> net_config: Running dhcpv4 client...
[00:00:30.466,827] <err> net_config: Timeout while waiting network interface
[00:00:30.466,827] <err> net_config: Network initialization failed (-115)
[00:00:30.466,888] <inf> net_mqtt_publisher_sample: attempting to connect:
[00:00:30.467,285] <dbg> net_mqtt_sock_tcp: mqtt_client_tcp_connect: (main): Created socket 9
[00:00:33.468,048] <inf> net_mqtt_publisher_sample: mqtt_connect: -116 <ERROR>
[00:00:33.968,536] <dbg> net_mqtt_sock_tcp: mqtt_client_tcp_connect: (main): Created socket 9
[00:00:36.969,299] <inf> net_mqtt_publisher_sample: mqtt_connect: -116 <ERROR>
[00:00:37.469,757] <dbg> net_mqtt_sock_tcp: mqtt_client_tcp_connect: (main): Created socket 9
[00:00:40.470,489] <inf> net_mqtt_publisher_sample: mqtt_connect: -116 <ERROR>
[00:00:40.970,977] <dbg> net_mqtt_sock_tcp: mqtt_client_tcp_connect: (main): Created socket 9
[00:00:43.971,740] <inf> net_mqtt_publisher_sample: mqtt_connect: -116 <ERROR>
[00:00:44.472,198] <dbg> net_mqtt_sock_tcp: mqtt_client_tcp_connect: (main): Created socket 9
[00:00:47.472,961] <inf> net_mqtt_publisher_sample: mqtt_connect: -116 <ERROR>
[00:00:47.973,419] <dbg> net_mqtt_sock_tcp: mqtt_client_tcp_connect: (main): Created socket 9
[00:00:50.974,182] <inf> net_mqtt_publisher_sample: mqtt_connect: -116 <ERROR>
[00:00:51.474,670] <dbg> net_mqtt_sock_tcp: mqtt_client_tcp_connect: (main): Created socket 9
[00:00:54.475,433] <inf> net_mqtt_publisher_sample: mqtt_connect: -116 <ERROR>
[00:00:54.975,891] <dbg> net_mqtt_sock_tcp: mqtt_client_tcp_connect: (main): Created socket 9
[00:00:57.976,654] <inf> net_mqtt_publisher_sample: mqtt_connect: -116 <ERROR>
[00:00:58.477,111] <dbg> net_mqtt_sock_tcp: mqtt_client_tcp_connect: (main): Created socket 9
[00:01:01.477,874] <inf> net_mqtt_publisher_sample: mqtt_connect: -116 <ERROR>
[00:01:01.978,363] <dbg> net_mqtt_sock_tcp: mqtt_client_tcp_connect: (main): Created socket 9
[00:01:04.979,125] <inf> net_mqtt_publisher_sample: mqtt_connect: -116 <ERROR>
[00:01:05.479,248] <inf> net_mqtt_publisher_sample: try_to_connect: -22 <ERROR>
[00:01:05.479,248] <inf> net_mqtt_publisher_sample: attempting to connect:
[00:01:05.479,644] <dbg> net_mqtt_sock_tcp: mqtt_client_tcp_connect: (main): Created socket 9
[00:01:08.480,407] <inf> net_mqtt_publisher_sample: mqtt_connect: -116 <ERROR>
[00:01:08.980,865] <dbg> net_mqtt_sock_tcp: mqtt_client_tcp_connect: (main): Created socket 9
[00:01:11.981,628] <inf> net_mqtt_publisher_sample: mqtt_connect: -116 <ERROR>
[00:01:12.482,116] <dbg> net_mqtt_sock_tcp: mqtt_client_tcp_connect: (main): Created socket 9
[00:01:15.482,879] <inf> net_mqtt_publisher_sample: mqtt_connect: -116 <ERROR>
[00:01:15.983,337] <dbg> net_mqtt_sock_tcp: mqtt_client_tcp_connect: (main): Created socket 9
[00:01:18.984,100] <inf> net_mqtt_publisher_sample: mqtt_connect: -116 <ERROR>
[00:01:19.484,588] <dbg> net_mqtt_sock_tcp: mqtt_client_tcp_connect: (main): Created socket 9

my prj.conf

CONFIG_NETWORKING=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_TCP=y
CONFIG_NET_LOG=y
CONFIG_MQTT_LOG_LEVEL_DBG=y

CONFIG_NET_IPV6_RA_RDNSS=y
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3
CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=2

CONFIG_PRINTK=y
CONFIG_STDOUT_CONSOLE=y

# Enable IPv6 support
CONFIG_NET_IPV6=n
# Enable IPv4 support
CONFIG_NET_IPV4=y

# Enable the MQTT Lib
CONFIG_MQTT_LIB=y

CONFIG_NET_CONFIG_SETTINGS=y
CONFIG_NET_CONFIG_MY_IPV6_ADDR="2001:db8::1"
CONFIG_NET_CONFIG_PEER_IPV6_ADDR="2001:db8::2"

CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.0.2.1"
CONFIG_NET_CONFIG_PEER_IPV4_ADDR="192.0.2.2"

CONFIG_MAIN_STACK_SIZE=2048

# For IPv6
CONFIG_NET_BUF_DATA_SIZE=256

CONFIG_NET_SHELL=y

CONFIG_ENTROPY_GENERATOR=y
CONFIG_TEST_RANDOM_GENERATOR=y

my overlay-nrf700x.conf

# Wi-Fi
CONFIG_WIFI=y
CONFIG_WIFI_NRF700X=y
CONFIG_WPA_SUPP=y
CONFIG_NET_L2_ETHERNET=y

# DHCPv4
CONFIG_NET_CONFIG_MY_IPV4_ADDR=""
CONFIG_NET_CONFIG_NEED_IPV4=y
CONFIG_NET_DHCPV4=y

# Connection manager
CONFIG_NET_CONNECTION_MANAGER=y

# Credentials
CONFIG_WIFI_CREDENTIALS=y
CONFIG_WIFI_CREDENTIALS_STATIC=y
CONFIG_WIFI_CREDENTIALS_STATIC_SSID="MySSID"
CONFIG_WIFI_CREDENTIALS_STATIC_PASSWORD="MyPassword"

Parents Reply
  • I was able to get the basic mqtt work without TLS

    Steps involved

    • Build and run the mqtt sample from /ncs/nrf/samples/net/mqtt
    • Build config
      • Board selected: nrf7002dk_nrf5340_cpuapp_ns
      • Config files: prj.conf, boards/nrf7002dk_nrf5340_cpuapp_ns.conf
    • Open the terminal: Please note that you get prints on both the COM ports in this project. Connect to the COM port that supports shell
    • Connect to Wifi: type the following commands in the shell
      • wifi_cred add MY_SSID WPA2-PSK My_Password
      • wifi_cred auto_connect
    • Now the device will connect to Wifi and then start publishing and subscribing to topics mentioned in the LOG
    • Modify the KConfigs MQTT_SAMPLE_TRANSPORT_PUBLISH_TOPIC and MQTT_SAMPLE_TRANSPORT_SUBSCRIBE_TOPIC provided in the Kconfig.transport file

    I will test the TLS and update soon

Children
Related